RTCDRV
[EM_Drivers]

RTCDRV timer module, see RTCDRV Real Time Clock Timer driver page for detailed documentation. More...

Collaboration diagram for RTCDRV:

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.

Detailed Description

RTCDRV timer module, see RTCDRV Real Time Clock Timer driver page for detailed documentation.


Define 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 )
#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 Documentation

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.

Note:
This callback is called from within an interrupt handler with interrupts disabled.
Parameters:
[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.


Enumeration Type Documentation

Timer type enumerator.

Enumerator:
rtcdrvTimerTypeOneshot 

Oneshot timer.

rtcdrvTimerTypePeriodic 

Periodic timer.

Definition at line 68 of file rtcdriver.h.


Function Documentation

Ecode_t RTCDRV_AllocateTimer ( RTCDRV_TimerID_t id  ) 

Allocate timer.

Reserve a timer instance.

Parameters:
[out] id The id of the reserved timer.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED when no timers are available.
ECODE_EMDRV_RTCDRV_PARAM_ERROR if an invalid id pointer was supplied.

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().

Here is the caller graph for this function:

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.

Returns:
ECODE_EMDRV_RTCDRV_OK.

Definition at line 406 of file rtcdriver.c.

References ECODE_EMDRV_RTCDRV_OK, SLEEP_SleepBlockEnd(), and sleepEM3.

Here is the call graph for this function:

Ecode_t RTCDRV_Delay ( uint32_t  ms  ) 

Millisecond delay function.

Parameters:
[in] ms Milliseconds to stay in the delay function.
Returns:
ECODE_EMDRV_RTCDRV_OK.

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.

Parameters:
[out] id The id of the timer to release.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value.

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().

Here is the caller graph for this function:

uint32_t RTCDRV_GetWallClock ( void   ) 

Get wallclock time.

Returns:
Seconds elapsed since RTCDRV was initialized.

Definition at line 743 of file rtcdriver.c.

References RTCDRV_GetWallClockTicks32().

Here is the call graph for this function:

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

Returns:
Wallclock tick counter.

Definition at line 759 of file rtcdriver.c.

Referenced by RTCDRV_GetWallClock(), and RTCDRV_SetWallClock().

Here is the caller graph for this function:

uint64_t RTCDRV_GetWallClockTicks64 ( void   ) 

Get wallclock tick count as a 64 bit value.

This will never overflow.

Returns:
Wallclock tick counter.

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.

Returns:
ECODE_EMDRV_RTCDRV_OK.

Definition at line 313 of file rtcdriver.c.

References ECODE_EMDRV_RTCDRV_OK, SLEEP_SleepBlockBegin(), and sleepEM3.

Referenced by SPIDRV_Init().

Here is the call graph for this function:

Here is the caller graph for this function:

Ecode_t RTCDRV_IsRunning ( RTCDRV_TimerID_t  id,
bool *  isRunning 
)

Check if a given timer is running.

Parameters:
[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.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value.
ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not reserved.
ECODE_EMDRV_RTCDRV_PARAM_ERROR if an invalid isRunning pointer was supplied.

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.

Parameters:
[in] ms Millisecond value to convert.
Returns:
Number of ticks.

Definition at line 828 of file rtcdriver.c.

uint64_t RTCDRV_SecsToTicks ( uint32_t  secs  ) 

Convert from seconds to RTC/RTCC ticks.

Parameters:
[in] secs Second value to convert.
Returns:
Number of ticks.

Definition at line 844 of file rtcdriver.c.

Ecode_t RTCDRV_SetWallClock ( uint32_t  secs  ) 

Set wallclock time.

Parameters:
[in] secs Value to set (seconds).
Returns:
ECODE_EMDRV_RTCDRV_OK

Definition at line 811 of file rtcdriver.c.

References ECODE_EMDRV_RTCDRV_OK, and RTCDRV_GetWallClockTicks32().

Here is the call graph for this function:

Ecode_t RTCDRV_StartTimer ( RTCDRV_TimerID_t  id,
RTCDRV_TimerType_t  type,
uint32_t  timeout,
RTCDRV_Callback_t  callback,
void *  user 
)

Start a timer.

Note:
It is legal to start an already running timer.
Parameters:
[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.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value.
ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not reserved.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Ecode_t RTCDRV_StopTimer ( RTCDRV_TimerID_t  id  ) 

Stop a given timer.

Parameters:
[in] id The id of the timer to stop.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value.
ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not reserved.

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().

Here is the caller graph for this function:

uint32_t RTCDRV_TicksToMsec ( uint64_t  ticks  ) 

Convert from RTC/RTCC ticks to milliseconds.

Parameters:
[in] ticks Number of ticks to convert.
Returns:
Number of milliseconds.

Definition at line 860 of file rtcdriver.c.

uint32_t RTCDRV_TicksToSec ( uint64_t  ticks  ) 

Convert from RTC/RTCC ticks to seconds.

Parameters:
[in] ticks Number of ticks to convert.
Returns:
Number of seconds.

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.

Parameters:
[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.
Returns:
ECODE_EMDRV_RTCDRV_OK on success.
ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value.
ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not reserved.
ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING if the timer is not running.
ECODE_EMDRV_RTCDRV_PARAM_ERROR if an invalid timeRemaining pointer was supplied.

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.