![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
Data Structures | |
struct | led_pin_config_t |
The pin config struct of LED. More... | |
struct | led_rgb_config_t |
The pin config struct of rgb LED. More... | |
struct | led_monochrome_config_t |
The pin config struct of monochrome LED. More... | |
struct | led_config_t |
The config struct of LED. More... | |
struct | led_flash_config_t |
The flash config struct of LED. More... | |
Macros | |
#define | LED_DIMMING_ENABLEMENT (0U) |
Definition to determine whether enable dimming. More... | |
#define | LED_HANDLE_SIZE ((16U * 3U) + 36U) |
Definition of LED handle size. More... | |
#define | LED_TIMER_INTERVAL (100U) |
Definition of LED timer interval,unit is ms. More... | |
#define | LED_DIMMING_UPDATE_INTERVAL (100U) |
Definition of LED dimming update interval,unit is ms. More... | |
#define | LED_FLASH_CYCLE_FOREVER (0xFFFFFFFFU) |
Definition of LED flash cycle forever. More... | |
#define | LED_BLIP_INTERVAL (250U) |
Definition of LED blip interval,unit is ms. More... | |
#define | LED_MAKE_COLOR(r, g, b) ((led_color_t)((((led_color_t)b) << 16) | (((led_color_t)g) << 8) | ((led_color_t)r))) |
Definition to set LED color. More... | |
Typedefs | |
typedef void * | led_handle_t |
The handle of LED. | |
typedef uint32_t | led_color_t |
The color struct of LED. | |
Enumerations | |
enum | led_status_t { kStatus_LED_Success = kStatus_Success, kStatus_LED_Error = MAKE_STATUS(kStatusGroup_LED, 1), kStatus_LED_InvalidParameter = MAKE_STATUS(kStatusGroup_LED, 2) } |
The status type of LED. More... | |
enum | led_flash_type_t { kLED_FlashOneColor = 0x00U, kLED_FlashColorWheel } |
The flash type of LED. More... | |
enum | _led_color { kLED_Black = LED_MAKE_COLOR(0, 0, 0), kLED_Red = LED_MAKE_COLOR(255, 0, 0), kLED_Green = LED_MAKE_COLOR(0, 255, 0), kLED_Yellow = LED_MAKE_COLOR(255, 255, 0), kLED_Blue = LED_MAKE_COLOR(0, 0, 255), kLED_Pink = LED_MAKE_COLOR(255, 0, 255), kLED_Aquamarine = LED_MAKE_COLOR(0, 255, 255), kLED_White = LED_MAKE_COLOR(255, 255, 255) } |
The color type of LED. More... | |
enum | led_type_t { kLED_TypeRgb = 0x01U, kLED_TypeMonochrome = 0x02U } |
The type of LED. More... | |
Functions | |
led_status_t | LED_Init (led_handle_t ledHandle, led_config_t *ledConfig) |
Initializes a LED with the LED handle and the user configuration structure. More... | |
led_status_t | LED_Deinit (led_handle_t ledHandle) |
Deinitializes a LED instance. More... | |
led_status_t | LED_SetColor (led_handle_t ledHandle, led_color_t ledRgbColor) |
Sets the LED color. More... | |
led_status_t | LED_TurnOnOff (led_handle_t ledHandle, uint8_t turnOnOff) |
Turns on or off the LED. More... | |
led_status_t | LED_Blip (led_handle_t ledHandle) |
Blips the LED. More... | |
led_status_t | LED_Flash (led_handle_t ledHandle, led_flash_config_t *ledFlash) |
Flashes the LED. More... | |
led_status_t | LED_Dimming (led_handle_t ledHandle, uint16_t dimmingPeriod, uint8_t increasement) |
Adjusts the brightness of the LED. More... | |
led_status_t | LED_EnterLowpower (led_handle_t ledHandle) |
Prepares to enter low power consumption. More... | |
led_status_t | LED_ExitLowpower (led_handle_t ledHandle) |
Restores from low power consumption. More... | |
struct led_pin_config_t |
Data Fields | |
uint8_t | dimmingEnable |
dimming enable, 0 - disable, 1 - enable | |
uint8_t | port |
GPIO Port. | |
uint8_t | pin |
GPIO Pin. | |
uint8_t | pinStateDefault |
GPIO Pin voltage when LED is off (0 - low level, 1 - high level) More... | |
uint32_t | sourceClock |
The clock source of the PWM module. | |
uint8_t | instance |
PWM instance of the pin. | |
uint8_t | channel |
PWM channel of the pin. | |
uint8_t led_pin_config_t::pinStateDefault |
The Pin voltage when LED is off (0 - low level, 1 - high level)
struct led_rgb_config_t |
Data Fields | |
led_pin_config_t | redPin |
Red pin setting. | |
led_pin_config_t | greenPin |
Green pin setting. | |
led_pin_config_t | bluePin |
Blue pin setting. | |
struct led_monochrome_config_t |
Data Fields | |
led_pin_config_t | monochromePin |
Monochrome pin setting. | |
struct led_config_t |
struct led_flash_config_t |
Data Fields | |
uint32_t | times |
Flash times, LED_FLASH_CYCLE_FOREVER for forever. | |
uint16_t | period |
Flash period, unit is ms. | |
led_flash_type_t | flashType |
Flash type, one color or color wheel. More... | |
uint8_t | duty |
Duty of the LED on for one period (duration = duty * period / 100). More... | |
led_flash_type_t led_flash_config_t::flashType |
Refer to led_flash_type_t
uint8_t led_flash_config_t::duty |
#define LED_DIMMING_ENABLEMENT (0U) |
Enable or disable the dimming feature
#define LED_HANDLE_SIZE ((16U * 3U) + 36U) |
#define LED_TIMER_INTERVAL (100U) |
#define LED_DIMMING_UPDATE_INTERVAL (100U) |
#define LED_FLASH_CYCLE_FOREVER (0xFFFFFFFFU) |
#define LED_BLIP_INTERVAL (250U) |
#define LED_MAKE_COLOR | ( | r, | |
g, | |||
b | |||
) | ((led_color_t)((((led_color_t)b) << 16) | (((led_color_t)g) << 8) | ((led_color_t)r))) |
enum led_status_t |
enum led_flash_type_t |
enum _led_color |
enum led_type_t |
led_status_t LED_Init | ( | led_handle_t | ledHandle, |
led_config_t * | ledConfig | ||
) |
This function configures the LED with user-defined settings. The user can configure the configuration structure. The parameter ledHandle is a pointer to point to a memory space of size LED_HANDLE_SIZE allocated by the caller. The LED supports two types LED, RGB and monochrome. Please refer to led_type_t. These two types can be set by using led_config_t. The LED also supports LED dimming mode.
Example below shows how to use this API to configure the LED. For monochrome LED,
For rgb LED,
For dimming monochrome LED,
ledHandle | Pointer to point to a memory space of size LED_HANDLE_SIZE allocated by the caller. |
ledConfig | Pointer to user-defined configuration structure. |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | LED initialization succeed. |
led_status_t LED_Deinit | ( | led_handle_t | ledHandle | ) |
This function deinitializes the LED instance.
ledHandle | LED handle pointer. |
kStatus_LED_Success | LED de-initialization succeed. |
led_status_t LED_SetColor | ( | led_handle_t | ledHandle, |
led_color_t | ledRgbColor | ||
) |
This function sets the LED color. The function only supports the RGB LED. The default color is kLED_White. Please refer to LED_MAKE_COLOR(r,g,b).
ledHandle | LED handle pointer. |
ledRgbColor | LED color. |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | Color setting succeed. |
led_status_t LED_TurnOnOff | ( | led_handle_t | ledHandle, |
uint8_t | turnOnOff | ||
) |
This function turns on or off the led.
ledHandle | LED handle pointer. |
turnOnOff | Setting value, 1 - turns on, 0 - turns off. |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | Successfully turn on or off the LED. |
led_status_t LED_Blip | ( | led_handle_t | ledHandle | ) |
This function blips the led.
ledHandle | LED handle pointer. |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | Successfully blip the LED. |
led_status_t LED_Flash | ( | led_handle_t | ledHandle, |
led_flash_config_t * | ledFlash | ||
) |
This function flashes the led. The flash configuration is passed by using led_flash_config_t.
ledHandle | LED handle pointer. |
ledFlash | LED flash configuration. |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | Successfully flash the LED. |
led_status_t LED_Dimming | ( | led_handle_t | ledHandle, |
uint16_t | dimmingPeriod, | ||
uint8_t | increasement | ||
) |
This function adjust the brightness of the LED.
ledHandle | LED handle pointer. |
dimmingPeriod | The duration of the dimming (unit is ms). |
increasement | Brighten or dim (1 - brighten, 0 - dim). |
kStatus_LED_Error | An error occurred. |
kStatus_LED_Success | Successfully adjust the brightness of the LED. |
led_status_t LED_EnterLowpower | ( | led_handle_t | ledHandle | ) |
This function is used to prepare to enter low power consumption.
ledHandle | LED handle pointer. |
kStatus_LED_Success | Successful operation. |
led_status_t LED_ExitLowpower | ( | led_handle_t | ledHandle | ) |
This function is used to restore from low power consumption.
ledHandle | LED handle pointer. |
kStatus_LED_Success | Successful operation. |