/** * @brief RTC Tamper Configuration.. * @param None * @retval None */ static void RTC_TamperConfig(void) { EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* EXTI configuration *********************************************************/ EXTI_ClearITPendingBit(EXTI_Line19); EXTI_InitStructure.EXTI_Line = EXTI_Line19; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable RTC_IRQn */ NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* determines the number of active pulse for the specific level */ RTC_TamperFilterConfig(RTC_TamperFilter_2Sample); /* Determines the frequency at which each of the tamper inputs are sampled */ RTC_TamperSamplingFreqConfig(RTC_TamperSamplingFreq_RTCCLK_Div32768); RTC_TamperPullUpCmd(DISABLE); /* Select the tamper 1 with High level */ RTC_TamperTriggerConfig(RTC_Tamper_1, RTC_TamperTrigger_LowLevel ); /* Clear tamper 1 falg */ RTC_ClearFlag(RTC_FLAG_TAMP1F); }
/** * @brief RTC Tamper Configuration.. * @param None * @retval None */ static void RTC_Config(void) { EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* Allow access to RTC */ PWR_BackupAccessCmd(ENABLE); /* Reset Backup Domain */ RCC_BackupResetCmd(ENABLE); RCC_BackupResetCmd(DISABLE); /* Enable the LSE OSC */ RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { } /* Select the RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); RTC_DeInit(); /* Configure the RTC data register and RTC prescaler */ RTC_InitStructure.RTC_AsynchPrediv = 0x7F; RTC_InitStructure.RTC_SynchPrediv = 0xFF; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); /* Set the time to 00h 00mn 00s AM */ RTC_TimeStruct.RTC_H12 = RTC_H12_AM; RTC_TimeStruct.RTC_Hours = 0x00; RTC_TimeStruct.RTC_Minutes = 0x00; RTC_TimeStruct.RTC_Seconds = 0x00; RTC_SetTime(RTC_Format_BCD, &RTC_TimeStruct); /* Enable the RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ RTC_WaitForSynchro(); /* EXTI configuration *******************************************************/ EXTI_ClearITPendingBit(EXTI_Line19); EXTI_InitStructure.EXTI_Line = EXTI_Line19; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable RTC_IRQn */ NVIC_InitStructure.NVIC_IRQChannel = TAMPER_STAMP_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* determines the number of active pulse for the specific level */ RTC_TamperFilterConfig(RTC_TamperFilter_2Sample); /* Determines the frequency at which each of the tamper inputs are sampled */ RTC_TamperSamplingFreqConfig(RTC_TamperSamplingFreq_RTCCLK_Div32768); RTC_TamperPullUpCmd(DISABLE); /* Select the tamper 21 with High level */ RTC_TamperTriggerConfig(RTC_Tamper_1, RTC_TamperTrigger_HighLevel ); /* Clear tamper 1 falg */ RTC_ClearFlag(RTC_FLAG_TAMP1F); }