当前位置: 首页>>代码示例>>C++>>正文


C++ HAL_RTC_GetDate函数代码示例

本文整理汇总了C++中HAL_RTC_GetDate函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_RTC_GetDate函数的具体用法?C++ HAL_RTC_GetDate怎么用?C++ HAL_RTC_GetDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HAL_RTC_GetDate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:main.c

示例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,代码来源:main.c

示例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,代码来源:main.c

示例4: RTC_CalendarShow

uint32_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,代码来源:stm32f401_lp_mode.c

示例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,代码来源:rtc_api.c

示例6: RTC_Read_datetime

//-------------------------------------------------------------------
//read date time
void 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(&current_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(&current_datetime[0],data,3);

		if(flag==1)
		{
			memcpy(data,temp,3);
		}
		osMutexRelease(rtc_mutex);
	}
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:37,代码来源:eric_rtc.c

示例7: rtcGetDateTime

void 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,代码来源:rtc.c

示例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,代码来源:main.c

示例9: rtc_init

void 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,代码来源:rtc.c

示例10: get_fattime

DWORD 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,代码来源:fatfs_port.c

示例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,代码来源:modutime.c

示例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,代码来源:k_rtc.c

示例13: RtcGetCalendar

static 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,代码来源:rtc-board.c

示例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(&current_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(&current_datetime[0],data,3);
#endif
		if(disp_sort==0)
				send_message(4);

	  osMutexRelease(rtc_mutex);

	}//data=null
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:55,代码来源:eric_rtc.c

示例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,代码来源:main.c


注:本文中的HAL_RTC_GetDate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。