Driver for generic LED.
More...
|
void | twr_led_init (twr_led_t *self, twr_gpio_channel_t gpio_channel, bool open_drain_output, int idle_state) |
| Initialize LED. More...
|
|
void | twr_led_init_virtual (twr_led_t *self, int channel, const twr_led_driver_t *driver, int idle_state) |
| Initialize virtual LED. More...
|
|
void | twr_led_set_slot_interval (twr_led_t *self, twr_tick_t interval) |
| Set slot interval for pattern processing. More...
|
|
void | twr_led_set_mode (twr_led_t *self, twr_led_mode_t mode) |
| Set LED mode. More...
|
|
void | twr_led_set_pattern (twr_led_t *self, uint32_t pattern) |
| Set custom blinking pattern. More...
|
|
void | twr_led_set_count (twr_led_t *self, int count) |
| Set count for blinking pattern executed. More...
|
|
void | twr_led_blink (twr_led_t *self, int count) |
| LED blink. More...
|
|
void | twr_led_pulse (twr_led_t *self, twr_tick_t duration) |
| Turn on LED for the specified duration of time. More...
|
|
bool | twr_led_is_pulse (twr_led_t *self) |
| Check if there is ongoing LED pulse. More...
|
|
Driver for generic LED.
Example: Blink with on-board LED
#include <twr_led.h>
void application_init(void)
{
}
@ TWR_GPIO_LED
GPIO channel LED.
struct twr_led_t twr_led_t
LED instance.
void twr_led_init(twr_led_t *self, twr_gpio_channel_t gpio_channel, bool open_drain_output, int idle_state)
Initialize LED.
void twr_led_set_mode(twr_led_t *self, twr_led_mode_t mode)
Set LED mode.
@ TWR_LED_MODE_BLINK
LED blinks.
◆ twr_led_mode_t
LED modes.
Enumerator |
---|
TWR_LED_MODE_TOGGLE | LED toggles between on/off state (this has no effect while processing alternating patterns)
|
TWR_LED_MODE_OFF | LED has steady off state.
|
TWR_LED_MODE_ON | LED has steady on state.
|
TWR_LED_MODE_BLINK | LED blinks.
|
TWR_LED_MODE_BLINK_SLOW | LED blinks slowly.
|
TWR_LED_MODE_BLINK_FAST | LED blinks quickly.
|
TWR_LED_MODE_FLASH | LED flashes repeatedly.
|
Definition at line 25 of file twr_led.h.
◆ twr_led_blink()
void twr_led_blink |
( |
twr_led_t * |
self, |
|
|
int |
count |
|
) |
| |
LED blink.
- Parameters
-
[in] | self | Instance |
[in] | count | Count of blink |
Definition at line 230 of file twr_led.c.
◆ twr_led_init()
Initialize LED.
- Parameters
-
[in] | self | Instance |
[in] | gpio_channel | GPIO channel LED is connected to |
[in] | open_drain_output | Determines if LED is driven by open-drain output |
[in] | idle_state | GPIO pin idle state (when LED is supposed to be off) |
Definition at line 75 of file twr_led.c.
◆ twr_led_init_virtual()
Initialize virtual LED.
- Parameters
-
[in] | self | Instance |
[in] | channel | Virtual channel LED is connected to |
[in] | driver | Virtual channel LED driver |
[in] | idle_state | Virtual pin idle state (when LED is supposed to be off) |
Definition at line 103 of file twr_led.c.
◆ twr_led_is_pulse()
Check if there is ongoing LED pulse.
- Parameters
-
- Returns
- true If pulse is now active
-
false If pulse is now inactive
Definition at line 251 of file twr_led.c.
◆ twr_led_pulse()
Turn on LED for the specified duration of time.
- Parameters
-
[in] | self | Instance |
[in] | duration | Duration for which LED will be turned on |
Definition at line 239 of file twr_led.c.
◆ twr_led_set_count()
void twr_led_set_count |
( |
twr_led_t * |
self, |
|
|
int |
count |
|
) |
| |
Set count for blinking pattern executed.
- Parameters
-
[in] | self | Instance |
[in] | count | Count for blinking pattern executed, negative value means infinity |
Definition at line 225 of file twr_led.c.
◆ twr_led_set_mode()
Set LED mode.
- Parameters
-
[in] | self | Instance |
[in] | mode | Desired LED mode |
Definition at line 125 of file twr_led.c.
◆ twr_led_set_pattern()
void twr_led_set_pattern |
( |
twr_led_t * |
self, |
|
|
uint32_t |
pattern |
|
) |
| |
Set custom blinking pattern.
- Parameters
-
[in] | self | Instance |
[in] | pattern | Blinking pattern (bits with log. 1 represent active slot) |
Definition at line 217 of file twr_led.c.
◆ twr_led_set_slot_interval()
Set slot interval for pattern processing.
- Parameters
-
[in] | self | Instance |
[in] | interval | Desired slot interval in ticks |
Definition at line 120 of file twr_led.c.