LED handler. More...
Data Structures | |
struct | LEDEventT |
Defines | |
#define | LED_OFF 0 |
LED action definitions. | |
#define | LED_ON 1 |
Switch LED on. | |
#define | LED_FLIP 2 |
Flip the LED state (toggle). | |
#define | LED_BLINK 4 |
Let the LED blink continuously. | |
#define | LED_SET_ON 0 |
#define | LED_SET_OFF 1 |
Functions | |
int | InitLED (LEDEventT *led) |
Configures LED connection port. | |
void | sys_led (void *arg) |
Thread to control blinking and flashing of all registered LEDs. | |
void | NutSetLed (HANDLE ledh, uint_fast8_t fxin, uint32_t timOn, uint32_t timOff) |
sets state of a LED | |
int | NutRegisterLed (HANDLE *ledh, int bank, int pin) |
Register an LED for handling. | |
Variables | |
LEDEventT * | first_led = NULL |
HANDLE | led_tmr = NULL |
HANDLE | led_evt = NULL |
LED handler.
#define LED_OFF 0 |
LED action definitions.
The LED modifies the LED according to these tokens when calling NutSetLed().
Switch LED off.
The LED will be switched off immediately. If a timOff parameter of not 0 is given, the LED will be switched off for the given time in ms an then return to on state.
#define LED_ON 1 |
Switch LED on.
The LED will be switched on immediately. If a timOff parameter of not 0 is given, the LED will be switched on for the given time in ms an then return off state.
#define LED_FLIP 2 |
Flip the LED state (toggle).
Toggle the LED from its actual state the the other. Timing parameters are not supported.
Referenced by NutSetLed(), and sys_led().
#define LED_BLINK 4 |
Let the LED blink continuously.
The parameter timOn specifies the on-time and parameter timOff the off-time. Together with higher timer settings a software dimming can as well be established as a simple blink effect or short / long flash effects. Be adviced that high timer rates can decrease overall system speed. Therefore you have to modify the timer rate in the led.c directly. Standard setting is 10ms cycle time.
Referenced by NutSetLed(), and sys_led().
#define LED_SET_ON 0 |
Referenced by NutSetLed().
#define LED_SET_OFF 1 |
Referenced by NutRegisterLed(), and NutSetLed().
int InitLED | ( | LEDEventT * | led | ) |
Configures LED connection port.
This is an internal function called by NutRegisterLED().
References LEDEventT::bank, GPIO_CFG_OUTPUT, GpioPinConfigSet(), GpioPinSetHigh, IOExpPinConfigSet(), IOExpSetBitHigh(), IOXP_PORT0, and LEDEventT::pin.
Referenced by NutRegisterLed().
void sys_led | ( | void * | arg | ) |
Thread to control blinking and flashing of all registered LEDs.
This is the internal LED handler thread. It si blocked by default, waiting for a timer event to run. The thread handles LED timing through reverse calculation of the actual timeout. This uses mor system time, but makes blinking effects more smooth even in situation where high priority tasks are delaying the timer interrupt or this threadf to be executed.
arg | Handle of an event queue. |
References first_led, LEDEventT::fx, LED_BLINK, LED_FLIP, LED_OFF, LED_ON, LEDEventT::next, NULL, NUT_WAIT_INFINITE, NUTASSERT, NutEventWait(), NutGetMillis(), NutSetLed(), NutThreadSetPriority(), LEDEventT::state, LEDEventT::tim, LEDEventT::timOff, and LEDEventT::timOn.
Referenced by NutRegisterLed().
void NutSetLed | ( | HANDLE | ledh, |
uint_fast8_t | fxin, | ||
uint32_t | timOn, | ||
uint32_t | timOff | ||
) |
sets state of a LED
ledh | The handle to the LED that should be controlled. |
fxin | Effect to set |
timOn | Duration of the LED's on-time of the effect given. |
timOff | Duration of the LED's off time of the effect given. |
References LEDEventT::bank, LEDEventT::fx, GpioPinSet, IOExpSetBit(), IOXP_PORT0, LED_BLINK, LED_FLIP, LED_OFF, LED_ON, LED_SET_OFF, LED_SET_ON, NULL, NUTASSERT, LEDEventT::pin, LEDEventT::state, LEDEventT::tim, LEDEventT::timOff, and LEDEventT::timOn.
Referenced by sys_led().
int NutRegisterLed | ( | HANDLE * | ledh, |
int | bank, | ||
int | pin | ||
) |
Register an LED for handling.
Register a LED for beeing controlled by this driver. LED can then be set by NutSetLed() by passing over the LEDs handler to that function. Also LEDs connectd through external (I2C / SPI) port chips can be driven, if the control for that chips is enabled in Nutconf. The desired GPIO pin (internal or external) should be configured correct before you can register a LED on it.
ledh | Pointer to a HANDLE for accessing the LED after registering. |
bank | Port of CPU or IO-Expander the LED is connected to. |
pin | Pin at the given port. |
References LEDEventT::bank, first_led, InitLED(), led_evt, LED_SET_OFF, led_tmr, malloc(), memset(), LEDEventT::next, NULL, NutEnterCritical, NutExitCritical, NutThreadCreate(), NutTimerStart(), LEDEventT::pin, LEDEventT::state, and sys_led().
Referenced by NutRegisterLed(), and sys_led().
Referenced by NutRegisterLed().
Referenced by NutRegisterLed().