frank-zago / ch341-i2c-spi-gpio

WinChipHead CH341 linux driver for I2C, SPI and GPIO mode
GNU General Public License v2.0
70 stars 29 forks source link

gpio-ch341.c: write_outputs, use new command #20

Closed mr-nice closed 1 year ago

mr-nice commented 1 year ago

Change write_outputs to use the 0xA1 pin IO interface from https://github.com/rogerjames99/spi-ch341-usb/blob/master/spi-ch341-usb.c

Keep the current interface of the old command and don't use new pins.

Reverse engineered from @icenowy and @geeksville

Also used at the manufacturers driver code example https://github.com/zoobab/ch341-parport/blob/master/CH341PAR_LINUX/demo/ch34x_lib.c

mr-nice commented 1 year ago

Hi, I did the first step and changed the I/O command to the new interface without changing anything on the other interfaces. I tested the result with gpioget with pins driven to low (connect gnd to the pin). And tested the outputs D0-D5 with gpioset and a logic analyzer. I was unable to test the SPI interface because this would need the INI# pin. I was also unable to test I2C because there is no driver for my I2C device. I have an I2C device and I can connect it but I missed some parts to get i2cdetect to work with both write_output implementations. I need to further investigate that, because I never used that on a non embedded machine. I can test the things you want me to test, if you provide information on how to test them.

I left out all the enhancements which this interface gives us to another PR to solve #5

The library code mentioned that it might be possible to use more pins as outputs but I leave that out for later.

Greets, mr-nice

frank-zago commented 1 year ago

Thanks. That looks good. I've tested it as well. Fix the typo and I'll merge.

frank-zago commented 1 year ago

rebased and merged.