EZR32 Leopard Gecko Software Documentation  ezr32lg-doc-4.2.1
rtcdriver.h
Go to the documentation of this file.
1 /***************************************************************************/
16 #ifndef __SILICON_LABS_RTCDRV_H__
17 #define __SILICON_LABS_RTCDRV_H__
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 
22 #include "ecode.h"
23 #include "rtcdrv_config.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /***************************************************************************/
34 /***************************************************************************/
41 #define ECODE_EMDRV_RTCDRV_OK ( ECODE_OK )
42 #define ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000001 )
43 #define ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID ( ECODE_EMDRV_RTCDRV_BASE | 0x00000002 )
44 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000003 )
45 #define ECODE_EMDRV_RTCDRV_PARAM_ERROR ( ECODE_EMDRV_RTCDRV_BASE | 0x00000004 )
46 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING ( ECODE_EMDRV_RTCDRV_BASE | 0x00000005 )
47 
48 typedef uint32_t RTCDRV_TimerID_t;
50 
51 /***************************************************************************/
65 typedef void (*RTCDRV_Callback_t)( RTCDRV_TimerID_t id, void *user );
66 
68 typedef enum {
72 
73 Ecode_t RTCDRV_AllocateTimer( RTCDRV_TimerID_t *id );
74 Ecode_t RTCDRV_DeInit( void );
75 Ecode_t RTCDRV_Delay( uint32_t ms );
76 Ecode_t RTCDRV_FreeTimer( RTCDRV_TimerID_t id );
77 Ecode_t RTCDRV_Init( void );
78 Ecode_t RTCDRV_IsRunning( RTCDRV_TimerID_t id, bool *isRunning );
79 Ecode_t RTCDRV_StartTimer( RTCDRV_TimerID_t id,
80  RTCDRV_TimerType_t type,
81  uint32_t timeout,
82  RTCDRV_Callback_t callback,
83  void *user );
84 Ecode_t RTCDRV_StopTimer( RTCDRV_TimerID_t id );
85 Ecode_t RTCDRV_TimeRemaining( RTCDRV_TimerID_t id, uint32_t *timeRemaining );
86 
87 #if defined( EMDRV_RTCDRV_WALLCLOCK_CONFIG )
88 uint32_t RTCDRV_GetWallClock( void );
89 uint32_t RTCDRV_GetWallClockTicks32( void );
90 uint64_t RTCDRV_GetWallClockTicks64( void );
91 uint64_t RTCDRV_MsecsToTicks( uint32_t ms );
92 uint64_t RTCDRV_SecsToTicks( uint32_t secs );
93 Ecode_t RTCDRV_SetWallClock( uint32_t secs );
94 uint32_t RTCDRV_TicksToMsec( uint64_t ticks );
95 uint32_t RTCDRV_TicksToSec( uint64_t ticks );
96 #endif
97 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* __SILICON_LABS_RTCDRV_H__ */
uint64_t RTCDRV_SecsToTicks(uint32_t secs)
Convert from seconds to RTC/RTCC ticks.
Definition: rtcdriver.c:853
uint32_t RTCDRV_TimerID_t
Timer ID.
Definition: rtcdriver.h:49
Periodic timer.
Definition: rtcdriver.h:70
Oneshot timer.
Definition: rtcdriver.h:69
Energy Aware drivers error code definitions.
Ecode_t RTCDRV_AllocateTimer(RTCDRV_TimerID_t *id)
Allocate timer.
Definition: rtcdriver.c:228
Ecode_t RTCDRV_SetWallClock(uint32_t secs)
Set wallclock time.
Definition: rtcdriver.c:820
Ecode_t RTCDRV_TimeRemaining(RTCDRV_TimerID_t id, uint32_t *timeRemaining)
Get time left before a given timer expires.
Definition: rtcdriver.c:696
RTCDRV_TimerType_t
Timer type enumerator.
Definition: rtcdriver.h:68
Ecode_t RTCDRV_StopTimer(RTCDRV_TimerID_t id)
Stop a given timer.
Definition: rtcdriver.c:661
Ecode_t RTCDRV_Init(void)
Initialize RTCDRV driver.
Definition: rtcdriver.c:322
uint32_t RTCDRV_GetWallClockTicks32(void)
Get wallclock tick count as a 32bit value. At 4 ticks per millisecond, overflow occurs after approxim...
Definition: rtcdriver.c:768
uint32_t RTCDRV_GetWallClock(void)
Get wallclock time.
Definition: rtcdriver.c:752
uint32_t RTCDRV_TicksToMsec(uint64_t ticks)
Convert from RTC/RTCC ticks to milliseconds.
Definition: rtcdriver.c:869
uint64_t RTCDRV_GetWallClockTicks64(void)
Get wallclock tick count as a 64 bit value. This will never overflow.
Definition: rtcdriver.c:795
uint64_t RTCDRV_MsecsToTicks(uint32_t ms)
Convert from milliseconds to RTC/RTCC ticks.
Definition: rtcdriver.c:837
Ecode_t RTCDRV_Delay(uint32_t ms)
Millisecond delay function.
Definition: rtcdriver.c:266
Ecode_t RTCDRV_FreeTimer(RTCDRV_TimerID_t id)
Free timer.
Definition: rtcdriver.c:294
Ecode_t RTCDRV_DeInit(void)
Deinitialize RTCDRV driver.
Definition: rtcdriver.c:415
void(* RTCDRV_Callback_t)(RTCDRV_TimerID_t id, void *user)
Typedef for the user supplied callback function which is called when a timer elapse.
Definition: rtcdriver.h:65
Ecode_t RTCDRV_StartTimer(RTCDRV_TimerID_t id, RTCDRV_TimerType_t type, uint32_t timeout, RTCDRV_Callback_t callback, void *user)
Start a timer.
Definition: rtcdriver.c:511
uint32_t Ecode_t
Typedef for API function errorcode return values.
Definition: ecode.h:31
Ecode_t RTCDRV_IsRunning(RTCDRV_TimerID_t id, bool *isRunning)
Check if a given timer is running.
Definition: rtcdriver.c:466
uint32_t RTCDRV_TicksToSec(uint64_t ticks)
Convert from RTC/RTCC ticks to seconds.
Definition: rtcdriver.c:885