你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】STM32 RTC相关函数和类型

[复制链接]
STMCU小助手 发布时间:2022-6-14 14:01
01. 概述
RTC相关函数和类型主要在stm32f4xx_rtc.h和stm32f4xx_rtc.c文件中。

02. 相关类型
  1. /**
  2.   * @brief  RTC Init structures definition  
  3.   */
  4. typedef struct
  5. {
  6.   uint32_t RTC_HourFormat;   /*!< Specifies the RTC Hour Format.
  7.                              This parameter can be a value of @ref RTC_Hour_Formats */

  8.   uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  9.                              This parameter must be set to a value lower than 0x7F */

  10.   uint32_t RTC_SynchPrediv;  /*!< Specifies the RTC Synchronous Predivider value.
  11.                              This parameter must be set to a value lower than 0x7FFF */
  12. }RTC_InitTypeDef;

  13. /**
  14.   * @brief  RTC Time structure definition  
  15.   */
  16. typedef struct
  17. {
  18.   uint8_t RTC_Hours;    /*!< Specifies the RTC Time Hour.
  19.                         This parameter must be set to a value in the 0-12 range
  20.                         if the RTC_HourFormat_12 is selected or 0-23 range if
  21.                         the RTC_HourFormat_24 is selected. */

  22.   uint8_t RTC_Minutes;  /*!< Specifies the RTC Time Minutes.
  23.                         This parameter must be set to a value in the 0-59 range. */

  24.   uint8_t RTC_Seconds;  /*!< Specifies the RTC Time Seconds.
  25.                         This parameter must be set to a value in the 0-59 range. */

  26.   uint8_t RTC_H12;      /*!< Specifies the RTC AM/PM Time.
  27.                         This parameter can be a value of @ref RTC_AM_PM_Definitions */
  28. }RTC_TimeTypeDef;

  29. /**
  30.   * @brief  RTC Date structure definition  
  31.   */
  32. typedef struct
  33. {
  34.   uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.
  35.                         This parameter can be a value of @ref RTC_WeekDay_Definitions */

  36.   uint8_t RTC_Month;   /*!< Specifies the RTC Date Month (in BCD format).
  37.                         This parameter can be a value of @ref RTC_Month_Date_Definitions */

  38.   uint8_t RTC_Date;     /*!< Specifies the RTC Date.
  39.                         This parameter must be set to a value in the 1-31 range. */

  40.   uint8_t RTC_Year;     /*!< Specifies the RTC Date Year.
  41.                         This parameter must be set to a value in the 0-99 range. */
  42. }RTC_DateTypeDef;

  43. /**
  44.   * @brief  RTC Alarm structure definition  
  45.   */
  46. typedef struct
  47. {
  48.   RTC_TimeTypeDef RTC_AlarmTime;     /*!< Specifies the RTC Alarm Time members. */

  49.   uint32_t RTC_AlarmMask;            /*!< Specifies the RTC Alarm Masks.
  50.                                      This parameter can be a value of @ref RTC_AlarmMask_Definitions */

  51.   uint32_t RTC_AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.
  52.                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */

  53.   uint8_t RTC_AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.
  54.                                      If the Alarm Date is selected, this parameter
  55.                                      must be set to a value in the 1-31 range.
  56.                                      If the Alarm WeekDay is selected, this
  57.                                      parameter can be a value of @ref RTC_WeekDay_Definitions */
  58. }RTC_AlarmTypeDef;

  59. /* Exported constants --------------------------------------------------------*/

  60. /** @defgroup RTC_Exported_Constants
  61.   * @{
  62.   */


  63. /** @defgroup RTC_Hour_Formats
  64.   * @{
  65.   */
  66. #define RTC_HourFormat_24              ((uint32_t)0x00000000)
  67. #define RTC_HourFormat_12              ((uint32_t)0x00000040)
  68. #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HourFormat_12) || \
  69.                                         ((FORMAT) == RTC_HourFormat_24))
  70. /**
  71.   * @}
  72.   */

  73. /** @defgroup RTC_Asynchronous_Predivider
  74.   * @{
  75.   */
  76. #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= 0x7F)

  77. /**
  78.   * @}
  79.   */


  80. /** @defgroup RTC_Synchronous_Predivider
  81.   * @{
  82.   */
  83. #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= 0x7FFF)

  84. /**
  85.   * @}
  86.   */

  87. /** @defgroup RTC_Time_Definitions
  88.   * @{
  89.   */
  90. #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0) && ((HOUR) <= 12))
  91. #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23)
  92. #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59)
  93. #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59)

  94. /**
  95.   * @}
  96.   */

  97. /** @defgroup RTC_AM_PM_Definitions
  98.   * @{
  99.   */
  100. #define RTC_H12_AM                     ((uint8_t)0x00)
  101. #define RTC_H12_PM                     ((uint8_t)0x40)
  102. #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))

  103. /**
  104.   * @}
  105.   */

  106. /** @defgroup RTC_Year_Date_Definitions
  107.   * @{
  108.   */
  109. #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99)

  110. /**
  111.   * @}
  112.   */

  113. /** @defgroup RTC_Month_Date_Definitions
  114.   * @{
  115.   */

  116. /* Coded in BCD format */
  117. #define RTC_Month_January              ((uint8_t)0x01)
  118. #define RTC_Month_February             ((uint8_t)0x02)
  119. #define RTC_Month_March                ((uint8_t)0x03)
  120. #define RTC_Month_April                ((uint8_t)0x04)
  121. #define RTC_Month_May                  ((uint8_t)0x05)
  122. #define RTC_Month_June                 ((uint8_t)0x06)
  123. #define RTC_Month_July                 ((uint8_t)0x07)
  124. #define RTC_Month_August               ((uint8_t)0x08)
  125. #define RTC_Month_September            ((uint8_t)0x09)
  126. #define RTC_Month_October              ((uint8_t)0x10)
  127. #define RTC_Month_November             ((uint8_t)0x11)
  128. #define RTC_Month_December             ((uint8_t)0x12)
  129. #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1) && ((MONTH) <= 12))
  130. #define IS_RTC_DATE(DATE)              (((DATE) >= 1) && ((DATE) <= 31))

  131. /**
  132.   * @}
  133.   */

  134. /** @defgroup RTC_WeekDay_Definitions
  135.   * @{
  136.   */

  137. #define RTC_Weekday_Monday             ((uint8_t)0x01)
  138. #define RTC_Weekday_Tuesday            ((uint8_t)0x02)
  139. #define RTC_Weekday_Wednesday          ((uint8_t)0x03)
  140. #define RTC_Weekday_Thursday           ((uint8_t)0x04)
  141. #define RTC_Weekday_Friday             ((uint8_t)0x05)
  142. #define RTC_Weekday_Saturday           ((uint8_t)0x06)
  143. #define RTC_Weekday_Sunday             ((uint8_t)0x07)
  144. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
  145.                                  ((WEEKDAY) == RTC_Weekday_Tuesday) || \
  146.                                  ((WEEKDAY) == RTC_Weekday_Wednesday) || \
  147.                                  ((WEEKDAY) == RTC_Weekday_Thursday) || \
  148.                                  ((WEEKDAY) == RTC_Weekday_Friday) || \
  149.                                  ((WEEKDAY) == RTC_Weekday_Saturday) || \
  150.                                  ((WEEKDAY) == RTC_Weekday_Sunday))
  151. /**
  152.   * @}
  153.   */


  154. /** @defgroup RTC_Alarm_Definitions
  155.   * @{
  156.   */
  157. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
  158. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
  159.                                                     ((WEEKDAY) == RTC_Weekday_Tuesday) || \
  160.                                                     ((WEEKDAY) == RTC_Weekday_Wednesday) || \
  161.                                                     ((WEEKDAY) == RTC_Weekday_Thursday) || \
  162.                                                     ((WEEKDAY) == RTC_Weekday_Friday) || \
  163.                                                     ((WEEKDAY) == RTC_Weekday_Saturday) || \
  164.                                                     ((WEEKDAY) == RTC_Weekday_Sunday))

  165. /**
  166.   * @}
  167.   */


  168. /** @defgroup RTC_AlarmDateWeekDay_Definitions
  169.   * @{
  170.   */
  171. #define RTC_AlarmDateWeekDaySel_Date      ((uint32_t)0x00000000)
  172. #define RTC_AlarmDateWeekDaySel_WeekDay   ((uint32_t)0x40000000)

  173. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
  174.                                             ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))

  175. /**
  176.   * @}
  177.   */


  178. /** @defgroup RTC_AlarmMask_Definitions
  179.   * @{
  180.   */
  181. #define RTC_AlarmMask_None                ((uint32_t)0x00000000)
  182. #define RTC_AlarmMask_DateWeekDay         ((uint32_t)0x80000000)
  183. #define RTC_AlarmMask_Hours               ((uint32_t)0x00800000)
  184. #define RTC_AlarmMask_Minutes             ((uint32_t)0x00008000)
  185. #define RTC_AlarmMask_Seconds             ((uint32_t)0x00000080)
  186. #define RTC_AlarmMask_All                 ((uint32_t)0x80808080)
  187. #define IS_ALARM_MASK(MASK)  (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)

  188. /**
  189.   * @}
  190.   */

  191. /** @defgroup RTC_Alarms_Definitions
  192.   * @{
  193.   */
  194. #define RTC_Alarm_A                       ((uint32_t)0x00000100)
  195. #define RTC_Alarm_B                       ((uint32_t)0x00000200)
  196. #define IS_RTC_ALARM(ALARM)     (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
  197. #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)

  198. /**
  199.   * @}
  200.   */

  201.   /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions
  202.   * @{
  203.   */
  204. #define RTC_AlarmSubSecondMask_All         ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
  205.                                                                        There is no comparison on sub seconds
  206.                                                                        for Alarm */
  207. #define RTC_AlarmSubSecondMask_SS14_1      ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
  208.                                                                        comparison. Only SS[0] is compared. */
  209. #define RTC_AlarmSubSecondMask_SS14_2      ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
  210.                                                                        comparison. Only SS[1:0] are compared */
  211. #define RTC_AlarmSubSecondMask_SS14_3      ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm
  212.                                                                        comparison. Only SS[2:0] are compared */
  213. #define RTC_AlarmSubSecondMask_SS14_4      ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm
  214.                                                                        comparison. Only SS[3:0] are compared */
  215. #define RTC_AlarmSubSecondMask_SS14_5      ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm
  216.                                                                        comparison. Only SS[4:0] are compared */
  217. #define RTC_AlarmSubSecondMask_SS14_6      ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm
  218.                                                                        comparison. Only SS[5:0] are compared */
  219. #define RTC_AlarmSubSecondMask_SS14_7      ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
  220.                                                                        comparison. Only SS[6:0] are compared */
  221. #define RTC_AlarmSubSecondMask_SS14_8      ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm
  222.                                                                        comparison. Only SS[7:0] are compared */
  223. #define RTC_AlarmSubSecondMask_SS14_9      ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm
  224.                                                                        comparison. Only SS[8:0] are compared */
  225. #define RTC_AlarmSubSecondMask_SS14_10     ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
  226.                                                                        comparison. Only SS[9:0] are compared */
  227. #define RTC_AlarmSubSecondMask_SS14_11     ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm
  228.                                                                        comparison. Only SS[10:0] are compared */
  229. #define RTC_AlarmSubSecondMask_SS14_12     ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm
  230.                                                                        comparison.Only SS[11:0] are compared */
  231. #define RTC_AlarmSubSecondMask_SS14_13     ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
  232.                                                                        comparison. Only SS[12:0] are compared */
  233. #define RTC_AlarmSubSecondMask_SS14        ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
  234.                                                                        comparison.Only SS[13:0] are compared */
  235. #define RTC_AlarmSubSecondMask_None        ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match
  236.                                                                        to activate alarm. */
  237. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)   (((MASK) == RTC_AlarmSubSecondMask_All) || \
  238.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \
  239.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \
  240.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \
  241.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \
  242.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \
  243.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \
  244.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \
  245.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \
  246.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \
  247.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \
  248.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \
  249.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \
  250.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \
  251.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14) || \
  252.                                               ((MASK) == RTC_AlarmSubSecondMask_None))
  253. /**
  254.   * @}
  255.   */

  256. /** @defgroup RTC_Alarm_Sub_Seconds_Value
  257.   * @{
  258.   */

  259. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF)

  260. /**
  261.   * @}
  262.   */

  263. /** @defgroup RTC_Wakeup_Timer_Definitions
  264.   * @{
  265.   */
  266. #define RTC_WakeUpClock_RTCCLK_Div16        ((uint32_t)0x00000000)
  267. #define RTC_WakeUpClock_RTCCLK_Div8         ((uint32_t)0x00000001)
  268. #define RTC_WakeUpClock_RTCCLK_Div4         ((uint32_t)0x00000002)
  269. #define RTC_WakeUpClock_RTCCLK_Div2         ((uint32_t)0x00000003)
  270. #define RTC_WakeUpClock_CK_SPRE_16bits      ((uint32_t)0x00000004)
  271. #define RTC_WakeUpClock_CK_SPRE_17bits      ((uint32_t)0x00000006)
  272. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
  273.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
  274.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \
  275.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
  276.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
  277.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
  278. #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFF)
  279. /**
  280.   * @}
  281.   */

  282. /** @defgroup RTC_Time_Stamp_Edges_definitions
  283.   * @{
  284.   */
  285. #define RTC_TimeStampEdge_Rising          ((uint32_t)0x00000000)
  286. #define RTC_TimeStampEdge_Falling         ((uint32_t)0x00000008)
  287. #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
  288.                                      ((EDGE) == RTC_TimeStampEdge_Falling))
  289. /**
  290.   * @}
  291.   */

  292. /** @defgroup RTC_Output_selection_Definitions
  293.   * @{
  294.   */
  295. #define RTC_Output_Disable             ((uint32_t)0x00000000)
  296. #define RTC_Output_AlarmA              ((uint32_t)0x00200000)
  297. #define RTC_Output_AlarmB              ((uint32_t)0x00400000)
  298. #define RTC_Output_WakeUp              ((uint32_t)0x00600000)

  299. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \
  300.                                ((OUTPUT) == RTC_Output_AlarmA) || \
  301.                                ((OUTPUT) == RTC_Output_AlarmB) || \
  302.                                ((OUTPUT) == RTC_Output_WakeUp))

  303. /**
  304.   * @}
  305.   */

  306. /** @defgroup RTC_Output_Polarity_Definitions
  307.   * @{
  308.   */
  309. #define RTC_OutputPolarity_High           ((uint32_t)0x00000000)
  310. #define RTC_OutputPolarity_Low            ((uint32_t)0x00100000)
  311. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \
  312.                                 ((POL) == RTC_OutputPolarity_Low))
  313. /**
  314.   * @}
  315.   */


  316. /** @defgroup RTC_Digital_Calibration_Definitions
  317.   * @{
  318.   */
  319. #define RTC_CalibSign_Positive            ((uint32_t)0x00000000)
  320. #define RTC_CalibSign_Negative            ((uint32_t)0x00000080)
  321. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
  322.                                  ((SIGN) == RTC_CalibSign_Negative))
  323. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)

  324. /**
  325.   * @}
  326.   */

  327. /** @defgroup RTC_Calib_Output_selection_Definitions
  328.   * @{
  329.   */
  330. #define RTC_CalibOutput_512Hz            ((uint32_t)0x00000000)
  331. #define RTC_CalibOutput_1Hz              ((uint32_t)0x00080000)
  332. #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CalibOutput_512Hz) || \
  333.                                       ((OUTPUT) == RTC_CalibOutput_1Hz))
  334. /**
  335.   * @}
  336.   */

  337. /** @defgroup RTC_Smooth_calib_period_Definitions
  338.   * @{
  339.   */
  340. #define RTC_SmoothCalibPeriod_32sec   ((uint32_t)0x00000000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
  341.                                                              period is 32s,  else 2exp20 RTCCLK seconds */
  342. #define RTC_SmoothCalibPeriod_16sec   ((uint32_t)0x00002000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
  343.                                                              period is 16s, else 2exp19 RTCCLK seconds */
  344. #define RTC_SmoothCalibPeriod_8sec    ((uint32_t)0x00004000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
  345.                                                              period is 8s, else 2exp18 RTCCLK seconds */
  346. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \
  347.                                              ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \
  348.                                              ((PERIOD) == RTC_SmoothCalibPeriod_8sec))

  349. /**
  350.   * @}
  351.   */

  352. /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions
  353.   * @{
  354.   */
  355. #define RTC_SmoothCalibPlusPulses_Set    ((uint32_t)0x00008000) /*!<  The number of RTCCLK pulses added  
  356.                                                                 during a X -second window = Y - CALM[8:0].
  357.                                                                  with Y = 512, 256, 128 when X = 32, 16, 8 */
  358. #define RTC_SmoothCalibPlusPulses_Reset  ((uint32_t)0x00000000) /*!<  The number of RTCCLK pulses subbstited
  359.                                                                  during a 32-second window =   CALM[8:0]. */
  360. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \
  361.                                          ((PLUS) == RTC_SmoothCalibPlusPulses_Reset))

  362. /**
  363.   * @}
  364.   */

  365. /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions
  366.   * @{
  367.   */
  368. #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)

  369. /**
  370.   * @}
  371.   */

  372. /** @defgroup RTC_DayLightSaving_Definitions
  373.   * @{
  374.   */
  375. #define RTC_DayLightSaving_SUB1H   ((uint32_t)0x00020000)
  376. #define RTC_DayLightSaving_ADD1H   ((uint32_t)0x00010000)
  377. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
  378.                                       ((SAVE) == RTC_DayLightSaving_ADD1H))

  379. #define RTC_StoreOperation_Reset        ((uint32_t)0x00000000)
  380. #define RTC_StoreOperation_Set          ((uint32_t)0x00040000)
  381. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \
  382.                                            ((OPERATION) == RTC_StoreOperation_Set))
  383. /**
  384.   * @}
  385.   */

  386. /** @defgroup RTC_Tamper_Trigger_Definitions
  387.   * @{
  388.   */
  389. #define RTC_TamperTrigger_RisingEdge            ((uint32_t)0x00000000)
  390. #define RTC_TamperTrigger_FallingEdge           ((uint32_t)0x00000001)
  391. #define RTC_TamperTrigger_LowLevel              ((uint32_t)0x00000000)
  392. #define RTC_TamperTrigger_HighLevel             ((uint32_t)0x00000001)
  393. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \
  394.                                         ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \
  395.                                         ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \
  396.                                         ((TRIGGER) == RTC_TamperTrigger_HighLevel))

  397. /**
  398.   * @}
  399.   */

  400. /** @defgroup RTC_Tamper_Filter_Definitions
  401.   * @{
  402.   */
  403. #define RTC_TamperFilter_Disable   ((uint32_t)0x00000000) /*!< Tamper filter is disabled */

  404. #define RTC_TamperFilter_2Sample   ((uint32_t)0x00000800) /*!< Tamper is activated after 2
  405.                                                           consecutive samples at the active level */
  406. #define RTC_TamperFilter_4Sample   ((uint32_t)0x00001000) /*!< Tamper is activated after 4
  407.                                                           consecutive samples at the active level */
  408. #define RTC_TamperFilter_8Sample   ((uint32_t)0x00001800) /*!< Tamper is activated after 8
  409.                                                           consecutive samples at the active leve. */
  410. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \
  411.                                       ((FILTER) == RTC_TamperFilter_2Sample) || \
  412.                                       ((FILTER) == RTC_TamperFilter_4Sample) || \
  413.                                       ((FILTER) == RTC_TamperFilter_8Sample))
  414. /**
  415.   * @}
  416.   */

  417. /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions
  418.   * @{
  419.   */
  420. #define RTC_TamperSamplingFreq_RTCCLK_Div32768  ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled
  421.                                                                            with a frequency =  RTCCLK / 32768 */
  422. #define RTC_TamperSamplingFreq_RTCCLK_Div16384  ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled
  423.                                                                             with a frequency =  RTCCLK / 16384 */
  424. #define RTC_TamperSamplingFreq_RTCCLK_Div8192   ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled
  425.                                                                            with a frequency =  RTCCLK / 8192  */
  426. #define RTC_TamperSamplingFreq_RTCCLK_Div4096   ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled
  427.                                                                            with a frequency =  RTCCLK / 4096  */
  428. #define RTC_TamperSamplingFreq_RTCCLK_Div2048   ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled
  429.                                                                            with a frequency =  RTCCLK / 2048  */
  430. #define RTC_TamperSamplingFreq_RTCCLK_Div1024   ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled
  431.                                                                            with a frequency =  RTCCLK / 1024  */
  432. #define RTC_TamperSamplingFreq_RTCCLK_Div512    ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
  433.                                                                            with a frequency =  RTCCLK / 512   */
  434. #define RTC_TamperSamplingFreq_RTCCLK_Div256    ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
  435.                                                                            with a frequency =  RTCCLK / 256   */
  436. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \
  437.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \
  438.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \
  439.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \
  440.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \
  441.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \
  442.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \
  443.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256))

  444. /**
  445.   * @}
  446.   */

  447.   /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions
  448.   * @{
  449.   */
  450. #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before
  451.                                                                          sampling during 1 RTCCLK cycle */
  452. #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000)  /*!< Tamper pins are pre-charged before
  453.                                                                          sampling during 2 RTCCLK cycles */
  454. #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000)  /*!< Tamper pins are pre-charged before
  455.                                                                          sampling during 4 RTCCLK cycles */
  456. #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000)  /*!< Tamper pins are pre-charged before
  457.                                                                          sampling during 8 RTCCLK cycles */

  458. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \
  459.                                                     ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \
  460.                                                     ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \
  461.                                                     ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK))
  462. /**
  463.   * @}
  464.   */

  465. /** @defgroup RTC_Tamper_Pins_Definitions
  466.   * @{
  467.   */
  468. #define RTC_Tamper_1                    RTC_TAFCR_TAMP1E
  469. #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))

  470. /**
  471.   * @}
  472.   */

  473. /** @defgroup RTC_Tamper_Pin_Selection
  474.   * @{
  475.   */
  476. #define RTC_TamperPin_PC13                 ((uint32_t)0x00000000)
  477. #define RTC_TamperPin_PI8                  ((uint32_t)0x00010000)
  478. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \
  479.                                 ((PIN) == RTC_TamperPin_PI8))
  480. /**
  481.   * @}
  482.   */

  483. /** @defgroup RTC_TimeStamp_Pin_Selection
  484.   * @{
  485.   */
  486. #define RTC_TimeStampPin_PC13              ((uint32_t)0x00000000)
  487. #define RTC_TimeStampPin_PI8               ((uint32_t)0x00020000)
  488. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
  489.                                    ((PIN) == RTC_TimeStampPin_PI8))
  490. /**
  491.   * @}
  492.   */

  493. /** @defgroup RTC_Output_Type_ALARM_OUT
  494.   * @{
  495.   */
  496. #define RTC_OutputType_OpenDrain           ((uint32_t)0x00000000)
  497. #define RTC_OutputType_PushPull            ((uint32_t)0x00040000)
  498. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \
  499.                                   ((TYPE) == RTC_OutputType_PushPull))

  500. /**
  501.   * @}
  502.   */

  503. /** @defgroup RTC_Add_1_Second_Parameter_Definitions
  504.   * @{
  505.   */
  506. #define RTC_ShiftAdd1S_Reset      ((uint32_t)0x00000000)
  507. #define RTC_ShiftAdd1S_Set        ((uint32_t)0x80000000)
  508. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \
  509.                                  ((SEL) == RTC_ShiftAdd1S_Set))
  510. /**
  511.   * @}
  512.   */

  513. /** @defgroup RTC_Substract_Fraction_Of_Second_Value
  514.   * @{
  515.   */
  516. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)

  517. /**
  518.   * @}
  519.   */

  520. /** @defgroup RTC_Backup_Registers_Definitions
  521.   * @{
  522.   */

  523. #define RTC_BKP_DR0                       ((uint32_t)0x00000000)
  524. #define RTC_BKP_DR1                       ((uint32_t)0x00000001)
  525. #define RTC_BKP_DR2                       ((uint32_t)0x00000002)
  526. #define RTC_BKP_DR3                       ((uint32_t)0x00000003)
  527. #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
  528. #define RTC_BKP_DR5                       ((uint32_t)0x00000005)
  529. #define RTC_BKP_DR6                       ((uint32_t)0x00000006)
  530. #define RTC_BKP_DR7                       ((uint32_t)0x00000007)
  531. #define RTC_BKP_DR8                       ((uint32_t)0x00000008)
  532. #define RTC_BKP_DR9                       ((uint32_t)0x00000009)
  533. #define RTC_BKP_DR10                      ((uint32_t)0x0000000A)
  534. #define RTC_BKP_DR11                      ((uint32_t)0x0000000B)
  535. #define RTC_BKP_DR12                      ((uint32_t)0x0000000C)
  536. #define RTC_BKP_DR13                      ((uint32_t)0x0000000D)
  537. #define RTC_BKP_DR14                      ((uint32_t)0x0000000E)
  538. #define RTC_BKP_DR15                      ((uint32_t)0x0000000F)
  539. #define RTC_BKP_DR16                      ((uint32_t)0x00000010)
  540. #define RTC_BKP_DR17                      ((uint32_t)0x00000011)
  541. #define RTC_BKP_DR18                      ((uint32_t)0x00000012)
  542. #define RTC_BKP_DR19                      ((uint32_t)0x00000013)
  543. #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0) || \
  544.                                            ((BKP) == RTC_BKP_DR1) || \
  545.                                            ((BKP) == RTC_BKP_DR2) || \
  546.                                            ((BKP) == RTC_BKP_DR3) || \
  547.                                            ((BKP) == RTC_BKP_DR4) || \
  548.                                            ((BKP) == RTC_BKP_DR5) || \
  549.                                            ((BKP) == RTC_BKP_DR6) || \
  550.                                            ((BKP) == RTC_BKP_DR7) || \
  551.                                            ((BKP) == RTC_BKP_DR8) || \
  552.                                            ((BKP) == RTC_BKP_DR9) || \
  553.                                            ((BKP) == RTC_BKP_DR10) || \
  554.                                            ((BKP) == RTC_BKP_DR11) || \
  555.                                            ((BKP) == RTC_BKP_DR12) || \
  556.                                            ((BKP) == RTC_BKP_DR13) || \
  557.                                            ((BKP) == RTC_BKP_DR14) || \
  558.                                            ((BKP) == RTC_BKP_DR15) || \
  559.                                            ((BKP) == RTC_BKP_DR16) || \
  560.                                            ((BKP) == RTC_BKP_DR17) || \
  561.                                            ((BKP) == RTC_BKP_DR18) || \
  562.                                            ((BKP) == RTC_BKP_DR19))
  563. /**
  564.   * @}
  565.   */

  566. /** @defgroup RTC_Input_parameter_format_definitions
  567.   * @{
  568.   */
  569. #define RTC_Format_BIN                    ((uint32_t)0x000000000)
  570. #define RTC_Format_BCD                    ((uint32_t)0x000000001)
  571. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))

  572. /**
  573.   * @}
  574.   */

  575. /** @defgroup RTC_Flags_Definitions
  576.   * @{
  577.   */
  578. #define RTC_FLAG_RECALPF                  ((uint32_t)0x00010000)
  579. #define RTC_FLAG_TAMP1F                   ((uint32_t)0x00002000)
  580. #define RTC_FLAG_TSOVF                    ((uint32_t)0x00001000)
  581. #define RTC_FLAG_TSF                      ((uint32_t)0x00000800)
  582. #define RTC_FLAG_WUTF                     ((uint32_t)0x00000400)
  583. #define RTC_FLAG_ALRBF                    ((uint32_t)0x00000200)
  584. #define RTC_FLAG_ALRAF                    ((uint32_t)0x00000100)
  585. #define RTC_FLAG_INITF                    ((uint32_t)0x00000040)
  586. #define RTC_FLAG_RSF                      ((uint32_t)0x00000020)
  587. #define RTC_FLAG_INITS                    ((uint32_t)0x00000010)
  588. #define RTC_FLAG_SHPF                     ((uint32_t)0x00000008)
  589. #define RTC_FLAG_WUTWF                    ((uint32_t)0x00000004)
  590. #define RTC_FLAG_ALRBWF                   ((uint32_t)0x00000002)
  591. #define RTC_FLAG_ALRAWF                   ((uint32_t)0x00000001)
  592. #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \
  593.                                ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \
  594.                                ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
  595.                                ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \
  596.                                ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \
  597.                                ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_RECALPF) || \
  598.                                 ((FLAG) == RTC_FLAG_SHPF))
  599. #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET))
  600. /**
  601.   * @}
  602.   */

  603. /** @defgroup RTC_Interrupts_Definitions
  604.   * @{
  605.   */
  606. #define RTC_IT_TS                         ((uint32_t)0x00008000)
  607. #define RTC_IT_WUT                        ((uint32_t)0x00004000)
  608. #define RTC_IT_ALRB                       ((uint32_t)0x00002000)
  609. #define RTC_IT_ALRA                       ((uint32_t)0x00001000)
  610. #define RTC_IT_TAMP                       ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */
  611. #define RTC_IT_TAMP1                      ((uint32_t)0x00020000)

  612. #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))
  613. #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \
  614.                            ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \
  615.                            ((IT) == RTC_IT_TAMP1))
  616. #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))

  617. /**
  618.   * @}
  619.   */

  620. /** @defgroup RTC_Legacy
  621.   * @{
  622.   */
  623. #define RTC_DigitalCalibConfig  RTC_CoarseCalibConfig
  624. #define RTC_DigitalCalibCmd     RTC_CoarseCalibCmd
复制代码

03. 相关函数
  1. /*  Function used to set the RTC configuration to the default reset state *****/
  2. ErrorStatus RTC_DeInit(void);

  3. /* Initialization and Configuration functions *********************************/
  4. ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);
  5. void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);
  6. void RTC_WriteProtectionCmd(FunctionalState NewState);
  7. ErrorStatus RTC_EnterInitMode(void);
  8. void RTC_ExitInitMode(void);
  9. ErrorStatus RTC_WaitForSynchro(void);
  10. ErrorStatus RTC_RefClockCmd(FunctionalState NewState);
  11. void RTC_BypassShadowCmd(FunctionalState NewState);

  12. /* Time and Date configuration functions **************************************/
  13. ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
  14. void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);
  15. void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
  16. uint32_t RTC_GetSubSecond(void);
  17. ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
  18. void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);
  19. void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);

  20. /* Alarms (Alarm A and Alarm B) configuration functions  **********************/
  21. void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
  22. void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);
  23. void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
  24. ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);
  25. void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask);
  26. uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm);

  27. /* WakeUp Timer configuration functions ***************************************/
  28. void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);
  29. void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);
  30. uint32_t RTC_GetWakeUpCounter(void);
  31. ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);

  32. /* Daylight Saving configuration functions ************************************/
  33. void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);
  34. uint32_t RTC_GetStoreOperation(void);

  35. /* Output pin Configuration function ******************************************/
  36. void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);

  37. /* Digital Calibration configuration functions *********************************/
  38. ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);
  39. ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);
  40. void RTC_CalibOutputCmd(FunctionalState NewState);
  41. void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput);
  42. ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
  43.                                   uint32_t RTC_SmoothCalibPlusPulses,
  44.                                   uint32_t RTC_SmouthCalibMinusPulsesValue);

  45. /* TimeStamp configuration functions ******************************************/
  46. void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);
  47. void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,
  48.                                       RTC_DateTypeDef* RTC_StampDateStruct);
  49. uint32_t RTC_GetTimeStampSubSecond(void);

  50. /* Tampers configuration functions ********************************************/
  51. void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);
  52. void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);
  53. void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter);
  54. void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq);
  55. void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration);
  56. void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState);
  57. void RTC_TamperPullUpCmd(FunctionalState NewState);

  58. /* Backup Data Registers configuration functions ******************************/
  59. void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
  60. uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);

  61. /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration
  62.    functions ******************************************************************/
  63. void RTC_TamperPinSelection(uint32_t RTC_TamperPin);
  64. void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);
  65. void RTC_OutputTypeConfig(uint32_t RTC_OutputType);

  66. /* RTC_Shift_control_synchonisation_functions *********************************/
  67. ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS);

  68. /* Interrupts and flags management functions **********************************/
  69. void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);
  70. FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);
  71. void RTC_ClearFlag(uint32_t RTC_FLAG);
  72. ITStatus RTC_GetITStatus(uint32_t RTC_IT);
  73. void RTC_ClearITPendingBit(uint32_t RTC_IT);
复制代码

04. 结构体封装
  1. /**
  2.   * @brief Real-Time Clock
  3.   */

  4. typedef struct
  5. {
  6.   __IO uint32_t TR;      /*!< RTC time register,                                        Address offset: 0x00 */
  7.   __IO uint32_t DR;      /*!< RTC date register,                                        Address offset: 0x04 */
  8.   __IO uint32_t CR;      /*!< RTC control register,                                     Address offset: 0x08 */
  9.   __IO uint32_t ISR;     /*!< RTC initialization and status register,                   Address offset: 0x0C */
  10.   __IO uint32_t PRER;    /*!< RTC prescaler register,                                   Address offset: 0x10 */
  11.   __IO uint32_t WUTR;    /*!< RTC wakeup timer register,                                Address offset: 0x14 */
  12.   __IO uint32_t CALIBR;  /*!< RTC calibration register,                                 Address offset: 0x18 */
  13.   __IO uint32_t ALRMAR;  /*!< RTC alarm A register,                                     Address offset: 0x1C */
  14.   __IO uint32_t ALRMBR;  /*!< RTC alarm B register,                                     Address offset: 0x20 */
  15.   __IO uint32_t WPR;     /*!< RTC write protection register,                            Address offset: 0x24 */
  16.   __IO uint32_t SSR;     /*!< RTC sub second register,                                  Address offset: 0x28 */
  17.   __IO uint32_t SHIFTR;  /*!< RTC shift control register,                               Address offset: 0x2C */
  18.   __IO uint32_t TSTR;    /*!< RTC time stamp time register,                             Address offset: 0x30 */
  19.   __IO uint32_t TSDR;    /*!< RTC time stamp date register,                             Address offset: 0x34 */
  20.   __IO uint32_t TSSSR;   /*!< RTC time-stamp sub second register,                       Address offset: 0x38 */
  21.   __IO uint32_t CALR;    /*!< RTC calibration register,                                 Address offset: 0x3C */
  22.   __IO uint32_t TAFCR;   /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */
  23.   __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register,                          Address offset: 0x44 */
  24.   __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register,                          Address offset: 0x48 */
  25.   uint32_t RESERVED7;    /*!< Reserved, 0x4C                                                                 */
  26.   __IO uint32_t BKP0R;   /*!< RTC backup register 1,                                    Address offset: 0x50 */
  27.   __IO uint32_t BKP1R;   /*!< RTC backup register 1,                                    Address offset: 0x54 */
  28.   __IO uint32_t BKP2R;   /*!< RTC backup register 2,                                    Address offset: 0x58 */
  29.   __IO uint32_t BKP3R;   /*!< RTC backup register 3,                                    Address offset: 0x5C */
  30.   __IO uint32_t BKP4R;   /*!< RTC backup register 4,                                    Address offset: 0x60 */
  31.   __IO uint32_t BKP5R;   /*!< RTC backup register 5,                                    Address offset: 0x64 */
  32.   __IO uint32_t BKP6R;   /*!< RTC backup register 6,                                    Address offset: 0x68 */
  33.   __IO uint32_t BKP7R;   /*!< RTC backup register 7,                                    Address offset: 0x6C */
  34.   __IO uint32_t BKP8R;   /*!< RTC backup register 8,                                    Address offset: 0x70 */
  35.   __IO uint32_t BKP9R;   /*!< RTC backup register 9,                                    Address offset: 0x74 */
  36.   __IO uint32_t BKP10R;  /*!< RTC backup register 10,                                   Address offset: 0x78 */
  37.   __IO uint32_t BKP11R;  /*!< RTC backup register 11,                                   Address offset: 0x7C */
  38.   __IO uint32_t BKP12R;  /*!< RTC backup register 12,                                   Address offset: 0x80 */
  39.   __IO uint32_t BKP13R;  /*!< RTC backup register 13,                                   Address offset: 0x84 */
  40.   __IO uint32_t BKP14R;  /*!< RTC backup register 14,                                   Address offset: 0x88 */
  41.   __IO uint32_t BKP15R;  /*!< RTC backup register 15,                                   Address offset: 0x8C */
  42.   __IO uint32_t BKP16R;  /*!< RTC backup register 16,                                   Address offset: 0x90 */
  43.   __IO uint32_t BKP17R;  /*!< RTC backup register 17,                                   Address offset: 0x94 */
  44.   __IO uint32_t BKP18R;  /*!< RTC backup register 18,                                   Address offset: 0x98 */
  45.   __IO uint32_t BKP19R;  /*!< RTC backup register 19,                                   Address offset: 0x9C */
  46. } RTC_TypeDef;
复制代码


收藏 评论0 发布时间:2022-6-14 14:01

举报

0个回答

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版