EVE 1.0
LED driver
Collaboration diagram for LED driver:

Data Structures

struct  led_counting_t
 
struct  led_flash_t
 

Enumerations

Functions called from application programs

void LedInit (void)
 Initialize LED driver. Must be called before LedSet() or LedCounting() can be called.
 
void LedSet (uint32_t Leds, uint32_t Function)
 Sets LED(s) function (on/off/flash). More...
 
static void LedCounting (uint32_t Leds, const struct led_counting_t *Function)
 Sets LED(s) to counting function. More...
 

Application' LED configuration and supplied functions.

The following is the LED driver setup for application's board.h and board.c files.

const struct led_flash_t LedFlashing [NUMBER_OF_FLASHING_PATTERN]
 User's array of led_flash_t defines flashing patterns.
 
static void UpdateLeds (uint32_t BitLedOn)
 User supplied function to update LEDs. More...
 
#define LED_FLASHING_ENABLED   true/false
 If true, LED driver supports flashing.
 
#define LED_COUNTING_ENABLED   true/false
 If true, LED driver supports sequence flashing.
 
#define NUMBER_OF_FLASHING_PATTERN   Number
 Number == How many flashing patterns defined?
 

Detailed Description

Totally 32 LEDs can be updated. Functionality included if LED_ENABLED is set true:

if flashing functions are wanted LED_FLASHING_ENABLED must be set true and the number of flashing pattern must be defined by NUMBER_OF_FLASHING_PATTERN. Each flashing pattern must be defined in table "struct led_flash_t LedFlashing[]" in Board.c. if counting function is wanted LED_COUNTING_ENABLED must be set true.

Output function for setting each led is based of the inline code UpdateLeds().

Enumeration Type Documentation

anonymous enum

Indexes of the Time array in the struct led_counting_t

Enumerator
COUNTING_ON 

Time in processor ticks LED(s) is on.

COUNTING_OFF 

Time in processor ticks LED(s) is off.

COUNTING_PAUSE 

Pause time in processor ticks between flashing series.

NUMBER_OF_COUNTING_TIMES 

Gives array size.

Definition at line 67 of file led.h.

anonymous enum

Input parameters for LedSet() function

Enumerator
LED_OFF 

Set LED(s) off.

LED_ON 

Set LED(s) on.

LED_FLASHING 

Set LED(s) to constant flashing.

LED_INVERT_FLASHING 

Set LED(s) to constant invert flashing.

Definition at line 90 of file led.h.

Function Documentation

void LedSet ( uint32_t  Leds,
uint32_t  Function 
)

Sets LED(s) function (on/off/flash).

Parameters
LedsEach bit position (0-31) represent a LED. New function can be set for several Leds in one function call. If no LEDs are already flashing, the flashing sequence is restarted.
FunctionSelect LED functionality: LED_OFF LED_ON LED_FLASHING + type of LED flashing pattern (0 to max 99)
  • optional LED_INVERT_FLASHING if inverted flashing pattern is wanted

Referenced by LedCounting().

static void LedCounting ( uint32_t  Leds,
const struct led_counting_t Function 
)
inlinestatic

Sets LED(s) to counting function.

Parameters
LedsEach bit position (0-31) represent a LED. New function can be set for several Leds in one function call. The counting sequence is stopped by LedSet(LED_OFF)
FunctionSelect LED funtionality: .Count - number of counts (0-255) .Invert - true is invert, else false .Time[COUNTING_ON] - counting pulse on time, .Time[COUNTING_OFF] - counting pulse off time .Time[COUNTING_PAUSE]- pause between counting sequences, set to 0 if only one counting sequence is wanted .Time[] is 1/1.024 ms resolution, use MWORK_MSEC().

Definition at line 145 of file led.h.

References LedSet().

static void UpdateLeds ( uint32_t  BitLedOn)
static

User supplied function to update LEDs.

The function must be provided to LED driver in board.h and allows application to use for example GPIO expanders instead of processor' GPIO to drive LEDs.

LED bit positions are abstract and application can map them to physical GPIO if required. So for example if application requests to turn LED #2 on, then the driver calls this UpdateLeds() callback with bit #2 settled.

Parameters
BitLedOnBit values (on/off) for all 32 LEDs