//http://www.waveshare.net/study/article-652-1.html
///rtc.c GKOSON ADD
static uint8_t rtc_alarm_flag = 0;
void GRTC_GET(uint8_t* showtime)
{
RTC_DateTypeDef sdatestructureget;
RTC_TimeTypeDef stimestructureget;
/* Get the RTC current Time */
HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);
/* Get the RTC current Date */
HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
/* Display time Format : hh:mm:ss */
//sprintf((char*)showtime,"%02d:%02d:%02d",stimestructureget.Hours, stimestructureget.Minutes, stimestructureget.Seconds);
printf("%02d:%02d:%02d\r\n",stimestructureget.Hours, stimestructureget.Minutes, stimestructureget.Seconds);
}
//__weak void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
rtc_alarm_flag++;
printf("\r\n\r\n\r\n%s %d\r\n\r\n\r\n",__FUNCTION__,rtc_alarm_flag);
}
uint8_t RTC_TimeAlarm(void)
{
return rtc_alarm_flag;
}
//дRTC
//GRTC_SET(19,4,23,11,12,13,RTC_WEEKDAY_TUESDAY)
void GRTC_SET(uint8_t year , uint8_t mon , uint8_t day ,
uint8_t hour , uint8_t min , uint8_t sec , uint8_t week)
{
RTC_DateTypeDef sdatestructureget;
RTC_TimeTypeDef stimestructureget;
sdatestructureget.WeekDay=week;//RTC_WEEKDAY_TUESDAY;
sdatestructureget.Month=mon;//RTC_MONTH_APRIL;
sdatestructureget.Date=day;//23;
sdatestructureget.Year=year;//19;
stimestructureget.Hours=hour;//11;
stimestructureget.Minutes=min;//12;
stimestructureget.Seconds=sec;//13;
if (HAL_RTC_SetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
if (HAL_RTC_SetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
}
extern void GRTC_GET(uint8_t* showtime);
extern void GRTC_SET(uint8_t year , uint8_t mon , uint8_t day ,uint8_t hour , uint8_t min , uint8_t sec , uint8_t week);
extern uint8_t RTC_TimeAlarm(void);