| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
Real Time Clock (RTC)

## Data Structures
struct | stc_rtc_freq_corr
| frequency correction configuration More...
struct | stc_rtc_timer
| Real Time Clock timer configuration structure. More...
struct | stc_rtc_int_sel
| Interrupt configuration structure. More...
struct | stc_rtc_int_cb
| RTC callback functions structure. 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_intern_data
| Datatype for holding internal data needed for RTC. More...
## Defines
#define | RTC_TIMEOUT (SystemCoreClock/10)
#define | RTC_ERR (-1)
#define | DecToBcd(x) ((((x)/10)<<4) + ((x)%10))
#define | BcdToDec(x) ((((x)>>4)*10) + ((x)&0x0F))
#define | RTC_MAX_FREQ_CORR_VALUE (0x3FFu)
| Rtccallback function prototypes.
#define | RTC_MAX_FREQ_CORR_CYCLE_SET_VALUE (0x3Fu)
| Maximum Frequency Correction Cycle Setting Value.
#define | RTC_MAX_TIMER_SET_VALUE (0x20000)
| Maxmimum Timer Setting Value [unit: second].
## Typedefs
typedef enum en_rtc_clk_sel | en_rtc_clk_sel_t
| Real Time Clock clock selection.
typedef enum en_rtc_rtcco_sel | en_rtc_rtcco_sel_t
| RTCCO output selection.
typedef struct stc_rtc_freq_corr | stc_rtc_freq_corr_t
| frequency correction configuration
typedef enum en_rtc_func | en_rtc_func_t
| Real Time Clock functions.
typedef enum en_rtc_day_of_week | en_rtc_day_of_week_t
| Day of week name definitions.
typedef enum en_rtc_month | en_rtc_month_t
| Month name definitions (not used in driver - to be used by user appliciation)
typedef enum en_rtc_time_mode | en_rtc_time_mode_t
| Real Time Clock timer mode selection.
typedef struct stc_rtc_timer | stc_rtc_timer_t
| Real Time Clock timer configuration structure.
typedef enum en_rtc_div_ratio | en_rtc_div_ratio_t
| Rtc Divider Ratio Setting.
typedef struct stc_rtc_int_sel | stc_rtc_int_sel_t
| Interrupt configuration structure.
typedef struct stc_rtc_int_cb | stc_rtc_int_cb_t
| RTC callback functions structure.
typedef struct stc_rtc_time | stc_rtc_time_t
| Real Time Clock Date and Time structure.
typedef enum en_rtc_status | en_rtc_status_t
| Real Time Clock status types.
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.
typedef struct stc_rtc_intern_data | stc_rtc_intern_data_t
| Datatype for holding internal data needed for RTC.
## Enumerations
enum | en_rtc_clk_sel { RtcUseSubClk = 0u, RtcuseMainClk = 1u }
| Real Time Clock clock selection. More...
enum | en_rtc_rtcco_sel { RtccoOutput2Hz = 0, RtccoOutput1Hz = 1 }
| RTCCO output selection. More...
enum | en_rtc_func { RtcCount = 0u, RtcTimer = 1u, RtcFreqCorr = 2u, RtcAlarmYearEn = 3u, RtcAlarmMonthEn = 4u, RtcAlarmDayEn = 5u, RtcAlarmHourEn = 6u, RtcAlarmMinEn = 7u }
| Real Time Clock functions. More...
enum | en_rtc_day_of_week { RtcSunday = 0, RtcMonday = 1, RtcTuesday = 2, RtcWednesday = 3, RtcThursday = 4, RtcFriday = 5, RtcSaturday = 6 }
| Day of week name definitions. More...
enum | en_rtc_month { RtcJanuary = 1, RtcFebuary = 2, RtcMarch = 3, RtcApril = 4, RtcMay = 5, RtcJune = 6, RtcJuly = 7, RtcAugust = 8, RtcSeptember = 9, RtcOctober = 10, RtcNovember = 11, RtcDecember = 12 }
| Month name definitions (not used in driver - to be used by user appliciation) More...
enum | en_rtc_time_mode { RtcTimerOneshot = 0u, RtcTimerPeriod = 1u }
| Real Time Clock timer mode selection. More...
enum | en_rtc_div_ratio { RtcDivRatio1 = 0x00u, RtcDivRatio2 = 0x01u, RtcDivRatio4 = 0x02u, RtcDivRatio8 = 0x03u, RtcDivRatio16 = 0x04u, RtcDivRatio32 = 0x05u, RtcDivRatio64 = 0x06u, RtcDivRatio128 = 0x07u, RtcDivRatio256 = 0x08u, RtcDivRatio512 = 0x09u, RtcDivRatio1024 = 0x0Au, RtcDivRatio2048 = 0x0Bu, RtcDivRatio4096 = 0x0Cu, RtcDivRatio8192 = 0x0Du, RtcDivRatio16384 = 0x0Eu, RtcDivRatio32768 = 0x0Fu }
| Rtc Divider Ratio Setting. More...
enum | en_rtc_status { RtcRewriteError = 0u, RtcAlarmElementMatch = 1u, RtcTimerUnderFlow = 2u, RtcOneHourFlag = 3u, RtcOneMiniteFlag = 4u, RtcOneSecondFlag = 5u, RtcHalfSecondFlag = 6u, RtcRunStatus = 7u, RtcTimerStatus = 8u }
| Real Time Clock status types. More...
## Functions
static void | RtcToTm (stc_rtc_time_t *pstcRtcTime, struct tm *pstcTime)
| Convert RTC time structure to time.h tm structure.
static void | RtcDisableNvic (void)
| Disable RTC NVIC and save original value.
static void | RtcRestoreNvic (void)
| Restore RTC NVIC.
static void | RtcInitIrq (void)
| Device dependent initialization of interrupts according CMSIS with level defined in pdl_user.h.
static void | RtcDeInitIrq (void)
| Device dependent de-initialization of interrupts according CMSIS with level defined in pdl.h.
void | Rtc_IrqHandler (void)
| RTC interrupt service routine.
en_result_t | Rtc_EnableInt (stc_rtc_int_sel_t *pstcIntSel, stc_rtc_int_cb_t *pstcIntCb)
| Enable RTC (and Timer) Interrupts.
en_result_t | Rtc_DisableInt (stc_rtc_int_sel_t *pstcIntSel)
| Disable RTC (and Timer) Interrupts.
en_result_t | Rtc_Init (stc_rtc_config_t *pstcConfig)
| Initialize RTC.
en_result_t | Rtc_DeInit (void)
| De-Initialize RTC.
en_result_t | Rtc_EnableFunc (en_rtc_func_t enFunc)
| Enable functions of RTC.
en_result_t | Rtc_DisableFunc (en_rtc_func_t enFunc)
| Disable functions of RTC.
boolean_t | Rtc_GetStatus (en_rtc_status_t enStatus)
| Get status of RTC according to status type.
en_result_t | Rtc_ClrStatus (en_rtc_status_t enStatus)
| Clear status of RTC according to status type.
void | Rtc_Reset (void)
| Reset RTC.
en_result_t | Rtc_SetDateTime (stc_rtc_time_t *pstcTimeDate, boolean_t bContinue)
| Set time and date after RTC is running.
en_result_t | Rtc_ReadDateTime (stc_rtc_time_t *pstcTimeDate)
| Read RTC time and date.
en_result_t | Rtc_SetAlarmDateTime (stc_rtc_alarm_t *pstcAlarm)
| Set time and date information of Alarm.
en_result_t | Rtc_GetAlarmDateTime (stc_rtc_alarm_t *pstcAlarm)
| Get time and date information of Alarm.
en_result_t | Rtc_SetDayOfWeek (stc_rtc_time_t *pstcRtcTime)
| Set Day of the Week.
en_result_t | Rtc_SetTimerCycle (uint32_t u32TimerCycle)
| Set cycle of RTC timer.
en_result_t | Rtc_SetFreqCorrValue (uint16_t u16Value)
| Set calibration value of RTC frequency correction module.
## Variables
static stc_rtc_intern_data_t | stcRtcInternData
static uint32_t | u32NvicData

## Detailed Description

Provided RTC module functions:

- Rtc_Init()
- Rtc_DeInit()
- Rtc_EnableInt()
- Rtc_DisableInt()
- Rtc_IrqHandler()
- Rtc_EnableFunc()
- Rtc_DisableFunc()
- Rtc_Reset()
- Rtc_GetStatus()
- Rtc_ClrStatus()
- Rtc_SetDateTime()
- Rtc_ReadDateTime()
- Rtc_SetAlarmDateTime()
- Rtc_GetAlarmDateTime()
- Rtc_SetTimerCycle()
- Rtc_SetFreqCorrValue()
- Rtc_SetDayOfWeek()

Rtc_Init() initializes an RTC instance according the configuration of the structure type stc_rtc_config_t. Rtc_DeInit() de-initializes an RTC instance.

Rtc_EnableInt() enables RTC interrupt sources selected by parameter Rtc_EnableInt::stc_rtc_int_sel_t and sets the according interrupt callback functions in the internal data structure. Rtc_DisableInt() disables the RTC interrupt sources selected.

Rtc_IrqHandler() is RTC IRQ handler function, which is called in interrupts.c.

Rtc_EnableFunc() enables RTC function selected by the parameter Rtc_EnableFunc::enFunc and Rtc_DisableFunc() disables RTC function selected.

Rtc_Reset() resets RTC peripheral as well as RTC registers.

Rtc_GetStatus() gets the status selected by Rtc_GetStatus::enStatus and Rtc_ClrStatus() clears the RTC status selected, some status can only be cleared by hardware automatically.

Rtc_SetDateTime() can change the time and date of RTC and Rtc_GetDateTime() gets current time and date.

Rtc_SetAlarmDateTime() can change the alarm time and date, and Rtc_GetAlarmDateTime() gets the alarm time and date.

Rtc_SetTimerCycle() sets the cycle of RTC timer, note that the unit of cycle is second.

Rtc_SetFreqCorrValue() sets the frequency correction value of RTC.

Rtc_SetDayOfWeek() sets the day of week based on time structure supplied.

## Define Documentation

#define BcdToDec | ( |  | x | ) | ((((x)>>4)*10) + ((x)&0x0F))

Definition at line 77 of file rtc.c.

Referenced by Rtc_GetAlarmDateTime(), and Rtc_ReadDateTime().

#define DecToBcd | ( |  | x | ) | ((((x)/10)<<4) + ((x)%10))

Definition at line 75 of file rtc.c.

Referenced by Rtc_Init(), Rtc_IrqHandler(), Rtc_SetAlarmDateTime(), and Rtc_SetDateTime().

#define RTC_ERR (-1)

Definition at line 73 of file rtc.c.

Referenced by Rtc_SetDayOfWeek().

#define RTC_MAX_FREQ_CORR_CYCLE_SET_VALUE (0x3Fu)

Maximum Frequency Correction Cycle Setting Value.

Definition at line 149 of file rtc.h.

Referenced by Rtc_Init().

#define RTC_MAX_FREQ_CORR_VALUE (0x3FFu)

Rtccallback function prototypes.

Maximum Frequency Correction Value

Definition at line 143 of file rtc.h.

Referenced by Rtc_Init(), and Rtc_SetFreqCorrValue().

#define RTC_MAX_TIMER_SET_VALUE (0x20000)

Maxmimum Timer Setting Value [unit: second].

Definition at line 155 of file rtc.h.

Referenced by Rtc_Init(), and Rtc_SetTimerCycle().

#define RTC_TIMEOUT (SystemCoreClock/10)

Definition at line 71 of file rtc.c.

Referenced by Rtc_Init(), Rtc_ReadDateTime(), and Rtc_SetDateTime().

## Typedef Documentation

typedef enum en_rtc_clk_sel en_rtc_clk_sel_t

Real Time Clock clock selection.

typedef enum en_rtc_day_of_week en_rtc_day_of_week_t

Day of week name definitions.

typedef enum en_rtc_div_ratio en_rtc_div_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_func en_rtc_func_t

Real Time Clock functions.

typedef enum en_rtc_month en_rtc_month_t

Month name definitions (not used in driver - to be used by user appliciation)

typedef enum en_rtc_rtcco_sel en_rtc_rtcco_sel_t

RTCCO output selection.

If user needs to output RTCCO, RTCCO pin function should also be enabled in in GPIO macro.

typedef enum en_rtc_status en_rtc_status_t

Real Time Clock status types.

typedef enum en_rtc_time_mode en_rtc_time_mode_t

Real Time Clock timer mode selection.

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_freq_corr stc_rtc_freq_corr_t

frequency correction configuration

typedef struct stc_rtc_int_cb stc_rtc_int_cb_t

RTC callback functions structure.

typedef struct stc_rtc_int_sel stc_rtc_int_sel_t

Interrupt configuration structure.

typedef struct stc_rtc_intern_data stc_rtc_intern_data_t

Datatype for holding internal data needed for RTC.

typedef struct stc_rtc_time stc_rtc_time_t

Real Time Clock Date and Time structure.

typedef struct stc_rtc_timer stc_rtc_timer_t

Real Time Clock timer configuration structure.

## Enumeration Type Documentation

enum en_rtc_clk_sel

Real Time Clock clock selection.

Enumerator:

  RtcUseSubClk | Use sub clock as RTC source clock.
  RtcuseMainClk | Use main clock as RTC source clock.

Definition at line 164 of file rtc.h.

enum en_rtc_day_of_week

Day of week name definitions.

Enumerator:

  RtcSunday | Sunday.
  RtcMonday | Monday.
  RtcTuesday | Tuesday.
  RtcWednesday | Wednesday.
  RtcThursday | Thursday.
  RtcFriday | Friday.
  RtcSaturday | Saturday.

Definition at line 217 of file rtc.h.

enum en_rtc_div_ratio

Rtc Divider Ratio Setting.

Divider Ration Settings for WTC. The enumarted values do not correspond to the bit patterns of WTDIV!

Enumerator:

  RtcDivRatio1 | RIN clock is not divided.
  RtcDivRatio2 | RIN clock is divided by 2.
  RtcDivRatio4 | RIN clock is divided by 4.
  RtcDivRatio8 | RIN clock is divided by 8.
  RtcDivRatio16 | RIN clock is divided by 16.
  RtcDivRatio32 | RIN clock is divided by 32.
  RtcDivRatio64 | RIN clock is divided by 64.
  RtcDivRatio128 | RIN clock is divided by 128.
  RtcDivRatio256 | RIN clock is divided by 256.
  RtcDivRatio512 | RIN clock is divided by 512.
  RtcDivRatio1024 | RIN clock is divided by 1024.
  RtcDivRatio2048 | RIN clock is divided by 2048.
  RtcDivRatio4096 | RIN clock is divided by 4096.
  RtcDivRatio8192 | RIN clock is divided by 8192.
  RtcDivRatio16384 | RIN clock is divided by 16384.
  RtcDivRatio32768 | RIN clock is divided by 32768.

Definition at line 278 of file rtc.h.

enum en_rtc_func

Real Time Clock functions.

Enumerator:

  RtcCount | RTC counting.
  RtcTimer | RTC timer.
  RtcFreqCorr | RTC frequency correction module.
  RtcAlarmYearEn | Year comparison enable of RTC alarm.
  RtcAlarmMonthEn | Month comparison enable of RTC alarm.
  RtcAlarmDayEn | D comparison enable of RTC alarm.
  RtcAlarmHourEn | Hour comparison enable of RTC alarm.
  RtcAlarmMinEn | Minute comparison enable of RTC alarm.

Definition at line 200 of file rtc.h.

enum en_rtc_month

Month name definitions (not used in driver - to be used by user appliciation)

Enumerator:

  RtcJanuary | January.
  RtcFebuary | February.
  RtcMarch | March.
  RtcApril | April.
  RtcMay | May.
  RtcJune | June.
  RtcJuly | July.
  RtcAugust | August.
  RtcSeptember | September.
  RtcOctober | October.
  RtcNovember | November.
  RtcDecember | December.

Definition at line 233 of file rtc.h.

enum en_rtc_rtcco_sel

RTCCO output selection.

If user needs to output RTCCO, RTCCO pin function should also be enabled in in GPIO macro.

Enumerator:

  RtccoOutput2Hz | Output 2Hz signal at RTCCO pin.
  RtccoOutput1Hz | Output 1Hz signal at RTCCO pin.

Definition at line 178 of file rtc.h.

enum en_rtc_status

Real Time Clock status types.

Enumerator:

  RtcRewriteError | Rewrite error.
  RtcAlarmElementMatch | One of alarm element matchs.
  RtcTimerUnderFlow | Timer underflow.
  RtcOneHourFlag | 1-hour count-up flag
  RtcOneMiniteFlag | 1-Minute count-up flag
  RtcOneSecondFlag | 1-second count-up flag
  RtcHalfSecondFlag | 0.5-second count-up flag
  RtcRunStatus | RTC counter run status.
  RtcTimerStatus | RTC timer status.

Definition at line 355 of file rtc.h.

enum en_rtc_time_mode

Real Time Clock timer mode selection.

Enumerator:

  RtcTimerOneshot | One-shot mode.
  RtcTimerPeriod | Periodical mode.

Definition at line 253 of file rtc.h.

## Function Documentation

en_result_t Rtc_ClrStatus | ( | en_rtc_status_t | enStatus | ) |

Clear status of RTC according to status type.

Parameters:

  [in] | enStatus | RTC status type RtcRewriteError RTC rewrite error RtcAlarmElementMatch RTC alarm match RtcTimerUnderFlow RTC Timer underflow RtcOneHourFlag 1-hour count-up flag RtcOneMiniteFlag 1-Minute count-up flag RtcOneSecondFlag 1-second count-up flag RtcHalfSecondFlag 0.5-second count-up flag RtcRunStatus RTC counter run status RtcTimerStatus RTC timer status

Return values:

  Ok | RTC status is cleared normally
  ErrorInvalidParameter | If one of following conditions are met: Invalid value of enStatus

Note:
  The following status can only be cleared by hardware behavior:
  - RtcRunStatus
  - RtcTimerStatus

Definition at line 918 of file rtc.c.

References ErrorInvalidParameter, Ok, RtcAlarmElementMatch, RtcHalfSecondFlag, RtcOneHourFlag, RtcOneMiniteFlag, RtcOneSecondFlag, RtcRewriteError, RtcRunStatus, RtcTimerStatus, and RtcTimerUnderFlow.

en_result_t Rtc_DeInit | ( | void |  | ) |

De-Initialize RTC.

This function stops and resets the RTC module and its interrupts.

Return values:

  Ok | RTC de-initialization normally

Definition at line 678 of file rtc.c.

References Ok.

en_result_t Rtc_DisableFunc | ( | en_rtc_func_t | enFunc | ) |

Disable functions of RTC.

These functions includes RTC counting, Timer, Alarm compariron and frequency correction module.

Parameters:

  enFunc | Function types RtcCount RTC counting RtcTimer RTC timer RtcFreqCorr RTC frequency correction module RtcAlarmYearEn Year comparison enable of RTC alarm RtcAlarmMonthEn Month comparison enable of RTC alarm RtcAlarmDayEn Day comparison enable of RTC alarm RtcAlarmHourEn Hour comparison enable of RTC alarm RtcAlarmMinEn Minute comparison enable of RTC alarm

Return values:

  Ok | RTC functions disabled normally
  ErrorInvalidParameter | If one of following conditions are met: Invalid value of enFunc

Definition at line 783 of file rtc.c.

References ErrorInvalidParameter, Ok, RtcAlarmDayEn, RtcAlarmHourEn, RtcAlarmMinEn, RtcAlarmMonthEn, RtcAlarmYearEn, RtcCount, RtcFreqCorr, and RtcTimer.

en_result_t Rtc_DisableInt | ( | stc_rtc_int_sel_t * | pstcIntSel | ) |

Disable RTC (and Timer) Interrupts.

Parameters:

  [in] | pstcIntSel | Pointer to RTC interrupt selection structure

Return values:

  Ok | Interrupts are disabled
  ErrorInvalidParameter | pstcIntSel == NULL

Definition at line 401 of file rtc.c.

References stc_rtc_int_sel::AlarmInt, ErrorInvalidParameter, FALSE, stc_rtc_int_sel::HalfSecondInt, Ok, stc_rtc_int_sel::OneHourInt, stc_rtc_int_sel::OneMinuteInt, stc_rtc_int_sel::OneSecondInt, RtcDeInitIrq(), stc_rtc_int_sel::TimeRewriteErrorInt, stc_rtc_int_sel::TimerInt, and TRUE.

Here is the call graph for this function:

en_result_t Rtc_EnableFunc | ( | en_rtc_func_t | enFunc | ) |

Enable functions of RTC.

These functions includes RTC counting, Timer, Alarm compariron and frequency correction module.

Parameters:

  enFunc | Function types RtcCount RTC counting RtcTimer RTC timer RtcFreqCorr RTC frequency correction module RtcAlarmYearEn Year comparison enable of RTC alarm RtcAlarmMonthEn Month comparison enable of RTC alarm RtcAlarmDayEn Day comparison enable of RTC alarm RtcAlarmHourEn Hour comparison enable of RTC alarm RtcAlarmMinEn Minute comparison enable of RTC alarm

Return values:

  Ok | RTC functions enabled normally
  ErrorInvalidParameter | If one of following conditions are met: Invalid value of enFunc

Definition at line 726 of file rtc.c.

References ErrorInvalidParameter, Ok, RtcAlarmDayEn, RtcAlarmHourEn, RtcAlarmMinEn, RtcAlarmMonthEn, RtcAlarmYearEn, RtcCount, RtcFreqCorr, and RtcTimer.

en_result_t Rtc_EnableInt | ( | stc_rtc_int_sel_t * | pstcIntSel,
|  | stc_rtc_int_cb_t * | pstcIntCb
| ) |  |

Enable RTC (and Timer) Interrupts.

Parameters:

  [in] | pstcIntSel | Pointer to RTC interrupt selection structure
  [in] | pstcIntCb | Pointer to RTC interrupt callback functions structure

Return values:

  Ok | Interrupts are enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcIntSel == NULL pstcIntCb == NULL

Definition at line 325 of file rtc.c.

References stc_rtc_int_sel::AlarmInt, ErrorInvalidParameter, stc_rtc_int_sel::HalfSecondInt, Ok, stc_rtc_int_sel::OneHourInt, stc_rtc_int_sel::OneMinuteInt, stc_rtc_int_sel::OneSecondInt, stc_rtc_int_cb::pfnAlarmCallback, stc_rtc_intern_data::pfnAlarmCallback, stc_rtc_int_cb::pfnHalfSecondCallback, stc_rtc_intern_data::pfnHalfSecondCallback, stc_rtc_int_cb::pfnOneHourCallback, stc_rtc_intern_data::pfnOneHourCallback, stc_rtc_int_cb::pfnOneMinuteCallback, stc_rtc_intern_data::pfnOneMinuteCallback, stc_rtc_int_cb::pfnOneSecondCallback, stc_rtc_intern_data::pfnOneSecondCallback, stc_rtc_int_cb::pfnTimerCallback, stc_rtc_intern_data::pfnTimerCallback, stc_rtc_int_cb::pfnTimeWrtErrCallback, stc_rtc_intern_data::pfnTimeWrtErrCallback, RtcInitIrq(), stc_rtc_int_sel::TimeRewriteErrorInt, stc_rtc_int_sel::TimerInt, and TRUE.

Here is the call graph for this function:

en_result_t Rtc_GetAlarmDateTime | ( | stc_rtc_alarm_t * | pstcAlarm | ) |

Get time and date information of Alarm.

Parameters:

  [in] | pstcAlarm | Time and date structure

Return values:

  Ok | RTC Alarm time and date is read normally
  ErrorInvalidParameter | If one of following conditions are met: pstcAlarm == NULL

Definition at line 1194 of file rtc.c.

References BcdToDec, ErrorInvalidParameter, Ok, stc_rtc_alarm::u16Year, stc_rtc_alarm::u8Day, stc_rtc_alarm::u8Hour, stc_rtc_alarm::u8Minute, and stc_rtc_alarm::u8Month.

boolean_t Rtc_GetStatus | ( | en_rtc_status_t | enStatus | ) |

Get status of RTC according to status type.

Parameters:

  [in] | enStatus | RTC status type RtcRewriteError RTC rewrite error RtcAlarmElementMatch RTC alarm match RtcTimerUnderFlow RTC Timer underflow RtcOneHourFlag 1-hour count-up flag RtcOneMiniteFlag 1-Minute count-up flag RtcOneSecondFlag 1-second count-up flag RtcHalfSecondFlag 0.5-second count-up flag RtcRunStatus RTC counter run status RtcTimerStatus RTC timer status

Return values:

  FALSE | If one of following conditions are met: No RTC rewrite error [enStatus = RtcRewriteError] No element of alarm matchs [enStatus = RtcAlarmElementMatch] RTC timer underflow doesn't occurs [enStatus = RtcTimerUnderFlow] 1-hour count-up flag is not set [enStatus = RtcOneHourFlag] 1-minute count-up flag is not set [enStatus = RtcOneMiniteFlag] 1-second count-up flag is not set [enStatus = RtcOneSecondFlag] 0.5-second count-up flag is not set [enStatus = RtcHalfSecondFlag] RTC is running [enStatus = RtcRunStatus] RTC timer is running [enStatus = RtcTimerStatus]
  TRUE | If one of following conditions are met: RTC rewrite error occurs [enStatus = RtcRewriteError] One of an element of alarm matchs [enStatus = RtcAlarmElementMatch] RTC timer underflow doesn't occurs [enStatus = RtcTimerUnderFlow] 1-hour count-up flag is set [enStatus = RtcOneHourFlag] 1-minute count-up flag is set [enStatus = RtcOneMiniteFlag] 1-second count-up flag is set [enStatus = RtcOneSecondFlag] 0.5-second count-up flag is set [enStatus = RtcHalfSecondFlag] RTC counter stops [enStatus = RtcRunStatus] RTC timer stops [enStatus = RtcTimerStatus]

Definition at line 855 of file rtc.c.

References FALSE, RtcAlarmElementMatch, RtcHalfSecondFlag, RtcOneHourFlag, RtcOneMiniteFlag, RtcOneSecondFlag, RtcRewriteError, RtcRunStatus, RtcTimerStatus, RtcTimerUnderFlow, and TRUE.

en_result_t Rtc_Init | ( | stc_rtc_config_t * | pstcConfig | ) |

Initialize RTC.

This function initializes the RTC module

Parameters:

  [in] | pstcConfig | Pointer to RTC configuration structure

Return values:

  Ok | RTC initialization completed normally
  ErrorInvalidParameter | If one of following conditions are met: pstcConfig == NULL Invalid value of a pstcConfig's element

Definition at line 488 of file rtc.c.

References __CLKMO, __CLKSO, stc_rtc_config::bEnSuboutDivider, stc_rtc_config::bInitAlarm, stc_rtc_config::bInitFreqCorr, stc_rtc_config::bInitTimeDate, stc_rtc_config::bInitTimer, DecToBcd, stc_rtc_config::enClkSel, stc_rtc_config::enDividerRatio, stc_rtc_timer::enMode, stc_rtc_config::enRtccoSel, ErrorInvalidParameter, ErrorTimeout, Ok, RTC_MAX_FREQ_CORR_CYCLE_SET_VALUE, RTC_MAX_FREQ_CORR_VALUE, RTC_MAX_TIMER_SET_VALUE, RTC_TIMEOUT, RtccoOutput2Hz, RtcDivRatio1, RtcDivRatio1024, RtcDivRatio128, RtcDivRatio16, RtcDivRatio16384, RtcDivRatio2, RtcDivRatio2048, RtcDivRatio256, RtcDivRatio32, RtcDivRatio32768, RtcDivRatio4, RtcDivRatio4096, RtcDivRatio512, RtcDivRatio64, RtcDivRatio8, RtcDivRatio8192, RtcTimerOneshot, RtcTimerPeriod, RtcuseMainClk, RtcUseSubClk, stc_rtc_config::stcAlarm, stc_rtc_config::stcFreqCorrConfig, stc_rtc_config::stcTimeDate, stc_rtc_config::stcTimer, TRUE, stc_rtc_freq_corr::u16FreqCorrCycle, stc_rtc_freq_corr::u16FreqCorrValue, stc_rtc_time::u16Year, stc_rtc_alarm::u16Year, stc_rtc_timer::u32TimerCycle, stc_rtc_time::u8Day, stc_rtc_alarm::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_alarm::u8Hour, stc_rtc_time::u8Minute, stc_rtc_alarm::u8Minute, stc_rtc_time::u8Month, stc_rtc_alarm::u8Month, and stc_rtc_time::u8Second.

void Rtc_IrqHandler | ( | void |  | ) |

RTC interrupt service routine.

Definition at line 184 of file rtc.c.

References DecToBcd, 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::pfnTimerCallback, stc_rtc_intern_data::pfnTimeWrtErrCallback, Rtc_ReadDateTime(), TRUE, stc_rtc_time::u16Year, stc_rtc_time::u8Day, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, and stc_rtc_time::u8Month.

Referenced by TIM_IRQHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

en_result_t Rtc_ReadDateTime | ( | stc_rtc_time_t * | pstcTimeDate | ) |

Read RTC time and date.

Parameters:

  [in] | pstcTimeDate | Time and date structure

Return values:

  Ok | RTC time and date is read normally
  ErrorInvalidParameter | If one of following conditions are met: pstcTimeDate == NULL
  ErrorTimeout | Time and date read timeout

Definition at line 1096 of file rtc.c.

References BcdToDec, ErrorInvalidParameter, ErrorTimeout, Ok, RTC_TIMEOUT, RtcDisableNvic(), RtcRestoreNvic(), stc_rtc_time::u16Year, stc_rtc_time::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, and stc_rtc_time::u8Second.

Referenced by Rtc_IrqHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

void Rtc_Reset | ( | void |  | ) |

Reset RTC.

Definition at line 957 of file rtc.c.

en_result_t Rtc_SetAlarmDateTime | ( | stc_rtc_alarm_t * | pstcAlarm | ) |

Set time and date information of Alarm.

Parameters:

  [in] | pstcAlarm | Time and date structure

Return values:

  Ok | RTC Alarm time and date is set normally
  ErrorInvalidParameter | If one of following conditions are met: pstcAlarm == NULL

Definition at line 1168 of file rtc.c.

References DecToBcd, ErrorInvalidParameter, Ok, stc_rtc_alarm::u16Year, stc_rtc_alarm::u8Day, stc_rtc_alarm::u8Hour, stc_rtc_alarm::u8Minute, and stc_rtc_alarm::u8Month.

en_result_t Rtc_SetDateTime | ( | stc_rtc_time_t * | pstcTimeDate,
|  | boolean_t | bContinue
| ) |  |

Set time and date after RTC is running.

Parameters:

  [in] | pstcTimeDate | Time and date structure
  [in] | bContinue | RTC counting continues or not FALSE RTC 1-second counting reset during setting procedure TRUE RTC 1-second continues during setting procedure

Return values:

  Ok | RTC time and date is set normally
  ErrorInvalidParameter | If one of following conditions are met: pstcTimeDate == NULL
  ErrorInvalidMode | RTC is running
  ErrorTimeout | RTC rewrite timeout

Definition at line 978 of file rtc.c.

References DecToBcd, ErrorInvalidMode, ErrorInvalidParameter, ErrorTimeout, Ok, RTC_TIMEOUT, RtcDisableNvic(), RtcRestoreNvic(), TRUE, stc_rtc_time::u16Year, stc_rtc_time::u8Day, stc_rtc_time::u8DayOfWeek, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, and stc_rtc_time::u8Second.

Here is the call graph for this function:

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.

Parameters:

  [in,out] | pstcRtcTime | RTC Time structure

Return values:

  Ok | Internal data has been setup
  ErrorInvalidParameter | pstcRtcTime == NULL or mktime failed

Definition at line 1230 of file rtc.c.

References ErrorInvalidParameter, Ok, RTC_ERR, RtcToTm(), and stc_rtc_time::u8DayOfWeek.

Here is the call graph for this function:

en_result_t Rtc_SetFreqCorrValue | ( | uint16_t | u16Value | ) |

Set calibration value of RTC frequency correction module.

Parameters:

  [in] | u16Value | Calibration value

Return values:

  Ok | RTC timer cycle is set normally
  ErrorInvalidParameter | If one of following conditions are met: u32TimerCycle > RTC_MAX_FREQ_CORR_VALUE

Definition at line 1294 of file rtc.c.

References ErrorInvalidParameter, Ok, and RTC_MAX_FREQ_CORR_VALUE.

en_result_t Rtc_SetTimerCycle | ( | uint32_t | u32TimerCycle | ) |

Set cycle of RTC timer.

Parameters:

  [in] | u32TimerCycle | Timer cycle

Return values:

  Ok | RTC timer cycle is set normally
  ErrorInvalidParameter | If one of following conditions are met: u32TimerCycle > RTC_MAX_TIMER_SET_VALUE

Note:
  The unit of parameter u32TimerCycle is second.

Definition at line 1272 of file rtc.c.

References ErrorInvalidParameter, Ok, and RTC_MAX_TIMER_SET_VALUE.

static void RtcDeInitIrq | ( | void |  | ) | `[static]`

Device dependent de-initialization of interrupts according CMSIS with level defined in pdl.h.

Definition at line 173 of file rtc.c.

References PDL_DEFAULT_INTERRUPT_LEVEL.

Referenced by Rtc_DisableInt().

Here is the caller graph for this function:

static void RtcDisableNvic | ( | void |  | ) | `[static]`

Disable RTC NVIC and save original value.

Definition at line 116 of file rtc.c.

References u32NvicData.

Referenced by Rtc_ReadDateTime(), and Rtc_SetDateTime().

Here is the caller graph for this function:

static void RtcInitIrq | ( | void |  | ) | `[static]`

Device dependent initialization of interrupts according CMSIS with level defined in pdl_user.h.

Definition at line 159 of file rtc.c.

References PDL_IRQ_LEVEL_CLK_WC_RTC.

Referenced by Rtc_EnableInt().

Here is the caller graph for this function:

static void RtcRestoreNvic | ( | void |  | ) | `[static]`

Restore RTC NVIC.

Definition at line 126 of file rtc.c.

References u32NvicData.

Referenced by Rtc_ReadDateTime(), and Rtc_SetDateTime().

Here is the caller graph for this function:

static void RtcToTm | ( | stc_rtc_time_t * | pstcRtcTime,
|  | struct tm * | pstcTime
| ) |  | `[static]`

Convert RTC time structure to time.h tm structure.

Parameters:

  [in] | pstcRtcTime | RTC Time structure
  [out] | pstcTime | tm Time structure

Definition at line 140 of file rtc.c.

References stc_rtc_time::u16Year, stc_rtc_time::u8Day, stc_rtc_time::u8Hour, stc_rtc_time::u8Minute, stc_rtc_time::u8Month, and stc_rtc_time::u8Second.

Referenced by Rtc_SetDayOfWeek().

Here is the caller graph for this function:

## Variable Documentation

stc_rtc_intern_data_t stcRtcInternData`[static]`

Definition at line 104 of file rtc.c.

uint32_t u32NvicData`[static]`

Definition at line 106 of file rtc.c.

Referenced by RtcDisableNvic(), and RtcRestoreNvic().