本文整理汇总了C++中RTC_WaitForLastTask函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_WaitForLastTask函数的具体用法?C++ RTC_WaitForLastTask怎么用?C++ RTC_WaitForLastTask使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_WaitForLastTask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RTC_IRQHandler
/*******************************************************************************
* 函 数 名:
* 功 能:
* 参 数:
* 返 回:
*******************************************************************************/
void RTC_IRQHandler(void)
{
//秒钟中断
if( RTC_GetITStatus(RTC_IT_SEC) != RESET )
{
if( sec_irq_handle != NULL)
{
sec_irq_handle();
}
RTC_ClearITPendingBit(RTC_IT_SEC);
}
//闹钟中断
if(RTC_GetITStatus(RTC_IT_ALR) != RESET)
{
if(alrf_irq_hanle != NULL)
{
alrf_irq_hanle();
}
RTC_ClearITPendingBit(RTC_IT_ALR);
}
//溢出中断
if(RTC_GetITStatus(RTC_IT_OW) != RESET)
{
if(ow_irq_hanle != NULL)
{
ow_irq_hanle();
}
RTC_ClearITPendingBit(RTC_IT_OW);
}
RTC_WaitForLastTask();
}
示例2: RTC_IRQHandler
/*******************************************************************************
* Function Name : RTC_IRQHandler
* Description : This function handles RTC global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void RTC_IRQHandler(void)
{
if(RTC_GetITStatus(RTC_IT_SEC) != RESET)
{
// /* If counter is equal to 86339: one day was elapsed */
// if((RTC_GetCounter() / 3600 == 23)
// && (((RTC_GetCounter() % 3600) / 60) == 59)
// && (((RTC_GetCounter() % 3600) % 60) == 59)) /* 23*3600 + 59*60 + 59 = 86339 */
// {
// /* Wait until last write operation on RTC registers has finished */
// RTC_WaitForLastTask();
//
// /* Reset counter value */
// RTC_SetCounter(0x0);
//
// /* Wait until last write operation on RTC registers has finished */
// RTC_WaitForLastTask();
//
// /* Increment no_of_days_elapsed variable here */
// }
/* Clear the RTC Second Interrupt pending bit */
RTC_ClearITPendingBit(RTC_IT_SEC);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
}
示例3: RTC_Configuration
void RTC_Configuration(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
PWR_BackupAccessCmd(ENABLE);
BKP_DeInit();
RCC_LSEConfig(RCC_LSE_ON);
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForSynchro();
RTC_WaitForLastTask();
RTC_ITConfig(RTC_IT_SEC, ENABLE);
RTC_WaitForLastTask();
RTC_SetPrescaler(32767);
RTC_WaitForLastTask();
}
示例4: RTC_IRQHandler
/*******************************************************************************
* Function Name : RTC_IRQHandler
* Description : This function handles RTC global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void RTC_IRQHandler(void)
{
volatile unsigned long int stanRTC;
static unsigned char stanRTCTekst[17] = {"0\0"};
unsigned long int godziny, minuty, sekundy;
if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
{
// Czekaj na zakonczenie ewentualnych operacji zapisu do rejestrów RTC
RTC_WaitForLastTask();
// Wyczysc flage od przerwania RTC
RTC_ClearITPendingBit(RTC_IT_SEC);
// Zmiana stanu wyprowadzenia PB15 co 1s
GPIO_WriteBit(GPIOB, GPIO_Pin_15, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_15)));
stanRTC=RTC_GetCounter();
//sprintf((char *)stanRTCTekst,"%16i\0",stanRTC);
//LCD_WriteTextXY(stanRTCTekst,0,1);
sekundy=stanRTC%60; //liczba sekund od ostatniej pelnej minuty
minuty=(long int)(stanRTC)/60; //dzielenie calkowite, "usuniecie" sekund, czas pracy w samych minutach
godziny=(long int)(minuty)/60; //dzielenie calkowite, "usuniecie" minut, czas pracy w samych godzinach
minuty=minuty%60; //liczba minut od ostatniej pelnej godziny
sprintf((char *)stanRTCTekst,"%3i:%02i:%02i\0",godziny,minuty,sekundy);
LCD_WriteTextXY(stanRTCTekst,7,1);
}
}
示例5: RTC_Alarm_Set
//初始化闹钟
//以1970年1月1日为基准
//1970~2099年为合法年份
//syear,smon,sday,hour,min,sec:闹钟的年月日时分秒
//返回值:0,成功;其他:错误代码.
u8 RTC_Alarm_Set(u16 syear,u8 smon,u8 sday,u8 hour,u8 min,u8 sec)
{
u16 t;
u32 seccount=0;
if(syear<1970||syear>2099)return 1;
for(t=1970;t<syear;t++) //把所有年份的秒钟相加
{
if(Is_Leap_Year(t))seccount+=31622400;//闰年的秒钟数
else seccount+=31536000; //平年的秒钟数
}
smon-=1;
for(t=0;t<smon;t++) //把前面月份的秒钟数相加
{
seccount+=(u32)mon_table[t]*86400;//月份秒钟数相加
if(Is_Leap_Year(syear)&&t==1)seccount+=86400;//闰年2月份增加一天的秒钟数
}
seccount+=(u32)(sday-1)*86400;//把前面日期的秒钟数相加
seccount+=(u32)hour*3600;//小时秒钟数
seccount+=(u32)min*60; //分钟秒钟数
seccount+=sec;//最后的秒钟加上去
//设置时钟
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //使能PWR和BKP外设时钟
PWR_BackupAccessCmd(ENABLE); //使能后备寄存器访问
//上面三步是必须的!
RTC_SetAlarm(seccount);
RTC_WaitForLastTask(); //等待最近一次对RTC寄存器的写操作完成
return 0;
}
示例6: timer_start
void timer_start()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,
ENABLE);
PWR_BackupAccessCmd(ENABLE);
RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForLastTask();
RTC_WaitForSynchro();
RTC_WaitForLastTask();
RTC_SetPrescaler(0); // counting at 8e6 / 128
RTC_WaitForLastTask();
RTC_SetCounter(0);
RTC_WaitForLastTask();
}
示例7: 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 the LSI OSC */
RCC_LSICmd(ENABLE);
/* Wait till LSI is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
/* 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(40000);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* To output second signal on Tamper pin, the tamper functionality
must be disabled (by default this functionality is disabled) */
BKP_TamperPinCmd(DISABLE);
/* Enable the RTC Second Output on Tamper Pin */
BKP_RTCOutputConfig(BKP_RTCOutputSource_Second);
}
示例8: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
/* Initialize LEDs and Key Button mounted on STM3210X-EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_PBInit(Button_KEY, Mode_EXTI);
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Configure EXTI Line to generate an interrupt on falling edge */
EXTI_Configuration();
/* Configure RTC clock source and prescaler */
RTC_Configuration();
/* NVIC configuration */
NVIC_Configuration();
/* Configure the SysTick to generate an interrupt each 1 millisecond */
SysTick_Configuration();
/* Turn on LED1 */
STM_EVAL_LEDOn(LED1);
while (1)
{
/* Insert 1.5 second delay */
Delay(1500);
/* Wait till RTC Second event occurs */
RTC_ClearFlag(RTC_FLAG_SEC);
while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);
/* Alarm in 3 second */
RTC_SetAlarm(RTC_GetCounter()+ 3);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Turn off LED1 */
STM_EVAL_LEDOff(LED1);
/* Request to enter STOP mode with regulator in low power mode*/
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
/* At this stage the system has resumed from STOP mode -------------------*/
/* Turn on LED1 */
STM_EVAL_LEDOn(LED1);
/* 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) */
SYSCLKConfig_STOP();
}
}
示例9: main
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
debug();
#endif
/* Clock configuration */
RCC_Configuration();
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* GPIO configuration */
GPIO_Configuration();
/* Configure EXTI Line to generate an interrupt on falling edge */
EXTI_Configuration();
/* Configure RTC clock source and prescaler */
RTC_Configuration();
/* NVIC configuration */
NVIC_Configuration();
/* Configure the SysTick to generate an interrupt each 1 millisecond */
SysTick_Configuration();
/* Turn on led connected to GPIO_LED Pin6 */
GPIO_SetBits(GPIO_LED, GPIO_Pin_6);
while (1)
{
/* Insert 1.5 second delay */
Delay(1500);
/* Wait till RTC Second event occurs */
RTC_ClearFlag(RTC_FLAG_SEC);
while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);
/* Alarm in 3 second */
RTC_SetAlarm(RTC_GetCounter()+ 3);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Turn off led connected to GPIO_LED Pin6 */
GPIO_ResetBits(GPIO_LED, GPIO_Pin_6);
/* Request to enter STOP mode with regulator in low power mode*/
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
/* At this stage the system has resumed from STOP mode -------------------*/
/* Turn on led connected to GPIO_LED Pin6 */
GPIO_SetBits(GPIO_LED, GPIO_Pin_6);
/* 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) */
SYSCLKConfig_STOP();
}
}
示例10: RTC_Init
/**
* @file RTC_Init
* @brief RTC Initialization
* @param 无
* @retval 无
*/
void RTC_Init(void)
{
if (BKP_ReadBackupRegister(BKP_DR1)!= 0xA5A5)
{
/* Backup data register value is not correct or not yet programmed (when
the first time the program is executed) */
printf("RTC not yet configured....\r\n");
/* RTC Configuration */
RTC_Configuration();
Time_Regulate();
/* Adjust time by values entred by the user on the hyperterminal */
printf("RTC configured....\r\n");
BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
}
else
{
/* Check if the Power On Reset flag is set */
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
{
printf("Power On Reset occurred....\r\n");
}
/* Check if the Pin Reset flag is set */
else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
{
printf("External Reset occurred....\r\n");
}
printf("No need to configure RTC....\r\n");
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Enable the RTC Second */
RTC_ITConfig(RTC_IT_SEC, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
/* NVIC configuration */
NVIC_Configuration();
#ifdef RTCClockOutput_Enable
/* Enable PWR and BKP clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(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_RTCOutputConfig(BKP_RTCOutputSource_CalibClock);
#endif
/* Clear reset flags */
RCC_ClearFlag();
return;
}
示例11: RTC_Configuration
/*******************************************************************************
* Function Name : RTC_Configuration
* Description : Configures the RTC.
* Input : None
* Output : None
* Return : 0 reday,-1 error.
*******************************************************************************/
int RTC_Configuration(void)
{
u32 count=0x200000;
/* 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) && (--count) );
if ( count == 0 ) {
return -1;
}
/* 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();
/* 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();
RTC_ITConfig(RTC_IT_SEC, ENABLE); // 使能RTC秒中断
RTC_WaitForLastTask();
PWR_BackupAccessCmd(DISABLE);
return 0;
}
示例12: Alarm_PreAdjust
/*******************************************************************************
* Function Name : Alarm_PreAdjust
* Description : Configures an alarm event to occurs within the current day.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Alarm_PreAdjust(void)
{
uint32_t tmp = 0;
/* Set the LCD Back Color */
LCD_SetBackColor(Blue);
/* Set the LCD Text Color */
LCD_SetTextColor(White);
if(BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
{
LCD_DisplayStringLine(Line8, "Time not configured ");
LCD_DisplayStringLine(Line9, " Press SEL ");
while(ReadKey() == NOKEY)
{
}
return;
}
/* Read the alarm value stored in the Backup register */
tmp = BKP_ReadBackupRegister(BKP_DR6);
tmp |= BKP_ReadBackupRegister(BKP_DR7) << 16;
/* Clear Line8 */
LCD_ClearLine(Line8);
/* Display time separators ":" on Line4 */
LCD_DisplayChar(Line8, 212, ':');
LCD_DisplayChar(Line8, 166, ':');
/* Display the alarm value */
Alarm_Display(tmp);
/* Store new alarm value */
tmp = Alarm_Regulate();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Set RTC Alarm register with the new value */
RTC_SetAlarm(tmp);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Save the Alarm value in the Backup register */
BKP_WriteBackupRegister(BKP_DR6, (tmp & 0x0000FFFF));
BKP_WriteBackupRegister(BKP_DR7, (tmp >> 16));
}
示例13: RTC_Configuration
/*******************************************************************************
* Function Name : RTC_Configuration
* Description : 来重新配置RTC和BKP,仅在检测到后备寄存器数据丢失时使用
* Input : None
* Output : None
* Return : None
*******************************************************************************/
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分频器,使RTC时钟为1Hz
//RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1)
RTC_SetPrescaler(32767);
//等待寄存器写入完成
RTC_WaitForLastTask();
//使能秒中断
RTC_ITConfig(RTC_IT_SEC, ENABLE);
//Enable the RTC Alarm interrupt
// RTC_ITConfig(RTC_IT_ALR, ENABLE);
//等待写入完成
RTC_WaitForLastTask();
return;
}
示例14: Time_Adjust
/*
* 函数名:Time_Adjust
* 描述 :时间调节
* 输入 :用于读取RTC时间的结构体指针
* 输出 :无
* 调用 :外部调用
*/
void Time_Adjust(struct rtc_time *tm)
{
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Get time entred by the user on the hyperterminal */
Time_Regulate(tm);
/* Get wday */
GregorianDay(tm);
/* 修改当前RTC计数寄存器内容 */
RTC_SetCounter(mktimev(tm));
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
示例15: RTC_IRQHandler
/*******************************************************************************
* Function Name : RTC_IRQHandler
* Description : This function handles RTC global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void RTC_IRQHandler(void)
{
if(RTC_GetFlagStatus(RTC_IT_ALR) != RESET)
{
RTC_ClearITPendingBit(RTC_IT_ALR); //Clear RTC Alarm interrupt pending bit
RTC_WaitForLastTask(); //Wait until last write operation on RTC registers has finished
}
}