MG32F157 Standard Peripherals Firmware Library
mg32f157_rtc.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32F157_RTC_H
12 #define __MG32F157_RTC_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32f157.h"
20 
29 /* Exported types ------------------------------------------------------------*/
30 /* Exported constants --------------------------------------------------------*/
31 
39 #define RTC_IT_OW ((uint16_t)0x0004)
40 #define RTC_IT_ALR ((uint16_t)0x0002)
41 #define RTC_IT_SEC ((uint16_t)0x0001)
43 #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00))
44 #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \
45  ((IT) == RTC_IT_SEC))
46 
54 #define RTC_FLAG_RTOFF ((uint16_t)0x0020)
55 #define RTC_FLAG_RSF ((uint16_t)0x0008)
56 #define RTC_FLAG_OW ((uint16_t)0x0004)
57 #define RTC_FLAG_ALR ((uint16_t)0x0002)
58 #define RTC_FLAG_SEC ((uint16_t)0x0001)
60 #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00))
61 #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \
62  ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \
63  ((FLAG) == RTC_FLAG_SEC))
64 #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF)
65 
73 /* Exported macro ------------------------------------------------------------*/
74 /* Exported functions --------------------------------------------------------*/
75 
76 void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState);
77 void RTC_EnterConfigMode(void);
78 void RTC_ExitConfigMode(void);
79 uint32_t RTC_GetCounter(void);
80 void RTC_SetCounter(uint32_t CounterValue);
81 void RTC_SetPrescaler(uint32_t PrescalerValue);
82 void RTC_SetAlarm(uint32_t AlarmValue);
83 uint32_t RTC_GetDivider(void);
84 void RTC_WaitForLastTask(void);
85 void RTC_WaitForSynchro(void);
86 FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG);
87 void RTC_ClearFlag(uint16_t RTC_FLAG);
88 ITStatus RTC_GetITStatus(uint16_t RTC_IT);
89 void RTC_ClearITPendingBit(uint16_t RTC_IT);
90 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* __MG32F157_RTC_H */
void RTC_ExitConfigMode(void)
Exits from the RTC configuration mode.
Definition: mg32f157_rtc.c:87
FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG)
Checks whether the specified RTC flag is set or not.
Definition: mg32f157_rtc.c:209
void RTC_SetCounter(uint32_t CounterValue)
Sets the RTC counter value.
Definition: mg32f157_rtc.c:110
void RTC_WaitForLastTask(void)
Waits until last write operation on RTC registers has finished.
Definition: mg32f157_rtc.c:172
ITStatus RTC_GetITStatus(uint16_t RTC_IT)
Checks whether the specified RTC interrupt has occurred or not.
Definition: mg32f157_rtc.c:256
void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState)
Enables or disables the specified RTC interrupts.
Definition: mg32f157_rtc.c:55
void RTC_ClearITPendingBit(uint16_t RTC_IT)
Clears the RTC's interrupt pending bits.
Definition: mg32f157_rtc.c:283
void RTC_SetAlarm(uint32_t AlarmValue)
Sets the RTC alarm value.
Definition: mg32f157_rtc.c:143
uint32_t RTC_GetDivider(void)
Gets the RTC divider value.
Definition: mg32f157_rtc.c:158
void RTC_WaitForSynchro(void)
Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL) are synchronized with RTC APB clock.
Definition: mg32f157_rtc.c:188
void RTC_EnterConfigMode(void)
Enters the RTC configuration mode.
Definition: mg32f157_rtc.c:76
void RTC_SetPrescaler(uint32_t PrescalerValue)
Sets the RTC prescaler value.
Definition: mg32f157_rtc.c:125
uint32_t RTC_GetCounter(void)
Gets the RTC counter value.
Definition: mg32f157_rtc.c:98
void RTC_ClearFlag(uint16_t RTC_FLAG)
Clears the RTC's pending flags.
Definition: mg32f157_rtc.c:238