Contiki-NG
|
Files | |
file | leds.h |
Header file for the LED HAL. | |
Data Structures | |
struct | leds_s |
A LED logical representation. More... | |
typedef uint8_t | leds_num_t |
The LED number. | |
typedef uint8_t | leds_mask_t |
An OR mask datatype to represents multiple LEDs. | |
typedef struct leds_s | leds_t |
A LED logical representation. | |
void | leds_init (void) |
Initialise the LED HAL. | |
void | leds_single_on (leds_num_t led) |
Turn a single LED on. | |
void | leds_single_off (leds_num_t led) |
Turn a single LED off. | |
void | leds_single_toggle (leds_num_t led) |
Toggle a single LED. | |
void | leds_on (leds_mask_t leds) |
Turn on multiple LEDs. | |
void | leds_off (leds_mask_t leds) |
Turn off multiple LEDs. | |
void | leds_toggle (leds_mask_t leds) |
Toggle multiple LEDs. | |
void | leds_set (leds_mask_t leds) |
Set all LEDs to a specific state. | |
leds_mask_t | leds_get (void) |
Get the status of LEDs. | |
#define | LEDS_COLOUR_NONE 0x00 |
A default LED colour for non-existing LEDs. | |
#define | LEDS_COUNT 0 |
The number of LEDs present on a device. | |
#define | LEDS_ALL ((1 << LEDS_COUNT) - 1) |
The OR mask representation of all device LEDs. | |
#define | LEDS_LED1 0x00 |
Convenience macro to refer to the 1st LED (LED 1) | |
#define | LEDS_LED2 0x01 |
Convenience macro to refer to the 2nd LED (LED 2) | |
#define | LEDS_LED3 0x02 |
Convenience macro to refer to the 3rd LED (LED 3) | |
#define | LEDS_LED4 0x03 |
Convenience macro to refer to the 4th LED (LED 4) | |
#define | LEDS_LED5 0x04 |
Convenience macro to refer to the 5th LED (LED 5) | |
#define | LEDS_NUM_TO_MASK(l) (1 << (l)) |
Convert a LED number to a mask representation. | |
#define LEDS_NUM_TO_MASK | ( | l | ) | (1 << (l)) |
A LED logical representation.
pin corresponds to the GPIO pin a LED is driven by, using GPIO HAL pin representation.
port corresponds to the GPIO port that the pin is connected to. This only makes sense if GPIO_HAL_CONF_PORT_PIN_NUMBERING is non-zero.
negative_logic should be set to false if the LED is active low.
leds_mask_t leds_get | ( | void | ) |
Get the status of LEDs.
The return value is a bitwise mask. If a bit is set then the corresponding LED is on.
Definition at line 224 of file leds.c.
References LEDS_COUNT.
void leds_init | ( | void | ) |
Initialise the LED HAL.
This function will set corresponding LED GPIO pins to output and will also set the initial state of all LEDs to off.
Definition at line 44 of file minileds.c.
References LEDS_ALL, LEDS_COUNT, and leds_off().
Referenced by platform_init_stage_one(), and platform_init_stage_one().
void leds_off | ( | leds_mask_t | leds | ) |
Turn off multiple LEDs.
leds | The leds to be turned off as an OR mask |
The led argument should be a bitwise mask of the LEDs to be changed. For example, to turn on LEDs 1 and 3, you should pass LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
This function will not change the state of other LEDs.
Definition at line 186 of file leds.c.
References LEDS_COUNT.
Referenced by leds_init(), and leds_set().
void leds_on | ( | leds_mask_t | leds | ) |
Turn on multiple LEDs.
leds | The leds to be turned on as an OR mask |
The led argument should be a bitwise mask of the LEDs to be changed. For example, to turn on LEDs 1 and 3, you should pass LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
This function will not change the state of other LEDs.
Definition at line 168 of file leds.c.
References LEDS_COUNT.
Referenced by leds_set().
void leds_set | ( | leds_mask_t | leds | ) |
Set all LEDs to a specific state.
leds | The state of all LEDs afer this function returns |
The led argument should be a bitwise mask of the LEDs to be changed. For example, to turn on LEDs 1 and 3, you should pass LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
This function will change the state of all LEDs. LEDs not set in the leds mask will be turned off.
Definition at line 217 of file leds.c.
References LEDS_ALL, leds_off(), and leds_on().
void leds_single_off | ( | leds_num_t | led | ) |
Turn a single LED off.
led | The led |
The led argument should be the LED's number, in other words one of the LED_Ln macros.
This function will not change the state of other LEDs.
Definition at line 141 of file leds.c.
References LEDS_COUNT.
void leds_single_on | ( | leds_num_t | led | ) |
Turn a single LED on.
led | The led |
The led argument should be the LED's number, in other words one of the LED_Ln macros.
This function will not change the state of other LEDs.
Definition at line 125 of file leds.c.
References LEDS_COUNT.
void leds_single_toggle | ( | leds_num_t | led | ) |
Toggle a single LED.
led | The led |
The led argument should be the LED's number, in other words one of the LED_Ln macros.
This function will not change the state of other LEDs.
Definition at line 157 of file leds.c.
References LEDS_COUNT.
void leds_toggle | ( | leds_mask_t | leds | ) |
Toggle multiple LEDs.
leds | The leds to be toggled as an OR mask |
The led argument should be a bitwise mask of the LEDs to be changed. For example, to turn on LEDs 1 and 3, you should pass LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
This function will not change the state of other LEDs.
Definition at line 204 of file leds.c.
References LEDS_COUNT.