void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
rtc_time_t tim = {0};
// 获取当前时间
RTC_GetTime(&tim);
alarm.AlarmTime.Hours = tim.Hours;
alarm.AlarmTime.Minutes =tim.Minutes;
alarm.AlarmTime.Seconds = tim.Seconds + 5; /* 设置下次闹钟提醒时间是当前时间的5s之后 */
alarm.Alarm = RTC_ALARM_A;
// 再次启动闹钟中断事件
if (HAL_RTC_SetAlarm_IT(hrtc, &alarm, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
printf("%02d/%02d/%02d %02d:%02d:%02d %d\r\n", tim.Year, tim.Month, tim.Day, tim.Hours, tim.Minutes, tim.Seconds, tim.WeekDay);
HAL_GPIO_TogglePin(GPIOE,GPIO_PIN_5);
printf("HAL_RTC_AlarmAEventCallback\r\n");
// printf("%02d:%02d:%02d \r\n",alarm.AlarmTime.Hours,alarm.AlarmTime.Minutes,alarm.AlarmTime.Seconds + 5);
}
|