1 #ifndef __SWM320_RTC_H__ 2 #define __SWM320_RTC_H__ 3 4 5 #define RTC_SUN 0x01 6 #define RTC_MON 0x02 7 #define RTC_TUE 0x04 8 #define RTC_WED 0x08 9 #define RTC_THU 0x10 10 #define RTC_FRI 0x20 11 #define RTC_SAT 0x40 12 13 14 typedef struct { 15 uint16_t Year; 16 uint8_t Month; //取值1--12 17 uint8_t Date; //取值1--31 18 uint8_t Hour; //取值0--23 19 uint8_t Minute; //取值0--59 20 uint8_t Second; //取值0--59 21 uint8_t SecondIEn; 22 uint8_t MinuteIEn; 23 } RTC_InitStructure; 24 25 typedef struct { 26 uint8_t Days; //RTC_SUN、RTC_MON、RTC_TUE、RTC_WED、RTC_THU、RTC_FRI、RTC_SAT及其或运算组合 27 uint8_t Hour; 28 uint8_t Minute; 29 uint8_t Second; 30 uint8_t AlarmIEn; 31 } RTC_AlarmStructure; 32 33 typedef struct { 34 uint16_t Year; 35 uint8_t Month; 36 uint8_t Date; 37 uint8_t Day; //RTC_SUN、RTC_MON、RTC_TUE、RTC_WED、RTC_THU、RTC_FRI、RTC_SAT 38 uint8_t Hour; 39 uint8_t Minute; 40 uint8_t Second; 41 } RTC_DateTime; 42 43 44 /* Interrupt Type */ 45 #define RTC_IT_SECOND (1 << 0) //Second Interrupt 46 #define RTC_IT_MINUTE (1 << 1) 47 #define RTC_IT_HOUR (1 << 2) 48 #define RTC_IT_DATE (1 << 3) 49 #define RTC_IT_ALARM (1 << 4) 50 51 52 void RTC_Init(RTC_TypeDef * RTCx, RTC_InitStructure * initStruct); 53 void RTC_Start(RTC_TypeDef * RTCx); 54 void RTC_Stop(RTC_TypeDef * RTCx); 55 56 void RTC_GetDateTime(RTC_TypeDef * RTCx, RTC_DateTime * dateTime); 57 58 void RTC_AlarmSetup(RTC_TypeDef * RTCx, RTC_AlarmStructure * alarmStruct); 59 60 61 void RTC_INTEn(RTC_TypeDef * RTCx, uint32_t it); 62 void RTC_INTDis(RTC_TypeDef * RTCx, uint32_t it); 63 void RTC_INTClr(RTC_TypeDef * RTCx, uint32_t it); 64 uint32_t RTC_INTStat(RTC_TypeDef * RTCx, uint32_t it); 65 66 #endif //__SWM320_RTC_H__ 67