{ "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-SOM, 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-SOM-EVB\n\nWhen using GPIO make sure that the desired gpio is not used by another periphery.\n\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 pyA20EVB.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 pyA20EVB.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 pyA20EVB.gpio import gpio\n from pyA20EVB.gpio import port\n from pyA20EVB.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 pyA20EVB 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 pyA20EVB 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 Changelog\n=========\n * pyA20EVB 0.2.1 (30 JUN 2015)\n * Fixed issue with SPI xfer function\n\n * pyA20EVB 0.2.0 (03 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": "pyA20EVB", "package_url": "https://pypi.org/project/pyA20EVB/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyA20EVB/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://www.olimex.com/" }, "release_url": "https://pypi.org/project/pyA20EVB/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Control GPIO, I2C and SPI", "version": "0.2.1" }, "last_serial": 1612818, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "34c13c85714610a23e4cb7c9c54de980", "sha256": "41c2eb3c660673faab616377e08ff2e1505b8dc5107ab917eac14812840b2ee7" }, "downloads": -1, "filename": "pyA20EVB-0.2.0.tar.gz", "has_sig": false, "md5_digest": "34c13c85714610a23e4cb7c9c54de980", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13497, "upload_time": "2014-12-15T13:01:23", "url": "https://files.pythonhosted.org/packages/0c/b7/f700c72c5d0d1610677e987a02b652e7a353fee17d4717a8115027405c75/pyA20EVB-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "b1e20d0dbaf33c596ff5da77991ff7a9", "sha256": "4715ca0467799e4a0159df3794f73571e1fcbbc1d044877fe9a25789a74c3a83" }, "downloads": -1, "filename": "pyA20EVB-0.2.1.tar.gz", "has_sig": false, "md5_digest": "b1e20d0dbaf33c596ff5da77991ff7a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13531, "upload_time": "2015-06-30T08:56:38", "url": "https://files.pythonhosted.org/packages/76/50/93d892f66e4eff6b1b0f29b8065d13791c3a44e55883c12a4fa2e78ee7d2/pyA20EVB-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b1e20d0dbaf33c596ff5da77991ff7a9", "sha256": "4715ca0467799e4a0159df3794f73571e1fcbbc1d044877fe9a25789a74c3a83" }, "downloads": -1, "filename": "pyA20EVB-0.2.1.tar.gz", "has_sig": false, "md5_digest": "b1e20d0dbaf33c596ff5da77991ff7a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13531, "upload_time": "2015-06-30T08:56:38", "url": "https://files.pythonhosted.org/packages/76/50/93d892f66e4eff6b1b0f29b8065d13791c3a44e55883c12a4fa2e78ee7d2/pyA20EVB-0.2.1.tar.gz" } ] }