LED Manager

LED Manager Overview

The LED Manager allows developers to configure LED settings, manage individual LED states, and process state transitions in a structured and efficient manner. Whether for simple on/off states or more complex lighting effects, the LED Manager streamlines the control of LEDs, making it an essential component for devices with visual feedback indicators or lighting effects.

Application Interface

The below table captures the functions that are to be called from the application layer.

API Functions

Function

Description

rs_led_manager_init

To open the LED manager.

rs_led_manager_set

To sets the state of a specific LED.

rs_led_manager_process

To processes the LED manager tasks.

Error Code

  • Every API’s for the led manager returns some success or failure values. Please refer below section,

LED Manager Header Details

Documentation from the relevant header as follows:

LED Specific APIs.

Defines macros and functions specific to LED functionality

Author

Embien RAPIDSEA Team

Copyright

Embien Technologies India Pvt. Ltd.

Defines

RS_LED_MANAGER_STATE_OFF

LED states LED OFF State

RS_LED_MANAGER_STATE_ON

LED ON State.

LED Slow blink State.

LED Fast blink State.

LED Single blink State.

RS_LED_MANAGER_STATE_DEFAULT

LED Default State.

RS_LED_MANAGER_NUM_LEDS

Maximum number of LEDs that can be configured.

Typedefs

typedef struct tag_rs_led_config rs_led_config_t

Structure for setting up each GPIO pin configuration.

typedef struct tag_rs_led_state rs_led_state_t

Structure for setting up each LED state configuration.

typedef struct tag_rs_led_manager_config rs_led_manager_config_t

Structure for LED Manager Configuration.

typedef struct tag_rs_led_manager_instance rs_led_manager_instance_t

Structure for LED Manager instance.

Functions

rs_ret_val_t rs_led_manager_open(rs_led_manager_instance_t *ptr_instance, rs_led_manager_config_t *ptr_config)

Opens and initializes the LED.

This function initializes the LED manager with the provided configuration, setting the initial LED state and the number of LEDs to manage.

Parameters:
  • ptr_instance[in] - Pointer to the LED Manager instance structure that defines LED settings.

  • ptr_config[in] - Pointer to the LED configuration structure.

Returns:

0 on success or error code on failure

rs_ret_val_t rs_led_manager_set(uint8_t u8_led_index, uint8_t u8_led_state)

Sets the state of a specific LED.

This function sets the state (ON/OFF/BLINK) of a specific LED identified by its index.

Parameters:
  • led_index[in] - The index of the LED to control.

  • u8_led_state[in] - The state to set for the LED:

Returns:

0 on success or error code on failure

rs_ret_val_t rs_led_manager_process()

Processes the LED manager tasks.

This function should be called periodically to handle any ongoing LED state changes, such as blinking or transitioning between states.

Returns:

0 on success or error code on failure

rs_ret_val_t rs_led_manager_close()

Close the LED Manager.

This function should be closed the LED Manager

Returns:

0 on success or error code on failure

struct tag_rs_led_config
#include <rs_led_manager.h>

Structure for setting up each GPIO pin configuration.

Public Members

uint8_t port_index

Index to GPIO port group as defined by underlying HAL layer.

uint8_t pin

Pin number inside the group.

Period for slow blink on/off time at 50% duty cycle.

Period for slow blink on/off time at 50% duty cycle.

Period for single blink on/off time at 50% duty cycle.

struct tag_rs_led_state
#include <rs_led_manager.h>

Structure for setting up each LED state configuration.

Public Members

uint8_t state

LED state to set to - Off, Slow blink, fast blink etc.

uint8_t gpio_state

Current pin level.

uint32_t last_time

Period for slow blink on/off time at 50% duty cycle.

struct tag_rs_led_manager_config
#include <rs_led_manager.h>

Structure for LED Manager Configuration.

Public Members

int32_t num_count

LED Count.

rs_led_config_t led_config[RS_LED_MANAGER_NUM_LEDS]

Structure for setting up each GPIO pin configuration.

struct tag_rs_led_manager_instance
#include <rs_led_manager.h>

Structure for LED Manager instance.

Public Members

rs_led_state_t led_state_info[RS_LED_MANAGER_NUM_LEDS]

Structure for setting up each LED state configuration.

rs_led_manager_config_t *ptr_config

Pointer to the LED manager structure.