Skip to main content

LED control

1 minute, 10 seconds

LED SPI multiplexer control

The 8 status LEDs on the Teal One are RGB LEDs which are controlled by an LED driver chip that can set brightness levels of red, green, and blue on each LED. The LED driver chip is an SPI slave device, and it is multiplexed to two different SPI masters- the TX1 and the IO MCU. On bootup, the IO MCU has control of the LED SPI port, and drives the LEDs to display a blue sweeping pattern to indicate that the drone is booting. Once the TX1 is booted, the TX1 can take control of the LED SPI port by driving a specific GPIO to switch the multiplexer.

The GPIO to select the LED SPI port master is controlled like this:
echo 1 > /sys/devices/teal/teal-gpio/led_spi_mux

Once the GPIO has been set, the TX1 can use the SPI port located at /dev/spidev3.0 to control the status LEDs by writing data to the LED driver chip.  The LED driver chip is a Toshiba TLC5947RHBT which uses a bit-shift scheme to send brightness levels for each LED all at once.  The SPI interface is used as a write-only process to fill the entire shift register in a single transaction.   The following sample code shows how to set color and brightness for each LED and then fill the shift register using the Linux SPI dev userspace driver.


Was this article helpful?