19 static uint16_t m_activity_led;
20 static uint16_t m_blink_led;
21 static bool m_initialized;
25 static size_t m_num_leds;
37 int8_t led_valid = -1;
40 (ii < m_num_leds) && (0 > led_valid);
43 if (led == m_led_list[ii])
55 int8_t index = is_led (led);
74 const size_t num_leds)
92 for (
size_t ii = 0u; ii < num_leds; ii++)
94 m_led_list[ii] = leds[ii];
95 m_led_active_state[ii] = active_states[ii];
98 err_code |=
ri_gpio_write (m_led_list[ii], !m_led_active_state[ii]);
103 m_num_leds = num_leds;
104 m_initialized =
true;
114 for (
size_t ii = 0U; ii < m_num_leds; ii++)
121 m_initialized =
false;
134 else if (0 > is_led (led))
161 else if (0 > is_led (led))
167 m_activity_led = led;
175 return m_activity_led;
181 void rt_led_blink_isr (
void *
const p_context)
183 static bool active =
true;
191 void rt_led_blink_once_isr (
void *
const p_context)
215 if (0 > is_led (led))
252 if (0 > is_led (led))
275 if (led != m_blink_led)
291 return m_initialized;
#define RD_ERROR_INVALID_PARAM
Invalid Parameter.
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
bool ri_gpio_is_init(void)
return true if GPIO is init, false otherwise.
rd_status_t ri_gpio_configure(const ri_gpio_id_t pin, const ri_gpio_mode_t mode)
Configure a pin of a port into a mode. If there are several ports the platform driver must implement ...
rd_status_t ri_gpio_init(void)
Initializes GPIO module. Call this before other GPIO functions. After initialization all GPIO pins sh...
rd_status_t ri_gpio_write(const ri_gpio_id_t pin, const ri_gpio_state_t state)
Write a pin of a port into given state If there are several ports the platform driver must implement ...
bool ri_timer_is_init(void)
Check if timer is initialized.
rd_status_t ri_timer_start(ri_timer_id_t timer_id, uint32_t ms, void *const context)
Start given timer at a mode defined in ri_timer_create.
rd_status_t ri_timer_create(ri_timer_id_t *p_timer_id, ri_timer_mode_t mode, ruuvi_timer_timeout_handler_t timeout_handler)
rd_status_t ri_timer_init(void)
rd_status_t ri_timer_stop(ri_timer_id_t timer_id)
void * ri_timer_id_t
Pointer to timer data.
@ RI_TIMER_MODE_SINGLE_SHOT
Header to enable and disable module compilation.
#define RT_MAX_LED_CFG
Conserve RAM for led task variables.
Ruuvi error codes and error check function.
uint16_t ri_gpio_id_t
port<<8 + pin
#define RI_GPIO_ID_UNUSED
Enable implementation selected by application.
@ RI_GPIO_MODE_OUTPUT_HIGHDRIVE
Push-pull output, can be written. Higher current drive than standard.
@ RI_GPIO_MODE_HIGH_Z
High-impedance mode, electrically disconnected.
ri_gpio_state_t
States of GPIO pins.
@ RI_GPIO_LOW
GPIO electrically low.
@ RI_GPIO_HIGH
GPIO electrically high.
Interface functions to timer.
rd_status_t rt_led_init(const ri_gpio_id_t *const leds, const ri_gpio_state_t *const active_states, const size_t num_leds)
LED initialization function.
rd_status_t rt_led_blink_once(const ri_gpio_id_t led, const uint16_t interval_ms)
Function to blink led once.
rd_status_t rt_led_activity_led_set(const ri_gpio_id_t led)
Set LED which is used to indicate activity.
uint16_t rt_led_activity_led_get(void)
Get LED which is used to indicate activity.
bool rt_led_is_init(void)
Check if LED task has been initialized.
rd_status_t rt_led_blink_start(const ri_gpio_id_t led, const uint16_t interval_ms)
Start blinking led at 50 % duty cycle at given interval.
rd_status_t rt_led_blink_stop(const ri_gpio_id_t led)
Stop blinking led and leave the pin as high-drive output in inactive state.
rd_status_t rt_led_write(const ri_gpio_id_t led, const bool state)
LED write function. Set given LED ON or OFF.
void rt_led_activity_indicate(const bool state)
Function to indicate activity in program. Led is turned on while program is active and off while in s...
rd_status_t rt_led_uninit(void)
LED uninitialization function.