Learn

Controlling YKUSH3 port switching using interfaces other than USB

Switch YKUSH3 USB ports using GPIO pins

YKUSH3 can be controlled with GPIO interface, in addition to the USB. This allows YKUSH3 to be attached to a PC and the port switching to be controlled by another device (e.g., a micro-controller board, a Raspberry Pi and others).

YKUSH3 boards have three GPIO pins, numbered from 1 to 3.

When GPIO control is enabled, the USB downstream ports are switched based on the logical signal inputed in the GPIO pins. If a GPIO pin is put into logical high the corresponding numbered USB port will be set to ON, otherwise if the GPIO pin is inputed with a logical low then the corresponding USB port is set to OFF.

GPIO USB Port
Number Input State Number State
1 high 1 on
1 low 1 off
2 high 2 on
2 low 2 off
3 high 3 on
3 low 3 off

YKUSH3 uses 3.3V TTL logic inputs in the GPIOs.

GPIO control interface is disabled by default on YKUSH3 boards. To enable it do the following.


# Enable GPIO control interface
$ sudo ykushcmd ykush3 --gpio enable

# Reset the board
$ sudo ykushcmd ykush3 --reset

At this point YKUSH3 downstream USB ports are being controlled by the logic input levels in the corresponding GPIO pins.

Note that, while the GPIO control interface is enabled, the USB controlled interface is also active but in practice it's not effective as it will be immediately over-ruled by the GPIO input. For example, if we set the GPIO 1 to logical high this will switch on the USB port 1. Now if on the PC we use ykushcmd to command port 1 to switch off it will look as if the command was not executed because if we look into the board the port 1 is still on.

In reality the command sent by the PC through USB was indeed executed and the port was switch-off during a millisecond, but as soon as the USB command is executed the board will "look" at the state of the GPIO 1 and will reflect that state in the switching state of the USB port 1, in this case switching it back on.

This behaviour makes the GPIO control interface suitable only if we intend it to be the master control interface, in other words, we do not want to use the PC command for switching the YKUSH3 USB ports. When we need to control simultaneously the YKUSH3 from the USB host PC and from another device, GPIO control interface should not be used and it should be disabled. Instead we should use I2C or UART control interfaces.

To disable the GPIO control interface we do the following.


# Disable GPIO control interface
$ sudo ykushcmd ykush3 --gpio disable

# Reset the board
$ sudo ykushcmd ykush3 --reset

What we used in this example

Troubleshooting

GPIO control is only available on boards with firmware version >= 1.2.0. If your board has a previous firmware version it will need to be updated to use the GPIO control interface.

This site uses cookies to enhance your experience. By continuing to browse the site you accept their use. To find out more read our cookies policy.