PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
rtc.c File Reference
#include "pdl.h"
Include dependency graph for rtc.c:

Go to the source code of this file.

Macros

#define RTC_YEAR_1900   (1900)
 
#define RTC_YEAR_2000   (2000)
 
#define RTC_SEC_MAX   (59u)
 
#define RTC_MIN_MAX   (59u)
 
#define RTC_HOUR_MAX   (23u)
 
#define RTC_DAY_MAX   (31u)
 
#define RTC_MONTH_MAX   (12u)
 
#define RTC_DAYOFWEEK_MAX   (6u)
 
#define RTC_YEAR_MAX   (99u)
 
#define RTC_4BIT   (4u)
 
#define RTC_8BIT   (8u)
 
#define RTC_16BIT   (16u)
 
#define RTC_DIGIT_10   (10u)
 
#define RTC_2BYTES   (2u)
 
#define RTC_4BYTES   (4u)
 
#define RTC_WTCR20_PWRITE   (0x20u)
 
#define RTC_WTCR20_PREAD   (0x10u)
 
#define RTC_WTCR20_BWRITE   (0x08u)
 
#define RTC_WTCR20_BREAD   (0x04u)
 
#define RTC_WTCR20_CWRITE   (0x02u)
 
#define RTC_WTCR20_CREAD   (0x01u)
 
#define RTC_MASK_LOW4BIT   (0x0Fu)
 
#define RTC_MASK_HIGH4BIT   (0xF0u)
 
#define RTC_ERR   (-1)
 

Functions

static void RtcToTm (stc_rtc_time_t *pstcRtcTime, struct tm *pstcTime)
 Convert RTC time structure to time.h tm structure. More...
 
static uint8_t RtcBinToBcd (uint8_t u8BinValue)
 Binary to BCD conversion. More...
 
static uint8_t RtcBcdToBin (uint8_t u8BcdValue)
 BCD to Binary conversion. More...
 
static void RtcInitIrq (void)
 Device dependent initialization of interrupts according CMSIS with level defined in pdl.h. More...
 
static void RtcDeInitIrq (void)
 Device dependent de-initialization of interrupts according CMSIS with level defined in pdl.h. More...
 
static en_result_t RtcWaitTransComplete (void)
 Wait to complete writing transmission. More...
 
static en_result_t RtcTransToVbat (uint8_t u8Control)
 Transfer to/from VBAT domain and wait to complete transmission. More...
 
void RtcDisableNvic (void)
 Disable RTC NVIC and save original value. More...
 
void RtcRestoreNvic (void)
 Restore RTC NVIC. More...
 
void RtcIrqHandler (void)
 RTC interrupt service routine. More...
 
en_result_t Rtc_Init (stc_rtc_config_t *pstcConfig, stc_rtc_time_t *pstcTime, stc_rtc_alarm_t *pstcAlarm, boolean_t bTouchNvic, boolean_t bResetNoReInit)
 Initialize RTC. More...
 
boolean_t Rtc_GetRunStatus (void)
 Initialize RTC. More...
 
en_result_t Rtc_SetDateTime (stc_rtc_time_t *pstcRtcTime)
 Check and Set RTC Date and RTC Time. More...
 
en_result_t Rtc_SetAlarmDateTime (stc_rtc_alarm_t *pstcRtcAlarm)
 Check and Set Alarm Date and Alarm Time. More...
 
en_result_t Rtc_EnableDisableInterrupts (stc_rtc_config_t *pstcConfig)
 Enable and/or Disable RTC (and Timer) Interrupts. More...
 
en_result_t Rtc_EnableDisableAlarmRegisters (stc_rtc_alarm_enable_t *pstcRtcAlarmEn)
 Enable and/or Disable RTC Alarm Register. More...
 
en_result_t Rtc_ReadDateTimePolling (stc_rtc_time_t *pstcRtcTime)
 Read recent Time of RTC in polling mode. More...
 
en_result_t Rtc_RequestDateTime (void)
 Request for Read recent Time of RTC. More...
 
en_result_t Rtc_TimerSet (stc_rtc_timer_config_t *pstcConfig)
 Set Timer Status of RTC. More...
 
en_result_t Rtc_TimerStart (void)
 Start Timer Status of RTC. More...
 
en_result_t Rtc_TimerStop (void)
 Stops Timer Status of RTC. More...
 
en_rtc_timer_status_t Rtc_TimerStatusRead (void)
 Read Timer Status of RTC. More...
 
en_rtc_trans_status_t Rtc_TransStatusRead (void)
 Read Transmission Status of RTC. More...
 
en_result_t Rtc_DeInit (void)
 De-Initialize RTC. More...
 
time_t Rtc_GetRawTime (stc_rtc_time_t *pstcRtcTime)
 Get raw time. More...
 
en_result_t Rtc_SetDayOfWeek (stc_rtc_time_t *pstcRtcTime)
 Set Day of the Week. More...
 
en_result_t Rtc_SetTime (stc_rtc_time_t *pstcRtcTime, time_t tRawTime)
 Sets the RTC time structure from raw time. More...
 
en_result_t Rtc_WriteBkupReg8 (uint8_t u8Data, uint8_t u8Area)
 Write the data to Backup Register (byte access) More...
 
en_result_t Rtc_WriteBkupReg16 (uint16_t u16Data, uint8_t u8Area)
 Write the data to Backup Register (half word access) More...
 
en_result_t Rtc_WriteBkupReg32 (uint32_t u32Data, uint8_t u8Area)
 Write the data to Backup Register (word access) More...
 
uint8_t Rtc_ReadBkupReg8 (uint8_t u8Area)
 Read the data from Backup Register (byte access) More...
 
uint16_t Rtc_ReadBkupReg16 (uint8_t u8Area)
 Read the data from Backup Register (half word access) More...
 
uint32_t Rtc_ReadBkupReg32 (uint8_t u8Area)
 Read the data from Backup Register (word access) More...
 

Variables

static stc_rtc_intern_data_t stcRtcInternData
 
static uint8_t u8CRead
 
static uint32_t u32NvicData
 

Detailed Description

A detailed description is available at RTC Module description

History:

  • 2013-04-04 1.0 NT First version.
  • 2013-11-22 1.1 EZ Add the "bNoInit" parameter in the Rtc_Init() function. Add Rtc_GetRunStatus() function.
  • 2014-01-15 1.2 EZ The RTC interrupt IRQ disable/enable replaces gloable RTC disable/enable

Definition in file rtc.c.