Contiki-NG
Modules | Files | Data Structures
Device Drivers

Modules

 Button HAL
 Hardware abstraction layer for user buttons.
 
 Disk device drivers
 Documentation for all the disk device drivers.
 
 EEPROM API
 The EEPROM API defines a common interface for EEPROM access on Contiki platforms.
 
 GPIO Hardware Abstraction Layer
 The GPIO HAL provides a set of common functions that can be used in a platform-independent fashion.
 
 Generic RGB LED driver
 This is a driver for a tri-color RGB LED part, such as for example the Broadcom (ex Avago Technologies) PLCC-4 Tricolor Black Surface LED present on all Zolertia Zoul-based boards.
 
 Generic external SPI flash driver
 This is a generic driver for external SPI flash memories.
 
 LED Hardware Abstraction Layer
 The LED HAL provides a set of functions that can manipulate LEDS.
 
 Radio API
 The radio API module defines a set of functions that a radio device driver must implement.
 
 SPI Hardware Abstraction Layer
 The SPI HAL provides a set of common functions that can be used in a platform-independent fashion.
 

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. More...
 
void leds_init (void)
 Initialise the LED HAL. More...
 
void leds_single_on (leds_num_t led)
 Turn a single LED on. More...
 
void leds_single_off (leds_num_t led)
 Turn a single LED off. More...
 
void leds_single_toggle (leds_num_t led)
 Toggle a single LED. More...
 
void leds_on (leds_mask_t leds)
 Turn on multiple LEDs. More...
 
void leds_off (leds_mask_t leds)
 Turn off multiple LEDs. More...
 
void leds_toggle (leds_mask_t leds)
 Toggle multiple LEDs. More...
 
void leds_set (leds_mask_t leds)
 Set all LEDs to a specific state. More...
 
leds_mask_t leds_get (void)
 Get the status of LEDs. More...
 
#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. More...
 

Detailed Description

Macro Definition Documentation

◆ LEDS_NUM_TO_MASK

#define LEDS_NUM_TO_MASK (   l)    (1 << (l))

Convert a LED number to a mask representation.

Parameters
lThe pin number (normally a variable of type leds_num_t)
Returns
An OR mask of type leds_mask_t

Definition at line 232 of file leds.h.

Typedef Documentation

◆ leds_t

typedef struct leds_s leds_t

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.

Note
Do not access the port member of this struct direct, use the LED_PORT() macro instead.

Function Documentation

◆ leds_get()

leds_mask_t leds_get ( void  )

Get the status of LEDs.

Returns
A bitwise mask indicating whether each individual LED is on or off

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.

◆ leds_init()

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_COUNT.

Referenced by platform_init_stage_one().

◆ leds_off()

void leds_off ( leds_mask_t  leds)

Turn off multiple LEDs.

Parameters
ledsThe 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 69 of file minileds.c.

References LEDS_COUNT.

Referenced by leds_set(), and rgb_led_off().

◆ leds_on()

void leds_on ( leds_mask_t  leds)

Turn on multiple LEDs.

Parameters
ledsThe 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 63 of file minileds.c.

References LEDS_COUNT.

Referenced by leds_set(), platform_init_stage_one(), and platform_init_stage_two().

◆ leds_set()

void leds_set ( leds_mask_t  leds)

Set all LEDs to a specific state.

Parameters
ledsThe 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().

◆ leds_single_off()

void leds_single_off ( leds_num_t  led)

Turn a single LED off.

Parameters
ledThe 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.

◆ leds_single_on()

void leds_single_on ( leds_num_t  led)

Turn a single LED on.

Parameters
ledThe 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.

◆ leds_single_toggle()

void leds_single_toggle ( leds_num_t  led)

Toggle a single LED.

Parameters
ledThe 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.

◆ leds_toggle()

void leds_toggle ( leds_mask_t  leds)

Toggle multiple LEDs.

Parameters
ledsThe 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 75 of file minileds.c.

References LEDS_COUNT.