71 lines
1.8 KiB
C
71 lines
1.8 KiB
C
|
|
#ifndef _RTC_H_
|
|||
|
|
#define _RTC_H_
|
|||
|
|
|
|||
|
|
#include "stdint.h"
|
|||
|
|
|
|||
|
|
/*RTC<54><43><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>*/
|
|||
|
|
#define RTC_SDA_INPUT GPIOB_ModeCfg(GPIO_Pin_8,GPIO_ModeIN_PU)
|
|||
|
|
#define RTC_SCL_INPUT GPIOB_ModeCfg(GPIO_Pin_9,GPIO_ModeIN_PU)
|
|||
|
|
#define RTC_SDA_OUTPUT GPIOB_ModeCfg(GPIO_Pin_8,GPIO_ModeOut_PP_20mA)
|
|||
|
|
#define RTC_SCL_OUTPUT GPIOB_ModeCfg(GPIO_Pin_9,GPIO_ModeOut_PP_20mA)
|
|||
|
|
#define RTC_SDA_H GPIOB_SetBits(GPIO_Pin_8)
|
|||
|
|
#define RTC_SCL_H GPIOB_SetBits(GPIO_Pin_9)
|
|||
|
|
#define RTC_SDA_L GPIOB_ResetBits(GPIO_Pin_8)
|
|||
|
|
#define RTC_SCL_L GPIOB_ResetBits(GPIO_Pin_9)
|
|||
|
|
#define RTC_SDA GPIOB_ReadPortPin(GPIO_Pin_8)
|
|||
|
|
#define RTC_SCL GPIOB_ReadPortPin(GPIO_Pin_9)
|
|||
|
|
|
|||
|
|
//RTC<54><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
|
#define RTC_Address 0x64
|
|||
|
|
|
|||
|
|
typedef struct{
|
|||
|
|
uint8_t second;
|
|||
|
|
uint8_t minute;
|
|||
|
|
uint8_t hour;
|
|||
|
|
uint8_t week;
|
|||
|
|
uint8_t day;
|
|||
|
|
uint8_t month;
|
|||
|
|
uint8_t year;
|
|||
|
|
}S_RTC;
|
|||
|
|
|
|||
|
|
typedef struct{
|
|||
|
|
uint32_t hour;
|
|||
|
|
uint16_t minute;
|
|||
|
|
uint16_t second;
|
|||
|
|
}G_CORE_RTC;
|
|||
|
|
|
|||
|
|
typedef struct{
|
|||
|
|
uint8_t time_select; //<2F><>ǰʱ<C7B0><CAB1>ѡ<EFBFBD><D1A1> 0x00:<3A><>ǰδѡ<CEB4><D1A1><EFBFBD><EFBFBD>0x01: ѡ<>ض<F1B1BEB5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x02:Ӳ<><D3B2>CSIO RTCʱ<43><CAB1>
|
|||
|
|
uint8_t csio_rtc_cnt; //CSIO RTCʱ<43>Ӽ<EFBFBD><D3BC><EFBFBD>
|
|||
|
|
|
|||
|
|
int16_t timezone; //ʱ<><CAB1>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
|||
|
|
uint32_t Mcu_GetTime_tick;
|
|||
|
|
}TIME_INFO_T;
|
|||
|
|
|
|||
|
|
#if (USE_CORE_TYPE == 1) //ʹ<><CAB9>C1F<31><46><EFBFBD>İ<EFBFBD> - ʹ<><CAB9>MCU RTC<54><43>ʱ
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
void RTC_Init(void);
|
|||
|
|
uint8_t RTC_ReadDate(S_RTC *psRTC);
|
|||
|
|
uint8_t RTC_WriteDate(S_RTC SetRTC);
|
|||
|
|
uint8_t RTC_DATA_Type_Cast_DEC(uint8_t data);
|
|||
|
|
void RTC_TASK(void);
|
|||
|
|
uint8_t RTC_TimeDate_Correct_Figure(uint8_t data);
|
|||
|
|
uint8_t HEX_Conversion_To_DEC(uint8_t c_num);
|
|||
|
|
uint8_t DEV_Conversion_To_HEX(uint8_t c_num);
|
|||
|
|
|
|||
|
|
uint32_t RTC_Conversion_To_Unix(S_RTC *rtc_time);
|
|||
|
|
void Unix_Conversion_To_RTC(S_RTC *rtc_time,uint32_t utc_tick);
|
|||
|
|
|
|||
|
|
extern S_RTC RTC_Raw_Data;
|
|||
|
|
extern S_RTC MCU_RTC_Data;
|
|||
|
|
extern S_RTC Net_RTC_Data;
|
|||
|
|
extern TIME_INFO_T g_time_info;
|
|||
|
|
|
|||
|
|
uint8_t NetRTC_WriteDate(S_RTC SetRTC);
|
|||
|
|
|
|||
|
|
#endif
|