![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
Data Structures | |
| struct | stc_rtc_interrupts |
| Interrupt configuration structure. More... | |
| struct | stc_rtc_alarm_enable |
| Alarm Register En- and Disable. More... | |
| struct | stc_rtc_time |
| Real Time Clock Date and Time structure. More... | |
| struct | stc_rtc_alarm |
| Real Time Clock Alarm structure. More... | |
| struct | stc_rtc_config |
| Real Time Clock configuration. More... | |
| struct | stc_rtc_timer_config |
| Real Time Clock Timer configuration. More... | |
| struct | stc_rtc_intern_data |
| Datatype for holding internal data needed for RTC. More... | |
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) |
| #define | RTC0 (*((volatile stc_rtcn_t *)FM4_RTC_BASE)) |
| Rtccallback function prototypes. More... | |
| #define | RTC_INTERRUPT_ENABLE_MASK (0xFFu) |
| Number of Irq bit fields, see stc_rtc_interrupts_t. More... | |
| #define | RTC_POLLING_TIMEOUT (100000u) |
| Timeout for WTCR2.CREAD bit polling. More... | |
| #define | RTC_BUSY_POLLING_TIMEOUT (200000u) |
| Timeout for BUSY bit polling. More... | |
| #define | RTC_TRANS_POLLING_TIMEOUT (500000u) |
| Timeout for TRANS bit polling. More... | |
| #define | Rtc_Year(a) ((a) - 2000) |
| Year calculation macro for adjusting RTC year format. More... | |
| #define | RTC_WTCR11_MIEN_FLAG_POSITION (0x01u) |
| Year calculation macro for adjusting RTC year format. More... | |
| #define | RTC_WTCR11_HEN_FLAG_POSITION (0x02u) |
| #define | RTC_WTCR11_DEN_FLAG_POSITION (0x04u) |
| #define | RTC_WTCR11_MOEN_FLAG_POSITION (0x08u) |
| #define | RTC_WTCR11_YEN_FLAG_POSITION (0x10u) |
| #define | RTC_WTCR11_ALL_FLAG_POSITION (0x1Fu) |
| #define | RTC_WTCR12_INTSSI_FLAG_POSITION (0x01u) |
| Bit Positions of Interrupt Flasgs in WTCR12. More... | |
| #define | RTC_WTCR12_INTSI_FLAG_POSITION (0x02u) |
| #define | RTC_WTCR12_INTMI_FLAG_POSITION (0x04u) |
| #define | RTC_WTCR12_INTHI_FLAG_POSITION (0x08u) |
| #define | RTC_WTCR12_INTTMI_FLAG_POSITION (0x10u) |
| #define | RTC_WTCR12_INTALI_FLAG_POSITION (0x20u) |
| #define | RTC_WTCR12_INTERI_FLAG_POSITION (0x40u) |
| #define | RTC_WTCR12_INTCRI_FLAG_POSITION (0x80u) |
| #define | RTC_MAX_FREQ_CORR_VALUE (0x3FFu) |
| Maxmimum Frequency Correction Value. More... | |
| #define | RTC_MAX_FREQ_CORR_CYCLE_SET_VALUE (0x3Fu) |
| Maxmimum Frequency Correction Cycle Setting Value. More... | |
| #define | RTC_MAX_TIMER_SET_VALUE (0x2A2FFu) |
| Maxmimum Timer Setting Value. More... | |
| #define | RTC_BKUP_REG_BASE (FM4_PERIPH_BASE + 0x3B200UL) /* Backup registers */ |
| Backup register area. More... | |
Typedefs | |
| typedef FM4_RTC_TypeDef | stc_rtcn_t |
| typedef void(* | func_ptr_rtc_arglist_t )(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t) |
| typedef enum en_rtc_month | en_rtc_month_t |
| Month name definitions (not used in driver - to be used by user applciation) More... | |
| typedef enum en_rtc_day_of_week | en_rtc_day_of_week_t |
| Day of week name definitions (not used in driver - to be used by user applciation) More... | |
| typedef enum en_rtc_timer_status | en_rtc_timer_status_t |
| Rtc Timer Status. More... | |
| typedef enum en_rtc_trans_status | en_rtc_trans_status_t |
| RTC Transmission Status. More... | |
| typedef enum en_rtc_divider_ratio | en_rtc_divider_ratio_t |
| Rtc Divider Ratio Setting. More... | |
| typedef enum en_rtc_co_div | en_rtc_co_div_t |
| Rtc CO Division. More... | |
| typedef enum en_rtc_bkup_reg_size | en_rtc_bkup_reg_size_t |
| Backup register access size. More... | |
| typedef enum en_rtc_bkup_reg_area | en_rtc_bkup_reg_area_t |
| Backup register area. More... | |
| typedef struct stc_rtc_interrupts | stc_rtc_interrupts_t |
| Interrupt configuration structure. More... | |
| typedef struct stc_rtc_alarm_enable | stc_rtc_alarm_enable_t |
| Alarm Register En- and Disable. More... | |
| typedef struct stc_rtc_time | stc_rtc_time_t |
| Real Time Clock Date and Time structure. More... | |
| typedef struct stc_rtc_alarm | stc_rtc_alarm_t |
| Real Time Clock Alarm structure. More... | |
| typedef struct stc_rtc_config | stc_rtc_config_t |
| Real Time Clock configuration. More... | |
| typedef struct stc_rtc_timer_config | stc_rtc_timer_config_t |
| Real Time Clock Timer configuration. More... | |
| typedef struct stc_rtc_intern_data | stc_rtc_intern_data_t |
| Datatype for holding internal data needed for RTC. More... | |
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 |
Provided functions of RTC module:
Rtc_Init() initializes the RTC with the given time and date given in the RTC configuration. It also initialized the NVIC, if specidfied. Rtc_SetDateTime() allows to set a new date and time. Rtc_SetAlarmDateTime() allows to set a new alarm date and time Rtc_EnableDisableInterrupts() allows to change the interrupt configurations on runtime without touching the RTC work. With Rtc_EnableDisableAlarmRegisters() the comparison to the recent time can be adjusted on runtime. Rtc_ReadClockStatus() reads out the status of the RTC. Rtc_TimerSet() sets the timer value for its interval or one-shot counting. Rtc_TimerStart() starts and Rtc_TimerStop() stops the Timer. With Rtc_ReadDateTimePolling() the recent date and time can be stored in the pointered configuration structure while the Read Completion Interrupt is temporarily disabled. Rtc_TimerStatusRead() reads out the Timer status. Rtc_TransStatusRead() reads out the transmission status. And finally Rtc_DeInit() allows to de-initialize all RTC functions and possible interrupts. Also here to touch the NVIC registers can be set.
Rtc_GetRawTime() is a helper function, which calculates the 'raw' time (UNIX time) from the RTC time structure stc_rtc_time_t. Rtc_SetDayOfWeek() is a helper function, which sets the day of the week calculated from the date and time given in stc_rtc_time_t. Rtc_SetTime() is a helper function which calculates the RTC time structure from the 'raw' time.
Rtc_WriteBkupReg8(), Rtc_WriteBkupReg16() and Rtc_WriteBkupReg32() write a single byte, 16-bit or 32-bit word to a given backup register area. Rtc_ReadBkupReg8(), Rtc_ReadBkupReg16() and Rtc_ReadBkupReg32() read a single byte, 16-bit or 32-bit word from a given backup register area.
| #define RTC0 (*((volatile stc_rtcn_t *)FM4_RTC_BASE)) |
| #define RTC_16BIT (16u) |
Definition at line 87 of file rtc.c.
Referenced by Rtc_TimerSet().
| #define RTC_2BYTES (2u) |
Definition at line 89 of file rtc.c.
Referenced by Rtc_ReadBkupReg16(), and Rtc_WriteBkupReg16().
| #define RTC_4BIT (4u) |
Definition at line 85 of file rtc.c.
Referenced by RtcBcdToBin(), and RtcBinToBcd().
| #define RTC_4BYTES (4u) |
Definition at line 90 of file rtc.c.
Referenced by Rtc_ReadBkupReg32(), and Rtc_WriteBkupReg32().
| #define RTC_8BIT (8u) |
Definition at line 86 of file rtc.c.
Referenced by Rtc_TimerSet().
| #define RTC_BKUP_REG_BASE (FM4_PERIPH_BASE + 0x3B200UL) /* Backup registers */ |
Backup register area.
Definition at line 208 of file rtc.h.
Referenced by Rtc_ReadBkupReg16(), Rtc_ReadBkupReg32(), Rtc_ReadBkupReg8(), Rtc_WriteBkupReg16(), Rtc_WriteBkupReg32(), and Rtc_WriteBkupReg8().
| #define RTC_BUSY_POLLING_TIMEOUT (200000u) |
Timeout for BUSY bit polling.
Definition at line 148 of file rtc.h.
Referenced by Rtc_SetDateTime(), and Rtc_TimerSet().
| #define RTC_DIGIT_10 (10u) |
Definition at line 88 of file rtc.c.
Referenced by RtcBcdToBin(), and RtcBinToBcd().
| #define RTC_ERR (-1) |
Definition at line 105 of file rtc.c.
Referenced by Rtc_GetRawTime(), and Rtc_SetDayOfWeek().
| #define RTC_INTERRUPT_ENABLE_MASK (0xFFu) |
Number of Irq bit fields, see stc_rtc_interrupts_t.
Definition at line 146 of file rtc.h.
Referenced by Rtc_Init().
| #define RTC_MASK_HIGH4BIT (0xF0u) |
Definition at line 102 of file rtc.c.
Referenced by RtcBcdToBin().
| #define RTC_MASK_LOW4BIT (0x0Fu) |
Definition at line 101 of file rtc.c.
Referenced by RtcBcdToBin().
| #define RTC_MAX_FREQ_CORR_CYCLE_SET_VALUE (0x3Fu) |
| #define RTC_MAX_FREQ_CORR_VALUE (0x3FFu) |
Maxmimum Frequency Correction Value.
Definition at line 190 of file rtc.h.
Referenced by Rtc_Init().
| #define RTC_MAX_TIMER_SET_VALUE (0x2A2FFu) |
| #define RTC_POLLING_TIMEOUT (100000u) |
| #define RTC_TRANS_POLLING_TIMEOUT (500000u) |
Timeout for TRANS bit polling.
Definition at line 149 of file rtc.h.
Referenced by RtcWaitTransComplete().
| #define RTC_WTCR11_MIEN_FLAG_POSITION (0x01u) |
| #define RTC_WTCR12_INTCRI_FLAG_POSITION (0x80u) |
Definition at line 184 of file rtc.h.
Referenced by Rtc_ReadDateTimePolling().
| #define RTC_WTCR12_INTSSI_FLAG_POSITION (0x01u) |
| #define RTC_WTCR20_BREAD (0x04u) |
Definition at line 96 of file rtc.c.
Referenced by Rtc_ReadBkupReg16(), Rtc_ReadBkupReg32(), and Rtc_ReadBkupReg8().
| #define RTC_WTCR20_BWRITE (0x08u) |
Definition at line 95 of file rtc.c.
Referenced by Rtc_WriteBkupReg16(), Rtc_WriteBkupReg32(), and Rtc_WriteBkupReg8().
| #define RTC_WTCR20_CREAD (0x01u) |
Definition at line 98 of file rtc.c.
Referenced by Rtc_ReadDateTimePolling(), Rtc_RequestDateTime(), and Rtc_SetAlarmDateTime().
| #define RTC_WTCR20_CWRITE (0x02u) |
Definition at line 97 of file rtc.c.
Referenced by Rtc_DeInit(), Rtc_EnableDisableAlarmRegisters(), Rtc_Init(), Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), Rtc_TimerSet(), Rtc_TimerStart(), and Rtc_TimerStop().
| #define RTC_WTCR20_PWRITE (0x20u) |
Definition at line 93 of file rtc.c.
Referenced by Rtc_DeInit(), and Rtc_Init().
| #define Rtc_Year | ( | a | ) | ((a) - 2000) |
| #define RTC_YEAR_1900 (1900) |
Definition at line 74 of file rtc.c.
Referenced by Rtc_SetTime(), and RtcToTm().
| #define RTC_YEAR_2000 (2000) |
Definition at line 75 of file rtc.c.
Referenced by Rtc_SetTime(), and RtcToTm().
| typedef enum en_rtc_bkup_reg_area en_rtc_bkup_reg_area_t |
Backup register area.
| typedef enum en_rtc_bkup_reg_size en_rtc_bkup_reg_size_t |
Backup register access size.
| typedef enum en_rtc_co_div en_rtc_co_div_t |
Rtc CO Division.
| typedef enum en_rtc_day_of_week en_rtc_day_of_week_t |
Day of week name definitions (not used in driver - to be used by user applciation)
| typedef enum en_rtc_divider_ratio en_rtc_divider_ratio_t |
Rtc Divider Ratio Setting.
Divider Ration Settings for WTC. The enumarted values do not correspond to the bit patterns of WTDIV!
| typedef enum en_rtc_month en_rtc_month_t |
Month name definitions (not used in driver - to be used by user applciation)
| typedef enum en_rtc_timer_status en_rtc_timer_status_t |
Rtc Timer Status.
Read-out Status of RTC Timer Status (WTCR21.TMRUN Register Bit)
| typedef enum en_rtc_trans_status en_rtc_trans_status_t |
RTC Transmission Status.
Read-out Status of RTC Transmission Status (WTCR10.TRANS Register Bit)
| typedef void(* func_ptr_rtc_arglist_t)(uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t) |
| typedef struct stc_rtc_alarm_enable stc_rtc_alarm_enable_t |
Alarm Register En- and Disable.
The RTC Alarm register configuration structure
| typedef struct stc_rtc_alarm stc_rtc_alarm_t |
Real Time Clock Alarm structure.
| typedef struct stc_rtc_config stc_rtc_config_t |
Real Time Clock configuration.
The RTC configuration settings
| typedef struct stc_rtc_intern_data stc_rtc_intern_data_t |
Datatype for holding internal data needed for RTC.
| typedef struct stc_rtc_interrupts stc_rtc_interrupts_t |
Interrupt configuration structure.
The RTC interrupt configuration structure
| typedef struct stc_rtc_time stc_rtc_time_t |
Real Time Clock Date and Time structure.
| typedef struct stc_rtc_timer_config stc_rtc_timer_config_t |
Real Time Clock Timer configuration.
The RTC Timer configuration settings
| typedef FM4_RTC_TypeDef stc_rtcn_t |
| enum en_rtc_bkup_reg_area |
Backup register area.
| enum en_rtc_bkup_reg_size |
| enum en_rtc_co_div |
| enum en_rtc_day_of_week |
| enum en_rtc_divider_ratio |
Rtc Divider Ratio Setting.
Divider Ration Settings for WTC. The enumarted values do not correspond to the bit patterns of WTDIV!
| enum en_rtc_month |
| enum en_rtc_timer_status |
| enum en_rtc_trans_status |
| en_result_t Rtc_DeInit | ( | void | ) |
De-Initialize RTC.
This function stops and resets the RTC module and its interrupts.
| Ok | Internal data has been setup |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1505 of file rtc.c.
References Ok, RTC_WTCR20_CWRITE, RTC_WTCR20_PWRITE, RtcDeInitIrq(), RtcTransToVbat(), and RtcWaitTransComplete().

| en_result_t Rtc_EnableDisableAlarmRegisters | ( | stc_rtc_alarm_enable_t * | pstcRtcAlarmEn | ) |
Enable and/or Disable RTC Alarm Register.
With this function the Alarm registers can be en- or disabled according the configuration
| [in] | pstcRtcAlarmEn | Pointer to settings of alarm enable |
| Ok | Alarm Register set |
| ErrorInvalidParameter | pstcRtcAlarmEn == NULL |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1086 of file rtc.c.
References stc_rtc_alarm_enable::AlarmDayEnable, stc_rtc_alarm_enable::AlarmHourEnable, stc_rtc_alarm_enable::AlarmMinuteEnable, stc_rtc_alarm_enable::AlarmMonthEnable, stc_rtc_alarm_enable::AlarmYearEnable, ErrorInvalidParameter, RTC_WTCR20_CWRITE, RtcTransToVbat(), and TRUE.
Referenced by Rtc_Init().


| en_result_t Rtc_EnableDisableInterrupts | ( | stc_rtc_config_t * | pstcConfig | ) |
Enable and/or Disable RTC (and Timer) Interrupts.
With this function the interrupts enabled and disabled by the RTC configuration can be changed.
| [in] | pstcConfig | RTC configuration structure |
| Ok | Interrupt settings done |
| ErrorInvalidParameter | pstcConfig == NULL |
Definition at line 1006 of file rtc.c.
References stc_rtc_interrupts::AlarmIrqEn, ErrorInvalidParameter, stc_rtc_interrupts::HalfSecondIrqEn, Ok, stc_rtc_interrupts::OneHourIrqEn, stc_rtc_interrupts::OneMinuteIrqEn, stc_rtc_interrupts::OneSecondIrqEn, stc_rtc_interrupts::ReadCompletionIrqEn, stc_rtc_config::stcRtcInterruptEnable, stc_rtc_interrupts::TimeRewriteErrorIrqEn, stc_rtc_interrupts::TimerIrqEn, and TRUE.
Referenced by Rtc_Init().

| time_t Rtc_GetRawTime | ( | stc_rtc_time_t * | pstcRtcTime | ) |
| boolean_t Rtc_GetRunStatus | ( | void | ) |
| 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.
This function initializes the RTC module and sets up the internal data structures. If the sub clock (VBAT domain) was not enabled before, the sub clock enable and stablilization is done in this function.
| [in] | pstcConfig | Pointer to RTC configuration structure |
| [in] | pstcTime | Pointer to RTC Date and Time structure |
| [in] | pstcAlarm | Pointer to RTC Alarm (Data and Time) structure |
| [in] | bTouchNvic | TRUE = touch shared NVIC registers FALSE = do not touch |
| [in] | bResetNoReInit | TRUE = don't initialize RTC if RTC is running FALSE = Initialize RTC regardness of RTC status |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 477 of file rtc.c.
References stc_rtc_config::bUseDivider, stc_rtc_config::bUseFreqCorr, ErrorInvalidParameter, ErrorTimeout, FALSE, Ok, stc_rtc_config::pfnAlarmCallback, stc_rtc_intern_data::pfnAlarmCallback, stc_rtc_config::pfnHalfSecondCallback, stc_rtc_intern_data::pfnHalfSecondCallback, stc_rtc_config::pfnOneHourCallback, stc_rtc_intern_data::pfnOneHourCallback, stc_rtc_config::pfnOneMinuteCallback, stc_rtc_intern_data::pfnOneMinuteCallback, stc_rtc_config::pfnOneSecondCallback, stc_rtc_intern_data::pfnOneSecondCallback, stc_rtc_config::pfnReadCallback, stc_rtc_intern_data::pfnReadCallback, stc_rtc_config::pfnTimerCallback, stc_rtc_intern_data::pfnTimerCallback, stc_rtc_config::pfnTimeWrtErrCallback, stc_rtc_intern_data::pfnTimeWrtErrCallback, Rtc_EnableDisableAlarmRegisters(), Rtc_EnableDisableInterrupts(), RTC_INTERRUPT_ENABLE_MASK, RTC_MAX_FREQ_CORR_VALUE, Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), RTC_WTCR20_CWRITE, RTC_WTCR20_PWRITE, RtcCoDiv1, RtcCoDiv2, RtcDivRatio1, RtcDivRatio1024, RtcDivRatio128, RtcDivRatio16, RtcDivRatio16384, RtcDivRatio2, RtcDivRatio2048, RtcDivRatio256, RtcDivRatio32, RtcDivRatio32768, RtcDivRatio4, RtcDivRatio4096, RtcDivRatio512, RtcDivRatio64, RtcDivRatio8, RtcDivRatio8192, RtcInitIrq(), RtcTransToVbat(), RtcWaitTransComplete(), stc_rtc_config::stcAlarmRegisterEnable, TRUE, stc_rtc_config::u16FreqCorrValue, stc_rtc_config::u8AllInterrupts, stc_rtc_config::u8CoSignalDiv, u8CRead, stc_rtc_config::u8DividerRatio, stc_rtc_config::u8FreqCorrCycle, stc_rtc_config::u8FreqCorrValue0, and stc_rtc_config::u8FreqCorrValue1.

| uint16_t Rtc_ReadBkupReg16 | ( | uint8_t | u8Area | ) |
Read the data from Backup Register (half word access)
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Backup | register value (half word size) (If u8Area is invalid, this function returns 0.) |
Definition at line 1859 of file rtc.c.
References Ok, RTC_2BYTES, RTC_BKUP_REG_BASE, RTC_WTCR20_BREAD, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

| uint32_t Rtc_ReadBkupReg32 | ( | uint8_t | u8Area | ) |
Read the data from Backup Register (word access)
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Backup | register value (word size) (If u8Area is invalid, this function returns 0.) |
Definition at line 1897 of file rtc.c.
References Ok, RTC_4BYTES, RTC_BKUP_REG_BASE, RTC_WTCR20_BREAD, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

| uint8_t Rtc_ReadBkupReg8 | ( | uint8_t | u8Area | ) |
Read the data from Backup Register (byte access)
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Backup | register value (byte size) (If u8Area is invalid, this function returns 0.) |
Definition at line 1824 of file rtc.c.
References Ok, RTC_BKUP_REG_BASE, RTC_WTCR20_BREAD, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

| en_result_t Rtc_ReadDateTimePolling | ( | stc_rtc_time_t * | pstcRtcTime | ) |
Read recent Time of RTC in polling mode.
This function requests a copy of the recent time to the RTC registers and waits until finish. The recent time is transfered to the configuration pointer structure.
| [in,out] | pstcRtcTime | RTC Date and Time structure |
| Ok | Date and time sucessfully transfered |
| ErrorInvalidParameter | pstcRtcTime == NULL |
| ErrorTimeout | Polling loop timed out |
Definition at line 1154 of file rtc.c.
References ErrorInvalidParameter, FALSE, Ok, RTC_WTCR12_INTCRI_FLAG_POSITION, RTC_WTCR20_CREAD, RtcBcdToBin(), RtcTransToVbat(), RtcWaitTransComplete(), stc_rtc_time::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, stc_rtc_time::u8Second, and stc_rtc_time::u8Year.

| en_result_t Rtc_RequestDateTime | ( | void | ) |
Request for Read recent Time of RTC.
This function requests a copy of the recent time to the RTC registers. In the RTC ISR the callback function stc_rtc_config_t::pfnReadCallback with all its 7 arguments for date and time is called.
| Ok | Date and time sucessfully transfered |
| ErrorNotReady | A previously request was not finished |
Definition at line 1225 of file rtc.c.
References ErrorNotReady, Ok, RTC_WTCR20_CREAD, TRUE, and u8CRead.
| en_result_t Rtc_SetAlarmDateTime | ( | stc_rtc_alarm_t * | pstcRtcAlarm | ) |
Check and Set Alarm Date and Alarm Time.
| [in] | pstcRtcAlarm | Pointer to RTC Alarm (Date and Time) structure |
| Ok | Successful initialization |
| ErrorInvalidParameter | If one of following conditions are met:
|
| ErrorTimeout | Timeout to complete transmission |
Definition at line 868 of file rtc.c.
References ErrorInvalidParameter, ErrorTimeout, FALSE, Ok, RTC_WTCR20_CREAD, RTC_WTCR20_CWRITE, RtcBinToBcd(), RtcDisableNvic(), RtcIrqHandler(), RtcRestoreNvic(), RtcTransToVbat(), RtcWaitTransComplete(), TRUE, stc_rtc_alarm::u8AlarmDay, stc_rtc_alarm::u8AlarmHour, stc_rtc_alarm::u8AlarmMinute, stc_rtc_alarm::u8AlarmMonth, and stc_rtc_alarm::u8AlarmYear.
Referenced by Rtc_Init().


| en_result_t Rtc_SetDateTime | ( | stc_rtc_time_t * | pstcRtcTime | ) |
Check and Set RTC Date and RTC Time.
This function builds two 32-bit words for minimum write access to the RTC's date and time registers.
| [in] | pstcRtcTime | Pointer to RTC Date and Time structure |
| Ok | Successful initialization |
| ErrorInvalidParameter | If one of following conditions are met:
|
| ErrorTimeout | Polling loop timed out |
Definition at line 731 of file rtc.c.
References ErrorInvalidParameter, ErrorTimeout, FALSE, Ok, PDL_WAIT_LOOP_HOOK(), RTC_BUSY_POLLING_TIMEOUT, RTC_WTCR20_CWRITE, RtcBinToBcd(), RtcDisableNvic(), RtcRestoreNvic(), RtcTransToVbat(), RtcWaitTransComplete(), TRUE, stc_rtc_time::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, stc_rtc_time::u8Second, and stc_rtc_time::u8Year.
Referenced by Rtc_Init().


| en_result_t Rtc_SetDayOfWeek | ( | stc_rtc_time_t * | pstcRtcTime | ) |
Set Day of the Week.
This function calculates the day of the week from YY-MM-DD in the Time structure. It uses mktime of time.h library.
| [in,out] | pstcRtcTime | RTC Time structure |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | pstcRtcTime == NULL or mktime failed |
Definition at line 1599 of file rtc.c.
References ErrorInvalidParameter, Ok, RTC_ERR, RtcToTm(), and stc_rtc_time::u8DayOfWeek.

| en_result_t Rtc_SetTime | ( | stc_rtc_time_t * | pstcRtcTime, |
| time_t | tRawTime | ||
| ) |
Sets the RTC time structure from raw time.
This function calculates from the RTC time structure "raw" time ('UNIX time').
| [out] | pstcRtcTime | RTC Time structure |
| [in] | tRawTime | "Raw" time |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | pstcRtcTime == NULL or localtime failed |
Definition at line 1643 of file rtc.c.
References ErrorInvalidParameter, Ok, RTC_YEAR_1900, RTC_YEAR_2000, stc_rtc_time::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, stc_rtc_time::u8Second, and stc_rtc_time::u8Year.
| en_result_t Rtc_TimerSet | ( | stc_rtc_timer_config_t * | pstcConfig | ) |
Set Timer Status of RTC.
This function sets the mode and Timer value of the RTC Timer.
| [in] | pstcConfig | Timer Configuration |
| Ok | Timer sucessfully set |
| ErrorInvalidParameter | If one of following conditions are met:
|
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1263 of file rtc.c.
References stc_rtc_timer_config::bTimerIntervalEnable, ErrorInvalidParameter, ErrorTimeout, FALSE, Ok, PDL_WAIT_LOOP_HOOK(), RTC_16BIT, RTC_8BIT, RTC_BUSY_POLLING_TIMEOUT, RTC_WTCR20_CWRITE, RtcDisableNvic(), RtcRestoreNvic(), RtcTransToVbat(), RtcWaitTransComplete(), TRUE, and stc_rtc_timer_config::u32TimerValue.

| en_result_t Rtc_TimerStart | ( | void | ) |
Start Timer Status of RTC.
This function starts the Timer of the RTC Timer.
| Ok | Timer sucessfully start |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1383 of file rtc.c.
References Ok, RTC_WTCR20_CWRITE, RtcTransToVbat(), and TRUE.

| en_rtc_timer_status_t Rtc_TimerStatusRead | ( | void | ) |
Read Timer Status of RTC.
This function provides the status of the TMRUN bit of the WTCR21 register.
| RtcTimerNoOperation | Timer Counter is not operating |
| RtcTimerInOperation | Timer Counter is operationg |
Definition at line 1450 of file rtc.c.
References FALSE, RtcTimerInOperation, and RtcTimerNoOperation.
| en_result_t Rtc_TimerStop | ( | void | ) |
Stops Timer Status of RTC.
This function stops the Timer of the RTC Timer.
| Ok | Timer sucessfully stop |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1418 of file rtc.c.
References FALSE, Ok, RTC_WTCR20_CWRITE, and RtcTransToVbat().

| en_rtc_trans_status_t Rtc_TransStatusRead | ( | void | ) |
Read Transmission Status of RTC.
This function provides the status of the TRANS bit of the WTCR10 register.
| RtcTransNoOperation | Transmission is not operating |
| RtcTransInOperation | Transmission is operationg |
Definition at line 1479 of file rtc.c.
References FALSE, RtcTransInOperation, and RtcTransNoOperation.
| en_result_t Rtc_WriteBkupReg16 | ( | uint16_t | u16Data, |
| uint8_t | u8Area | ||
| ) |
Write the data to Backup Register (half word access)
| [in] | u16Data | Data for backup |
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | Backup register area is out of range or not 2byte alignment |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1735 of file rtc.c.
References ErrorInvalidParameter, Ok, RTC_2BYTES, RTC_BKUP_REG_BASE, RTC_WTCR20_BWRITE, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

| en_result_t Rtc_WriteBkupReg32 | ( | uint32_t | u32Data, |
| uint8_t | u8Area | ||
| ) |
Write the data to Backup Register (word access)
| [in] | u32Data | Data for backup |
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | Backup register area is out of range or not 4byte alignment |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1781 of file rtc.c.
References ErrorInvalidParameter, Ok, RTC_4BYTES, RTC_BKUP_REG_BASE, RTC_WTCR20_BWRITE, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

| en_result_t Rtc_WriteBkupReg8 | ( | uint8_t | u8Data, |
| uint8_t | u8Area | ||
| ) |
Write the data to Backup Register (byte access)
| [in] | u8Data | Data for backup |
| [in] | u8Area | Backup register area This parameter should be set RtcBkupRegAreaXX (XX is 00 to 1F for Unicorn) |
| Ok | Internal data has been setup |
| ErrorInvalidParameter | Backup register area is out of range |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 1693 of file rtc.c.
References ErrorInvalidParameter, Ok, RTC_BKUP_REG_BASE, RTC_WTCR20_BWRITE, RtcBkupRegAreaMax, RtcTransToVbat(), and RtcWaitTransComplete().

|
static |
BCD to Binary conversion.
| [in] | u8BcdValue | BCD Value |
Definition at line 209 of file rtc.c.
References RTC_4BIT, RTC_DIGIT_10, RTC_MASK_HIGH4BIT, and RTC_MASK_LOW4BIT.
Referenced by Rtc_ReadDateTimePolling(), and RtcIrqHandler().

|
static |
Binary to BCD conversion.
| [in] | u8BinValue | Binary Value |
Definition at line 187 of file rtc.c.
References RTC_4BIT, and RTC_DIGIT_10.
Referenced by Rtc_SetAlarmDateTime(), and Rtc_SetDateTime().

|
static |
Device dependent de-initialization of interrupts according CMSIS with level defined in pdl.h.
Definition at line 243 of file rtc.c.
References PDL_DEFAULT_INTERRUPT_LEVEL.
Referenced by Rtc_DeInit().

| void RtcDisableNvic | ( | void | ) |
Disable RTC NVIC and save original value.
Definition at line 142 of file rtc.c.
References u32NvicData.
Referenced by Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), and Rtc_TimerSet().

|
static |
Device dependent initialization of interrupts according CMSIS with level defined in pdl.h.
Definition at line 228 of file rtc.c.
References PDL_IRQ_LEVEL_RTC0.
Referenced by Rtc_Init().

| void RtcIrqHandler | ( | void | ) |
RTC interrupt service routine.
Definition at line 309 of file rtc.c.
References FALSE, stc_rtc_intern_data::pfnAlarmCallback, stc_rtc_intern_data::pfnHalfSecondCallback, stc_rtc_intern_data::pfnOneHourCallback, stc_rtc_intern_data::pfnOneMinuteCallback, stc_rtc_intern_data::pfnOneSecondCallback, stc_rtc_intern_data::pfnReadCallback, stc_rtc_intern_data::pfnTimerCallback, stc_rtc_intern_data::pfnTimeWrtErrCallback, RtcBcdToBin(), TRUE, and u8CRead.
Referenced by Rtc_SetAlarmDateTime().


| void RtcRestoreNvic | ( | void | ) |
Restore RTC NVIC.
Definition at line 152 of file rtc.c.
References u32NvicData.
Referenced by Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), and Rtc_TimerSet().

|
static |
Convert RTC time structure to time.h tm structure.
| [in] | pstcRtcTime | RTC Time structure |
| [out] | pstcTime | tm Time structure |
Definition at line 166 of file rtc.c.
References RTC_YEAR_1900, RTC_YEAR_2000, stc_rtc_time::u8Day, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, stc_rtc_time::u8Second, and stc_rtc_time::u8Year.
Referenced by Rtc_GetRawTime(), and Rtc_SetDayOfWeek().

|
static |
Transfer to/from VBAT domain and wait to complete transmission.
| [in] | u8Control | Control to transmission |
| Ok | Success to complete transmission |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 292 of file rtc.c.
References RtcWaitTransComplete().
Referenced by Rtc_DeInit(), Rtc_EnableDisableAlarmRegisters(), Rtc_Init(), Rtc_ReadBkupReg16(), Rtc_ReadBkupReg32(), Rtc_ReadBkupReg8(), Rtc_ReadDateTimePolling(), Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), Rtc_TimerSet(), Rtc_TimerStart(), Rtc_TimerStop(), Rtc_WriteBkupReg16(), Rtc_WriteBkupReg32(), and Rtc_WriteBkupReg8().


|
static |
Wait to complete writing transmission.
| Ok | Success to complete transmission |
| ErrorTimeout | Timeout to complete transmission |
Definition at line 260 of file rtc.c.
References ErrorTimeout, Ok, PDL_WAIT_LOOP_HOOK(), RTC_TRANS_POLLING_TIMEOUT, and TRUE.
Referenced by Rtc_DeInit(), Rtc_Init(), Rtc_ReadBkupReg16(), Rtc_ReadBkupReg32(), Rtc_ReadBkupReg8(), Rtc_ReadDateTimePolling(), Rtc_SetAlarmDateTime(), Rtc_SetDateTime(), Rtc_TimerSet(), Rtc_WriteBkupReg16(), Rtc_WriteBkupReg32(), Rtc_WriteBkupReg8(), and RtcTransToVbat().


|
static |
|
static |
Definition at line 132 of file rtc.c.
Referenced by RtcDisableNvic(), and RtcRestoreNvic().
|
static |
Definition at line 131 of file rtc.c.
Referenced by Rtc_Init(), Rtc_RequestDateTime(), and RtcIrqHandler().