Synopsis
void platform_write_led(int index,
                        int state);
Description

platform_write_led sets the platform LED with index index on or off according to state. If state is zero, the LED is turned off and if state is non-zero, it is turned on.

platform_write_led takes care of initializing the GPIO pin and handing LEDs connected with both positive and negative logic. If the LED's GPIO cannot be claimed, the LED is not driven—this allows shared use where a LED is connected to a GPIO as an indicator. For instance, the BugBlat Cortino has two LEDs, connected to A4/SDA and A5/SCL so, for instance, a client can request an I2C bus on those two pins and attempting to write to the LEDs using platform_write_led will be a no-operation as SCL and SDA are claimed for I2C. If, however, the LEDs are written using platform_write_led, the pins are claimed as general purpose outputs and trying to establish an I2C bus on them will fail.

Note

A LED doesn't need to be directly attached to a GPIO, but this is the typical configuration.