本文整理汇总了C++中HAL_RTC_SetDate函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_RTC_SetDate函数的具体用法?C++ HAL_RTC_SetDate怎么用?C++ HAL_RTC_SetDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_RTC_SetDate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MX_RTC_BACKUP_Init
void MX_RTC_BACKUP_Init(void){
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1) != TSTWORD){
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1, TSTWORD);
sTime.Hours = 22;
sTime.Minutes = 02;
sTime.Seconds = 00;
sTime.
HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
sDate.WeekDay = RTC_WEEKDAY_FRIDAY;
sDate.Month = RTC_MONTH_APRIL;
sDate.Date = 23;
sDate.Year = 16;
HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
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);
} else {
sDate.Month = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR2);
sDate.Date = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR3);
sDate.Year = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR4);
HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
}
}
开发者ID:Casa2011,项目名称:devices,代码行数:32,代码来源:main.c
示例2: RTC_TimeStampConfig
/**
* @brief Configures the current time and date.
* @param None
* @retval None
*/
static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/*##-3- Configure the Date #################################################*/
/* Set Date: Tuesday February 18th 2014 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_FEBRUARY;
sdatestructure.Date = 0x18;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RtcHandle,&sdatestructure,FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-4- Configure the Time #################################################*/
/* Set Time: 08:10:00 */
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle,&stimestructure,FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
开发者ID:adibacco,项目名称:contiki,代码行数:38,代码来源:stm32cube_hal_init.c
示例3: BSP_RTC_Init
/**
* @brief RTC Initialization function
*/
void BSP_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
/**Initialize RTC and set the Time and Date
*/
hrtc_bsp.Instance = RTC;
hrtc_bsp.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc_bsp.Init.AsynchPrediv = 127; //LSI clock AsyncPrediv 127 HSE clock AsyncPrediv 124
hrtc_bsp.Init.SynchPrediv = 255; //LSI clock SyncPrediv 255 HSE clock SyncPrediv 7999
hrtc_bsp.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc_bsp.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc_bsp.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
BSP_RTC_MspInit(&hrtc_bsp);
HAL_RTC_Init(&hrtc_bsp);
sTime.Hours = 0;
sTime.Minutes = 0;
sTime.Seconds = 0;
sTime.SubSeconds = 0;
sTime.TimeFormat = RTC_HOURFORMAT12_AM;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&hrtc_bsp, &sTime, FORMAT_BIN);
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 1;
sDate.Year = 00;
HAL_RTC_SetDate(&hrtc_bsp, &sDate, FORMAT_BIN);
}
开发者ID:glocklueng,项目名称:STM32F4-Dev,代码行数:36,代码来源:stm32f4_discovery_rtc.c
示例4: rtc_write
void rtc_write(time_t t) {
RTC_DateTypeDef dateStruct;
RTC_TimeTypeDef timeStruct;
RtcHandle.Instance = RTC;
// Convert the time into a tm
struct tm *timeinfo = localtime(&t);
// Fill RTC structures
dateStruct.WeekDay = timeinfo->tm_wday;
dateStruct.Month = timeinfo->tm_mon + 1;
dateStruct.Date = timeinfo->tm_mday;
dateStruct.Year = timeinfo->tm_year - 100;
timeStruct.Hours = timeinfo->tm_hour;
timeStruct.Minutes = timeinfo->tm_min;
timeStruct.Seconds = timeinfo->tm_sec;
timeStruct.TimeFormat = RTC_HOURFORMAT12_PM;
timeStruct.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
timeStruct.StoreOperation = RTC_STOREOPERATION_RESET;
// Change the RTC current date/time
HAL_RTC_SetDate(&RtcHandle, &dateStruct, FORMAT_BIN);
HAL_RTC_SetTime(&RtcHandle, &timeStruct, FORMAT_BIN);
}
开发者ID:logxen,项目名称:mbed,代码行数:25,代码来源:rtc_api.c
示例5: MX_RTC_Init
/* RTC init function */
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef DateToUpdate;
/**Initialize RTC and set the Time and Date
*/
hrtc.Instance = RTC;
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE;
HAL_RTC_Init(&hrtc);
sTime.Hours = 0x10;
sTime.Minutes = 0x6;
sTime.Seconds = 0x24;
HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD);
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
DateToUpdate.Month = RTC_MONTH_AUGUST;
DateToUpdate.Date = 0x15;
DateToUpdate.Year = 0x16;
HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD);
}
开发者ID:ZBT1314douhao,项目名称:STM32F107VCT6,代码行数:27,代码来源:rtc.c
示例6: RTC_CalendarConfig
/**
* @brief Configure the current time and date.
* @param None
* @retval None
*/
static void RTC_CalendarConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/*##-1- Configure the Date #################################################*/
/* Set Date: Tuesday April 14th 2015 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_JANUARY;
sdatestructure.Date = 0x01;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RTCHandle,&sdatestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Time #################################################*/
/* Set Time: 02:00:00 */
stimestructure.Hours = 0x00;
stimestructure.Minutes = 0x00;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RTCHandle,&stimestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
开发者ID:gilbertjuly,项目名称:cannon,代码行数:39,代码来源:stm32f401_lp_mode.c
示例7: Clocks_Init
void Clocks_Init(void)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
//TODO: на реальном приборе кварц не 8 а 25 ћ√ц. исправить делитель
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV8; // RTCCLK = 1MHz
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
__HAL_RCC_RTC_ENABLE();
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 124;
hrtc.Init.SynchPrediv = 7999;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
sTime.Hours = 1;
sTime.Minutes = 1;
sTime.Seconds = 1;
sTime.SubSeconds = 0;
sTime.TimeFormat = RTC_HOURFORMAT_24;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BCD);
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 1;
sDate.Year = 0;
HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BCD);
}
开发者ID:bearxiong99,项目名称:SmI_IEC104,代码行数:35,代码来源:clocks.c
示例8: RTC_CalendarConfig
STATIC void RTC_CalendarConfig(void) {
// set the date to 1st Jan 2015
RTC_DateTypeDef date;
date.Year = 15;
date.Month = 1;
date.Date = 1;
date.WeekDay = RTC_WEEKDAY_THURSDAY;
if(HAL_RTC_SetDate(&RTCHandle, &date, FORMAT_BIN) != HAL_OK) {
// init error
return;
}
// set the time to 00:00:00
RTC_TimeTypeDef time;
time.Hours = 0;
time.Minutes = 0;
time.Seconds = 0;
time.TimeFormat = RTC_HOURFORMAT12_AM;
time.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
time.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&RTCHandle, &time, FORMAT_BIN) != HAL_OK) {
// init error
return;
}
}
开发者ID:19emtuck,项目名称:micropython,代码行数:27,代码来源:rtc.c
示例9: MX_RTC_Init
/* RTC init function */
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
RTC_AlarmTypeDef sAlarm;
/**Initialize RTC and set the Time and Date
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
sTime.Hours = 0;
sTime.Minutes = 0;
sTime.Seconds = 0;
sTime.SubSeconds = 0;
sTime.TimeFormat = RTC_HOURFORMAT12_AM;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BIN);
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 1;
sDate.Year = 0;
HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BIN);
/**Enable the Alarm A
*/
sAlarm.AlarmTime.Hours = 0;
sAlarm.AlarmTime.Minutes = 0;
sAlarm.AlarmTime.Seconds = 0;
sAlarm.AlarmTime.SubSeconds = 0;
sAlarm.AlarmTime.TimeFormat = RTC_HOURFORMAT12_AM;
sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
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);
/**Enable the Alarm B
*/
sAlarm.Alarm = RTC_ALARM_B;
HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN);
/**Enable the WakeUp
*/
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 196, RTC_WAKEUPCLOCK_RTCCLK_DIV2);
}
开发者ID:will9twl,项目名称:FM24V10_I2C_FRAM,代码行数:60,代码来源:main.c
示例10: RTC_TimeStampConfig
/**
* @brief Configures the current time and date.
* @param None
* @retval None
*/
static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
RTC_TamperTypeDef stamperstructure;
/*##-1- Configure the Tamper ###############################################*/
/* Configure Tamper registers */
/* RTC Tamper configured as follow:
- Pamper = Tamper1
- Pin selection = PC13
- Trigger = Falling Edge
- TimeStamp On Tamper Detection = Enable */
stamperstructure.Filter = RTC_TAMPERFILTER_DISABLE;
stamperstructure.Tamper = RTC_TAMPER_1;
stamperstructure.PinSelection = RTC_TAMPERPIN_PC13;
stamperstructure.Trigger = RTC_TAMPERTRIGGER_FALLINGEDGE;
stamperstructure.SamplingFrequency = RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096;
stamperstructure.PrechargeDuration = RTC_TAMPERPRECHARGEDURATION_1RTCCLK;
stamperstructure.TamperPullUp = RTC_TAMPER_PULLUP_DISABLE;
stamperstructure.TimeStampOnTamperDetection = RTC_TIMESTAMPONTAMPERDETECTION_ENABLE;
HAL_RTCEx_SetTamper(&RtcHandle, &stamperstructure);
/*##-2- Configure the Time Stamp peripheral ################################*/
/* RTC TimeStamp flag Generation: TimeStamp Rising Edge on PC13 Pin */
HAL_RTCEx_SetTimeStamp_IT(&RtcHandle, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_PC13);
/* Clear the TIMESTAMP interrupt pending bit */
__HAL_RTC_TIMESTAMP_CLEAR_FLAG(&RtcHandle,RTC_FLAG_TSF);
/*##-3- Configure the Date #################################################*/
/* Set Date: Tuesday February 18th 2014 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_FEBRUARY;
sdatestructure.Date = 0x18;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RtcHandle,&sdatestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-4- Configure the Time #################################################*/
/* Set Time: 08:10:00 */
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle,&stimestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:63,代码来源:main.c
示例11: MX_RTC_Init
/* RTC init function */
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
RTC_AlarmTypeDef sAlarm;
/**Initialize RTC and set the Time and Date
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
/* USER CODE BEGIN*/
rtc_backup_init();
if(rtc_check()==0)
{
sTime.Hours = 16;
sTime.Minutes = 52;
sTime.Seconds = 50;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BIN);
sDate.WeekDay = RTC_WEEKDAY_WEDNESDAY;
sDate.Month = RTC_MONTH_APRIL;
sDate.Date = 20;
sDate.Year = 16;
HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BIN);
/**Enable the Alarm A
*/
sAlarm.AlarmTime.Hours = 16;
sAlarm.AlarmTime.Minutes = 53;
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);
}
/* USER CODE END*/
/**Enable the WakeUp
*/
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 10240, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:57,代码来源:rtc.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(¤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,代码来源:eric_rtc.c
示例13: RTC_AlarmConfig
/**
* @brief Configure the current time and date.
* @param None
* @retval None
*/
static void RTC_AlarmConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
RTC_AlarmTypeDef salarmstructure;
/*##-1- Configure the Date #################################################*/
/* Set Date: Tuesday February 18th 2014 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_FEBRUARY;
sdatestructure.Date = 0x18;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RtcHandle,&sdatestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Time #################################################*/
/* Set Time: 02:20:00 */
stimestructure.Hours = 0x02;
stimestructure.Minutes = 0x20;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle,&stimestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-3- Configure the RTC Alarm peripheral #################################*/
/* Set Alarm to 02:20:30
RTC Alarm Generation: Alarm on Hours, Minutes and Seconds */
salarmstructure.Alarm = RTC_ALARM_A;
salarmstructure.AlarmDateWeekDay = RTC_WEEKDAY_MONDAY;
salarmstructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
salarmstructure.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY;
salarmstructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE;
salarmstructure.AlarmTime.TimeFormat = RTC_HOURFORMAT12_AM;
salarmstructure.AlarmTime.Hours = 0x02;
salarmstructure.AlarmTime.Minutes = 0x20;
salarmstructure.AlarmTime.Seconds = 0x30;
salarmstructure.AlarmTime.SubSeconds = 0x56;
if(HAL_RTC_SetAlarm_IT(&RtcHandle,&salarmstructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
开发者ID:451506709,项目名称:automated_machine,代码行数:59,代码来源:main.c
示例14: RtcSetConfig
static void RtcSetConfig( void )
{
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
//RTC_AlarmTypeDef salarmstructure;
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower();
/* Enable the fast wake up from Ultra low power mode */
HAL_PWREx_EnableFastWakeUp();
/* Select HSI as system clock source after Wake Up from Stop mode */
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_StopWakeUpClock_HSI);
/*##-1- Configure the RTC peripheral #######################################*/
/* 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.Instance = RTC;
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;
HAL_RTC_Init(&RTCHandle);
//Initiate data and time
RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT12_AM;
RTC_TimeStruct.Hours = 0x00;
RTC_TimeStruct.Minutes = 0x00;
RTC_TimeStruct.Seconds = 0x00;
RTC_TimeStruct.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
RTC_TimeStruct.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&RTCHandle,&RTC_TimeStruct,FORMAT_BIN);
// RTC_TimeStructInit( &RTC_TimeStruct );
RTC_DateStruct.WeekDay = RTC_WEEKDAY_SATURDAY;
RTC_DateStruct.Date = 0x01;
RTC_DateStruct.Month = RTC_MONTH_JANUARY;
RTC_DateStruct.Year = 0x01;
HAL_RTC_SetDate(&RTCHandle,&RTC_DateStruct,FORMAT_BIN);
}
开发者ID:qlcGit,项目名称:NPLink-Mote-STM32-SDK,代码行数:53,代码来源:rtc_board.c
示例15: MX_RTC_Init
/* RTC init function */
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
/**Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Initialize RTC and set the Time and Date
*/
if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) != 0x32F2){
sTime.Hours = 0x0;
sTime.Minutes = 0x0;
sTime.Seconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x1;
sDate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR0,0x32F2);
}
/**Enable the WakeUp
*/
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 5, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
开发者ID:theapi,项目名称:solar,代码行数:54,代码来源:rtc.c
示例16: MX_RTC_Init
/* RTC init function */
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
/**Initialize RTC and set the Time and Date
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
sTime.Hours = 0x17;
sTime.Minutes = 0x3B;
sTime.Seconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BIN);
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x1;
sDate.Year = 0x0;
HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BIN);
/**Enable the Alarm A
*/
sAlarm.AlarmTime.Hours = 0x17;
sAlarm.AlarmTime.Minutes = 0x3B;
sAlarm.AlarmTime.Seconds = 0x9;
sAlarm.AlarmTime.SubSeconds = 0x0;
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 = 0x1;
sAlarm.Alarm = RTC_ALARM_A;
// HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN);
//__HAL_RCC_RTC_ENABLE();
/*##-4- Configure the NVIC for RTC Alarm ###################################*/
}
开发者ID:Csatacsibe,项目名称:Vadalarm_quad,代码行数:52,代码来源:main.c
示例17: rtcSetDateTime
void rtcSetDateTime(RTC_DateTypeDef *date, RTC_TimeTypeDef *time)
{
if(HAL_RTC_SetDate(&RtcHandle,date,FORMAT_BIN) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
if(HAL_RTC_SetTime(&RtcHandle,time,FORMAT_BIN) != HAL_OK)
{
/* Error */
Error_Handler();
}
}
开发者ID:FlankerZ,项目名称:epaper_cnt,代码行数:14,代码来源:rtc.c
示例18: RTC_AlarmConfig
/**
* @brief Configure the current time and date.
* @param None
* @retval None
*/
static void RTC_AlarmConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
RTC_AlarmTypeDef salarmstructure;
/*##-1- Configure the Date #################################################*/
/* Set Date: Tuesday February 18th 2014 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_FEBRUARY;
sdatestructure.Date = 0x18;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RtcHandle,&sdatestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Time #################################################*/
/* Set Time: 02:20:00 */
stimestructure.Hours = 0x02;
stimestructure.Minutes = 0x20;
stimestructure.Seconds = 0x00;
if(HAL_RTC_SetTime(&RtcHandle,&stimestructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-3- Configure the RTC Alarm peripheral #################################*/
/* Set Alarm to 02:20:30
RTC Alarm Generation: Alarm on Hours, Minutes and Seconds */
salarmstructure.Alarm = RTC_ALARM_A;
salarmstructure.AlarmTime.Hours = 0x02;
salarmstructure.AlarmTime.Minutes = 0x20;
salarmstructure.AlarmTime.Seconds = 0x30;
if(HAL_RTC_SetAlarm_IT(&RtcHandle,&salarmstructure,RTC_FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:50,代码来源:main.c
示例19: pyb_rtc_datetime
mp_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,代码来源:rtc.c
示例20: RtcInit
void RtcInit( void )
{
RtcCalendar_t rtcInit;
if( RtcInitialized == false )
{
__HAL_RCC_RTC_ENABLE( );
RtcHandle.Instance = RTC;
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
RtcHandle.Init.AsynchPrediv = PREDIV_A; // RTC_ASYNCH_PREDIV;
RtcHandle.Init.SynchPrediv = PREDIV_S; // RTC_SYNCH_PREDIV;
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init( &RtcHandle );
// Set Date: Friday 1st of January 2000
rtcInit.CalendarDate.Year = 0;
rtcInit.CalendarDate.Month = RTC_MONTH_JANUARY;
rtcInit.CalendarDate.Date = 1;
rtcInit.CalendarDate.WeekDay = RTC_WEEKDAY_SATURDAY;
HAL_RTC_SetDate( &RtcHandle, &rtcInit.CalendarDate, RTC_FORMAT_BIN );
// Set Time: 00:00:00
rtcInit.CalendarTime.Hours = 0;
rtcInit.CalendarTime.Minutes = 0;
rtcInit.CalendarTime.Seconds = 0;
rtcInit.CalendarTime.SecondFraction = 0;
rtcInit.CalendarTime.TimeFormat = RTC_HOURFORMAT12_AM;
rtcInit.CalendarTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
rtcInit.CalendarTime.StoreOperation = RTC_STOREOPERATION_RESET;
HAL_RTC_SetTime( &RtcHandle, &rtcInit.CalendarTime, RTC_FORMAT_BIN );
// Enable Direct Read of the calendar registers (not through Shadow registers)
HAL_RTCEx_EnableBypassShadow( &RtcHandle );
HAL_NVIC_SetPriority( RTC_Alarm_IRQn, 1, 0 );
HAL_NVIC_EnableIRQ( RTC_Alarm_IRQn );
RtcInitialized = true;
}
}
开发者ID:Lora-net,项目名称:LoRaMac-node,代码行数:43,代码来源:rtc-board.c
注:本文中的HAL_RTC_SetDate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论