Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_led.h
1 #ifndef _BC_LED_H
2 #define _BC_LED_H
3 
4 #include <bc_gpio.h>
5 #include <bc_scheduler.h>
6 
22 
24 
25 typedef enum
26 {
29 
32 
35 
38 
41 
44 
47 
49 
51 
52 typedef struct bc_led_t bc_led_t;
53 
55 
56 typedef struct
57 {
59  void (*init)(bc_led_t *self);
60 
62  void (*on)(bc_led_t *self);
63 
65  void (*off)(bc_led_t *self);
66 
68 
70 
71 typedef union
72 {
73  bc_gpio_channel_t gpio;
74  int virtual;
75 
76 } bc_led_channel_t;
77 
78 struct bc_led_t
79 {
80  bc_led_channel_t _channel;
81  const bc_led_driver_t *_driver;
82  bool _open_drain_output;
83  int _idle_state;
84  bc_tick_t _slot_interval;
85  uint32_t _pattern;
86  uint32_t _selector;
87  int _count;
88  bool _pulse_active;
89  bc_scheduler_task_id_t _task_id;
90 };
91 
93 
99 
100 void bc_led_init(bc_led_t *self, bc_gpio_channel_t gpio_channel, bool open_drain_output, int idle_state);
101 
107 
108 void bc_led_init_virtual(bc_led_t *self, int channel, const bc_led_driver_t *driver, int idle_state);
109 
113 
114 void bc_led_set_slot_interval(bc_led_t *self, bc_tick_t interval);
115 
119 
120 void bc_led_set_mode(bc_led_t *self, bc_led_mode_t mode);
121 
125 
126 void bc_led_set_pattern(bc_led_t *self, uint32_t pattern);
127 
131 
132 void bc_led_set_count(bc_led_t *self, int count);
133 
137 
138 void bc_led_blink(bc_led_t *self, int count);
139 
143 
144 void bc_led_pulse(bc_led_t *self, bc_tick_t duration);
145 
150 
151 bool bc_led_is_pulse(bc_led_t *self);
152 
154 
155 #endif // _BC_LED_H
bool bc_led_is_pulse(bc_led_t *self)
Check if there is ongoing LED pulse.
Definition: bc_led.c:251
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
LED toggles between on/off state (this has no effect while processing alternating patterns) ...
Definition: bc_led.h:28
LED driver interface.
Definition: bc_led.h:56
bc_led_mode_t
LED modes.
Definition: bc_led.h:25
void bc_led_set_slot_interval(bc_led_t *self, bc_tick_t interval)
Set slot interval for pattern processing.
Definition: bc_led.c:120
void bc_led_set_count(bc_led_t *self, int count)
Set count for blinking pattern executed.
Definition: bc_led.c:225
LED has steady off state.
Definition: bc_led.h:31
void bc_led_blink(bc_led_t *self, int count)
LED blink.
Definition: bc_led.c:230
LED flashes repeatedly.
Definition: bc_led.h:46
struct bc_led_t bc_led_t
LED instance.
Definition: bc_led.h:52
LED blinks slowly.
Definition: bc_led.h:40
LED blinks quickly.
Definition: bc_led.h:43
void bc_led_set_mode(bc_led_t *self, bc_led_mode_t mode)
Set LED mode.
Definition: bc_led.c:125
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
LED blinks.
Definition: bc_led.h:37
void bc_led_init(bc_led_t *self, bc_gpio_channel_t gpio_channel, bool open_drain_output, int idle_state)
Initialize LED.
Definition: bc_led.c:75
void bc_led_set_pattern(bc_led_t *self, uint32_t pattern)
Set custom blinking pattern.
Definition: bc_led.c:217
bc_gpio_channel_t
GPIO channels.
Definition: bc_gpio.h:12
LED has steady on state.
Definition: bc_led.h:34
void bc_led_init_virtual(bc_led_t *self, int channel, const bc_led_driver_t *driver, int idle_state)
Initialize virtual LED.
Definition: bc_led.c:103
void bc_led_pulse(bc_led_t *self, bc_tick_t duration)
Turn on LED for the specified duration of time.
Definition: bc_led.c:239