Appiko
|
Driver to use milli-second timers using the RTC peripheral. More...
Macros | |
#define | MS_TIMER_RTC_USED RTC_USED_MS_TIMER |
#define | MS_TIMER_CC_COUNT CONCAT_3(RTC, MS_TIMER_RTC_USED, _CC_NUM) |
The number of CC registers in the RTC peripheral used for MS timer. | |
#define | MS_TIMER_FREQ 32768 |
#define | MS_TIMER_TICKS_MS(ms) ((uint32_t) ROUNDED_DIV( (MS_TIMER_FREQ*(uint64_t)(ms)) , 1000) ) |
Enumerations | |
enum | ms_timer_num { MS_TIMER0, MS_TIMER1, MS_TIMER2, MS_TIMER_MAX } |
Enumeration used for specifying the timers that can be used with a RTC peripheral. More... | |
enum | ms_timer_mode { MS_SINGLE_CALL, MS_REPEATED_CALL } |
Enumeration to specify the mode of operation of the timer. More... | |
Functions | |
void | ms_timer_init (uint32_t irq_priority) |
void | ms_timer_start (ms_timer_num id, ms_timer_mode mode, uint64_t ticks, void(*handler)(void)) |
void | ms_timer_stop (ms_timer_num id) |
bool | ms_timer_get_on_status (ms_timer_num id) |
uint32_t | ms_timer_get_current_count (void) |
Return the current count (24 bit) of the RTC timer used. More... | |
#define MS_TIMER_FREQ 32768 |
The frequency used by the RTC running the ms timer. Must be a power of 2 and at max 32768 Hz
Definition at line 55 of file ms_timer.h.
#define MS_TIMER_RTC_USED RTC_USED_MS_TIMER |
Specify which RTC peripheral would be used for the ms timer module
Definition at line 48 of file ms_timer.h.
#define MS_TIMER_TICKS_MS | ( | ms | ) | ((uint32_t) ROUNDED_DIV( (MS_TIMER_FREQ*(uint64_t)(ms)) , 1000) ) |
Macro to find out the rounded number of MS_TIMER ticks for the passed time in milli-seconds
Definition at line 64 of file ms_timer.h.
enum ms_timer_mode |
Enumerator | |
---|---|
MS_SINGLE_CALL | One shot call of the timer. |
MS_REPEATED_CALL | Repeated call of the timer. |
Definition at line 81 of file ms_timer.h.
enum ms_timer_num |
Enumerator | |
---|---|
MS_TIMER0 | Millisecond Timer 0. |
MS_TIMER1 | Millisecond Timer 1. |
MS_TIMER2 | Millisecond Timer 2. |
MS_TIMER_MAX | Not a timer, just used to find the number of timers. |
Definition at line 68 of file ms_timer.h.
|
inline |
Definition at line 127 of file ms_timer.h.
References CONCAT_2, and MS_TIMER_RTC_USED.
Referenced by device_tick_process(), and out_gen_get_ticks().
bool ms_timer_get_on_status | ( | ms_timer_num | id | ) |
Returns if a timer is on
id | ID of timer being enquired |
Definition at line 186 of file ms_timer.c.
void ms_timer_init | ( | uint32_t | irq_priority | ) |
Initialize the RTC peripheral of ID MS_TIMER_RTC_USED to use as a milli-second timer.
irq_priority | The priority of the interrupt level at which the callback function is called |
Definition at line 111 of file ms_timer.c.
References LFCLK_FREQ, MS_SINGLE_CALL, MS_TIMER0, MS_TIMER_FREQ, MS_TIMER_MAX, and ROUNDED_DIV.
Referenced by crystal_test(), and main().
void ms_timer_start | ( | ms_timer_num | id, |
ms_timer_mode | mode, | ||
uint64_t | ticks, | ||
void(*)(void) | handler | ||
) |
Start a milli-second timer
id | ID of the timer to be used from ms_timer_num |
mode | Mode of the timer as specified in ms_timer_mode |
ticks | The number of ticks at MS_TIMER_FREQ after which the timer expires |
handler | Pointer to a function which needs to be called when the timer expires |
Definition at line 134 of file ms_timer.c.
References ASSERT, MS_REPEATED_CALL, MS_SINGLE_CALL, and ms_timer_stop().
Referenced by ble_adv_start(), crystal_test(), device_tick_init(), device_tick_process(), device_tick_switch_mode(), and green_process().
void ms_timer_stop | ( | ms_timer_num | id | ) |
Stop a milli-second timer
id | ID of the timer to be stopped |
Definition at line 173 of file ms_timer.c.
References MS_SINGLE_CALL.
Referenced by ble_adv_stop(), ms_timer_start(), out_gen_stop(), and sensebe_tx_rx_stop().