SWM341_rtc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __SWM341_RTC_H__
  2. #define __SWM341_RTC_H__
  3. #define RTC_CLKSRC_LRC32K 0
  4. #define RTC_CLKSRC_XTAL32K 1
  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. typedef struct {
  13. uint8_t clksrc; //RTC_CLKSRC_RC32K、RTC_CLKSRC_XTAL32K
  14. uint16_t Year;
  15. uint8_t Month; //取值1--12
  16. uint8_t Date; //取值1--31
  17. uint8_t Hour; //取值0--23
  18. uint8_t Minute; //取值0--59
  19. uint8_t Second; //取值0--59
  20. uint8_t SecondIEn;
  21. uint8_t MinuteIEn;
  22. } RTC_InitStructure;
  23. typedef struct {
  24. uint8_t Days; //RTC_SUN、RTC_MON、RTC_TUE、RTC_WED、RTC_THU、RTC_FRI、RTC_SAT及其或运算组合
  25. uint8_t Hour;
  26. uint8_t Minute;
  27. uint8_t Second;
  28. uint8_t AlarmIEn;
  29. } RTC_AlarmStructure;
  30. typedef struct {
  31. uint16_t Year;
  32. uint8_t Month;
  33. uint8_t Date;
  34. uint8_t Day; //RTC_SUN、RTC_MON、RTC_TUE、RTC_WED、RTC_THU、RTC_FRI、RTC_SAT
  35. uint8_t Hour;
  36. uint8_t Minute;
  37. uint8_t Second;
  38. } RTC_DateTime;
  39. /* Interrupt Type */
  40. #define RTC_IT_SECOND (1 << 0) //Second Interrupt
  41. #define RTC_IT_MINUTE (1 << 1)
  42. #define RTC_IT_HOUR (1 << 2)
  43. #define RTC_IT_DATE (1 << 3)
  44. #define RTC_IT_ALARM (1 << 4)
  45. #define RTC_IT_SECOND_DIV2 (1 << 6) //1/2 Second Interrupt
  46. #define RTC_IT_SECOND_DIV4 (1 << 7) //1/4 Second Interrupt
  47. void RTC_Init(RTC_TypeDef * RTCx, RTC_InitStructure * initStruct);
  48. void RTC_Start(RTC_TypeDef * RTCx);
  49. void RTC_Stop(RTC_TypeDef * RTCx);
  50. void RTC_GetDateTime(RTC_TypeDef * RTCx, RTC_DateTime * dateTime);
  51. void RTC_AlarmSetup(RTC_TypeDef * RTCx, RTC_AlarmStructure * alarmStruct);
  52. void RTC_INTEn(RTC_TypeDef * RTCx, uint32_t it);
  53. void RTC_INTDis(RTC_TypeDef * RTCx, uint32_t it);
  54. void RTC_INTClr(RTC_TypeDef * RTCx, uint32_t it);
  55. uint32_t RTC_INTStat(RTC_TypeDef * RTCx, uint32_t it);
  56. #endif //__SWM341_RTC_H__