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


C++ HAL_RTC_GetTime函数代码示例

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


在下文中一共展示了HAL_RTC_GetTime函数的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例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: 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

示例10: 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

示例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: 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

示例13: fp_get_rtc_time

/*
    Conditions:
      0
    Exit points:
      1
    M = 0 - 1 + 2 = 3
    Cyclomatic complexity
      1
  */
uint32_t fp_get_rtc_time(void)
{
  RTC_TimeTypeDef sTime;
  uint32_t curTime;

  HAL_RTC_GetTime(&rtc, &sTime, FORMAT_BIN);

  curTime = (sTime.Hours * 3600) + (sTime.Minutes * 60) + (sTime.Seconds);

  return curTime;
}
开发者ID:ChicoState,项目名称:eggbeater,代码行数:20,代码来源:fingerprint_reader.c

示例14: 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

示例15: main

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


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