rtcdriver.h

Go to the documentation of this file.
00001 /***************************************************************************/
00016 #ifndef __SILICON_LABS_RTCDRV_H__
00017 #define __SILICON_LABS_RTCDRV_H__
00018 
00019 #include <stdint.h>
00020 #include <stdbool.h>
00021 
00022 #include "ecode.h"
00023 #include "rtcdrv_config.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /***************************************************************************/
00034 /***************************************************************************/
00041 #define ECODE_EMDRV_RTCDRV_OK                   ( ECODE_OK )                             ///< Success return value.
00042 #define ECODE_EMDRV_RTCDRV_ALL_TIMERS_USED      ( ECODE_EMDRV_RTCDRV_BASE | 0x00000001 ) ///< No timers available.
00043 #define ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID     ( ECODE_EMDRV_RTCDRV_BASE | 0x00000002 ) ///< Illegal timer id.
00044 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED  ( ECODE_EMDRV_RTCDRV_BASE | 0x00000003 ) ///< Timer is not allocated.
00045 #define ECODE_EMDRV_RTCDRV_PARAM_ERROR          ( ECODE_EMDRV_RTCDRV_BASE | 0x00000004 ) ///< Illegal input parameter.
00046 #define ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING    ( ECODE_EMDRV_RTCDRV_BASE | 0x00000005 ) ///< Timer is not running.
00047 
00049 typedef uint32_t RTCDRV_TimerID_t;
00050 
00051 /***************************************************************************/
00065 typedef void (*RTCDRV_Callback_t)( RTCDRV_TimerID_t id, void *user );
00066 
00068 typedef enum {
00069   rtcdrvTimerTypeOneshot=0,    
00070   rtcdrvTimerTypePeriodic=1    
00071 } RTCDRV_TimerType_t;
00072 
00073 Ecode_t   RTCDRV_AllocateTimer( RTCDRV_TimerID_t *id );
00074 Ecode_t   RTCDRV_DeInit( void );
00075 Ecode_t   RTCDRV_Delay( uint32_t ms );
00076 Ecode_t   RTCDRV_FreeTimer( RTCDRV_TimerID_t id );
00077 Ecode_t   RTCDRV_Init( void );
00078 Ecode_t   RTCDRV_IsRunning( RTCDRV_TimerID_t id, bool *isRunning );
00079 Ecode_t   RTCDRV_StartTimer( RTCDRV_TimerID_t id,
00080                              RTCDRV_TimerType_t type,
00081                              uint32_t timeout,
00082                              RTCDRV_Callback_t callback,
00083                              void *user );
00084 Ecode_t   RTCDRV_StopTimer( RTCDRV_TimerID_t id );
00085 Ecode_t   RTCDRV_TimeRemaining( RTCDRV_TimerID_t id, uint32_t *timeRemaining );
00086 
00087 #if defined( EMDRV_RTCDRV_WALLCLOCK_CONFIG )
00088 uint32_t  RTCDRV_GetWallClock( void );
00089 Ecode_t   RTCDRV_SetWallClock( uint32_t secs );
00090 #endif
00091 
00095 #ifdef __cplusplus
00096 }
00097 #endif
00098 
00099 #endif /* __SILICON_LABS_RTCDRV_H__ */