78 #include <stm32f4xx.h>
85 #define CARME_RTC_STATE_REG RTC_BKP_DR0
86 #define CARME_RTC_STATE_INIT_OK 0x35AC
87 #define CARME_RTC_STATE_TIME_OK 0xA3C5
144 if (
RTC_Init(&RTC_InitStruct) == ERROR) {
172 assert(time->
year < 100 && time->
year >= 0);
173 assert(time->
month <= 12 && time->
month >= 1);
174 assert(time->
day <= 31 && time->
day >= 1);
175 assert(time->
wday <= 7 && time->
wday >= 1);
176 assert(time->
hour < 24 && time->
hour >= 0);
177 assert(time->
min < 60 && time->
min >= 0);
178 assert(time->
sec < 60 && time->
sec >= 0);
222 #if CARME_RTC_USE_WAKEUP_ISR==1
231 void CARME_RTC_SetWakeUpInterrupt(CARME_RTC_WAKEUP_t wakeup) {
235 static uint32_t wakeup_time = 0x7FF;
237 if (wakeup == CARME_RTC_WAKEUP_STOP) {
252 EXTI_InitStructure.
EXTI_Mode = EXTI_Mode_Interrupt;
269 EXTI_InitStructure.
EXTI_Mode = EXTI_Mode_Interrupt;
279 wakeup_time = 0xEFFF;
282 wakeup_time = 0x4FFF;
285 wakeup_time = 0x27FF;
293 case RTC_WAKEUP_500ms:
296 case RTC_WAKEUP_125ms:
332 return (((uint32_t) time.
year + 20) << 25)
333 | ((uint32_t) time.
month << 21)
334 | ((uint32_t) time.
day << 16)
335 | ((uint32_t) time.
hour << 11)
336 | ((uint32_t) time.
min << 5)
337 | ((uint32_t) time.
sec << 1);
uint8_t ERROR_CODES
Error variable.
void CARME_RTC_GetTime(CARME_RTC_TIME_t *time)
Get the date and time from the internal rtc.
RTC interface. Communication interface to use the RTC from the CARME-M4.
ErrorStatus RTC_WaitForSynchro(void)
Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock...
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
void PWR_BackupAccessCmd(FunctionalState NewState)
Enables or disables access to the backup domain (RTC registers, RTC backup data registers and backup ...
void CARME_RTC_Init(void)
Initialize and start the internal RTC of the STM32F4xx. The date and time is set from the external R...
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)
Configures the RTC Wakeup clock source.
uint8_t NVIC_IRQChannelPreemptionPriority
void CARME_RTC_Ext_GetTime(CARME_RTC_TIME_t *time)
Get the Time from the external RTC on mainboard.
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
Checks whether the specified RCC flag is set or not.
void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)
Enables or disables the specified RTC interrupts.
EXTIMode_TypeDef EXTI_Mode
RTC Date structure definition.
ErrorStatus RTC_WakeUpCmd(FunctionalState NewState)
Enables or Disables the RTC WakeUp timer.
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
Configures the RTC clock (RTCCLK).
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct.
uint32_t RTC_AsynchPrediv
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Set the RTC current time.
uint32_t get_fattime(void)
Get the time from the RTC. This function is used from the FatFs and the function prototype is given ...
NVIC Init Structure definition.
void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Get the RTC current Time.
void RCC_RTCCLKCmd(FunctionalState NewState)
Enables or disables the RTC clock.
FunctionalState NVIC_IRQChannelCmd
EXTI Init Structure definition.
RTC Time structure definition.
ERROR_CODES CARME_RTC_SetTime(CARME_RTC_TIME_t *time)
Set the internal rtc date and time.
uint8_t NVIC_IRQChannelSubPriority
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
Configures the RTC Wakeup counter.
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Set the RTC current date.
Structure to store a full date and time.
uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)
Reads data from the specified RTC Backup data Register.
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Enables or disables the Low Speed APB (APB1) peripheral clock.
EXTITrigger_TypeDef EXTI_Trigger
void CARME_RTC_Ext_Init(void)
Initialize the RTC on the CARME mainboard.
void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Get the RTC current date.
void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)
Writes a data in a specified RTC Backup data register.
Communication interface to use the RTC on the CARME mainboard.
void RCC_LSEConfig(uint8_t RCC_LSE)
Configures the External Low Speed oscillator (LSE).
RTC Init structures definition.
FunctionalState EXTI_LineCmd
I2C board support package for the CARME module.