Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_tick.c
1 #include <bc_tick.h>
2 #include <bc_irq.h>
3 #include <stm32l0xx.h>
4 
5 static bc_tick_t _bc_tick_counter = 0;
6 
8 {
9  bc_tick_t tick;
10 
11  // Disable interrupts
13 
14  // Get current tick counter
15  tick = _bc_tick_counter;
16 
17  // Enable interrupts
18  bc_irq_enable();
19 
20  return tick;
21 }
22 
24 {
25  bc_tick_t timeout = bc_tick_get() + delay;
26 
27  while (bc_tick_get() < timeout)
28  {
29  continue;
30  }
31 }
32 
33 void bc_tick_inrement_irq(bc_tick_t delta)
34 {
35  _bc_tick_counter += delta;
36 }
void bc_tick_wait(bc_tick_t delay)
Delay execution for specified amount of ticks.
Definition: bc_tick.c:23
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
void bc_irq_enable(void)
Enable interrupt requests globally (call can be nested)
Definition: bc_irq.c:21
bc_tick_t bc_tick_get(void)
Get absolute timestamp since start of program.
Definition: bc_tick.c:7
void bc_irq_disable(void)
Disable interrupt requests globally (call can be nested)
Definition: bc_irq.c:7