Hi,
My use case is I have an RGB LED that I want to be green for normal operation, but blink red for 0.5s when a serial driver error occurs.
R, G, and B are each attached to a separate GPIO pin.
How I am planning to do this is:
void serial_event_handler(struct nrf_serial_s const * p_serial, nrf_serial_event_t event) { switch (event) { ... case NRF_SERIAL_EVENT_DRV_ERR: nrf_gpio_pin_set(LED_RED); err_code = app_timer_start(m_led_blink_timer_id, APP_TIMER_TICKS(500), NULL); APP_ERROR_CHECK(err_code); break; ... } }
And the timeout_handler() clears LED_RED and sets LED_GREEN.
But I am trying to support one edge case, which is: if a second error occurs within 0.5s of the first error, I would like to simply feed the timer, so it turns LED_RED off 0.5s after the most recent error, whenever it is.
(For example, say an error occurs at time t = 0 and again at time t = 0.25s. This means LED_RED should be on from time t=0 to t=0.75s.)
My question: is there a way to feed an application timer?
I was thinking I could call app_timer_stop() before every call to app_timer_start(), but in the case of multiple errors occurring in rapid succession, I was concerned if too many start/stops get queued at once, I might hit this "no_mem" condition (screenshot):
1. how much memory does this queue have, and how much memory does one app_timer_start() or app_timer_stop() operation take?
2. is there a way to modify the timer register to feed the timer directly?
Thanks!