gschorcht / spi-ch341-usb

Linux kernel driver for CH341A USB to SPI and GPIO adapters
160 stars 63 forks source link

4 usable GPIOs? #1

Closed zoobab closed 6 years ago

zoobab commented 6 years ago

Hi,

I have tested your driver on my electrodragon board:

http://www.zoobab.com/ch341-usb-spi-i2c-uart-isp-dongle#toc5

I could manage to see 4 gpios in sysfs with the following pinout on the board:

D4 = GPIO4 D2 = GPIO3 D1 = GPIO2 ??? = GPIO5

Now, I am trying to use them with urjtag, that needs 4 GPIOs to have a JTAG cable, but it complains GPIO5 cannot be set.

Is there a way to have 4 usable GPIOs, or for now the maximum is 3?

Thanks again for your work.

gschorcht commented 6 years ago

Hi,

sorry for the late answer, we had holiday season here.

The default configuration is

struct ch341_pin_config ch341_board_config[CH341_GPIO_NUM_PINS] = 
{
    // pin  GPIO mode           GPIO name   hwirq
    {   15, CH341_PIN_MODE_CS , "cs0"     , 0 }, // used as CS0
    {   16, CH341_PIN_MODE_CS , "cs1"     , 0 }, // used as CS1
    {   17, CH341_PIN_MODE_CS , "cs2"     , 0 }, // used as CS2
    {   19, CH341_PIN_MODE_IN , "gpio4"   , 1 }, // used as input with hardware IRQ
    {   21, CH341_PIN_MODE_IN , "gpio5"   , 0 }  // used as input
};

So, at least in the default configuration pin 21 that corresponds to D6 is called gpio5 and becomes visible in sysfs as an input port. Unfortunatly, this is the only pin that can't be an output.

How does your ch341_board_config looks like?

Regards Gunar

zoobab commented 6 years ago

I could have more usable GPIOs (6 in total) with your other driver i2c-ch341-usb, see here:

http://www.zoobab.com/ch341-usb-spi-i2c-uart-isp-dongle

gschorcht commented 6 years ago

More GPIO's could be used with i2c-ch341-usb driver.