CMSIS-RTOS2
Version 2.1.2
Real-Time Operating System: API and RTX Reference Implementation
|
Provides a low level API between an device agnostic RTOS implementation and specific periodic timer capabilities. More...
Functions | |
int32_t | OS_Tick_Setup (uint32_t freq, IRQHandler_t handler) |
Setup OS Tick. More... | |
void | OS_Tick_Enable (void) |
Enable OS Tick. More... | |
void | OS_Tick_Disable (void) |
Disable OS Tick. More... | |
void | OS_Tick_AcknowledgeIRQ (void) |
Acknowledge OS Tick IRQ. More... | |
int32_t | OS_Tick_GetIRQn (void) |
Get OS Tick IRQ number. More... | |
uint32_t | OS_Tick_GetClock (void) |
Get OS Tick clock. More... | |
uint32_t | OS_Tick_GetInterval (void) |
Get OS Tick interval. More... | |
uint32_t | OS_Tick_GetCount (void) |
Get OS Tick count value. More... | |
uint32_t | OS_Tick_GetOverflow (void) |
Get OS Tick overflow status. More... | |
The CMSIS OS Tick API may be used by an arbitrary RTOS implementation to be easily potable across a wide range of controllers.
Cortex-M devices share a common System Tick Timer to be used for RTOS timing purposes. Cortex-A devices do not have a common System Tick Timer but various vendor specific solution. In order to make it easier to enable an RTOS, such as RTX5, to support a wide range of Cortex Microcontrollers the OS Tick API is used to encapsulate the device specific timer implementations.
A default implementation for Cortex-M System Tick Timer can be found in os_systick.c.
weak
thus it can easily be overwritten by an alternative user implementation.int32_t OS_Tick_Setup | ( | uint32_t | freq, |
IRQHandler_t | handler | ||
) |
[in] | freq | tick frequency in Hz |
[in] | handler | tick IRQ handler |
Setup the a hardware time to be used for generating periodic tick interrupts to the RTOS.
The timer should be configured to generate interrupts at the given frequency. The given callback should be used as the interrupt handler.
The timer should only be initialized and configured accordingly. It must not be started nor creating interrupts before OS_Tick_Enable is called.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
int32_t OS_Tick_Enable | ( | void | ) |
Start the timer to count and enable generation of periodic interrupts.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
int32_t OS_Tick_Disable | ( | void | ) |
Stop the timer from counting and disable generation of periodic interrupts.
After a call to this function the timer must not generate any further interrupt.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
int32_t OS_Tick_AcknowledgeIRQ | ( | void | ) |
Acknowledge the pending tick interrupt, i.e. by clear the pending flag.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
int32_t OS_Tick_GetIRQn | ( | void | ) |
Return the actual numeric value to identify the interrupt used by the timer.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
uint32_t OS_Tick_GetClock | ( | void | ) |
Return the clock frequency the timer operates at, i.e. giving the rate the internal counter value is incremented at.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
uint32_t OS_Tick_GetInterval | ( | void | ) |
Return the actual counting interval used for the internal counter value between to consecutive tick interrupts.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
uint32_t OS_Tick_GetCount | ( | void | ) |
Return the current value of the internal counter between 0 to OS_Tick_GetInterval() - 1.
This value is used to calculate subticks, i.e. OS_Tick_GetCount() / OS_Tick_GetInterval(), if a higher time resolution is needed.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example:
OS_Tick_GetOverflow | ( | void | ) |
Return the current state of the overflow signal, i.e. the timers interrupt pending bit.
This information can be used to calculate an intermediate (but correct) tick value while the tick interrupt is pending but blocked.
For a simple Cortex-M device using the built in SystemTick timer the default implementation looks like the following example: