eblot / pyftdi

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

Bus C and D are used as serial ports and A and B are used as gpio, Will there be any conflict when the four are used together #381

Open zhimayun opened 4 months ago

zhimayun commented 4 months ago

chip is FT4232H,

A and B are used as gpio C and D are used as serial ports

When calling the following code:

def power_down():
     print("power_down")
     print("self.power_gpio.is_connected {}".format(power_gpio.is_connected))
     pins = power_gpio.read()
     pins |= 1 << 6
     power_gpio.write(pins)
      print(hex(power_gpio.read()))

def power_on():
     print("power_on")
     print("self.power_gpio.is_connected {}".format(power_gpio.is_connected))
     pins = power_gpio.read()
     pins &= ~(1 << 6)
     power_gpio.write(pins)
     print(hex(power_gpio.read()))

if __name__ == "__main__":
     power_gpio = GpioAsyncController()
     pwr_url = " ftdi://ftdi:4232:0:1/1 "
     power_gpio.configure(pwr_url, direction=0xC0)
     power_on()
     time.sleep(1)
     power_down()
     print('sleep...')
     time.sleep(5)
     power_gpio.close()

Set the 6th and 7th pins as outputs, and then call

pins &= ~(1 << 6)
power_gpio.write(pins)

Changing the level of gpio will result the serial ports of C and D not being able to read data. Only when I call gpio. close() can I read data. if the serial port and gpio cannot be used simultaneously? thank you very much