RTCDRV timer module, see RTCDRV Real Time Clock Timer driver page for detailed documentation. More...
![]() |
Defines | |
#define | ECODE_EMDRV_RTCDRV_OK ( ECODE_OK ) |
Success return value. | |
#define | ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000001 ) |
No timers available. | |
#define | ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID ( ECODE_EMDRV_RTCDRV_BASE | 0x00000002 ) |
Illegal timer id. | |
#define | ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000003 ) |
Timer is not allocated. | |
#define | ECODE_EMDRV_RTCDRV_PARAM_ERROR ( ECODE_EMDRV_RTCDRV_BASE | 0x00000004 ) |
Illegal input parameter. | |
#define | ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING ( ECODE_EMDRV_RTCDRV_BASE | 0x00000005 ) |
Timer is not running. | |
#define | EMDRV_RTCDRV_NUM_TIMERS (4) |
Define the number of timers the application needs. | |
Typedefs | |
typedef uint32_t | RTCDRV_TimerID_t |
Timer ID. | |
typedef void(* | RTCDRV_Callback_t )(RTCDRV_TimerID_t id, void *user) |
Typedef for the user supplied callback function which is called when a timer elapse. | |
Enumerations | |
enum | RTCDRV_TimerType_t { rtcdrvTimerTypeOneshot = 0, rtcdrvTimerTypePeriodic = 1 } |
Timer type enumerator. More... | |
Functions | |
Ecode_t | RTCDRV_AllocateTimer (RTCDRV_TimerID_t *id) |
Allocate timer. | |
Ecode_t | RTCDRV_DeInit (void) |
Deinitialize RTCDRV driver. | |
Ecode_t | RTCDRV_Delay (uint32_t ms) |
Millisecond delay function. | |
Ecode_t | RTCDRV_FreeTimer (RTCDRV_TimerID_t id) |
Free timer. | |
Ecode_t | RTCDRV_Init (void) |
Initialize RTCDRV driver. | |
Ecode_t | RTCDRV_IsRunning (RTCDRV_TimerID_t id, bool *isRunning) |
Check if a given timer is running. | |
Ecode_t | RTCDRV_StartTimer (RTCDRV_TimerID_t id, RTCDRV_TimerType_t type, uint32_t timeout, RTCDRV_Callback_t callback, void *user) |
Start a timer. | |
Ecode_t | RTCDRV_StopTimer (RTCDRV_TimerID_t id) |
Stop a given timer. | |
Ecode_t | RTCDRV_TimeRemaining (RTCDRV_TimerID_t id, uint32_t *timeRemaining) |
Get time left before a given timer expires. | |
uint32_t | RTCDRV_GetWallClock (void) |
Get wallclock time. | |
uint32_t | RTCDRV_GetWallClockTicks32 (void) |
Get wallclock tick count as a 32bit value. | |
uint64_t | RTCDRV_GetWallClockTicks64 (void) |
Get wallclock tick count as a 64 bit value. | |
uint64_t | RTCDRV_MsecsToTicks (uint32_t ms) |
Convert from milliseconds to RTC/RTCC ticks. | |
uint64_t | RTCDRV_SecsToTicks (uint32_t secs) |
Convert from seconds to RTC/RTCC ticks. | |
Ecode_t | RTCDRV_SetWallClock (uint32_t secs) |
Set wallclock time. | |
uint32_t | RTCDRV_TicksToMsec (uint64_t ticks) |
Convert from RTC/RTCC ticks to milliseconds. | |
uint32_t | RTCDRV_TicksToSec (uint64_t ticks) |
Convert from RTC/RTCC ticks to seconds. |
RTCDRV timer module, see RTCDRV Real Time Clock Timer driver page for detailed documentation.
#define ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000001 ) |
No timers available.
Definition at line 42 of file rtcdriver.h.
Referenced by RTCDRV_AllocateTimer().
#define ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID ( ECODE_EMDRV_RTCDRV_BASE | 0x00000002 ) |
Illegal timer id.
Definition at line 43 of file rtcdriver.h.
Referenced by RTCDRV_FreeTimer(), RTCDRV_IsRunning(), RTCDRV_StartTimer(), RTCDRV_StopTimer(), and RTCDRV_TimeRemaining().
#define ECODE_EMDRV_RTCDRV_OK ( ECODE_OK ) |
Success return value.
Definition at line 41 of file rtcdriver.h.
Referenced by RTCDRV_AllocateTimer(), RTCDRV_DeInit(), RTCDRV_Delay(), RTCDRV_FreeTimer(), RTCDRV_Init(), RTCDRV_IsRunning(), RTCDRV_SetWallClock(), RTCDRV_StartTimer(), RTCDRV_StopTimer(), RTCDRV_TimeRemaining(), and SPIDRV_Init().
#define ECODE_EMDRV_RTCDRV_PARAM_ERROR ( ECODE_EMDRV_RTCDRV_BASE | 0x00000004 ) |
Illegal input parameter.
Definition at line 45 of file rtcdriver.h.
Referenced by RTCDRV_AllocateTimer(), RTCDRV_IsRunning(), and RTCDRV_TimeRemaining().
#define ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000003 ) |
Timer is not allocated.
Definition at line 44 of file rtcdriver.h.
Referenced by RTCDRV_IsRunning(), RTCDRV_StartTimer(), RTCDRV_StopTimer(), and RTCDRV_TimeRemaining().
#define ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING ( ECODE_EMDRV_RTCDRV_BASE | 0x00000005 ) |
Timer is not running.
Definition at line 46 of file rtcdriver.h.
Referenced by RTCDRV_TimeRemaining().
#define EMDRV_RTCDRV_NUM_TIMERS (4) |
Define the number of timers the application needs.
Definition at line 29 of file rtcdrv_config.h.
Referenced by RTCDRV_AllocateTimer(), RTCDRV_FreeTimer(), RTCDRV_IsRunning(), RTCDRV_StartTimer(), RTCDRV_StopTimer(), and RTCDRV_TimeRemaining().
typedef void(* RTCDRV_Callback_t)(RTCDRV_TimerID_t id, void *user) |
Typedef for the user supplied callback function which is called when a timer elapse.
[in] | id | The timer id. |
[in] | user | Extra parameter for user application. |
Definition at line 65 of file rtcdriver.h.
typedef uint32_t RTCDRV_TimerID_t |
Timer ID.
Definition at line 49 of file rtcdriver.h.
enum RTCDRV_TimerType_t |
Timer type enumerator.
Definition at line 68 of file rtcdriver.h.
Ecode_t RTCDRV_AllocateTimer | ( | RTCDRV_TimerID_t * | id | ) |
Allocate timer.
Reserve a timer instance.
[out] | id | The id of the reserved timer. |
Definition at line 219 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED, ECODE_EMDRV_RTCDRV_OK, ECODE_EMDRV_RTCDRV_PARAM_ERROR, and EMDRV_RTCDRV_NUM_TIMERS.
Referenced by SPIDRV_Init().
Ecode_t RTCDRV_DeInit | ( | void | ) |
Deinitialize RTCDRV driver.
Will disable interrupts and turn off the clock to the underlying hardware timer. If integration with SLEEP module is enabled it will remove any restriction that are set on energy mode usage.
Definition at line 406 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_OK, SLEEP_SleepBlockEnd(), and sleepEM3.
Ecode_t RTCDRV_Delay | ( | uint32_t | ms | ) |
Millisecond delay function.
[in] | ms | Milliseconds to stay in the delay function. |
Definition at line 257 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_OK.
Ecode_t RTCDRV_FreeTimer | ( | RTCDRV_TimerID_t | id | ) |
Free timer.
Release a reserved timer.
[out] | id | The id of the timer to release. |
Definition at line 285 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID, ECODE_EMDRV_RTCDRV_OK, and EMDRV_RTCDRV_NUM_TIMERS.
Referenced by SPIDRV_DeInit().
uint32_t RTCDRV_GetWallClock | ( | void | ) |
Get wallclock time.
Definition at line 743 of file rtcdriver.c.
References RTCDRV_GetWallClockTicks32().
uint32_t RTCDRV_GetWallClockTicks32 | ( | void | ) |
Get wallclock tick count as a 32bit value.
At 4 ticks per millisecond, overflow occurs after approximately 12.5 days
Definition at line 759 of file rtcdriver.c.
Referenced by RTCDRV_GetWallClock(), and RTCDRV_SetWallClock().
uint64_t RTCDRV_GetWallClockTicks64 | ( | void | ) |
Get wallclock tick count as a 64 bit value.
This will never overflow.
Definition at line 786 of file rtcdriver.c.
Ecode_t RTCDRV_Init | ( | void | ) |
Initialize RTCDRV driver.
Will enable all necessary clocks. Initializes internal datastructures and configures the underlying hardware timer.
Definition at line 313 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_OK, SLEEP_SleepBlockBegin(), and sleepEM3.
Referenced by SPIDRV_Init().
Ecode_t RTCDRV_IsRunning | ( | RTCDRV_TimerID_t | id, | |
bool * | isRunning | |||
) |
Check if a given timer is running.
[in] | id | The id of the timer to query. |
[out] | isRunning | True if timer is running. False if not running. Only valid if return status is ECODE_EMDRV_RTCDRV_OK. |
Definition at line 457 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID, ECODE_EMDRV_RTCDRV_OK, ECODE_EMDRV_RTCDRV_PARAM_ERROR, ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED, and EMDRV_RTCDRV_NUM_TIMERS.
uint64_t RTCDRV_MsecsToTicks | ( | uint32_t | ms | ) |
Convert from milliseconds to RTC/RTCC ticks.
[in] | ms | Millisecond value to convert. |
Definition at line 828 of file rtcdriver.c.
uint64_t RTCDRV_SecsToTicks | ( | uint32_t | secs | ) |
Convert from seconds to RTC/RTCC ticks.
[in] | secs | Second value to convert. |
Definition at line 844 of file rtcdriver.c.
Ecode_t RTCDRV_SetWallClock | ( | uint32_t | secs | ) |
Set wallclock time.
[in] | secs | Value to set (seconds). |
Definition at line 811 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_OK, and RTCDRV_GetWallClockTicks32().
Ecode_t RTCDRV_StartTimer | ( | RTCDRV_TimerID_t | id, | |
RTCDRV_TimerType_t | type, | |||
uint32_t | timeout, | |||
RTCDRV_Callback_t | callback, | |||
void * | user | |||
) |
Start a timer.
[in] | id | The id of the timer to start. |
[in] | type | Timer type, oneshot or periodic. See RTCDRV_TimerType_t. |
[in] | timeout | Timeout expressed in milliseconds. If the timeout value is 0, the callback function will be called immediately and the timer will not be started. |
[in] | callback | Function to call on timer expiry. See RTCDRV_Callback_t. NULL is a legal value. |
[in] | user | Extra callback function parameter for user application. |
Definition at line 502 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID, ECODE_EMDRV_RTCDRV_OK, ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED, EMDRV_RTCDRV_NUM_TIMERS, rtcdrvTimerTypePeriodic, SLEEP_SleepBlockBegin(), and sleepEM3.
Referenced by SPIDRV_SReceive(), SPIDRV_SReceiveB(), SPIDRV_STransfer(), SPIDRV_STransferB(), SPIDRV_STransmit(), and SPIDRV_STransmitB().
Ecode_t RTCDRV_StopTimer | ( | RTCDRV_TimerID_t | id | ) |
Stop a given timer.
[in] | id | The id of the timer to stop. |
Definition at line 652 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID, ECODE_EMDRV_RTCDRV_OK, ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED, and EMDRV_RTCDRV_NUM_TIMERS.
Referenced by SPIDRV_AbortTransfer(), and SPIDRV_DeInit().
uint32_t RTCDRV_TicksToMsec | ( | uint64_t | ticks | ) |
Convert from RTC/RTCC ticks to milliseconds.
[in] | ticks | Number of ticks to convert. |
Definition at line 860 of file rtcdriver.c.
uint32_t RTCDRV_TicksToSec | ( | uint64_t | ticks | ) |
Convert from RTC/RTCC ticks to seconds.
[in] | ticks | Number of ticks to convert. |
Definition at line 876 of file rtcdriver.c.
Ecode_t RTCDRV_TimeRemaining | ( | RTCDRV_TimerID_t | id, | |
uint32_t * | timeRemaining | |||
) |
Get time left before a given timer expires.
[in] | id | The id of the timer to query. |
[out] | timeRemaining | Time left expressed in milliseconds. Only valid if return status is ECODE_EMDRV_RTCDRV_OK. |
Definition at line 687 of file rtcdriver.c.
References ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID, ECODE_EMDRV_RTCDRV_OK, ECODE_EMDRV_RTCDRV_PARAM_ERROR, ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED, ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING, and EMDRV_RTCDRV_NUM_TIMERS.