eblot / pyftdi

FTDI device driver written in pure Python
Other
509 stars 212 forks source link

Error running example to use GPIO with I2C #312

Open pond-fssw opened 2 years ago

pond-fssw commented 2 years ago

Hi - thank you for your work!

I have a small problem running the example from the documentations (configured for my path) below and writing onto the GPIO ports in general.

use I2C feature

i2c = I2cController()

configure the I2C feature, and predefines the direction of the GPIO pins

i2c.configure('ftdi:///1', direction=0x78) gpio = i2c.get_gpio()

read whole port

pins = gpio.read()

clearing out I2C bits (SCL, SDAo, SDAi)

pins &= 0x07

set AD4

pins |= 1 << 4

update GPIO output

gpio.write(pins)

OUTPUT: Traceback (most recent call last): File "c:/Users/Pond Posphiwat/Documents/random/ft-gpio-ex.py", line 19, in gpio.write(pins) File "C:\Users\Pond Posphiwat\Documents\embedded-systems\drive\lib\site-packages\pyftdi\i2c.py", line 318, in write return self._controller.write_gpio(value) File "C:\Users\Pond Posphiwat\Documents\embedded-systems\drive\lib\site-packages\pyftdi\i2c.py", line 913, in write_gpio (self._gpio_dir, value)) pyftdi.i2c.I2cIOError: No such GPO pins: 0000/0010

I have debugged it at every step and can confirm that everything is configured correct and the gpio pins are seemingly already configured (using gpio.pins).

Also, the 'direction' param in configure does not seem to be writing the pin directions for me and I needed to call gpio.set_direction() to get the output ports configured.

Has anyone run into similar problems or know a fix to this GPIO write issue? Thanks!

pond-fssw commented 2 years ago

I'm sorry the headers are just the comments from the example code