/*** 
 * @Author: mbw
 * @Date: 2024-11-30 15:46:21
 * @LastEditors: mbw && 1600520629@qq.com
 * @LastEditTime: 2025-02-21 10:00:21
 * @FilePath: \ble_bjq_ch303rct6_ml307\bsp\inc\bsp_rtc.h
 * @Description: 
 * @
 * @Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
 */
/*
 * @Author       : stark1898y 1658608470@qq.com
 * @Date         : 2024-09-05 10:25:51
 * @LastEditors  : stark1898y 1658608470@qq.com
 * @LastEditTime : 2024-09-25 10:18:41
 * @FilePath     : \JT-DT-YD4N02A_RTT_MRS\bsp\inc\bsp_rtc.h
 * @Description  :
 *
 * Copyright (c) 2024 by yzy, All Rights Reserved.
 */
#ifndef __BSP_RTC_H__
#define __BSP_RTC_H__

#include "board.h"
#include "rtdef.h"

#define TSET_BSP_RTC

typedef struct __attribute__((packed))
{
    uint16_t year;     // 年份设置，取值范围为
    uint8_t month;    // 日期设置，取值范围为1~31
    uint16_t day;     // 月份设置，取值范围为1~12

    uint8_t hour;   /* 小时设置 */
    uint8_t minute; /* 分钟设置 */
    uint8_t second; /* 秒设置 */

    uint8_t week;  // 星期几设置，取值范围为1~7，对应星期一~星期日
} TsRtcDateTime;

extern TsRtcDateTime RtcDateTime;

uint32_t DateTime2Seconds(uint16_t syear, uint8_t smon, uint8_t sday, uint8_t hour, uint8_t min, uint8_t sec);
void Seconds2DateTime(uint32_t seconds, TsRtcDateTime* pDateTime);
uint32_t RTC_Time2TimeStamp(void);

void RTC_GetTime(void);
uint8_t RTC_GetWeek(uint16_t year, uint8_t month, uint8_t day);
void RTC_SetTime(rt_uint16_t syear, rt_uint8_t smon
    , rt_uint8_t sday, rt_uint8_t hour, rt_uint8_t min, rt_uint8_t sec);
void RTC_ShowTime(void);
int BSP_RTC_Init(void);
void Timestamp_To_Rtc_DateTime(time_t timestamp, TsRtcDateTime *rtc_dt);
#endif //!__BSP_RTC_H__
