SWM320_rtc.h 1.7 KB

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