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.
Ecode_t RTCDRV_SetWallClock (uint32_t secs)
 Set wallclock time.

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 48 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 208 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 390 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 246 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 274 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 727 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 302 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 441 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.

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 753 of file rtcdriver.c.

References ECODE_EMDRV_RTCDRV_OK.

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 486 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 636 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:

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 671 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.