/**
  ******************************************************************************
  * @file    rtc_hal.h
  * @author  Product application department
  * @version V1.0
  * @date    2020.03.25
  * @brief   Header file of RTC HAL module.
  * 
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RTC_HAL_H
#define __RTC_HAL_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "type.h"
#include "hal_def.h"
#include "rtc_drv.h"

/**@defgroup HAL HAL driver
  *
  *@{
  */

/** @defgroup HAL_RTC RTC
  *
  *@{
  */

/*** 宏定义 *******************************************************************/
/** @defgroup RTC_Exported_Macros Exported Macros
  *
  * @{
  */
  #define RTC_WCLK_MAX 10000000 /**< 10MHz */

  /**
  * @}
  */

  /*** 结构体、枚举变量定义 *****************************************************/
  /** @defgroup RTC_Exported_Types Exported Types
  *
  * @{
  */

  /**
 * @brief RTC 时间类型枚举
 *
 */
  typedef enum
  {
    ALARM_NULL = 0,
    ALARM_DAY = 0x01,
    ALARM_HOUR = 0x02,
    ALARM_MIN = 0x04,
    ALARM_SEC = 0x08,
  } RTC_AlarmITTypeDef;

  /**
 * @brief RTC 触发类型枚举
 *
 */
  typedef enum
  {
    ALARM_LOW_LEVEL = 0,
    ALARM_RISE,
    ALARM_FALL,
    ALARM_RISE_FALL,
} RTC_AlarmTypeDef;

  //typedef struct
  //{
  //	__IO uint16_t days;
  //	__IO uint8_t  hours;
  //	__IO uint8_t  minutes;
  //	__IO uint8_t  seconds;
  //}RTC_TimeTypeDef;

  /**
 * @brief RTC 初始化结构体定义
 *
 */
  typedef struct
  {
    RTC_TimeTypeDef set_time;
    RTC_TimeTypeDef set_aralm_time;
    RTC_AlarmITTypeDef alarm_it_type;
    RTC_AlarmTypeDef alarm_type;
    uint32_t sys_clk;
  } RTC_InitTypeDef;

  /**
  * @}
  */

  /*** 全局变量声明 **************************************************************/
  /** @defgroup RTC_Exported_Variables Exported Variables
  *
  * @{
  */

  /**
  * @}
  */

  /*** 函数声明 ******************************************************************/
  /** @defgroup RTC_Exported_Functions Exported Functions
  * @{
  */

  extern void HAL_RTC_IRQHandler(void);
  extern void HAL_RTC_AralmConfig(RTC_AlarmITTypeDef AlarmITType, RTC_AlarmTypeDef AlarmType, RTC_TimeTypeDef *Time);
  extern HAL_StatusTypeDef HAL_RTC_Init(RTC_InitTypeDef *pRTCInit);
  extern void HAL_RTC_GetTime(RTC_TimeTypeDef *Time);
  extern void HAL_RTC_SetTime(RTC_TimeTypeDef *Time);

  /**
  * @}
  */

  /**
  *@}
  */

  /**
  *@}
  */

#ifdef __cplusplus
}
#endif

#endif /* __RTC_HAL_H */

