EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
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 /***************************************************************************/
39 #define ECODE_EMDRV_RTCDRV_OK ( ECODE_OK )
40 #define ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000001 )
41 #define ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID ( ECODE_EMDRV_RTCDRV_BASE | 0x00000002 )
42 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED ( ECODE_EMDRV_RTCDRV_BASE | 0x00000003 )
43 #define ECODE_EMDRV_RTCDRV_PARAM_ERROR ( ECODE_EMDRV_RTCDRV_BASE | 0x00000004 )
44 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING ( ECODE_EMDRV_RTCDRV_BASE | 0x00000005 )
45 
46 typedef uint32_t RTCDRV_TimerID_t;
48 
49 /***************************************************************************/
63 typedef void (*RTCDRV_Callback_t)( RTCDRV_TimerID_t id, void *user );
64 
66 typedef enum {
70 
71 Ecode_t RTCDRV_AllocateTimer( RTCDRV_TimerID_t *id );
72 Ecode_t RTCDRV_DeInit( void );
73 Ecode_t RTCDRV_Delay( uint32_t ms );
74 Ecode_t RTCDRV_FreeTimer( RTCDRV_TimerID_t id );
75 Ecode_t RTCDRV_Init( void );
76 Ecode_t RTCDRV_IsRunning( RTCDRV_TimerID_t id, bool *isRunning );
77 Ecode_t RTCDRV_StartTimer( RTCDRV_TimerID_t id,
78  RTCDRV_TimerType_t type,
79  uint32_t timeout,
80  RTCDRV_Callback_t callback,
81  void *user );
82 Ecode_t RTCDRV_StopTimer( RTCDRV_TimerID_t id );
83 Ecode_t RTCDRV_TimeRemaining( RTCDRV_TimerID_t id, uint32_t *timeRemaining );
84 
85 #if defined( EMDRV_RTCDRV_WALLCLOCK_CONFIG )
86 uint32_t RTCDRV_GetWallClock( void );
87 uint32_t RTCDRV_GetWallClockTicks32( void );
88 uint64_t RTCDRV_GetWallClockTicks64( void );
89 uint64_t RTCDRV_MsecsToTicks( uint32_t ms );
90 uint64_t RTCDRV_SecsToTicks( uint32_t secs );
91 Ecode_t RTCDRV_SetWallClock( uint32_t secs );
92 uint32_t RTCDRV_TicksToMsec( uint64_t ticks );
93 uint32_t RTCDRV_TicksToSec( uint64_t ticks );
94 #endif
95 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* __SILICON_LABS_RTCDRV_H__ */
uint64_t RTCDRV_SecsToTicks(uint32_t secs)
Convert from seconds to RTC/RTCC ticks.
Definition: rtcdriver.c:868
uint32_t RTCDRV_TimerID_t
Timer ID.
Definition: rtcdriver.h:47
Periodic timer.
Definition: rtcdriver.h:68
Oneshot timer.
Definition: rtcdriver.h:67
Energy Aware drivers error code definitions.
Ecode_t RTCDRV_AllocateTimer(RTCDRV_TimerID_t *id)
Allocate timer.
Definition: rtcdriver.c:231
Ecode_t RTCDRV_SetWallClock(uint32_t secs)
Set wallclock time.
Definition: rtcdriver.c:835
Ecode_t RTCDRV_TimeRemaining(RTCDRV_TimerID_t id, uint32_t *timeRemaining)
Get time left before a given timer expires.
Definition: rtcdriver.c:711
RTCDRV_TimerType_t
Timer type enumerator.
Definition: rtcdriver.h:66
Ecode_t RTCDRV_StopTimer(RTCDRV_TimerID_t id)
Stop a given timer.
Definition: rtcdriver.c:674
Ecode_t RTCDRV_Init(void)
Initialize RTCDRV driver.
Definition: rtcdriver.c:324
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:783
uint32_t RTCDRV_GetWallClock(void)
Get wallclock time.
Definition: rtcdriver.c:767
uint32_t RTCDRV_TicksToMsec(uint64_t ticks)
Convert from RTC/RTCC ticks to milliseconds.
Definition: rtcdriver.c:884
uint64_t RTCDRV_GetWallClockTicks64(void)
Get wallclock tick count as a 64 bit value. This will never overflow.
Definition: rtcdriver.c:810
uint64_t RTCDRV_MsecsToTicks(uint32_t ms)
Convert from milliseconds to RTC/RTCC ticks.
Definition: rtcdriver.c:852
Ecode_t RTCDRV_Delay(uint32_t ms)
Millisecond delay function.
Definition: rtcdriver.c:270
Ecode_t RTCDRV_FreeTimer(RTCDRV_TimerID_t id)
Free timer.
Definition: rtcdriver.c:298
uint32_t Ecode_t
Typedef for API function error code return values.
Definition: ecode.h:51
Ecode_t RTCDRV_DeInit(void)
Deinitialize RTCDRV driver.
Definition: rtcdriver.c:417
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:63
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:515
Ecode_t RTCDRV_IsRunning(RTCDRV_TimerID_t id, bool *isRunning)
Check if a given timer is running.
Definition: rtcdriver.c:468
uint32_t RTCDRV_TicksToSec(uint64_t ticks)
Convert from RTC/RTCC ticks to seconds.
Definition: rtcdriver.c:900