{ "info": { "author": "Stefan Mavrodiev", "author_email": "support@olimex.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Topic :: Home Automation", "Topic :: Software Development :: Embedded Systems" ], "description": "This package provide methods for controlling GPIO pins, I2C and SPI buses.\nThis is written for A20-OLinuXino-LIME2, but it can be used with other boards. If you do\nthis we cannot guarantee proper operation of the module. Before using this\npackage we recommend reading the article at olimex wiki:\n\nhttps://www.olimex.com/wiki/A20-OLinuXino-LIME2\n\nWhen using GPIO make sure that the desired gpio is not used by another periphery.\n\nGPIO METHODS\n============\n\n init() - Make initialization of the module. Always must be called first.\n getcfg() - Read current configuration of gpio.\n setcfg() - Write configuration to gpio.\n input() - Return current value of gpio.\n output() - Set output value.\n pullup() - Set pull-up/pull-down.\n\n\nThe available constants are:\n\n NAME - EQUALS TO\n ==== =========\n HIGH -> 1\n LOW -> 0\n INPUT -> 0\n OUPTUT -> 1\n PULLUP -> 1\n PULLDOWN -> 2\n\n\nThe gpio are named two ways:\n\n By port name: PH0, PG2, PE10, etc.\n These can be imported from port module:\n\n >>> from pyA20Lime2.gpio import port\n >>> dir(port)\n\n By connector name and pin number: gpio2p12, gpio3p8, etc.\n These can be imported from connector module:\n\n >>> from pyA20Lime2.gpio import connector\n >>> dir(connector)\n\nGenerally these constants are just an offset in the memory from the base GPIO address, so they can\nbe assigned to a number type variable.\n\n >>> led = port.PH2\n >>> print led\n 226\n\n\n\nI2C METHODS\n===========\n\n init() - Make initialization of the module\n open() - Begin communication with slave device\n read() - Read from slave device\n write() - Write data to slave device\n close() - End communication with slave device\n\n\nSPI METHODS\n===========\n\n open() - Open SPI bus with given configuration\n read() - Read data from slave device without write\n write() - Write data to slave device without read\n xfer() - Do write and after that read\n close() - Close SPI bus\n\n\n\nExamples\n========\n\nGPIO::\n\n #!/usr/bin/env python\n\n from pyA20Lime2.gpio import gpio\n from pyA20Lime2.gpio import port\n from pyA20Lime2.gpio import connector\n\n gpio.init() #Initialize module. Always called first\n\n gpio.setcfg(port.PG9, gpio.OUTPUT) #Configure LED1 as output\n gpio.setcfg(port.PG9, 1) #This is the same as above\n\n gpio.setcfg(port.PE11, gpio.INPUT) #Configure PE11 as input\n gpio.setcfg(port.PE11, 0) #Same as above\n\n gpio.pullup(port.PE11, 0) #Clear pullups\n gpio.pullup(port.PE11, gpio.PULLDOWN) #Enable pull-down\n gpio.pullup(port.PE11, gpio.PULLUP) #Enable pull-up\n\n while True:\n if gpio.input(port.PE11) == 1:\n gpio.output(port.PG9, gpio.LOW)\n gpio.output(port.PG9, 0)\n else:\n gpio.output(port.PG9, gpio.HIGH)\n gpio.output(port.PG9, 1)\n\n\nI2C::\n\n #!/usr/bin/env python\n\n from pyA20Lime2 import i2c\n\n i2c.init(\"/dev/i2c-2\") #Initialize module to use /dev/i2c-2\n i2c.open(0x55) #The slave device address is 0x55\n\n #If we want to write to some register\n i2c.write([0xAA, 0x20]) #Write 0x20 to register 0xAA\n i2c.write([0xAA, 0x10, 0x11, 0x12]) #Do continuous write with start address 0xAA\n\n #If we want to do write and read\n i2c.write([0xAA]) #Set address at 0xAA register\n value = i2c.read(1) #Read 1 byte with start address 0xAA\n\n i2c.close() #End communication with slave device\n\n\nSPI::\n\n #!/usr/bin/env python\n\n from pyA20Lime2 import spi\n\n spi.open(\"/dev/spidev2.0\")\n #Open SPI device with default settings\n # mode : 0\n # speed : 100000kHz\n # delay : 0\n # bits-per-word: 8\n\n #Different ways to open device\n spi.open(\"/dev/spidev2.0\", mode=1)\n spi.open(\"/dev/spidev2.0\", mode=2, delay=0)\n spi.open(\"/dev/spidev2.0\", mode=3, delay=0, bits_per_word=8)\n spi.open(\"/dev/spidev2.0\", mode=0, delay=0, bits_per_word=8, speed=100000)\n\n spi.write([0x01, 0x02]) #Write 2 bytes to slave device\n spi.read(2) #Read 2 bytes from slave device\n spi.xfer([0x01, 0x02], 2) #Write 2 byte and then read 2 bytes.\n\n spi.close() #Close SPI bus\n\n\nIt's important that you run your python script as root!\n \n\n \nChangelog\n=========\n * pyAA20Lime2 0.2.1 (30 JUN 2015)\n * Fixed issue with SPI xfer function\n\n * pyA20Lime2 0.2.0 (3 SEP 2014)\n * Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.olimex.com/", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "pyA20Lime2", "package_url": "https://pypi.org/project/pyA20Lime2/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyA20Lime2/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://www.olimex.com/" }, "release_url": "https://pypi.org/project/pyA20Lime2/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Control GPIO, I2C and SPI", "version": "0.2.1" }, "last_serial": 1612822, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "44db0492d9d99c1b27c405a724a691c8", "sha256": "9c7749d999285dbec8ee3a9b56839d03d633b4b23b52070f51c7b6a9072381f9" }, "downloads": -1, "filename": "pyA20Lime2-0.2.0.tar.gz", "has_sig": false, "md5_digest": "44db0492d9d99c1b27c405a724a691c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13803, "upload_time": "2014-12-15T12:59:03", "url": "https://files.pythonhosted.org/packages/60/85/5da5e242b8817c42cd79fe488ed40d4ab29112fd15c9bc72fc4327931891/pyA20Lime2-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "eb5273096f0c724e2b6df038906dcad2", "sha256": "478d99212a8275ee78091e59a7241f54ce90257feffb46437e5050c3f02f7d2d" }, "downloads": -1, "filename": "pyA20Lime2-0.2.1.tar.gz", "has_sig": false, "md5_digest": "eb5273096f0c724e2b6df038906dcad2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13849, "upload_time": "2015-06-30T08:57:04", "url": "https://files.pythonhosted.org/packages/52/59/a96753e14f538d6b19f5822003753d562cdbbea0c9502a43d2befb469e4e/pyA20Lime2-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb5273096f0c724e2b6df038906dcad2", "sha256": "478d99212a8275ee78091e59a7241f54ce90257feffb46437e5050c3f02f7d2d" }, "downloads": -1, "filename": "pyA20Lime2-0.2.1.tar.gz", "has_sig": false, "md5_digest": "eb5273096f0c724e2b6df038906dcad2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13849, "upload_time": "2015-06-30T08:57:04", "url": "https://files.pythonhosted.org/packages/52/59/a96753e14f538d6b19f5822003753d562cdbbea0c9502a43d2befb469e4e/pyA20Lime2-0.2.1.tar.gz" } ] }