Firmware SDK
twr_tick.c
1 #include <twr_tick.h>
2 #include <twr_irq.h>
3 #include <stm32l0xx.h>
4 
5 static volatile twr_tick_t _twr_tick_counter = 0;
6 
8 {
9  twr_tick_t tick;
10 
11  // Disable interrupts
13 
14  // Get current tick counter
15  tick = _twr_tick_counter;
16 
17  // Enable interrupts
19 
20  return tick;
21 }
22 
24 {
25  twr_tick_t timeout = twr_tick_get() + delay;
26 
27  while (twr_tick_get() < timeout)
28  {
29  continue;
30  }
31 }
32 
33 void twr_tick_increment_irq(twr_tick_t delta)
34 {
35  _twr_tick_counter += delta;
36 }
void twr_tick_wait(twr_tick_t delay)
Delay execution for specified amount of ticks.
Definition: twr_tick.c:23
void twr_irq_enable(void)
Enable interrupt requests globally (call can be nested)
Definition: twr_irq.c:21
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
twr_tick_t twr_tick_get(void)
Get absolute timestamp since start of program.
Definition: twr_tick.c:7
void twr_irq_disable(void)
Disable interrupt requests globally (call can be nested)
Definition: twr_irq.c:7