
#include "HD_RTC.h"
#include "stm32g431xx.h"


void HD_RTC_Init(void)
{
    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;
    hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
    if (HAL_RTC_Init(&hrtc) != HAL_OK)
    {
        Error_Handler();
    }

    // RTC_TimeTypeDef sTime = {0};
    // RTC_DateTypeDef sDate = {0};

    // sTime.Hours = 0;
    // sTime.Minutes = 0;
    // sTime.Seconds = 0;
    // sTime.SubSeconds = 0;
    // sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
    // sTime.StoreOperation = RTC_STOREOPERATION_RESET;
    // if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
    // {
    //     Error_Handler();
    // }
    // sDate.WeekDay = RTC_WEEKDAY_MONDAY;
    // sDate.Month = RTC_MONTH_JANUARY;
    // sDate.Date = 1;
    // sDate.Year = 0;

    // if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)
    // {
    //     Error_Handler();
    // }
}



