本文整理汇总了C++中RTC_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_Init函数的具体用法?C++ RTC_Init怎么用?C++ RTC_Init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RTC_Start
void RTC_Start(){
if(RTC_SR == RTC_SR_TCE_MASK){ // If RTC clock is already running
RTC = RTC_Init(NULL, true); // Initialise the RTC softly
}else{
RTC = RTC_Init(NULL, false); // Initialise the RTC hard (reset time/date etc.)
for(uint8 i = 0; i < 4; i++){
LED_Red_On();
DelayMs(500);
LED_Red_Off();
DelayMs(500);
}
}
}
示例2: RTC_Configuration
/**
* @brief Configures the RTC peripheral.
* @param None
* @retval None
*/
int8_t RTC_Configuration(void)
{
RTC_Error = 0;
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
/* LSI used as RTC source clock */
/* The RTC Clock may varies due to LSI frequency dispersion. */
/* Enable the LSI OSC */
// RCC_LSICmd(ENABLE);
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSI is ready */
//while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{
}
/* Select the RTC Clock Source */
//RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
//RTC_WaitForLastTask();
/* Calendar Configuration with LSI supposed at 32KHz */
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0xFF; /* (32KHz / 128) - 1 = 0xFF*/
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
/* Get the LSI frequency: TIM5 is used to measure the LSI frequency */
//LsiFreq = GetLSIFrequency();
/* Adjust LSI Configuration */
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
//RTC_InitStructure.RTC_SynchPrediv = (LsiFreq/128) - 1;
RTC_InitStructure.RTC_SynchPrediv = (32767/128) - 1;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
return RTC_Error;
}
示例3: rtcSetup
void rtcSetup(){
RTC_Init_TypeDef rtcInit = RTC_INIT_DEFAULT;
/* Enabling clock to LE configuration register */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Selecting crystal oscillator to drive LF clock */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
/* 32 clock division to save energy */
CMU_ClockDivSet(cmuClock_RTC, cmuClkDiv_32768);
/* Providing clock to RTC */
CMU_ClockEnable(cmuClock_RTC, true);
/* Initialize RTC */
rtcInit.enable = false; /* Do not start RTC after initialization is complete. */
rtcInit.debugRun = false; /* Halt RTC when debugging. */
rtcInit.comp0Top = true; /* Wrap around on COMP0 match. */
RTC_Init(&rtcInit);
/* Interrupt every minute */
RTC_CompareSet(0, ((RTC_FREQ / CLOCK_DIVISION) * 10 ) - 1 );
/* Enable interrupt */
NVIC_EnableIRQ(RTC_IRQn);
RTC_IntEnable(RTC_IEN_COMP0);
/* Start Counter */
RTC_Enable(true);
}
示例4: RTC_Setup
/***************************************************************************//**
* @brief Enables LFACLK and selects osc as clock source for RTC
******************************************************************************/
void RTC_Setup(CMU_Select_TypeDef osc)
{
RTC_Init_TypeDef init;
/* Ensure LE modules are accessible */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Enable osc as LFACLK in CMU (will also enable oscillator if not enabled) */
CMU_ClockSelectSet(cmuClock_LFA, osc);
/* No division prescaler to increase accuracy. */
CMU_ClockDivSet(cmuClock_RTC, cmuClkDiv_1);
/* Enable clock to RTC module */
CMU_ClockEnable(cmuClock_RTC, true);
init.enable = false;
init.debugRun = false;
init.comp0Top = true; /* Count only to top before wrapping */
RTC_Init(&init);
RTC_CompareSet(0, ((LFRCOFREQ * WAKEUP_US) / 1000000));
/* Disable interrupt generation from RTC0, is enabled before each sample-run. */
RTC_IntDisable(_RTC_IF_MASK);
/* Enable interrupts in NVIC */
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
}
示例5: lp_ticker_init
void lp_ticker_init()
{
core_util_critical_section_enter();
if (!rtc_inited) {
CMU_ClockEnable(cmuClock_RTC, true);
/* Initialize RTC */
RTC_Init_TypeDef init = RTC_INIT_DEFAULT;
init.enable = 1;
/* Don't use compare register 0 as top value */
init.comp0Top = 0;
/* Initialize */
RTC_Init(&init);
RTC_CounterSet(20);
/* Enable Interrupt from RTC */
RTC_IntDisable(RTC_IF_COMP0);
RTC_IntClear(RTC_IF_COMP0);
NVIC_SetVector(RTC_IRQn, (uint32_t)RTC_IRQHandler);
NVIC_EnableIRQ(RTC_IRQn);
rtc_inited = true;
} else {
/* Cancel current interrupt by virtue of calling init again */
RTC_IntDisable(RTC_IF_COMP0);
RTC_IntClear(RTC_IF_COMP0);
}
core_util_critical_section_exit();
}
示例6: Init
void Init() {
PWR_Init();
CLOCK_Init();
UART_Initialize();
printf("Start\n");
Initialize_ButtonMatrix();
SPIFlash_Init(); //This must come before LCD_Init() for 7e
LCD_Init();
CHAN_Init();
SPITouch_Init();
SOUND_Init();
BACKLIGHT_Init();
BACKLIGHT_Brightness(1);
AUTODIMMER_Init();
SPI_FlashBlockWriteEnable(1); //Enable writing to all banks of SPIFlash
PPMin_TIM_Init();
#ifdef MODULAR
//Force protocol to none to initialize RAM
Model.protocol = PROTOCOL_NONE;
PROTOCOL_Init(1);
#endif
#if HAS_RTC
RTC_Init(); // Watchdog must be running in case something goes wrong (e.g no crystal)
#endif
}
示例7: startRTCTick
/******************************************************************************
* @brief
* Configures and starts RTC from ULFRCO
*****************************************************************************/
void startRTCTick(void)
{
/* Set-up RTC init struct */
RTC_Init_TypeDef rtcInit;
rtcInit.comp0Top = true;
rtcInit.debugRun = false;
rtcInit.enable = true;
/* Enable clock to LF peripherals */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Set ULFRCO as clock source for RTC */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_ULFRCO);
/* Turn on clock for RTC */
CMU_ClockEnable(cmuClock_RTC, true);
/* Enable RTC interrupt lines */
NVIC_EnableIRQ(RTC_IRQn);
RTC_IntEnable(RTC_IF_COMP0);
/* Set compare register */
RTC_CompareSet(0, MS_TO_SLEEP);
/* Initialize and start RTC */
RTC_Init(&rtcInit);
}
示例8: main
int main(void)
{
u8 t=0;
u16 Time=0,dis_pre=0;
float V_ave; //平均速度
char code_ave[5],code_v[5],code_vr[5], mileage[5];//信息储存数组
delay_init(72); //延时函数初始化
Stm32_Clock_Init(9); //系统时钟设置
uart_init(72,9600); //串口初始化为9600
usmart_dev.init(72); //初始化USMART
EXTIX_Init(); //外部中断初始化
TIM3_Int_Init(5000,7199); //10Khz的计数频率,计数到5000为500ms
LCD_Init(); // PE.ALL,PD1~5
LCD_Display_Dir(1); //设置显示方向为横屏显示
LED_Init(); //初始化与LED连接的硬件接口
KEY_Init(); //初始化按键
while(RTC_Init())
{ //等待RTC初始化
delay_ms(200);
printf("rtc waiting```\r\n");
}
printf("finish\n");
display_jing();
//初始化完成
while(1)
{
POINT_COLOR=RED;
if(t!=calendar.sec) //时间更新后显示新时间
{
t=calendar.sec;
LCD_ShowNum(200,135,calendar.min,2,32);
LCD_ShowString(230,135,200,32,32,":");
LCD_ShowNum(248,135,calendar.sec,2,32);
Time = 60*calendar.min+calendar.sec;//比赛用时
if(dis_pre != quanshu_tenfold) //有位移变化
{
V_ave=(0.154*quanshu_tenfold)/Time;
dis_pre = quanshu_tenfold;
sprintf(code_ave,"%.2f",V_ave);
LCD_ShowString(100,200,200,32,32,code_ave);//修改一下位置
}
}
sprintf(code_v,"%.2f",V); //float 转 字符串
LCD_ShowString(365,275,200,32,32,code_v); //速度
sprintf(code_vr,"%d",V_RPM); //float 转 字符串
LCD_ShowString(365,275,200,32,32,code_vr); //转速
sprintf(mileage,"%.2f",0.154*quanshu_tenfold);
LCD_ShowString(250,225,200,24,32,mileage); //里程
display_dong(V_RPM,V,50);
delay_ms(300);
}
}
示例9: RTC_Setup
/***************************************************************************//**
* @brief Enables LFACLK and selects LFRCO as clock source for RTC
******************************************************************************/
static void RTC_Setup(void)
{
RTC_Init_TypeDef init;
rtcInitialized = 1;
/* Ensure LE modules are accessible */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Enable LFRCO as LFACLK in CMU (will also enable oscillator if not enabled) */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO);
/* Enable clock to RTC module */
CMU_ClockEnable(cmuClock_RTC, true);
init.enable = false;
init.debugRun = false;
init.comp0Top = false; /* Count to max before wrapping */
RTC_Init(&init);
/* Disable interrupt generation from RTC0 */
RTC_IntDisable(_RTC_IF_MASK);
/* Enable interrupts */
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
}
示例10: rtc_crystal_init
/**
* Initialize RTC Based on Crystal Oscillator
*/
void rtc_crystal_init(void)
{
RTC_Init_TypeDef init;
/* Ensure LE modules are accessible */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Enable LFACLK in CMU (will also enable oscillator if not enabled) */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
/* Use the prescaler to reduce power consumption. */
CMU_ClockDivSet(cmuClock_RTC, RTC_PRESCALE);
/* Enable clock to RTC module */
CMU_ClockEnable(cmuClock_RTC, true);
init.enable = false; /* Start disabled to reset counter */
init.debugRun = false;
init.comp0Top = false; /* Count to max before wrapping */
RTC_Init(&init);
/* Disable interrupt generation from RTC0 */
RTC_IntDisable(_RTC_IF_MASK);
/* Enable interrupts */
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
/* Start RTC counter */
RTC_Enable(true);
}
示例11: System_Time_Init
static void System_Time_Init(void)
{
/* RTC Block section ------------------------------------------------------ */
// Init RTC module
RTC_Init(LPC_RTC);
/* Disable RTC interrupt */
NVIC_DisableIRQ(RTC_IRQn);
/* preemption = 1, sub-priority = 1 */
NVIC_SetPriority(RTC_IRQn, ((0x01<<3)|0x01));
/* Enable rtc (starts increase the tick counter and second counter register) */
RTC_ResetClockTickCounter(LPC_RTC);
RTC_Cmd(LPC_RTC, ENABLE);
RTC_CalibCounterCmd(LPC_RTC, DISABLE);
/* Set current time for RTC */
// Current time is 06:45:00PM, 2011-03-25
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MINUTE, 45);
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_HOUR, 15);
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MONTH, 3);
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_YEAR, 2014);
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH, 30);
return;
}
示例12: main
int main(void)
{
uint8_t last_sec;
RTC_CalanderTypeDef RTC_Calander1;
//初始化系统时钟 使用外部50M晶振 PLL倍频到100M
SystemClockSetup(ClockSource_EX50M,CoreClock_100M);
DelayInit();
LED_Init(LED_PinLookup_CHK60EVB, kNumOfLED);
UART_DebugPortInit(UART4_RX_C14_TX_C15, 115200);
UART_printf("RTC TEST\r\n");
RTC_Init();
//可以设置时间
RTC_Calander1.Hour = 10;
RTC_Calander1.Minute = 57;
RTC_Calander1.Second = 58;
RTC_Calander1.Month = 10;
RTC_Calander1.Date = 10;
RTC_Calander1.Year = 2013;
//RTC_SetCalander(&RTC_Calander1);
NVIC_EnableIRQ(RTC_IRQn);
while(1)
{
RTC_GetCalander(&RTC_Calander1); //读取时间
if(last_sec != RTC_Calander1.Second)
{
UART_printf("%d-%d-%d %d:%d:%d\r\n", RTC_Calander1.Year, RTC_Calander1.Month, RTC_Calander1.Date, RTC_Calander1.Hour, RTC_Calander1.Minute, RTC_Calander1.Second);
last_sec = RTC_Calander1.Second;
}
}
}
示例13: TM_RTC_SetDateTime
void TM_RTC_SetDateTime(TM_RTC_Time_t* data, TM_RTC_Format_t format) {
/* Fill time */
RTC_TimeStruct.RTC_Hours = data->hours;
RTC_TimeStruct.RTC_Minutes = data->minutes;
RTC_TimeStruct.RTC_Seconds = data->seconds;
/* Fill date */
RTC_DateStruct.RTC_Date = data->date;
RTC_DateStruct.RTC_Month = data->month;
RTC_DateStruct.RTC_Year = data->year;
RTC_DateStruct.RTC_WeekDay = data->day;
/* Set the RTC time base to 1s and hours format to 24h */
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
RTC_InitStruct.RTC_AsynchPrediv = uwAsynchPrediv;
RTC_InitStruct.RTC_SynchPrediv = uwSynchPrediv;
RTC_Init(&RTC_InitStruct);
if (format == TM_RTC_Format_BCD) {
RTC_SetTime(RTC_Format_BCD, &RTC_TimeStruct);
} else {
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
}
if (format == TM_RTC_Format_BCD) {
RTC_SetDate(RTC_Format_BCD, &RTC_DateStruct);
} else {
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
}
if (TM_RTC_Status != RTC_STATUS_ZERO) {
/* Write backup registers */
RTC_WriteBackupRegister(RTC_STATUS_REG, RTC_STATUS_TIME_OK);
}
}
示例14: rtimer_arch_init
/*---------------------------------------------------------------------------*/
void
rtimer_arch_init(void)
{
RTC_Init_TypeDef init = RTC_INIT_DEFAULT;
/* Ensure LE modules are accessible */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Enable LFACLK in CMU (will also enable oscillator if not enabled) */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
/* Don't use prescaler to have highest precision */
CMU_ClockDivSet(cmuClock_RTC, cmuClkDiv_1);
/* Enable clock to RTC module */
CMU_ClockEnable(cmuClock_RTC, true);
init.enable = false; /* Start disabled to reset counter */
init.debugRun = false;
init.comp0Top = false; /* Don't Reset Count on comp0 */
RTC_Init(&init);
/* Disable interrupt generation from RTC0 */
RTC_IntDisable(_RTC_IF_MASK);
/* Enable interrupts */
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
/* Start RTC counter */
RTC_Enable(true);
}
示例15: main
int main(void)
{
TIME time;
/*时钟初始化*/
CLK_Config();
/*初始化电源控制*/
GPIO_DeInit(GPIOD);
GPIO_Init(GPIOD,GPIO_PIN_3,GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_DeInit(GPIOC);
GPIO_Init(GPIOC,GPIO_PIN_1,GPIO_MODE_OUT_PP_LOW_FAST);
/*上电,3.3V/12V*/
VDD3V3_ON();
VDD12_ON();
RTC_Init();
while (1)
{
RTC_ReadDate(&time);
}
return 0;
}