Generic LED API.
The LED driver is a platfom level software module that manages the control of various types of LEDs. There are currently two types of LEDs supported by the LED driver:
The common LED functions are called through the generic LED driver, while other functions specific to a certain type of LED are called directly through their own driver.
All LED instances are configured with an sl_led_t struct and a type specific context struct, and sometimes additional structs. There is also a typedef sl_led_state_t to get the state of an LED. These structs are automatically generated after an LED is set up using Simplicity Studio's wizard, along with a function definition for initializing all LEDs of that type. Specific setups for the various LED types are in the following sections.
Once the LED structs are defined, the common LED functions can be called being passed an instance of sl_led_t, which will be redirected to calling the type specific version of that function. The common functions include the following:
These functions allow for initializing the LED, turning it on and off, toggling it, and getting the current on/off state of it. Other functions are called through the specific type of LED's API directly. The usages of the different types of LEDs are described in detail in the following sections.
|Simple LED Driver|
|Simple LED Driver. |
|Simple RGBW PWM LED Driver|
|Simple Red/Green/Blue/White PWM LED Driver. |
|A LED instance. |
|sl_status_t||sl_led_init (const sl_led_t *led_handle)|
|Initialize the LED driver. |
|void||sl_led_turn_on (const sl_led_t *led_handle)|
|Turn on the LED. |
|void||sl_led_turn_off (const sl_led_t *led_handle)|
|Turn off the LED. |
|void||sl_led_toggle (const sl_led_t *led_handle)|
|Toggle the LED. |
|sl_led_state_t||sl_led_get_state (const sl_led_t *led_handle)|
|Get the current state of the LED. |
|LED state off. |
|LED state on. |
|LED state. |
|sl_status_t sl_led_init||(||const sl_led_t *||)|
Initialize the LED driver.
Call this function before any other LED function. Initializes the selected LED GPIO, mode, and polarity.
Pointer to instance of sl_led_t to initialize
- Status Code:
|void sl_led_turn_on||(||const sl_led_t *||)|
Turn on the LED.
Pointer to instance of sl_led_t to turn on
|void sl_led_turn_off||(||const sl_led_t *||)|
Turn off the LED.
Pointer to instance of sl_led_t to turn off
|void sl_led_toggle||(||const sl_led_t *||)|
Toggle the LED.
Turn it on if it is off, and off if it is on.
Pointer to instance of sl_led_t to toggle
Get the current state of the LED.
Pointer to instance of sl_led_t to check
- sl_led_state_t Current state of LED. 1 for on, 0 for off
Macro Definition Documentation
|#define SL_LED_CURRENT_STATE_OFF 0U|
LED state off.
|#define SL_LED_CURRENT_STATE_ON 1U|
LED state on.
|typedef uint8_t sl_led_state_t|