12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef __RTC_H
- #define __RTC_H
- #include "at32f403a_407.h"
- #define TM_RTC_LEAP_YEAR(year) ((((year) % 4 == 0) && ((year) % 100 != 0)) || ((year) % 400 == 0))
- typedef struct
- {
- __IO uint8_t seconds;
- __IO uint16_t subseconds;
- __IO uint8_t minutes;
- __IO uint8_t hours;
- __IO uint8_t day;
- __IO uint8_t date;
- __IO uint8_t month;
- __IO uint8_t year;
- __IO uint32_t unix;
-
- } TM_RTC_t;
- typedef enum {
- TM_RTC_Result_Ok,
- TM_RTC_Result_Error
- } TM_RTC_Result_t;
- typedef enum {
- TM_RTC_Format_BIN = 0x00,
- TM_RTC_Format_BCD
- } TM_RTC_Format_t;
- uint8_t TM_RTC_Init(void);
- void TM_RTC_SetDataTimeUnix(uint32_t unixTime);
- TM_RTC_Result_t TM_RTC_SetDateTime(TM_RTC_t* data);
- TM_RTC_Result_t TM_RTC_SetDateTimeString(char* str);
- void TM_RTC_GetDateTime(TM_RTC_t* data, TM_RTC_Format_t format);
- uint32_t TM_RTC_GetUnixTimeStamp(TM_RTC_t* data);
- void TM_RTC_GetDateTimeFromUnix(TM_RTC_t* data, uint32_t unix);
- void TM_RTC_PrintTime(void);
- uint32_t RTC_GetUnixTime(void);
- #if 0
- void sntp_config(void);
- void lwip_time_sinhro(uint32_t utime);
- #endif
- #endif
|