Microchip® Advanced Software Framework

led.c File Reference
#include <avr32/io.h>
#include "preprocessor.h"
#include "compiler.h"
#include "evk1101.h"
#include "led.h"

Data Structures

struct  tLED_DESCRIPTOR
 Structure describing LED hardware connections. More...
 

Macros

#define INSERT_LED_DESCRIPTOR(LED_NO, unused)
 

Functions

void LED_Display (U32 leds)
 Sets the state of all LEDs. More...
 
void LED_Display_Field (U32 field, U32 leds)
 Sets as a bit-field the state of the specified LEDs. More...
 
void LED_Display_Mask (U32 mask, U32 leds)
 Sets the state of the specified LEDs. More...
 
U8 LED_Get_Intensity (U32 led)
 Gets the intensity of the specified LED. More...
 
void LED_Off (U32 leds)
 Turns off the specified LEDs. More...
 
void LED_On (U32 leds)
 Turns on the specified LEDs. More...
 
U32 LED_Read_Display (void)
 Gets the last state of all LEDs set through the LED API. More...
 
U32 LED_Read_Display_Field (U32 field)
 Gets as a bit-field the last state of the specified LEDs set through the LED API. More...
 
U32 LED_Read_Display_Mask (U32 mask)
 Gets the last state of the specified LEDs set through the LED API. More...
 
void LED_Set_Intensity (U32 leds, U8 intensity)
 Sets the intensity of the specified LEDs. More...
 
bool LED_Test (U32 leds)
 Tests the last state of the specified LEDs set through the LED API. More...
 
void LED_Toggle (U32 leds)
 Toggles the specified LEDs. More...
 

Variables

static tLED_DESCRIPTOR LED_DESCRIPTOR [LED_COUNT]
 Hardware descriptors of all LEDs. More...
 
static volatile U32 LED_State = (1 << LED_COUNT) - 1
 Saved state of all LEDs. More...
 

#define INSERT_LED_DESCRIPTOR (   LED_NO,
  unused 
)
Value:
{ \
{LED##LED_NO##_GPIO / 32, 1 << (LED##LED_NO##_GPIO % 32)},\
{LED##LED_NO##_PWM, LED##LED_NO##_PWM_FUNCTION } \
},

void LED_Display ( U32  leds)

Sets the state of all LEDs.

Parameters
ledsNew state of all LEDs (1 bit per LED).
Note
The pins of all LEDs are set to GPIO output mode.

References tLED_DESCRIPTOR::GPIO, LED_COUNT, LED_State, tLED_DESCRIPTOR::PIN_MASK, and tLED_DESCRIPTOR::PORT.

void LED_Display_Field ( U32  field,
U32  leds 
)

Sets as a bit-field the state of the specified LEDs.

Parameters
fieldLEDs of which to set the state (1 bit per LED).
ledsNew state of the specified LEDs (1 bit per LED, beginning with the first specified LED).
Note
The pins of the specified LEDs are set to GPIO output mode.

References ctz, and LED_Display_Mask().

void LED_Display_Mask ( U32  mask,
U32  leds 
)

Sets the state of the specified LEDs.

Parameters
maskLEDs of which to set the state (1 bit per LED).
ledsNew state of the specified LEDs (1 bit per LED).
Note
The pins of the specified LEDs are set to GPIO output mode.

References ctz, tLED_DESCRIPTOR::GPIO, LED_COUNT, LED_State, tLED_DESCRIPTOR::PIN_MASK, tLED_DESCRIPTOR::PORT, and Wr_bits.

Referenced by LED_Display_Field().

U8 LED_Get_Intensity ( U32  led)

Gets the intensity of the specified LED.

Parameters
ledLED of which to get the intensity (1 bit per LED; only the least significant set bit is used).
Returns
Intensity of the specified LED (0x00 to 0xFF).
Warning
The PWM channel of the specified LED is supposed to be used only by this module.
Note
The GPIO pin configuration of all LEDs is left unchanged.

References tLED_DESCRIPTOR::CHANNEL, ctz, LED_COUNT, and tLED_DESCRIPTOR::PWM.

void LED_Off ( U32  leds)

Turns off the specified LEDs.

Parameters
ledsLEDs to turn off (1 bit per LED).
Note
The pins of the specified LEDs are set to GPIO output mode.

References Clr_bits, ctz, tLED_DESCRIPTOR::GPIO, LED_COUNT, LED_State, tLED_DESCRIPTOR::PIN_MASK, and tLED_DESCRIPTOR::PORT.

Referenced by ui_com_rx_stop(), ui_com_tx_stop(), ui_init(), ui_powerdown(), ui_process(), ui_stop_read(), and ui_stop_write().

void LED_On ( U32  leds)

Turns on the specified LEDs.

Parameters
ledsLEDs to turn on (1 bit per LED).
Note
The pins of the specified LEDs are set to GPIO output mode.

References ctz, tLED_DESCRIPTOR::GPIO, LED_COUNT, LED_State, tLED_DESCRIPTOR::PIN_MASK, tLED_DESCRIPTOR::PORT, and Set_bits.

Referenced by ui_com_rx_start(), ui_com_tx_start(), ui_init(), ui_process(), ui_start_read(), ui_start_write(), and ui_wakeup().

U32 LED_Read_Display ( void  )

Gets the last state of all LEDs set through the LED API.

Returns
State of all LEDs (1 bit per LED).
Note
The GPIO pin configuration of all LEDs is left unchanged.

References LED_State.

U32 LED_Read_Display_Field ( U32  field)

Gets as a bit-field the last state of the specified LEDs set through the LED API.

Parameters
fieldLEDs of which to get the state (1 bit per LED).
Returns
State of the specified LEDs (1 bit per LED, beginning with the first specified LED).
Note
The GPIO pin configuration of all LEDs is left unchanged.

References LED_State, and Rd_bitfield.

U32 LED_Read_Display_Mask ( U32  mask)

Gets the last state of the specified LEDs set through the LED API.

Parameters
maskLEDs of which to get the state (1 bit per LED).
Returns
State of the specified LEDs (1 bit per LED).
Note
The GPIO pin configuration of all LEDs is left unchanged.

References LED_State, and Rd_bits.

void LED_Set_Intensity ( U32  leds,
U8  intensity 
)

Sets the intensity of the specified LEDs.

Parameters
ledsLEDs of which to set the intensity (1 bit per LED).
intensityNew intensity of the specified LEDs (0x00 to 0xFF).
Warning
The PWM channels of the specified LEDs are supposed to be used only by this module.
Note
The pins of the specified LEDs are set to PWM output mode.

References tLED_DESCRIPTOR::CHANNEL, ctz, tLED_DESCRIPTOR::FUNCTION, tLED_DESCRIPTOR::GPIO, LED_COUNT, tLED_DESCRIPTOR::PIN_MASK, tLED_DESCRIPTOR::PORT, and tLED_DESCRIPTOR::PWM.

bool LED_Test ( U32  leds)

Tests the last state of the specified LEDs set through the LED API.

Parameters
ledsLEDs of which to test the state (1 bit per LED).
Returns
true if at least one of the specified LEDs has a state on, else false.
Note
The GPIO pin configuration of all LEDs is left unchanged.

References LED_State, and Tst_bits.

void LED_Toggle ( U32  leds)

Toggles the specified LEDs.

Parameters
ledsLEDs to toggle (1 bit per LED).
Note
The pins of the specified LEDs are set to GPIO output mode.

References ctz, tLED_DESCRIPTOR::GPIO, LED_COUNT, LED_State, tLED_DESCRIPTOR::PIN_MASK, tLED_DESCRIPTOR::PORT, and Tgl_bits.

tLED_DESCRIPTOR LED_DESCRIPTOR[LED_COUNT]
static
Initial value:
=
{
#define INSERT_LED_DESCRIPTOR(LED_NO, unused)
}

Hardware descriptors of all LEDs.

volatile U32 LED_State = (1 << LED_COUNT) - 1
static