/**
  ******************************************************************************
  * @file    RTC_CFG.h
  * @author  SINOMCU-AE
  * @brief   Header file of RTC_CFG.c file.
  *    
  *          This file describes the CRC macro definitions used:
  *    Micro define user LSI or LSE,RTC init date and time,alarm time
  *    RTC init RTC_ASYNCH_PREDIV,RTC_SYNCH_PREDIV,SS mask bit num.
  * 
  ******************************************************************************
  * @attention 
  *                           DISCLAIMER
  * The present firmware which is for guidance only aims at providing customers
  * with coding information regarding their products in order for them to save
  * time. As a result, SinoMCU shall not be held liable for any direct,indirect
  * or consequential damages with respect to any claims arising from the content 
  * of such firmware and/or the use made by customers of the coding information 
  * contained herein in connection with their products.
  *
  * <h2><center>&copy; Copyright (c) 2021 sinomcu All rights reserved.</center></h2>
  *
  ******************************************************************************
  */

#ifndef __RTC_CFG_H
#define __RTC_CFG_H

#include "ms32f0xx.h"

#define RTC_USER_LSE              1              // 1:use LSE,0:use LSI

#define RTC_INIT_IDF_VAL          0x5A5A         // RTC had init
// 23:58:45
#define RTC_INIT_HOURS            0x23
#define RTC_INIT_MINUTES          0x58
#define RTC_INIT_SECONDS          0x45
// 2021-12-10
#define RTC_INIT_WEEKDAY          MS32_RTC_WEEKDAY_FRIDAY
#define RTC_INIT_DAY              0x10
#define RTC_INIT_MONTH            MS32_RTC_MONTH_DECEMBER
#define RTC_INIT_YEAR             0x21

// 23:58:50
#define RTC_ALARM_HOURS           0x23
#define RTC_ALARM_MINUTES         0x58
#define RTC_ALARM_SECONDS         0x50

// ck_apre=LSxFreq/(ASYNC prediv + 1) ,LSI:40K,LSE:32.768K
// ck_spre=ck_apre/(SYNC prediv + 1) 
#if(defined(RTC_USER_LSE) && RTC_USER_LSE) 
#define RTC_ASYNCH_PREDIV         0x7F
#define RTC_SYNCH_PREDIV          0xFF
#else
#define RTC_ASYNCH_PREDIV         39
// RTC_SYNCH_PREDIV 1023,RTC calendar clk 0.97Hz
// RTC_SYNCH_PREDIV 999,alatm add once 1s,RTC calendar clk 1Hz
#define RTC_SYNCH_PREDIV          0x3FF
#endif

#define SUB_SECOND_MASK_BIT_NONE  0x00
#define SUB_SECOND_MASK_BIT_NUM1  0x01
#define SUB_SECOND_MASK_BIT_NUM2  0x02
#define SUB_SECOND_MASK_BIT_NUM3  0x03
#define SUB_SECOND_MASK_BIT_NUM4  0x04
#define SUB_SECOND_MASK_BIT_NUM5  0x05
#define SUB_SECOND_MASK_BIT_NUM6  0x06
#define SUB_SECOND_MASK_BIT_NUM7  0x07
#define SUB_SECOND_MASK_BIT_NUM8  0x08
#define SUB_SECOND_MASK_BIT_NUM9  0x09
#define SUB_SECOND_MASK_BIT_NUM10 0x0A
#define SUB_SECOND_MASK_BIT_NUM11 0x0B
#define SUB_SECOND_MASK_BIT_NUM12 0x0C
#define SUB_SECOND_MASK_BIT_NUM13 0x0D
#define SUB_SECOND_MASK_BIT_NUM14 0x0E
#define SUB_SECOND_MASK_BIT_ALL   0x0F

void rtc_config(void);
void rtc_alarm_config(void);

#endif /* __RTC_CFG_H */ 

/******************************** END OF FILE *********************************/
