I'm using app_timer_set to start a timer, in the handler of this timer, a variable "timerCounter" will be incremented. Somewhere "timerCounter" will be retrieved, I would like to suspend this counter before reading the value of "timeCounter", then resume it again. So I would like to know how to suspend and resume this timer, thanks.
in app_ble_timer_handler(x, x, x, x)
{
timerCounter++;
app_timer_set(SPS_TIMER, TASK_APP, 100);
return (KE_MSG_CONSUMED);
}
Device:
你怎么是n? Everything is single-threaded so there shouldn't be any issues such as interleaving two threads.
If you use timerCounter in interrupts (which I doubt is a good idea), you can use GLOBAL_INT_STOP(); and GLOBAL_INT_START(); around timerCounter++ in non-interrupt code.