这篇教程C++ HAL_RTC_GetDate函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HAL_RTC_GetDate函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_RTC_GetDate函数的具体用法?C++ HAL_RTC_GetDate怎么用?C++ HAL_RTC_GetDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HAL_RTC_GetDate函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: RTC_CalendarShow/** * @brief Displays the current time and date. * @param None * @retval None */static void RTC_CalendarShow(void){ RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; #ifdef USE_LCD /* Get the RTC current Time */ HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BCD); /* Get the RTC current Date */ HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BCD); /* Set the Back Color */ BSP_LCD_SetBackColor(LCD_COLOR_WHITE); /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAtLine(6, (uint8_t *)"Current Time Display"); RTC_Time_display(7, LCD_COLOR_BLACK , RTC_Get_Time(&stimestructureget));#else /* Get the RTC current Time */ HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BIN); /* Get the RTC current Date */ HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BIN); /* Display time Format : hh:mm:ss */ sprintf((char*)aShowTime,"%0.2d:%0.2d:%0.2d", stimestructureget.Hours, stimestructureget.Minutes, stimestructureget.Seconds); /* Display date Format : mm-dd-yy */ sprintf((char*)aShowDate,"%0.2d-%0.2d-%0.2d", sdatestructureget.Month, sdatestructureget.Date, 2000 + sdatestructureget.Year); #endif /* USE_LCD */}
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:33,
示例2: StartTaskTFT/* StartTaskTFT function */void StartTaskTFT(void const * argument){ /* USER CODE BEGIN StartTaskTFT */RTC_TimeTypeDef sTime;RTC_DateTypeDef sDate;char buf[100]; sprintf(buf, "tft run/r/n"); HAL_UART_Transmit(&huart1,(uint8_t*)buf,strlen(buf),100);SSD1289_Init();LCD_Clear(yellow); memset(buf,0,100); LCD_WriteString_5x7(20, 240 - 30, "Hello world.", red, yellow, 0, 1); LCD_WriteString_5x7(20, 240 - 30 - 20, "STM32F103VET6", green, yellow, 0, 1); /* Infinite loop */ for(;;) { HAL_RTC_GetDate(&hrtc, &sDate, FORMAT_BIN); HAL_RTC_GetTime(&hrtc, &sTime, FORMAT_BIN); memset(buf,0,100); sprintf(buf, "Date: %02d/%02d/%02d", sDate.Date, sDate.Month, sDate.Year); LCD_WriteString_5x7(50,100, buf, magneta, yellow,0, 2); memset(buf,0,100); sprintf(buf, "Time: %02d:%02d:%02d", sTime.Hours, sTime.Minutes, sTime.Seconds); LCD_WriteString_5x7(50, 160, buf, magneta, yellow,0, 2); LCD_WriteString_5x7(50, 50, gbuf, green, yellow,0, 2); osDelay(500); } /* USER CODE END StartTaskTFT */}
开发者ID:Casa2011,项目名称:devices,代码行数:33,
示例3: StartDefaultTask/* StartDefaultTask function */void StartDefaultTask(void const * argument){ /* init code for FATFS */ MX_FATFS_Init(); /* USER CODE BEGIN 5 */uint8_t sec = 0;RTC_TimeTypeDef sTime;RTC_DateTypeDef sDate;char buf[50]; sprintf(buf, "idle run/r/n"); HAL_UART_Transmit(&huart1,(uint8_t*)buf,strlen(buf),100); /* Infinite loop */ for(;;) { HAL_RTC_GetDate(&hrtc, &sDate, FORMAT_BIN); HAL_RTC_GetTime(&hrtc, &sTime, FORMAT_BIN); //memset(buf,0,255); if(sec != sTime.Seconds){ sec = sTime.Seconds; memset(buf,0,50); sprintf(buf, "Date: %02d/%02d/%02d Time: %02d:%02d:%02d/r/n/0", sDate.Date, sDate.Month, sDate.Year, sTime.Hours, sTime.Minutes, sTime.Seconds); HAL_UART_Transmit(&huart1,(uint8_t*)buf,strlen(buf),100); } osDelay(1000); } /* USER CODE END 5 */ }
开发者ID:Casa2011,项目名称:devices,代码行数:30,
示例4: RTC_CalendarShowuint32_t RTC_CalendarShow(uint8_t* showtime){ uint32_t current_time; RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; /* Get the RTC current Time */ HAL_RTC_GetTime(&RTCHandle, &stimestructureget, RTC_FORMAT_BIN); /* Get the RTC current Date */ HAL_RTC_GetDate(&RTCHandle, &sdatestructureget, RTC_FORMAT_BIN);#ifdef RTC_LSI current_time = ( (1000 - (stimestructureget.SubSeconds)*1000/1032) + (stimestructureget.Seconds )*1000+ (stimestructureget.Minutes )*1000*60 );#endif#ifdef RTC_LSE current_time = ( (1000 - (stimestructureget.SubSeconds)*1000/1023) + (stimestructureget.Seconds )*1000+ (stimestructureget.Minutes )*1000*60 );#endif current_time &= 0x00FFFFFF; return current_time;}
开发者ID:gilbertjuly,项目名称:cannon,代码行数:30,
示例5: rtc_read/* RTC Registers RTC_WeekDay 1=monday, 2=tuesday, ..., 7=sunday RTC_Month 1=january, 2=february, ..., 12=december RTC_Date day of the month 1-31 RTC_Year year 0-99 struct tm tm_sec seconds after the minute 0-61 tm_min minutes after the hour 0-59 tm_hour hours since midnight 0-23 tm_mday day of the month 1-31 tm_mon months since January 0-11 tm_year years since 1900 tm_wday days since Sunday 0-6 tm_yday days since January 1 0-365 tm_isdst Daylight Saving Time flag*/time_t rtc_read(void) { RTC_DateTypeDef dateStruct; RTC_TimeTypeDef timeStruct; struct tm timeinfo; RtcHandle.Instance = RTC; // Read actual date and time // Warning: the time must be read first! HAL_RTC_GetTime(&RtcHandle, &timeStruct, FORMAT_BIN); HAL_RTC_GetDate(&RtcHandle, &dateStruct, FORMAT_BIN); // Setup a tm structure based on the RTC timeinfo.tm_wday = dateStruct.WeekDay; timeinfo.tm_mon = dateStruct.Month - 1; timeinfo.tm_mday = dateStruct.Date; timeinfo.tm_year = dateStruct.Year + 100; timeinfo.tm_hour = timeStruct.Hours; timeinfo.tm_min = timeStruct.Minutes; timeinfo.tm_sec = timeStruct.Seconds; // Convert to timestamp time_t t = mktime(&timeinfo); return t;}
开发者ID:logxen,项目名称:mbed,代码行数:43,
示例6: RTC_Read_datetime//-------------------------------------------------------------------//read date timevoid RTC_Read_datetime(uint8_t * data,uint8_t flag){ uint8_t temp[3]; //first read tiem ,then read date, or not time is not run; RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; HAL_RTCStateTypeDef status; if(data!=NULL) { osMutexWait(rtc_mutex, osWaitForever); /* Get the RTC current Time */ HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN); temp[0]=stimestructureget.Hours; temp[1]=stimestructureget.Minutes; temp[2]=stimestructureget.Seconds; memcpy(¤t_datetime[3],temp,3); /* Get the RTC current Date */ HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN); data[0]=sdatestructureget.Year; data[1]=sdatestructureget.Month; data[2]=sdatestructureget.Date; current_datetime[6]=sdatestructureget.WeekDay; memcpy(¤t_datetime[0],data,3); if(flag==1) { memcpy(data,temp,3); } osMutexRelease(rtc_mutex); }}
开发者ID:hlmpost,项目名称:code_backup,代码行数:37,
示例7: rtcGetDateTimevoid rtcGetDateTime(RTC_DateTypeDef *date, RTC_TimeTypeDef *time){ /* Get the RTC current Time */ HAL_RTC_GetTime(&RtcHandle, time, FORMAT_BIN); /* Get the RTC current Date */ HAL_RTC_GetDate(&RtcHandle, date, FORMAT_BIN);}
开发者ID:FlankerZ,项目名称:epaper_cnt,代码行数:7,
示例8: HAL_GPIO_EXTI_Callback/** * @brief EXTI line detection callbacks * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ if(GPIO_Pin == KEY_BUTTON_PIN) { HAL_RTC_GetTime(&RTCHandle, &RTC_TimeStructure, RTC_FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &RTC_DateStructure, RTC_FORMAT_BIN); /* Set the alarm to current time + 5s */ RTC_AlarmStructure.Alarm = RTC_ALARM_A; RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_TimeStructure.TimeFormat; RTC_AlarmStructure.AlarmTime.Hours = RTC_TimeStructure.Hours; RTC_AlarmStructure.AlarmTime.Minutes = RTC_TimeStructure.Minutes; RTC_AlarmStructure.AlarmTime.Seconds = (RTC_TimeStructure.Seconds + 0x05) % 60; RTC_AlarmStructure.AlarmDateWeekDay = 0x31; RTC_AlarmStructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; RTC_AlarmStructure.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_MINUTES; RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE; /* The Following Wakeup sequence is highly recommended prior to each Standby mode entry mainly when using more than one wakeup source this is to not miss any wakeup event: - Disable all used wakeup sources, - Clear all related wakeup flags, - Re-enable all used wakeup sources, - Enter the Standby mode. */ /*## Disable all used wakeup sources #####################################*/ /* Disable Wake-up timer */ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); /* Disable RTC Alarm */ HAL_RTC_DeactivateAlarm(&RTCHandle, RTC_ALARM_A); /*## Clear all related wakeup flags ######################################*/ /* Clear PWR wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /* Clear the Alarm Flag */ __HAL_RTC_ALARM_CLEAR_FLAG(&RTCHandle, RTC_FLAG_ALRAF); /*## Re-enable all used wakeup sources ###################################*/ /* Set RTC alarm */ if(HAL_RTC_SetAlarm_IT(&RTCHandle, &RTC_AlarmStructure, RTC_FORMAT_BIN) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Enable WKUP pin */ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); /* Turn LED1 off */ BSP_LED_Off(LED1); /*## Enter Standby Mode ##################################################*/ HAL_PWR_EnterSTANDBYMode(); }}
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:64,
示例9: rtc_initvoid rtc_init(void) { RTCHandle.Instance = RTC; RTC_DateTypeDef date; /* Configure RTC prescaler and RTC data registers */ /* RTC configured as follow: - Hour Format = Format 24 - Asynch Prediv = Value according to source clock - Synch Prediv = Value according to source clock - OutPut = Output Disable - OutPutPolarity = High Polarity - OutPutType = Open Drain */ RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24; RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE; RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; // if LTE enabled & ready --> no need to (re-)init RTC if ((RCC->BDCR & (RCC_BDCR_LSEON | RCC_BDCR_LSERDY)) == (RCC_BDCR_LSEON | RCC_BDCR_LSERDY)) { // remove Backup Domain write protection PWR->CR |= PWR_CR_DBP; // Clear source Reset Flag __HAL_RCC_CLEAR_RESET_FLAGS(); // provide some status information rtc_info |= 0x40000 | (RCC->BDCR & 7) | (RCC->CSR & 3) << 8; return; } mp_uint_t tick = HAL_GetTick(); if (HAL_RTC_Init(&RTCHandle) != HAL_OK) { // init error rtc_info = 0xffff; // indicate error return; } // record how long it took for the RTC to start up rtc_info = HAL_GetTick() - tick; HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN); if (date.Year == 0 && date.Month ==0 && date.Date == 0) { // fresh reset; configure RTC Calendar RTC_CalendarConfig(); } else { // RTC was previously set, so leave it alone if(__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) { // power on reset occurred rtc_info |= 0x10000; } if(__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) { // external reset occurred rtc_info |= 0x20000; } // Clear source Reset Flag __HAL_RCC_CLEAR_RESET_FLAGS(); }}
开发者ID:opensourcekids,项目名称:micropython,代码行数:59,
示例10: get_fattimeDWORD get_fattime(void) { rtc_init_finalise(); RTC_TimeTypeDef time; RTC_DateTypeDef date; HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN); return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2);}
开发者ID:19emtuck,项目名称:micropython,代码行数:8,
示例11: time_time/// /function time()/// Returns the number of seconds, as an integer, since 1/1/2000.STATIC mp_obj_t time_time(void) { // get date and time // note: need to call get time then get date to correctly access the registers RTC_DateTypeDef date; RTC_TimeTypeDef time; HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN); return mp_obj_new_int(timeutils_seconds_since_2000(2000 + date.Year, date.Month, date.Date, time.Hours, time.Minutes, time.Seconds));}
开发者ID:EmuxEvans,项目名称:micropython,代码行数:11,
示例12: k_GetDate/** * @brief RTC Get date * @param Date: Pointer to Date structure * @retval None */void k_GetDate( RTC_DateTypeDef *Date){ HAL_RTC_GetDate(&RtcHandle, Date, FORMAT_BIN); if((Date->Date == 0) || (Date->Month == 0)) { Date->Date = Date->Month = 1; } }
开发者ID:MrZANE42,项目名称:verisure1512,代码行数:14,
示例13: RtcGetCalendarstatic RtcCalendar_t RtcGetCalendar( void ){ RtcCalendar_t calendar; HAL_RTC_GetTime( &RtcHandle, &calendar.CalendarTime, RTC_FORMAT_BIN ); HAL_RTC_GetDate( &RtcHandle, &calendar.CalendarDate, RTC_FORMAT_BIN ); calendar.CalendarCentury = Century; RtcCheckCalendarRollOver( calendar.CalendarDate.Year ); return calendar;}
开发者ID:CommunicationSolutions,项目名称:Comsol_LPWA_Node,代码行数:9,
示例14: RTC_Set_datetime//------------------------------------------------------------------void RTC_Set_datetime(uint8_t * data){ uint8_t temp[3]; RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; if(data!=NULL) { osMutexWait(rtc_mutex, osWaitForever); sdatestructure.Year =data[0]; sdatestructure.Month = data[1]; sdatestructure.Date = data[2]; sdatestructure.WeekDay= CaculateWeekDay(data[0],data[1],data[2]); if(HAL_RTC_SetDate(&hrtc,&sdatestructure,RTC_FORMAT_BIN) != HAL_OK) { /* Initialization Error */ Error_Handler("set time error"); } stimestructure.Hours = data[3]; stimestructure.Minutes = data[4]; stimestructure.Seconds = data[5]; stimestructure.TimeFormat = RTC_HOURFORMAT12_AM; stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; stimestructure.StoreOperation = RTC_STOREOPERATION_RESET; if(HAL_RTC_SetTime(&hrtc,&stimestructure,RTC_FORMAT_BIN) != HAL_OK) { /* Initialization Error */ Error_Handler("set date error"); } #if 0 //flash lcd HAL_RTC_GetTime(&hrtc, &stimestructure, RTC_FORMAT_BIN); temp[0]=stimestructure.Hours; temp[1]=stimestructure.Minutes; temp[2]=stimestructure.Seconds; memcpy(¤t_datetime[3],temp,3); /* Get the RTC current Date */ HAL_RTC_GetDate(&hrtc, &sdatestructure, RTC_FORMAT_BIN); data[0]=sdatestructure.Year; data[1]=sdatestructure.Month; data[2]=sdatestructure.Date; current_datetime[6]=sdatestructure.WeekDay; memcpy(¤t_datetime[0],data,3);#endif if(disp_sort==0) send_message(4); osMutexRelease(rtc_mutex); }//data=null}
开发者ID:hlmpost,项目名称:code_backup,代码行数:55,
示例15: RTC_TimeShow/** * @brief Display the current time. * @param showtime : pointer to buffer * @retval None */static void RTC_TimeShow(uint8_t* showtime){ RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; /* Get the RTC current Time */ HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BIN); /* Get the RTC current Date */ HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BIN); /* Display time Format : hh:mm:ss */ sprintf((char*)showtime,"%02d:%02d:%02d",stimestructureget.Hours, stimestructureget.Minutes, stimestructureget.Seconds);}
开发者ID:451506709,项目名称:automated_machine,代码行数:17,
示例16: mainint main(void){ /* USER CODE BEGIN 1 */ trace_printf("Hello/n"); RTC_TimeTypeDef Tim; RTC_DateTypeDef Dat; /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ /* Initialize LED 4 */ BSP_LED_Init(LED4); /* Initialize RTC */ BSP_RTC_Init(); BSP_RTC_Alarm_Init(AlarmA,0,0,5,RTC_ALARMDATEWEEKDAYSEL_DATE); //Generate alarm interrupt /* Initialize UART with 115200 baud rate */ BSP_UART_Init(115200); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ __HAL_RTC_ALARM_CLEAR_FLAG(&hrtc_bsp,RTC_ISR_ALRAF); __HAL_RTC_ALARM_CLEAR_FLAG(&hrtc_bsp,RTC_ISR_ALRBF); HAL_RTC_GetTime(&hrtc_bsp,&Tim,FORMAT_BIN); HAL_RTC_GetDate(&hrtc_bsp,&Dat,FORMAT_BIN); Tim.SubSeconds = 1000 - ((hrtc_bsp.Instance->SSR*1000)/hrtc_bsp.Init.SynchPrediv); // Count msec uprintf("/x1b[3;1H %d02 : %d02 : %d02 : %d04",Tim.Hours,Tim.Minutes,Tim.Seconds,Tim.SubSeconds);// uprintf("/x1b[4;1H %d02 / %d02 / %d04", Dat.Date,Dat.Month,Dat.Year); } /* USER CODE END 3 */}
开发者ID:glocklueng,项目名称:STM32F4-Dev,代码行数:52,
示例17: HAL_GPIO_EXTI_Callback/** * @brief EXTI line detection callbacks * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ if (GPIO_Pin == USER_BUTTON_PIN) { /* Wait that user release the User push-button */ while(BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_SET){} HAL_RTC_GetTime(&RTCHandle, &RTC_TimeStructure, RTC_FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &RTC_DateStructure, RTC_FORMAT_BIN); /* Set the alarm to current time + 5s */ RTC_AlarmStructure.Alarm = RTC_ALARM_A; RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_TimeStructure.TimeFormat; RTC_AlarmStructure.AlarmTime.Hours = RTC_TimeStructure.Hours; RTC_AlarmStructure.AlarmTime.Minutes = RTC_TimeStructure.Minutes; RTC_AlarmStructure.AlarmTime.Seconds = (RTC_TimeStructure.Seconds + 5) % 60; RTC_AlarmStructure.AlarmDateWeekDay = 31; RTC_AlarmStructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; RTC_AlarmStructure.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_MINUTES; RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE; if (HAL_RTC_SetAlarm_IT(&RTCHandle, &RTC_AlarmStructure, RTC_FORMAT_BIN) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* The Following Wakeup sequence is highly recommended prior to each Standby mode entry mainly when using more than one wakeup source this is to not miss any wakeup event. - Disable all used wakeup sources, - Clear all related wakeup flags, - Re-enable all used wakeup sources, - Enter the Standby mode. */ /*#### Disable all used wakeup sources: WKUP pin ###########################*/ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); /*#### Clear all related wakeup flags ######################################*/ /* Clear PWR wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /* Enable WKUP pin */ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); /* Turn LED3 off */ BSP_LED_Off(LED3); /* Request to enter STANDBY mode */ HAL_PWR_EnterSTANDBYMode(); }}
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:57,
示例18: get_fattimeMP_WEAK DWORD get_fattime(void) { #if MICROPY_HW_ENABLE_RTC rtc_init_finalise(); RTC_TimeTypeDef time; RTC_DateTypeDef date; HAL_RTC_GetTime(&RTCHandle, &time, RTC_FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &date, RTC_FORMAT_BIN); return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2); #else // Jan 1st, 2018 at midnight. Not sure what timezone. return ((2018 - 1980) << 25) | ((1) << 21) | ((1) << 16) | ((0) << 11) | ((0) << 5) | (0 / 2); #endif}
开发者ID:DanielO,项目名称:micropython,代码行数:13,
示例19: TM_RTC_GetDateTimeTM_RTC_Result_t TM_RTC_GetDateTime(TM_RTC_t* data, TM_RTC_Format_t format) { uint32_t unix; /* Get time */ if (format == TM_RTC_Format_BIN) { HAL_RTC_GetTime(&hRTC, &RTC_TimeStruct, RTC_FORMAT_BIN); } else { HAL_RTC_GetTime(&hRTC, &RTC_TimeStruct, RTC_FORMAT_BCD); } /* Format hours */ data->Hours = RTC_TimeStruct.Hours; data->Minutes = RTC_TimeStruct.Minutes; data->Seconds = RTC_TimeStruct.Seconds; /* Get subseconds */ data->Subseconds = RTC->SSR; /* Get date */ if (format == TM_RTC_Format_BIN) { HAL_RTC_GetDate(&hRTC, &RTC_DateStruct, RTC_FORMAT_BIN); } else { HAL_RTC_GetDate(&hRTC, &RTC_DateStruct, RTC_FORMAT_BCD); } /* Format date */ data->Year = RTC_DateStruct.Year; data->Month = RTC_DateStruct.Month; data->Day = RTC_DateStruct.Date; data->WeekDay = RTC_DateStruct.WeekDay; /* Calculate unix offset */ unix = TM_RTC_GetUnixTimeStamp(data); data->Unix = unix; /* Return OK */ return TM_RTC_Result_Ok;}
开发者ID:qermit,项目名称:stm32fxxx_hal_libraries,代码行数:38,
示例20: RTC_Alarm_IRQHandler/*** @brief This function handles RTC alarms A and B interrupt through EXTI line 17.*/void RTC_Alarm_IRQHandler(void){ /* USER CODE BEGIN RTC_Alarm_IRQn 0 */ /* Get time and date from RTC registers */ HAL_RTC_GetTime(&hrtc, &time_now, RTC_FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &date_now, RTC_FORMAT_BIN); /* USER CODE END RTC_Alarm_IRQn 0 */ HAL_RTC_AlarmIRQHandler(&hrtc); /* USER CODE BEGIN RTC_Alarm_IRQn 1 */ /* USER CODE END RTC_Alarm_IRQn 1 */}
开发者ID:outsidersdelaelectronica,项目名称:tiic-2015,代码行数:17,
示例21: HAL_RTCEx_RTCEventCallback/* USER CODE BEGIN 0 */void HAL_RTCEx_RTCEventCallback(RTC_HandleTypeDef *hrtc){ RTC_TimeTypeDef sTime; RTC_DateTypeDef sDate; static int day = 0;HAL_RTC_GetDate(hrtc, &sDate, FORMAT_BIN);HAL_RTC_GetTime(hrtc, &sTime, FORMAT_BIN); if(day != sDate.Date){ day = sDate.Date; HAL_RTCEx_BKUPWrite(hrtc, RTC_BKP_DR2,sDate.Month); HAL_RTCEx_BKUPWrite(hrtc, RTC_BKP_DR3,sDate.Date); HAL_RTCEx_BKUPWrite(hrtc, RTC_BKP_DR4,sDate.Year); }};
开发者ID:Casa2011,项目名称:devices,代码行数:16,
示例22: rtc_checkstatic uint8_t rtc_check(){ uint8_t hour,min; RTC_AlarmTypeDef sAlarm; RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) != 0x32F2) { HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0x32F2); return 0; } else { //read time HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN); //set alarm /**Enable the Alarm A */ hour=stimestructureget.Hours; min=stimestructureget.Minutes+1; if(min>59) { min-=60; if(hour==23) hour=0; else hour++; } sAlarm.AlarmTime.Hours = hour; sAlarm.AlarmTime.Minutes = min; sAlarm.AlarmTime.Seconds = 1; sAlarm.AlarmTime.SubSeconds = 0; sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET; sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY; sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL; sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; sAlarm.AlarmDateWeekDay = 1; sAlarm.Alarm = RTC_ALARM_A; HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN); return 1; }}
开发者ID:hlmpost,项目名称:code_backup,代码行数:47,
示例23: mainint main(void){ /* USER CODE BEGIN 1 */ trace_printf("Hello/n"); RTC_TimeTypeDef Tim; RTC_DateTypeDef Dat; /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ /* Initialize RTC */ BSP_RTC_Init(); /* Initialize UART with 115200 baud rate */ BSP_UART_Init(115200); uprintf("Set Time: "); BSP_RTC_Change_Time(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_RTC_GetTime(&hrtc_bsp,&Tim,FORMAT_BIN); HAL_RTC_GetDate(&hrtc_bsp,&Dat,FORMAT_BIN); Tim.SubSeconds = 1000 - ((hrtc_bsp.Instance->SSR*1000)/hrtc_bsp.Init.SynchPrediv); // Count msec uprintf("/x1b[3;1H %d02 : %d02 : %d02 : %d04",Tim.Hours,Tim.Minutes,Tim.Seconds,Tim.SubSeconds); } /* USER CODE END 3 */}
开发者ID:glocklueng,项目名称:STM32F4-Dev,代码行数:47,
示例24: pyb_rtc_datetimemp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) { rtc_init_finalise(); if (n_args == 1) { // get date and time // note: need to call get time then get date to correctly access the registers RTC_DateTypeDef date; RTC_TimeTypeDef time; HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN); mp_obj_t tuple[8] = { mp_obj_new_int(2000 + date.Year), mp_obj_new_int(date.Month), mp_obj_new_int(date.Date), mp_obj_new_int(date.WeekDay), mp_obj_new_int(time.Hours), mp_obj_new_int(time.Minutes), mp_obj_new_int(time.Seconds), mp_obj_new_int(rtc_subsec_to_us(time.SubSeconds)), }; return mp_obj_new_tuple(8, tuple); } else { // set date and time mp_obj_t *items; mp_obj_get_array_fixed_n(args[1], 8, &items); RTC_DateTypeDef date; date.Year = mp_obj_get_int(items[0]) - 2000; date.Month = mp_obj_get_int(items[1]); date.Date = mp_obj_get_int(items[2]); date.WeekDay = mp_obj_get_int(items[3]); HAL_RTC_SetDate(&RTCHandle, &date, FORMAT_BIN); RTC_TimeTypeDef time; time.Hours = mp_obj_get_int(items[4]); time.Minutes = mp_obj_get_int(items[5]); time.Seconds = mp_obj_get_int(items[6]); time.SubSeconds = rtc_us_to_subsec(mp_obj_get_int(items[7])); time.TimeFormat = RTC_HOURFORMAT12_AM; time.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; time.StoreOperation = RTC_STOREOPERATION_SET; HAL_RTC_SetTime(&RTCHandle, &time, FORMAT_BIN); return mp_const_none; }}
开发者ID:19emtuck,项目名称:micropython,代码行数:45,
示例25: HAL_GPIO_EXTI_Callback/** * @brief EXTI line detection callbacks * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ if (GPIO_Pin == TAMPER_BUTTON_PIN) { HAL_RTC_GetTime(&RTCHandle, &RTC_TimeStructure, RTC_FORMAT_BIN); HAL_RTC_GetDate(&RTCHandle, &RTC_DateStructure, RTC_FORMAT_BIN); /* Set the alarm to current time + 5s */ RTC_AlarmStructure.Alarm = RTC_ALARM_A; RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_TimeStructure.TimeFormat; RTC_AlarmStructure.AlarmTime.Hours = RTC_TimeStructure.Hours; RTC_AlarmStructure.AlarmTime.Minutes = RTC_TimeStructure.Minutes; RTC_AlarmStructure.AlarmTime.Seconds = (RTC_TimeStructure.Seconds + 5) % 60; RTC_AlarmStructure.AlarmDateWeekDay = 31; RTC_AlarmStructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; RTC_AlarmStructure.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_MINUTES; RTC_AlarmStructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE; if (HAL_RTC_SetAlarm_IT(&RTCHandle, &RTC_AlarmStructure, RTC_FORMAT_BIN) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Wait that user release the Tamper push-button */ while(BSP_PB_GetState(BUTTON_TAMPER) == GPIO_PIN_SET){} /* Disable all used wakeup sources: WKUP pin */ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4); /* Clear all related wakeup flags */ /* Clear PWR wake up Flag */ __HAL_PWR_CLEAR_WAKEUP_FLAG(PWR_WAKEUP_PIN_FLAG4); /* Enable WKUP pin */ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN4); /* Turn on LED1 */ BSP_LED_Off(LED1); /* Request to enter STANDBY mode */ HAL_PWR_EnterSTANDBYMode(); }}
开发者ID:MrZANE42,项目名称:verisure1512,代码行数:48,
示例26: current_timedouble current_time(){ RTC_TimeTypeDef time; RTC_DateTypeDef date; uint32_t subsec; /* must get time and date here due to STM32 HW bug */ HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN); subsec = (255 - time.SubSeconds) * 1000 / 255; (void)date; /* return seconds.milliseconds */ return ((double)time.Hours * 24) + ((double)time.Minutes * 60) + (double)time.Seconds + ((double)subsec/1000);}
开发者ID:NickolasLapp,项目名称:wolfssl,代码行数:19,
示例27: mo_Get_UnixTime_haltime_t mo_Get_UnixTime_hal(void){ RTC_DateTypeDef sdatestructureget; RTC_TimeTypeDef stimestructureget; struct tm tmstruct; memset(&tmstruct, 0, sizeof(tm)); /* Get the RTC current Time */ HAL_RTC_GetTime(&RtcHandle, &stimestructureget, RTC_FORMAT_BIN); /* Get the RTC current Date */ HAL_RTC_GetDate(&RtcHandle, &sdatestructureget, RTC_FORMAT_BIN); tmstruct.tm_year = 2000 + sdatestructureget.Year - 1900; tmstruct.tm_mon = sdatestructureget.Month - 1; tmstruct.tm_mday = sdatestructureget.Date; tmstruct.tm_hour = stimestructureget.Hours; tmstruct.tm_min = stimestructureget.Minutes; tmstruct.tm_sec = stimestructureget.Seconds; time_t t = mktime( &tmstruct ); return t;}
开发者ID:HitszChen,项目名称:intorobot-firmware,代码行数:20,
示例28: vOutputTimevoid vOutputTime (void){ extern RTC_HandleTypeDef hrtc; RTC_TimeTypeDef sTime; RTC_DateTypeDef sDate;// if( xSemaphoreTake( xDEBUGbusMutex, cmdMAX_MUTEX_WAIT ) == pdPASS ) // ждем семафор cmdMAX_MUTEX_WAIT иначе уходим// { HAL_RTC_GetTime(&hrtc, &sTime, FORMAT_BIN); // Читаем время HAL_RTC_GetDate(&hrtc, &sDate, FORMAT_BIN); // читаем дату char* WriteBuffer = pvPortMalloc(30); sprintf( WriteBuffer, "[%d.%d.%d.%u] ",sTime.Hours,sTime.Minutes,sTime.Seconds,(uint16_t)(sTime.SubSeconds/2) ); USART_0TRACE(WriteBuffer); vPortFree(WriteBuffer);// xSemaphoreGive( xDEBUGbusMutex ); // вернём семафор// }}
开发者ID:sagok,项目名称:SmI_IEC104,代码行数:20,
示例29: mainint main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_RTC_Init(); //if(!(*(volatile uint32_t *) (BDCR_RTCEN_BB)))__HAL_RCC_RTC_ENABLE(); MX_TIM2_Init(); MX_TIM3_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_RTC_GetTime(&hrtc, &myTime, FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &myDate, FORMAT_BIN); } /* USER CODE END 3 */}
开发者ID:fominok,项目名称:znp,代码行数:41,
注:本文中的HAL_RTC_GetDate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ HAL_RTC_GetTime函数代码示例 C++ HAL_RESTORE_INTERRUPTS函数代码示例 |