本文整理汇总了C++中RTC_ITConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_ITConfig函数的具体用法?C++ RTC_ITConfig怎么用?C++ RTC_ITConfig使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_ITConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRTCTime
/*********************************
**函数名:SetRTCTime
**功能:设置时间,除了把Real_Time的值改变外,还要把时分秒转换为RTC计数值,年月日存到后备寄存器上
**注意事项:函数内会自动根据年月日计算星期,并且返回到*time上
**********************************/
void SetRTCTime(T_STRUCT* time)
{
u32 count;
RTC_ITConfig(RTC_IT_SEC, DISABLE); //关闭秒中断
RTC_WaitForLastTask();
//付时间值到Real_Time上
Real_Time.year=time->year;
Real_Time.month=time->month;
Real_Time.day=time->day;
Real_Time.hour=time->hour;
Real_Time.minute=time->minute;
Real_Time.sec=time->sec;
//计算星期
time->date=Real_Time.date=GetDate(time);
//把新的年月日存到掉电寄存器上
BKP_WriteBackupRegister(BKP_TIME_DATE,Real_Time.date);
// RTC_WaitForLastTask();
BKP_WriteBackupRegister(BKP_TIME_DAY,Real_Time.day);
// RTC_WaitForLastTask();
BKP_WriteBackupRegister(BKP_TIME_MONTH,Real_Time.month);
// RTC_WaitForLastTask();
BKP_WriteBackupRegister(BKP_TIME_YEAR,Real_Time.year);
// RTC_WaitForLastTask();
//计算新的RTC count值
count=Real_Time.hour*3600+Real_Time.minute*60+Real_Time.sec;
RTC_WaitForLastTask();
RTC_SetCounter(count);
RTC_WaitForLastTask();
RTC_ITConfig(RTC_IT_SEC, ENABLE); //打开秒中断
}
示例2: sleep
/***************************************************************************
Declaration : void sleep(char wdt_prescaler)
Description : Sleep until WDT interrupt controlled by wdt_prescaler
***************************************************************************/
void sleep(int data_ms, char mode)
{
/* Enable the RTC Alarm interrupt */
RTC_ITConfig(RTC_IT_ALR, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Alarm in data_ms */
// RTC_SetAlarm(RTC_GetCounter()+ data_ms<<5);
RTC_SetAlarm(RTC_GetCounter()+ data_ms);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Request to enter STOP mode with regulator ON */
PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFI);
/* At this stage the system has resumed from STOP mode -------------------*/
/* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL
as system clock source (HSE and PLL are disabled in STOP mode) */
/* Enable the RTC Alarm interrupt */
SYSCLKConfig_STOP();
RTC_ITConfig(RTC_IT_ALR, DISABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
示例3: radiotimer_schedule
void radiotimer_schedule(uint16_t offset) {
RTC_ITConfig(RTC_IT_ALR, DISABLE);
//need to disable radio also in case that a radio interrupt is happening
// Set the RTC alarm(RTC timer will alarm at next state of slot)
RTC_SetAlarm(offset);
RTC_WaitForLastTask();
//set radiotimer irpstatus
radiotimer_vars.overflowORcompare = RADIOTIMER_COMPARE;
RTC_ClearFlag(RTC_IT_ALR);
RTC_ITConfig(RTC_IT_ALR, ENABLE);
}
示例4: radiotimer_cancel
void radiotimer_cancel() {
RTC_ITConfig(RTC_IT_ALR, DISABLE);
//need to disable radio also in case that a radio interrupt is happening
// set RTC alarm (slotlength)
RTC_SetAlarm(radiotimer_vars.currentSlotPeriod);
RTC_WaitForLastTask();
//set radiotimer irpstatus
radiotimer_vars.overflowORcompare = RADIOTIMER_OVERFLOW;
RTC_ClearFlag(RTC_IT_ALR);
RTC_ITConfig(RTC_IT_ALR, ENABLE);
}
示例5: RTC_Configuration
/**
* @brief Configures the RTC.
* @param None
* @retval : None
*/
void RTC_Configuration(void)
{
/* Enable PWR and BKP clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
/* Reset Backup Domain */
BKP_DeInit();
/* Enable LSE */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Enable the RTC Second */
RTC_ITConfig(RTC_IT_SEC, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Set RTC prescaler: set RTC period to 1sec */
RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
示例6: HAL_RTC_Set_UnixAlarm
void HAL_RTC_Set_UnixAlarm(time_t value)
{
RTC_AlarmTypeDef RTC_AlarmStructure;
time_t alarm_time = HAL_RTC_Get_UnixTime() + value;
struct tm *alarm_time_tm;
alarm_time_tm = localtime(&alarm_time);
/* Disable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = alarm_time_tm->tm_hour;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = alarm_time_tm->tm_min;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = alarm_time_tm->tm_sec;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = alarm_time_tm->tm_mday;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_None;
/* Configure the RTC Alarm A register */
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable the RTC Alarm A Interrupt */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Clear RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
}
示例7: RTC_Configuration
/**
* @file RTC_Configuration
* @brief Configures the RTC.
* @param 无
* @retval 无
*/
static void RTC_Configuration(void)
{
//启用PWR和BKP的时钟(from APB1)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
//后备域解锁
PWR_BackupAccessCmd(ENABLE);
//备份寄存器模块复位
BKP_DeInit();
//外部32.768K时钟使能
RCC_LSEConfig(RCC_LSE_ON);
//等待稳定
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
//RTC时钟源配置成LSE(外部32.768K)
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
//RTC开启
RCC_RTCCLKCmd(ENABLE);
//开启后需要等待APB1时钟与RTC时钟同步,才能读写寄存器
RTC_WaitForSynchro();
//读写寄存器前,要确定上一个操作已经结束
RTC_WaitForLastTask();
//使能秒中断
RTC_ITConfig(RTC_IT_SEC, ENABLE);
//等待寄存器写入完成
RTC_WaitForLastTask();
//设置RTC分频器,使RTC时钟为1Hz
//RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1)
RTC_SetPrescaler(32767);
//等待写入完成
RTC_WaitForLastTask();
}
示例8: RTC_Configuration
/**
* @brief Configures RTC clock source and prescaler.
* @param None
* @retval None
*/
void RTC_Configuration(void)
{
/* RTC clock source configuration ----------------------------------------*/
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
/* Reset Backup Domain */
BKP_DeInit();
/* Enable LSE OSC */
RCC_LSICmd(ENABLE);
/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{
}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* RTC configuration -----------------------------------------------------*/
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Set the RTC time base to 1s */
RTC_SetPrescaler(32767);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
RTC_ITConfig(RTC_IT_ALR, ENABLE);
RTC_WaitForLastTask();
}
示例9: rtc_InitWakeUpInterrupt
void rtc_InitWakeUpInterrupt(){
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
// NVIC init
NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
// ext Interrupt 22 einstellen (fuer WakeUp)
EXTI_ClearITPendingBit(EXTI_Line22);
EXTI_InitStructure.EXTI_Line = EXTI_Line22;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
// zum einstellen muss Wakup disabled sein
RTC_WakeUpCmd(DISABLE);
// Teiler 16 => 32,768kHz:16 => 2048 Hz
RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
// WakeUp Counter einstellen
RTC_SetWakeUpCounter(16); //set to 16 -> 128 interrupts per second (32768Hz / Div16 = 2048; 2948 / 128 = 16
// enable Interrupt
RTC_ITConfig(RTC_IT_WUT, ENABLE);
// enable Wakeup
RTC_WakeUpCmd(ENABLE);
}
示例10: SysSetTime
/*设置系统时间*/
void SysSetTime(FUN_BLOCK **funBlock)
{
DIS_SING *sing_temp;
GetSubFunBlock(&pfunSubBlock);
sing_temp = (DIS_SING *)(pfunSubBlock->current_display);
pfunSubBlock->data_type = ZINUM;//显示属性
RTC_ITConfig(RTC_IT_SEC, DISABLE); //关RTC中断,防止systmtime被修改
strcpy(sing_temp->y2 , "请输入时间");
/*取得VIRTUAL_NUM_LENGTH位数的箱门数*/
if(CANCEL == KeyDisplay(pfunSubBlock , 10))
{
FreeMem();
return;
}
/*读取时间值*/
systmtime.tm_year = 2000 + (sing_temp->y3[0]-'0')*10 + sing_temp->y3[1]-'0';
systmtime.tm_mon = (sing_temp->y3[2]-'0')*10 + sing_temp->y3[3]-'0';
systmtime.tm_mday = (sing_temp->y3[4]-'0')*10 + sing_temp->y3[5]-'0';
systmtime.tm_hour = (sing_temp->y3[6]-'0')*10 + sing_temp->y3[7]-'0';
systmtime.tm_min = (sing_temp->y3[8]-'0')*10 + sing_temp->y3[9]-'0';
memset(sing_temp->y3 , 0 , 10);
/*写入时间*/
RTC_Configuration();
Time_Adjust(&systmtime);//写入系统时间
BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
strcpy(sing_temp->y2 , "系统时间修改成功");
DisplaySubBlock(pfunSubBlock);
FreeMem();
}
示例11: EnterSTANDBYMode
/**
* @brief Enters STANDBY mode, RTC Alarm within 3 second or an external RESET
* will wake-up the system from STANDBY
* @param None
* @retval None
*/
static void EnterSTANDBYMode(void)
{
RTC_AlarmTypeDef RTC_AlarmStructure;
RTC_TimeTypeDef RTC_TimeStructure;
/* Disable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
/* Get the current time */
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
/* Set the alarm to current time + 3s */
RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = RTC_TimeStructure.RTC_H12;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = RTC_TimeStructure.RTC_Hours;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = RTC_TimeStructure.RTC_Minutes;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = (RTC_TimeStructure.RTC_Seconds + 0x3) % 60;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = 31;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Hours | RTC_AlarmMask_Minutes;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable RTC Alarm A Interrupt: this Interrupt will wake-up the system from
STANDBY mode (RTC Alarm IT not enabled in NVIC) */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Clear RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
PWR_EnterSTANDBYMode();
}
示例12: RTC_AlarmConfig
/**
* @brief Configures the RTC Alarm.
* @param None
* @retval None
*/
void RTC_AlarmConfig(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
RTC_AlarmTypeDef RTC_AlarmStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* EXTI configuration */
EXTI_ClearITPendingBit(EXTI_Line17);
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable the RTC Alarm Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Set the alarmA Masks */
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);
/* Enable AlarmA interrupt */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the alarmA */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
}
示例13: RtcSetAlarmConfig
static void RtcSetAlarmConfig( void )
{
EXTI_InitTypeDef EXTI_InitStructure;
RTC_AlarmTypeDef RTC_AlarmStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* EXTI configuration */
EXTI_ClearITPendingBit( EXTI_Line17 );
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init( &EXTI_InitStructure );
/* Enable the RTC Alarm Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init( &NVIC_InitStructure );
/* Set the alarmA Masks */
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
RTC_SetAlarm( RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure );
/* Enable AlarmA interrupt */
RTC_ITConfig( RTC_IT_ALRA, DISABLE );
/* Enable the alarmA */
RTC_AlarmCmd( RTC_Alarm_A, DISABLE );
}
示例14: TM_RTC_DisableAlarm
void TM_RTC_DisableAlarm(TM_RTC_Alarm_t Alarm) {
switch (Alarm) {
case TM_RTC_Alarm_A:
/* Disable Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
/* Disable Alarm A interrupt */
RTC_ITConfig(RTC_IT_ALRA, DISABLE);
/* Clear Alarm A pending bit */
RTC_ClearFlag(RTC_IT_ALRA);
break;
case TM_RTC_Alarm_B:
/* Disable Alarm B */
RTC_AlarmCmd(RTC_Alarm_B, DISABLE);
/* Disable Alarm B interrupt */
RTC_ITConfig(RTC_IT_ALRB, DISABLE);
/* Clear Alarm B pending bit */
RTC_ClearFlag(RTC_IT_ALRB);
break;
default:
break;
}
/* Clear RTC Alarm pending bit */
EXTI_ClearITPendingBit(EXTI_Line17);
/* Configure EXTI 17 as interrupt */
EXTI_InitStruct.EXTI_Line = EXTI_Line17;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
/* Initialite Alarm EXTI interrupt */
EXTI_Init(&EXTI_InitStruct);
/* Configure the RTC Alarm Interrupt */
NVIC_InitStruct.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = RTC_PRIORITY;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = RTC_ALARM_SUBPRIORITY;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
/* Initialize RTC Alarm Interrupt */
NVIC_Init(&NVIC_InitStruct);
}
示例15: RTC_Configure
// 配置RTC硬件。
void RTC_Configure(void)
{
/* Enable PWR and BKP clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
RCC_RTCCLKCmd(ENABLE);
/* Reset Backup Domain */
BKP_DeInit();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
#ifdef RTCClockSource_LSI
/* Enable LSI */
RCC_LSICmd(ENABLE);
/* Wait till LSI is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);
/* Select LSI as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
#elif defined RTCClockSource_LSE
/* Enable LSE */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
#endif
// 上电后需要校准RTC时钟,也即准确计算出RTC的周期时长。
RTC_Calibrate();
#ifdef RTCClockOutput_Enable
/* Disable the Tamper Pin */
BKP_TamperPinCmd(DISABLE); /* To output RTCCLK/64 on Tamper pin, the tamper functionality must be disabled */
/* Enable RTC Clock Output on Tamper Pin */
BKP_RTCCalibrationClockOutputCmd(ENABLE);
#endif
/*允许RTC报警中断*/
RTC_ITConfig(RTC_IT_ALR, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}