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

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

[复制链接]
STMCU小助手 发布时间:2022-6-14 14:01
01. 概述6 v) }2 j9 b( y/ O$ @
RTC相关函数和类型主要在stm32f4xx_rtc.h和stm32f4xx_rtc.c文件中。
; C  K" p6 L/ A: a6 l( b$ b" G/ D9 B: d& P; y, k' f
02. 相关类型3 y9 a* ~2 K" t- ~$ X, e, F8 y
  1. /**
    2 A* o+ y) Y0 u/ m! v
  2.   * @brief  RTC Init structures definition  ; ?9 o$ v, ?& p: t2 n4 T" r
  3.   */ # V, w$ d# R5 Q2 b
  4. typedef struct( `- F% h; J6 D) C$ v/ W- c
  5. {4 q7 ~  u+ \/ n) [1 L/ Z9 ^
  6.   uint32_t RTC_HourFormat;   /*!< Specifies the RTC Hour Format.. w+ Q' k: @6 r+ V" y
  7.                              This parameter can be a value of @ref RTC_Hour_Formats */
    ; {( ]0 t+ @+ I3 O

  8. 4 j+ |( B" w# z0 E1 a1 ^
  9.   uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value./ N* V3 Z" N* {6 `
  10.                              This parameter must be set to a value lower than 0x7F */
    6 g- U3 N& x, {  E+ J  t% N

  11. % t1 t7 ]9 j! U* l1 w
  12.   uint32_t RTC_SynchPrediv;  /*!< Specifies the RTC Synchronous Predivider value., k& Z+ p% U, u: {' ~2 h
  13.                              This parameter must be set to a value lower than 0x7FFF */
    ) U2 @6 H4 T( ^8 b1 {: B8 d/ _
  14. }RTC_InitTypeDef;
    4 T6 |, F/ U3 z$ ?7 T" u

  15. - {7 Z* r- }+ e' [: p
  16. /** 2 e! ]8 q+ y) j' Y6 E4 \2 m1 ]
  17.   * @brief  RTC Time structure definition  
    * `: e* u( ?, E# s- G& i2 |
  18.   */5 _6 z9 R. T+ @# V. `1 F
  19. typedef struct4 Y( K# R$ ^" t) N
  20. {
      r. Z: h. k0 W. Z8 n* ]. D
  21.   uint8_t RTC_Hours;    /*!< Specifies the RTC Time Hour.
    ; z3 J8 A' b+ q- l
  22.                         This parameter must be set to a value in the 0-12 range5 a% S: F. I0 L- s: R
  23.                         if the RTC_HourFormat_12 is selected or 0-23 range if$ I# o' C. u7 t$ H9 M; T" c
  24.                         the RTC_HourFormat_24 is selected. */3 k" T  d4 M; k" n& O

  25. 6 v6 U# @! @# _* `4 o8 Q. N  d4 o* {
  26.   uint8_t RTC_Minutes;  /*!< Specifies the RTC Time Minutes.
    $ m5 {$ f- j( {9 D2 ]; t0 W
  27.                         This parameter must be set to a value in the 0-59 range. */% d: j! N( q) u

  28. 2 T7 y6 I9 S! U* a
  29.   uint8_t RTC_Seconds;  /*!< Specifies the RTC Time Seconds.5 m1 @& F! K3 U+ Q
  30.                         This parameter must be set to a value in the 0-59 range. */5 o7 S- W6 ]2 W- n) a9 \
  31. 0 M2 d5 `- [. C8 p* z
  32.   uint8_t RTC_H12;      /*!< Specifies the RTC AM/PM Time.4 {2 L! N! Z1 L* S* s
  33.                         This parameter can be a value of @ref RTC_AM_PM_Definitions */
    ; O3 G) R8 H0 U6 ^9 d; N% g
  34. }RTC_TimeTypeDef;
    : t5 }1 ~* k1 }& ~: U
  35. 3 b0 V. I* c% b) |
  36. /**
    ' L8 c0 t+ ]* Q7 l) G- }
  37.   * @brief  RTC Date structure definition  
    $ Q7 b, m9 s/ d: _& G4 h
  38.   */- D6 ^0 P" o9 ]0 I( V
  39. typedef struct
    $ j5 b- V; ]+ W
  40. {6 e4 t) |4 i6 U. @2 @9 K) v5 @6 U
  41.   uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.
    + M8 h: Z" a& r4 F. y" u
  42.                         This parameter can be a value of @ref RTC_WeekDay_Definitions */. M/ o7 P% x$ b$ o7 t7 P8 u# ~
  43. ' k  z4 P' ^% |7 I; H
  44.   uint8_t RTC_Month;   /*!< Specifies the RTC Date Month (in BCD format).# @2 D4 j0 i' s: U! x( s  I
  45.                         This parameter can be a value of @ref RTC_Month_Date_Definitions */5 o% X" Z& o* G' }

  46. ' z6 q+ t! B  z3 {$ i
  47.   uint8_t RTC_Date;     /*!< Specifies the RTC Date.
    # ?8 }: s% F* @/ u% N. ]7 v! |9 P
  48.                         This parameter must be set to a value in the 1-31 range. */, `% j4 X# |" h) u

  49. 6 B( d. Y9 w, T- {
  50.   uint8_t RTC_Year;     /*!< Specifies the RTC Date Year.2 F) V- }" ?0 R! U  z
  51.                         This parameter must be set to a value in the 0-99 range. */4 m3 ^- P" |8 |) a
  52. }RTC_DateTypeDef;$ b" l; s. L) {. U( @
  53. / z8 j5 H+ h$ a7 m& h! {
  54. /**
    + `8 m0 K9 `$ S4 f2 c7 X
  55.   * @brief  RTC Alarm structure definition  
    - O2 P) M% f$ M: j
  56.   */$ Q# j! T% C! Q9 ~3 z  y, @% o; |
  57. typedef struct; k. v! }- r8 E! z2 e
  58. {
    / A4 G7 _7 e  e7 ~7 t- F6 n5 u
  59.   RTC_TimeTypeDef RTC_AlarmTime;     /*!< Specifies the RTC Alarm Time members. */, X( a7 [* \, F- U. _

  60. 7 U5 N1 R( i1 K# D! C+ J$ P
  61.   uint32_t RTC_AlarmMask;            /*!< Specifies the RTC Alarm Masks.# Q" b/ {( P! E9 b4 \- y
  62.                                      This parameter can be a value of @ref RTC_AlarmMask_Definitions */- R% |; U" l+ d8 ]$ h6 w" |

  63. # o9 A6 }1 W! D3 a$ Z
  64.   uint32_t RTC_AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.8 f( [7 N4 m$ Z4 }
  65.                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */* y0 t5 R: U/ x0 F
  66. / @# h$ `% Y2 }6 O# F5 j9 ]
  67.   uint8_t RTC_AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.; s# `' ~9 b8 ^
  68.                                      If the Alarm Date is selected, this parameter9 W" J  l! H- S8 G& q
  69.                                      must be set to a value in the 1-31 range.
    ! s  q# B5 I6 F6 I- ]" P
  70.                                      If the Alarm WeekDay is selected, this
    . }( }* Z$ b, C8 f% ]4 Q, B
  71.                                      parameter can be a value of @ref RTC_WeekDay_Definitions */! V3 i3 L- a  K! X
  72. }RTC_AlarmTypeDef;1 |/ Z) p- X' K. ^# d  I9 i$ A

  73. 3 g* z/ K2 X1 c& L' i9 j
  74. /* Exported constants --------------------------------------------------------*/
    & n* C1 R2 H/ P, ]* s+ b; s! a

  75. * Q" Y+ |0 f: n7 k
  76. /** @defgroup RTC_Exported_Constants
    ! q" ]" x) n& C- F5 S6 j* ~6 h. f
  77.   * @{
    5 r& K3 V# g# \
  78.   */ ; w% j/ D+ Y3 g5 ]9 L
  79. 9 l/ t, ^$ s0 b5 U; f
  80. 5 g/ b2 Y( d. H: E# [2 t9 {1 ?$ o
  81. /** @defgroup RTC_Hour_Formats : A3 y! H  K1 F: _4 u7 Z
  82.   * @{4 {( w5 x, v  P( E' @- Q  {' o
  83.   */ ! e& Q1 N. n& ^' T) \3 z
  84. #define RTC_HourFormat_24              ((uint32_t)0x00000000)0 B( G1 G% ]+ C* M
  85. #define RTC_HourFormat_12              ((uint32_t)0x00000040)+ D1 g6 y  ]6 _  S4 j* \; F
  86. #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HourFormat_12) || \
    * H- ]  F* b, Z
  87.                                         ((FORMAT) == RTC_HourFormat_24))+ k7 C7 e; [6 j% e4 }; r' T
  88. /**! Y5 O( e( G; g7 {$ I! m) ~9 Q
  89.   * @}
    " C9 {) w! x; d8 Y
  90.   */
    6 h! s+ o) d1 {4 U' {
  91. 5 X. f$ [" ~6 R* y$ P
  92. /** @defgroup RTC_Asynchronous_Predivider
    ' T% o8 W8 Y% l3 T9 ^
  93.   * @{
      Q9 {; p& T1 V, \& W: i
  94.   */ , M9 w: @% o7 h( v. @
  95. #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= 0x7F)
    # U6 Z  Y3 [$ e, ~# i
  96. , _$ Y( d$ v3 o5 }* p
  97. /**
    7 A( O$ R/ ~7 q( J. G* X2 q) j
  98.   * @}
    & K% k/ _/ Y" J; u( ]+ Y' c6 q
  99.   */ ' }1 _5 p! M- M3 J8 Z

  100. 2 U8 G, F7 y  ?' g

  101. . V; S+ J; y8 p# I0 f
  102. /** @defgroup RTC_Synchronous_Predivider 0 q7 q) M- C' v: D) ^) L9 J/ ~
  103.   * @{
    / i0 E( u5 U0 j
  104.   */
    3 H- }" Q* N/ ?' D* g8 h  T
  105. #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= 0x7FFF)  i- L4 q& ?" ~, _) {; E- d

  106. 2 ]) H: e2 {! D4 ?. i
  107. /*** S2 L! b5 m" w% c
  108.   * @}
    / Q% v$ q. R$ E8 Z" M
  109.   */ 3 H7 R% h9 ^/ N& `7 g) X. `
  110. 6 O( R# I0 B5 t1 a* M. t0 Q
  111. /** @defgroup RTC_Time_Definitions
    3 D& T3 U" ?. c) J3 A* q: _
  112.   * @{' p4 l4 h1 e/ o* p0 l8 v
  113.   */ $ s! x4 s* \9 ~+ t5 W, B& M: j
  114. #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0) && ((HOUR) <= 12))
    ) ^/ ?9 n/ a( I5 L+ s
  115. #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23)( [, d+ C5 A. X4 K% S
  116. #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59)
    8 P8 B! @  t9 M! z& w/ c
  117. #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59)& K# M  j1 D) o

  118. ( G, N' j/ r+ ^) p0 P- A' t3 U
  119. /**
    - c# p+ s; J9 r7 l
  120.   * @}
    0 I! I! w) N8 T1 L0 W' [
  121.   */
    5 z; g1 k& P( o( Z" Y
  122. # e  a) g" t. J, A' P
  123. /** @defgroup RTC_AM_PM_Definitions
    8 U6 ^) h  Z7 ]; h% n& ~5 p/ E+ \
  124.   * @{
    . j2 `1 b! j) i
  125.   */
    2 q' _. D9 Q$ y8 N2 H- Q
  126. #define RTC_H12_AM                     ((uint8_t)0x00)3 X) F  t) R; j
  127. #define RTC_H12_PM                     ((uint8_t)0x40)/ Y& W. c: N: v' M4 b6 E
  128. #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))8 w- l; I* r; U! |
  129. ; R5 U& K: O. X% @5 z- [0 j8 |1 j
  130. /**
    ) T1 H1 K6 t& @$ V1 a: o6 n
  131.   * @}8 v& I# R- ]6 t5 S9 A2 S4 C. Q
  132.   */
    * K; ?  k$ i( _6 z* e6 @" R6 \7 b
  133. # ^0 C/ A- x3 ~. z0 z  n
  134. /** @defgroup RTC_Year_Date_Definitions 6 }5 n9 ^* [( s1 I+ k
  135.   * @{
    8 w+ H- d3 g5 `4 w, `2 S
  136.   */ + ?$ C* n5 `; s
  137. #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99)
    ! V& h* _/ w3 r) V* p$ d; I4 V
  138. % r, _4 I$ l8 u; v8 ~3 p" t) G( v- ]
  139. /**( b; P0 b& l( G
  140.   * @}
    0 K$ }( v8 \% ^* L3 v1 V/ `6 A
  141.   */ ; ]  R9 Y2 p$ l1 @
  142. ( r: x! s; b- O0 s7 P
  143. /** @defgroup RTC_Month_Date_Definitions + t" M- a* ^# C) f; I- \6 x9 r; P9 [
  144.   * @{
    - W$ g" m! W1 f! W( ]' x' u4 ]
  145.   */ " S7 v, g6 _8 p# l' D
  146. ; X; l/ m% W2 ~/ p2 \6 S8 v
  147. /* Coded in BCD format */
    8 \$ n! X' ~/ k0 C6 E5 ~
  148. #define RTC_Month_January              ((uint8_t)0x01)
    9 }# ^5 n! `2 x; j
  149. #define RTC_Month_February             ((uint8_t)0x02)6 t9 _: ~7 b7 ]: [. N0 ^
  150. #define RTC_Month_March                ((uint8_t)0x03)
    , Y8 V# }' s$ O1 Y
  151. #define RTC_Month_April                ((uint8_t)0x04)
    4 Y6 b" c3 `" @4 y- W/ ]  Z6 W
  152. #define RTC_Month_May                  ((uint8_t)0x05)
    6 L/ ]3 {7 R% L; |7 B  L& N
  153. #define RTC_Month_June                 ((uint8_t)0x06)! U7 ^' a: P- ?0 Y
  154. #define RTC_Month_July                 ((uint8_t)0x07)! n( v' w8 H2 r
  155. #define RTC_Month_August               ((uint8_t)0x08)
    % ^6 A7 O6 i* ~9 c9 R
  156. #define RTC_Month_September            ((uint8_t)0x09)
    + N# Z3 Q4 i9 _; t" [8 f' y
  157. #define RTC_Month_October              ((uint8_t)0x10)
    ! @9 O3 Z- m) Z1 v, a) T7 t' w2 Z) h2 a
  158. #define RTC_Month_November             ((uint8_t)0x11)/ _# Q* Y( w4 K* `1 g. C
  159. #define RTC_Month_December             ((uint8_t)0x12)
    5 F( \1 L0 O# {& `( `) s" a
  160. #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1) && ((MONTH) <= 12))
    # n4 l3 h9 M- ]* u
  161. #define IS_RTC_DATE(DATE)              (((DATE) >= 1) && ((DATE) <= 31))
    * d6 C3 L9 j1 g

  162. 2 a; L7 ?2 G! r1 f
  163. /**
    7 D: o3 \& }' \# k
  164.   * @}. e; I5 \# t6 R8 b
  165.   */
    : l3 g0 @9 h7 K& k+ Y
  166. , l9 P& G* j: b- D  z% [2 v, W
  167. /** @defgroup RTC_WeekDay_Definitions 6 r4 m: z' _- t6 {
  168.   * @{
    4 X1 Q; m- \8 d. {5 ]
  169.   */ - y; s# c/ ^: K9 ]' \
  170. 0 E! l$ J$ t( x
  171. #define RTC_Weekday_Monday             ((uint8_t)0x01)1 m- M2 ^8 B$ P. Q& b. o
  172. #define RTC_Weekday_Tuesday            ((uint8_t)0x02)3 O6 |7 r2 f! C  z& Y6 d, n/ r
  173. #define RTC_Weekday_Wednesday          ((uint8_t)0x03)
      E6 I; p- q7 p2 z
  174. #define RTC_Weekday_Thursday           ((uint8_t)0x04)
    $ w+ _5 D  ]" D" O
  175. #define RTC_Weekday_Friday             ((uint8_t)0x05)
    1 u6 L9 e3 ~+ S& K1 T: g
  176. #define RTC_Weekday_Saturday           ((uint8_t)0x06); n% G- l0 P1 V! u/ l
  177. #define RTC_Weekday_Sunday             ((uint8_t)0x07)
    0 o- p4 G6 y1 q% I* ?
  178. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
    0 k+ z; i2 `9 ^' c7 M2 C
  179.                                  ((WEEKDAY) == RTC_Weekday_Tuesday) || \
    7 m* G0 O; r9 A' T' ]
  180.                                  ((WEEKDAY) == RTC_Weekday_Wednesday) || \
    * X! F3 Y, e- `! ~0 k8 Q6 A
  181.                                  ((WEEKDAY) == RTC_Weekday_Thursday) || \
    & t( }: `6 w, k2 i) L: D0 O
  182.                                  ((WEEKDAY) == RTC_Weekday_Friday) || \" D4 I# _6 a( ]' `, t
  183.                                  ((WEEKDAY) == RTC_Weekday_Saturday) || \
    ( ]$ G4 _( i- a& Q
  184.                                  ((WEEKDAY) == RTC_Weekday_Sunday))- O+ X) ]1 h. `! w
  185. /**8 r& B# A: C0 N" N3 j) O8 D
  186.   * @}
    4 W4 P. O6 ]7 K, j5 F
  187.   */ 9 V9 r4 v9 k. o% G: U1 x; r8 X
  188. 0 q/ `$ F$ G3 M  N0 z
  189. 9 j7 X5 i( p' M8 M. W
  190. /** @defgroup RTC_Alarm_Definitions
    % N: l; [3 q/ F$ K
  191.   * @{
    & p) W# U4 u4 W2 W$ h
  192.   */
    " U0 G0 [$ `* W
  193. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
    % V2 @/ T; Z: {( ^" C. t
  194. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \( M, ~) }, D: c
  195.                                                     ((WEEKDAY) == RTC_Weekday_Tuesday) || \
    2 w; H9 R$ S7 p& F1 L. ?1 h" D
  196.                                                     ((WEEKDAY) == RTC_Weekday_Wednesday) || \
    6 t( h. G  q7 r
  197.                                                     ((WEEKDAY) == RTC_Weekday_Thursday) || \  h3 m. W& \0 c6 J
  198.                                                     ((WEEKDAY) == RTC_Weekday_Friday) || \
    7 H4 {& [1 \8 F) k5 Q
  199.                                                     ((WEEKDAY) == RTC_Weekday_Saturday) || \
    % n: |1 }& E0 u2 e* R  a
  200.                                                     ((WEEKDAY) == RTC_Weekday_Sunday))
    + |; Q$ J8 O' F4 Z. a
  201. % N7 X; D/ x7 K- e4 P
  202. /**9 C( i% k- ~$ S' G5 J
  203.   * @}
    9 k3 h" V, I6 @5 O" u
  204.   */
    * ]( o; q8 \* _9 u5 q0 ?7 x7 J

  205. ( F8 c* r- g# X+ \9 Q: D
  206. 7 i0 p2 b% f1 O' [& q
  207. /** @defgroup RTC_AlarmDateWeekDay_Definitions
    0 V6 M- h; w+ Z' ~. ^' A+ [
  208.   * @{" d# s  i1 A3 E& ^, A6 B1 p. d
  209.   */ $ y% b$ V% Q" X# G( D
  210. #define RTC_AlarmDateWeekDaySel_Date      ((uint32_t)0x00000000)
    ! }! G* u/ x2 {8 h
  211. #define RTC_AlarmDateWeekDaySel_WeekDay   ((uint32_t)0x40000000)
    4 g- N" D( Q9 g& a+ T2 C

  212. # W6 Q7 B9 x% @
  213. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
    * P9 T! ~1 N5 d4 @
  214.                                             ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))
    / v, ?2 [2 U% F+ b
  215. , @! r8 z  D  q/ I, Z7 Z- K# K
  216. /**
    / a0 e# j7 _* r, s# V; Z3 U
  217.   * @}; G- I6 O0 ~4 W/ p8 P9 t
  218.   */ & @  Y+ z5 u! W* t9 B

  219. 9 K$ X+ F3 N) Y( g" h
  220. 5 v( A* r0 x" l6 g
  221. /** @defgroup RTC_AlarmMask_Definitions
    , |% ~0 `- w. c4 |
  222.   * @{
    9 l; i7 J0 c4 O% v
  223.   */ 4 i8 ?$ h/ C7 n0 p
  224. #define RTC_AlarmMask_None                ((uint32_t)0x00000000)' @2 d3 @8 {, ^' V
  225. #define RTC_AlarmMask_DateWeekDay         ((uint32_t)0x80000000)4 W/ K7 g+ T! _9 r* p
  226. #define RTC_AlarmMask_Hours               ((uint32_t)0x00800000)' I$ t. j  p8 t; t8 @- w
  227. #define RTC_AlarmMask_Minutes             ((uint32_t)0x00008000)! p- u/ ^: o6 m0 w
  228. #define RTC_AlarmMask_Seconds             ((uint32_t)0x00000080)
    * ^6 \2 W4 W9 v# l0 O
  229. #define RTC_AlarmMask_All                 ((uint32_t)0x80808080)
    - ]3 v- s" ~& U* X7 n. S
  230. #define IS_ALARM_MASK(MASK)  (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
    " p( b3 |8 I; P$ K+ P! z' A: L

  231. & E1 ]$ T; x) R) V9 I( A8 }: ^
  232. /**
    / A) T; e4 n8 }2 ?
  233.   * @}
    0 s  M8 R" N! p- V5 C+ \' P
  234.   */
    + g0 t& N9 A: q8 T6 ]7 h" _$ }

  235. ' _/ _" B. `' v, U
  236. /** @defgroup RTC_Alarms_Definitions $ S# m& t3 B0 b+ \
  237.   * @{- V5 {$ s) S# {
  238.   */
    1 M$ ~% `* m9 T- B
  239. #define RTC_Alarm_A                       ((uint32_t)0x00000100)
    ; ?$ A+ l+ b0 A- l9 k+ c
  240. #define RTC_Alarm_B                       ((uint32_t)0x00000200)* j9 F/ K7 J( v9 v" U! w
  241. #define IS_RTC_ALARM(ALARM)     (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
    3 r5 E2 X+ n6 {" C  n- [
  242. #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)6 ~2 ?. ]$ Z" o1 s/ X: j
  243. ! k4 M9 ~/ @( i9 H4 Y
  244. /**9 f1 |2 ~3 V# ?
  245.   * @}
      c# K/ y. i- y3 I* w8 l6 M
  246.   */ " A- P& Z/ D3 }! P, }
  247. 3 F3 ?; P6 ~6 b2 D8 Z# y! B; t  {
  248.   /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions+ z3 Z6 ]1 G" S, L3 O0 h4 ~
  249.   * @{
    8 c5 _* I( v1 q8 x
  250.   */ " q6 v' h9 T5 G2 }# c( I! ]
  251. #define RTC_AlarmSubSecondMask_All         ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
    - S- @$ z+ A1 ^: U
  252.                                                                        There is no comparison on sub seconds - u/ A$ w, w2 d2 c
  253.                                                                        for Alarm */
    1 I! h6 y4 Z8 S! m
  254. #define RTC_AlarmSubSecondMask_SS14_1      ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm 4 A1 v+ W5 J$ h2 d5 Y- w5 j7 P
  255.                                                                        comparison. Only SS[0] is compared. */* g( i: v5 m6 [! }/ J
  256. #define RTC_AlarmSubSecondMask_SS14_2      ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
    3 |1 b! x5 O; S+ j% S. Y& {6 W; F
  257.                                                                        comparison. Only SS[1:0] are compared */
    ; k3 {  J5 M# [! m7 _8 m( f2 Y+ Z
  258. #define RTC_AlarmSubSecondMask_SS14_3      ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm & ?0 c4 \4 t& b3 f
  259.                                                                        comparison. Only SS[2:0] are compared */1 ^4 M- f) ^! ?9 D: i1 M
  260. #define RTC_AlarmSubSecondMask_SS14_4      ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm + q1 y  x7 p3 _$ u8 R
  261.                                                                        comparison. Only SS[3:0] are compared */* Q2 e& P5 r: b
  262. #define RTC_AlarmSubSecondMask_SS14_5      ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm , p% _3 @* N) h8 a, t1 \. g# g
  263.                                                                        comparison. Only SS[4:0] are compared */
    # ?2 o2 R1 d2 R4 D- k) }, A
  264. #define RTC_AlarmSubSecondMask_SS14_6      ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm
    / p% K* F1 G- m+ I) p% Y5 `* R2 c
  265.                                                                        comparison. Only SS[5:0] are compared */& [6 |6 c( p, ^0 }5 }$ E: i2 R( g
  266. #define RTC_AlarmSubSecondMask_SS14_7      ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
    9 h% j+ v3 f5 n: ?; A
  267.                                                                        comparison. Only SS[6:0] are compared */
    & V# i. r' j5 Z& G3 J8 A, v& ?
  268. #define RTC_AlarmSubSecondMask_SS14_8      ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm
    0 n0 S6 f# }3 a8 {; |7 |. ?, c
  269.                                                                        comparison. Only SS[7:0] are compared */4 }6 X' [; R: v1 q! D( ]% o
  270. #define RTC_AlarmSubSecondMask_SS14_9      ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm
    , Z; }- E8 Y# A7 [, Z
  271.                                                                        comparison. Only SS[8:0] are compared */
    # ^2 N2 H5 R) O8 r
  272. #define RTC_AlarmSubSecondMask_SS14_10     ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
    1 V! V% C% \$ k8 b3 c' a  f
  273.                                                                        comparison. Only SS[9:0] are compared */
    6 L- p8 B# V! l7 U2 r* d4 A
  274. #define RTC_AlarmSubSecondMask_SS14_11     ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm - a" w/ C) i5 J0 e
  275.                                                                        comparison. Only SS[10:0] are compared */
    6 |, q; F- R5 r6 O# Z
  276. #define RTC_AlarmSubSecondMask_SS14_12     ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm - g& y4 ^$ K/ ]7 N& U% v
  277.                                                                        comparison.Only SS[11:0] are compared */4 L% d) d5 p1 S
  278. #define RTC_AlarmSubSecondMask_SS14_13     ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
    8 L9 _) e6 u$ P
  279.                                                                        comparison. Only SS[12:0] are compared */
    / f7 Q, O' G$ l
  280. #define RTC_AlarmSubSecondMask_SS14        ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm 5 ~6 J& q( f) w9 Q
  281.                                                                        comparison.Only SS[13:0] are compared */7 N5 g$ j8 f5 B' B
  282. #define RTC_AlarmSubSecondMask_None        ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match 4 l. Z4 K9 t. J9 Z( n4 \7 r* Y
  283.                                                                        to activate alarm. */
    1 A; \9 n% N9 Q. Y" i& k1 ?: x
  284. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)   (((MASK) == RTC_AlarmSubSecondMask_All) || \# @# d  Q) v2 W4 E/ B
  285.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \4 I. r5 y1 w+ F9 ~
  286.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \+ M8 D" i$ f" x
  287.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \& H0 @3 }5 G2 ?% [
  288.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \5 b- @4 Z' G7 k' w  _; n6 f
  289.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \
    ( U; v# @9 t# L0 l: J  a" l6 b1 N
  290.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \
    & g8 w* g& Y# a; J0 v" {; c4 s
  291.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \% S* H4 f6 U. Q, Y  j3 @
  292.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \$ i6 _( Q! L: N, g6 Q% Y$ `' c
  293.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \
    ! X8 Q; N) ~' E0 s6 G0 Y) ^0 h' h7 S
  294.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \
    7 {; H6 F  A4 w/ \. _- h
  295.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \2 j- L  x) S7 e- a; [2 {
  296.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \  \' X0 R2 j% y+ G, w+ S- j
  297.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \& M4 V% o6 n& p6 U
  298.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14) || \8 e- Z" I1 c, b9 H- L
  299.                                               ((MASK) == RTC_AlarmSubSecondMask_None))( S8 j  U# w4 O9 m3 T2 T9 H) |
  300. /**: a; f$ m# g+ R: i1 m. o
  301.   * @}
    0 u) E; V( l/ c8 e6 q. E6 T
  302.   */ 5 A. i( A( r5 `/ {

  303. 4 P  w, e6 {( L  y8 \# R, t
  304. /** @defgroup RTC_Alarm_Sub_Seconds_Value2 G2 N3 M' b; ]! o& Y7 a, j
  305.   * @{
    ' u, b6 @  R7 L9 B7 h- _4 C$ e
  306.   */
    % ^. O6 i1 f, Q/ g# C1 F6 J" D( m
  307. 3 m- ]) H& v5 @5 J6 u8 n
  308. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF)
    8 E( `% b4 L' ^9 G- B+ ]4 Y

  309. ( @( d4 ~7 `& o9 B# v! o& o
  310. /**
    4 U8 |# ~( E( m' x* t% J- G
  311.   * @}. R% t+ u9 p3 g" s9 ?
  312.   */
    * h6 P! O) R$ l) A# n
  313. # _3 g8 X6 u9 V* p" H
  314. /** @defgroup RTC_Wakeup_Timer_Definitions
    2 V/ M# D; h$ d" G7 b4 ?: n% z
  315.   * @{
    7 v  K$ a" Y+ y3 J3 ^3 I5 u+ h
  316.   */
    7 ~( `$ y5 R9 N7 k9 s7 q4 _" b6 g
  317. #define RTC_WakeUpClock_RTCCLK_Div16        ((uint32_t)0x00000000)
    % ]% O1 ^7 g' L/ l: T
  318. #define RTC_WakeUpClock_RTCCLK_Div8         ((uint32_t)0x00000001)
    4 B, j1 ~1 a* @; U) g2 `, f& f
  319. #define RTC_WakeUpClock_RTCCLK_Div4         ((uint32_t)0x00000002)8 E& }' Q$ x' v
  320. #define RTC_WakeUpClock_RTCCLK_Div2         ((uint32_t)0x00000003)
    / ]6 g: Z2 c! @* [9 N  `
  321. #define RTC_WakeUpClock_CK_SPRE_16bits      ((uint32_t)0x00000004)7 c) D/ ^8 H9 D8 w& z
  322. #define RTC_WakeUpClock_CK_SPRE_17bits      ((uint32_t)0x00000006)3 p2 X, f+ c* K9 V0 X% H/ y7 B8 w0 j
  323. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
    : N" B& i4 @7 \0 d: u  p
  324.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \) Y+ Z) r; `* S( |# ?3 a7 x
  325.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \% W* q2 _. k$ h, t- [: N7 L+ M4 e
  326.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
    6 b0 b2 r2 E" O! d7 j
  327.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
    ) k1 g0 N7 H4 s( V8 r( l  o
  328.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
    8 F5 @8 [  M1 _/ p3 B6 c- X: ~
  329. #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFF)
    ' b- Q3 c2 T, C5 l! L5 j
  330. /**
    - v5 A) @4 ], x+ r. D( U
  331.   * @}! ~( l1 b6 T2 d& ], {2 w
  332.   */   ^$ {" U( F: w& b1 Z# u
  333. 6 t/ r8 R" ]+ e2 Y- [7 l$ x- w* a
  334. /** @defgroup RTC_Time_Stamp_Edges_definitions ' c& X- p' K3 k
  335.   * @{
    3 q. v( K3 f1 ^% Y' c
  336.   */ ; j; w# l8 `, T* X' z2 x
  337. #define RTC_TimeStampEdge_Rising          ((uint32_t)0x00000000)
    9 S! n+ R" h8 i: K6 h% q
  338. #define RTC_TimeStampEdge_Falling         ((uint32_t)0x00000008)7 f4 Q3 \' i% o% A
  339. #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
    ' S! e6 u# i  [. D0 Q
  340.                                      ((EDGE) == RTC_TimeStampEdge_Falling))7 w) i: ], n( A" z% R
  341. /**
    , Y+ L  I- y1 ]9 M7 z. T$ [7 x$ t1 k
  342.   * @}% _) f" I  q) L* _- v: ]. L3 A- r
  343.   */ - v9 v3 y1 n* P, o+ t
  344. 6 L3 X6 }- }4 V
  345. /** @defgroup RTC_Output_selection_Definitions
    0 R& N6 v3 n1 q3 `2 S. s5 L
  346.   * @{
    8 K9 R/ j, Y6 _. K
  347.   */ + s( B, V& B/ p. _8 P
  348. #define RTC_Output_Disable             ((uint32_t)0x00000000)2 Z5 z/ r) x  W* x
  349. #define RTC_Output_AlarmA              ((uint32_t)0x00200000)
    ' Y5 F# _* I0 ]6 u+ f  t' K
  350. #define RTC_Output_AlarmB              ((uint32_t)0x00400000)
    ) j" ?5 _* V' r* v% K
  351. #define RTC_Output_WakeUp              ((uint32_t)0x00600000)& z7 D+ d0 O! T% I0 Y

  352. 5 W# x, x9 p8 }! _
  353. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \6 ], R5 \! [- U1 i9 V
  354.                                ((OUTPUT) == RTC_Output_AlarmA) || \
    4 X4 P; K) h, k  z7 w! J1 W
  355.                                ((OUTPUT) == RTC_Output_AlarmB) || \( l+ l: [- \: l* O
  356.                                ((OUTPUT) == RTC_Output_WakeUp)), K' K& O# R* I+ T4 X/ e3 X  f) w

  357. / i, W. l" ^. N+ [
  358. /**! k, n( x' D6 @
  359.   * @}
    0 D9 C: ^8 ^5 c, Y
  360.   */
    - g( I/ z: Y0 b2 C
  361. 0 n. Z/ Q* M+ X0 k
  362. /** @defgroup RTC_Output_Polarity_Definitions
    2 f" U5 b7 r0 Y
  363.   * @{
    2 V: m1 J7 @4 u. }
  364.   */ 0 f( F% r2 \% Z- N" P/ r5 V1 E. G
  365. #define RTC_OutputPolarity_High           ((uint32_t)0x00000000)2 p1 a$ b, F# a3 N
  366. #define RTC_OutputPolarity_Low            ((uint32_t)0x00100000)
    6 C; L: y3 c9 f
  367. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \# J$ C: \  t( W3 F" Q% z# g
  368.                                 ((POL) == RTC_OutputPolarity_Low)), U# g" q$ P2 `; H- \- l
  369. /**
    ' U0 ~- N9 Z8 z' G8 {! P4 A
  370.   * @}
    : T. F" G  `' j! e2 T$ F
  371.   */ # M& v9 ~1 e; B7 v& s0 I2 L# E
  372. . S& q  W) o8 ^5 x  N
  373. ( f) S+ M/ b8 {8 ^& O
  374. /** @defgroup RTC_Digital_Calibration_Definitions
    ) T: G2 K# T* O2 i
  375.   * @{; O& D4 v- C/ T2 p% p/ g
  376.   */ ) G$ `6 R7 C. B, \+ g) h
  377. #define RTC_CalibSign_Positive            ((uint32_t)0x00000000) 4 r  j4 G6 i8 Z1 `! I
  378. #define RTC_CalibSign_Negative            ((uint32_t)0x00000080)
    4 b' n+ e' m& y4 V4 W# ~* T# c
  379. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \8 o; k9 I9 w, y2 F
  380.                                  ((SIGN) == RTC_CalibSign_Negative))
    2 r" S  M0 x$ z9 N7 H2 n
  381. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)# a/ z& d) n# l
  382. * x+ u; h# i1 l8 r: A# _2 C
  383. /**/ p3 i( ]5 {8 }4 h/ A% i1 p/ y% s
  384.   * @}
    + F2 a! |! u* |8 N+ {% Y
  385.   */
    : @. J3 X# U% \7 W
  386. & R+ |2 W0 L( c6 o. {8 _
  387. /** @defgroup RTC_Calib_Output_selection_Definitions
    8 n0 b! s3 L1 g+ p* W: G$ r) b
  388.   * @{
    . k. l: N1 [4 s, w; Z: _
  389.   */ : V3 R: a( O/ e* \' p
  390. #define RTC_CalibOutput_512Hz            ((uint32_t)0x00000000)
    ( z$ X3 _1 q& |0 E
  391. #define RTC_CalibOutput_1Hz              ((uint32_t)0x00080000)2 ]0 [! d+ s# g4 n5 @% G$ Z2 Z6 Y6 D
  392. #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CalibOutput_512Hz) || \: \8 |# t$ B! D3 g* p; n
  393.                                       ((OUTPUT) == RTC_CalibOutput_1Hz))7 q1 {; o% m5 Q  S9 c  j* Z6 \
  394. /**! b3 Z& Y# A1 S' O
  395.   * @}" |& x% x' R5 b4 A! ?( N
  396.   */
    - ]. ]9 s2 c/ L9 t

  397. 5 b/ _* _7 u% I, u( D9 Q9 R$ X6 M
  398. /** @defgroup RTC_Smooth_calib_period_Definitions
    & K# f+ c1 E5 d
  399.   * @{4 G3 ?6 j- Y' k3 ]
  400.   */ 1 Z# H8 ^" [: l( m+ w" i
  401. #define RTC_SmoothCalibPeriod_32sec   ((uint32_t)0x00000000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation" {' `" M: m( i2 d0 Y) J5 P! d
  402.                                                              period is 32s,  else 2exp20 RTCCLK seconds */5 e1 w7 a# |) y& w
  403. #define RTC_SmoothCalibPeriod_16sec   ((uint32_t)0x00002000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
    " H# Y+ p9 W! j) v
  404.                                                              period is 16s, else 2exp19 RTCCLK seconds */
    ' u# N* R: G& q: v% ^) q/ X
  405. #define RTC_SmoothCalibPeriod_8sec    ((uint32_t)0x00004000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation . y( t0 K7 V$ e
  406.                                                              period is 8s, else 2exp18 RTCCLK seconds *// A' c$ @: M- F7 v) Q% W
  407. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \9 E2 i( a- i4 F* U; }, {2 g: t2 Q
  408.                                              ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \) ?/ U3 V7 _' v% e- N* L" ]% P+ ~
  409.                                              ((PERIOD) == RTC_SmoothCalibPeriod_8sec))3 M6 W; l' R/ V, m& U3 t4 L
  410. 8 s6 `! ~& I+ `* \/ g9 f5 a
  411. /**' j  u* ]( i( @; c9 i; F8 o/ j
  412.   * @}! m6 D* j$ c: l! B
  413.   */
    * V+ @# S' V. y" Y) P
  414. $ ?( n6 N1 f* j5 r9 K' N& o
  415. /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions $ D; K9 B5 p( X
  416.   * @{
    , W, ]; `- t9 {+ F
  417.   */
    6 C& g1 M4 Y: i; Z! w
  418. #define RTC_SmoothCalibPlusPulses_Set    ((uint32_t)0x00008000) /*!<  The number of RTCCLK pulses added  2 U1 `5 Z1 f6 \' P0 H" M( |
  419.                                                                 during a X -second window = Y - CALM[8:0]. 7 o& C* G" Q7 r/ ?1 I7 \" c
  420.                                                                  with Y = 512, 256, 128 when X = 32, 16, 8 */; P1 m  b6 U( f  \' u/ j# e/ n
  421. #define RTC_SmoothCalibPlusPulses_Reset  ((uint32_t)0x00000000) /*!<  The number of RTCCLK pulses subbstited) o8 A% ?5 d; P
  422.                                                                  during a 32-second window =   CALM[8:0]. */& r4 {4 V; y& ~0 {
  423. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \
    ' v0 Y7 U. I) p1 o  C
  424.                                          ((PLUS) == RTC_SmoothCalibPlusPulses_Reset)). z. b/ k9 g! j4 ^- _' C7 Y! d, P* }
  425. 3 n7 D) _  T: m& C& F3 j: g# [
  426. /*** M" N9 G6 @% M  |7 b( L! k
  427.   * @}
    , A% }2 x6 I% l; x, R
  428.   */
    7 M3 P) R/ z$ e) |) o7 ]

  429. 1 u4 N% B8 F3 V* ^6 l0 V! I
  430. /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions
    ' d3 R5 x+ W4 `7 V
  431.   * @{' }8 k, y$ {/ Y  A
  432.   */
    : Y$ U* l# \. i0 o" v) m5 h( d
  433. #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
    + T- u" M' u  c) x$ P

  434. . ?  k, n. M: ^4 H+ a9 y
  435. /**
    3 m6 H- e1 R* S6 o1 P$ x- S
  436.   * @}
    6 X+ ]" E0 i" Z
  437.   *// b: y" M; u1 z) O

  438. & R8 I( z" Z' c
  439. /** @defgroup RTC_DayLightSaving_Definitions 6 p( s. H" @& _: h! Q; n& \' I$ ^8 i
  440.   * @{8 A7 ~# K4 X$ H8 w( q
  441.   */ 7 K2 O7 X) V8 }, r4 S2 g: n+ s! P/ S
  442. #define RTC_DayLightSaving_SUB1H   ((uint32_t)0x00020000)8 L) m) p6 U! h$ d* `1 d, \+ `7 w& z
  443. #define RTC_DayLightSaving_ADD1H   ((uint32_t)0x00010000)
    3 |, K  _" H/ i6 ]. \. ?
  444. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \" T2 ^, ~  o5 \. Z5 x# P1 p% Z
  445.                                       ((SAVE) == RTC_DayLightSaving_ADD1H))4 r5 Z$ h" S" y( d" G

  446. & e- v! X1 p4 K8 h* u- g
  447. #define RTC_StoreOperation_Reset        ((uint32_t)0x00000000)) E8 X9 N1 k- \  A5 c& {
  448. #define RTC_StoreOperation_Set          ((uint32_t)0x00040000)) z1 x8 W5 t! \  b$ j# i$ ]  Q
  449. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \* D* I; T7 e% e# u3 G6 R* m
  450.                                            ((OPERATION) == RTC_StoreOperation_Set))
    . g  a* ~8 d$ m5 q1 s
  451. /**
    - M9 F# I6 z( P5 t6 A
  452.   * @}
      c  O) s( f7 o* m9 `  m2 t
  453.   */ 6 b2 Q% N/ f( p3 H( Y  a$ W
  454. 8 g, }$ B4 h/ Y  x0 l* K
  455. /** @defgroup RTC_Tamper_Trigger_Definitions ! {5 x, V7 n  g8 I5 o
  456.   * @{3 Z/ z9 E8 [$ \8 L  g6 Q
  457.   */ , l/ T1 M) _! V* t; h) k0 V
  458. #define RTC_TamperTrigger_RisingEdge            ((uint32_t)0x00000000)
    ( R8 v/ p/ A2 U5 P
  459. #define RTC_TamperTrigger_FallingEdge           ((uint32_t)0x00000001)
    0 |* T# ~" v3 C6 [
  460. #define RTC_TamperTrigger_LowLevel              ((uint32_t)0x00000000), _8 U" ?) r4 r: d
  461. #define RTC_TamperTrigger_HighLevel             ((uint32_t)0x00000001)5 Y4 B! x4 V7 b7 B$ P% ?$ Y0 r
  462. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \' u2 J6 u- e- A
  463.                                         ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \
    ( M' f  z: M1 N6 ~0 }1 i
  464.                                         ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \
    / N) Y) t0 c1 Q. m0 {
  465.                                         ((TRIGGER) == RTC_TamperTrigger_HighLevel)) % a2 N. b- {# c5 y5 s* w5 Y& X
  466. , g8 d. Q% A2 j& \
  467. /**7 X9 L& G1 U  ^# |# f# C& I+ A
  468.   * @}
    0 @4 h6 @+ i7 N  A% |5 M
  469.   */ 8 Y" _5 Z+ u1 Y# N, |  l% m7 R+ X8 }9 L
  470. : W3 D8 g6 k6 H6 A& q
  471. /** @defgroup RTC_Tamper_Filter_Definitions 3 c; ]/ f& N* V9 }( K- x, v1 d
  472.   * @{/ v: Q5 f' S# Q" C+ r
  473.   */
    $ @( n! Z  v# d) ?: d" a/ V; ~+ C
  474. #define RTC_TamperFilter_Disable   ((uint32_t)0x00000000) /*!< Tamper filter is disabled */
    % |' \, y$ i2 }0 _1 ~; I
  475. 3 ^' G# z4 i' c: E+ N: q2 |
  476. #define RTC_TamperFilter_2Sample   ((uint32_t)0x00000800) /*!< Tamper is activated after 2 * q+ e/ V% B9 S9 W7 Y
  477.                                                           consecutive samples at the active level */
    - L$ R# ^" E5 ?% ^
  478. #define RTC_TamperFilter_4Sample   ((uint32_t)0x00001000) /*!< Tamper is activated after 4 + R1 H( b* h1 O
  479.                                                           consecutive samples at the active level */3 D6 _, ?, {: j9 C" n$ P
  480. #define RTC_TamperFilter_8Sample   ((uint32_t)0x00001800) /*!< Tamper is activated after 8 4 C- ^: S8 {% p+ i; N+ @
  481.                                                           consecutive samples at the active leve. */* g$ _2 ?6 S# Q% V; h0 y: \
  482. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \4 S* p$ Q' Z# F7 w
  483.                                       ((FILTER) == RTC_TamperFilter_2Sample) || \
    % `: u5 j4 S9 g8 g
  484.                                       ((FILTER) == RTC_TamperFilter_4Sample) || \
    - a: X; j. I7 j7 Z7 A, _
  485.                                       ((FILTER) == RTC_TamperFilter_8Sample))4 e/ l3 P2 g: S4 A& d' p4 Z
  486. /**
    , C; D: A1 R8 ]2 D- O
  487.   * @}
    2 y* b) B7 U" ^8 I
  488.   */
    / D1 Q9 Q  L6 D& w% V

  489. 8 e% T5 J2 h4 A' M7 Z
  490. /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions 7 `% {4 ]" ~5 {7 y1 E# G
  491.   * @{5 M" ~* ?0 Q4 y% @9 {" W
  492.   */ 6 |) I/ T+ M' x; M! w5 q' D8 {
  493. #define RTC_TamperSamplingFreq_RTCCLK_Div32768  ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled! s6 u- l0 N( V/ p/ M
  494.                                                                            with a frequency =  RTCCLK / 32768 */) [8 ]' `7 Z  `
  495. #define RTC_TamperSamplingFreq_RTCCLK_Div16384  ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled: h  l! x# _. ~5 `2 `+ z# u- P
  496.                                                                             with a frequency =  RTCCLK / 16384 */: `; U/ I& U# f' E
  497. #define RTC_TamperSamplingFreq_RTCCLK_Div8192   ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled
    9 A' w- v/ ~' [$ S
  498.                                                                            with a frequency =  RTCCLK / 8192  */
    3 Z# O, o% d2 k2 Y" w  Q
  499. #define RTC_TamperSamplingFreq_RTCCLK_Div4096   ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled+ ~& E( }! J; O& S* m
  500.                                                                            with a frequency =  RTCCLK / 4096  */
    ; B( V' |: j3 p1 C, _: |
  501. #define RTC_TamperSamplingFreq_RTCCLK_Div2048   ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled& W' d" z* S3 _1 _
  502.                                                                            with a frequency =  RTCCLK / 2048  */
    ; o4 J" M3 D7 O1 R
  503. #define RTC_TamperSamplingFreq_RTCCLK_Div1024   ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled$ @( M3 f( X: X
  504.                                                                            with a frequency =  RTCCLK / 1024  */
    6 c- x% K& q# |% d( j4 ?
  505. #define RTC_TamperSamplingFreq_RTCCLK_Div512    ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
    ( T6 g7 E- A( `  v
  506.                                                                            with a frequency =  RTCCLK / 512   */# P' k, z. i7 c4 O( R2 [" \; S
  507. #define RTC_TamperSamplingFreq_RTCCLK_Div256    ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
    5 Z- {, f2 F) p9 f4 [0 s
  508.                                                                            with a frequency =  RTCCLK / 256   */' z7 J9 N' T8 h9 b
  509. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \6 z2 r3 @9 D' V" Z. G
  510.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \
      g" B2 r4 W$ R8 b( F9 R7 E
  511.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \
    / [8 D8 V" t" t2 g& S( p7 m: T( V
  512.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \4 `8 x5 m) G7 ~' `" {
  513.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \# p/ \' G# y, r# g( n$ U
  514.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \
    5 V" ~# V; W5 u( D6 ]9 S5 p
  515.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \) R; {# A! q7 }+ n& c% S
  516.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256))8 [, ^3 ?* @6 x4 f2 \' C2 g+ Z
  517. 0 [- ~" d0 G% t( {5 `, d: u
  518. /**
    . F6 \$ s7 U8 w' y
  519.   * @}
    2 c' C, d* s9 t
  520.   */. ]& L8 L: h5 f' r) N  z
  521. 9 h8 g! \4 ]6 F) N0 J+ G$ A+ N
  522.   /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions " a. q8 B* T4 W* y
  523.   * @{: L( b2 R% ]& D5 }0 B
  524.   */ ( N; q" \* j. |, }* x
  525. #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before
    . p7 i' R, W* k$ |+ {  z
  526.                                                                          sampling during 1 RTCCLK cycle */  p5 I5 B+ r9 b5 b
  527. #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000)  /*!< Tamper pins are pre-charged before + r/ {1 e& j3 g
  528.                                                                          sampling during 2 RTCCLK cycles */+ k/ s1 u: ]5 _, y0 _
  529. #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000)  /*!< Tamper pins are pre-charged before
    " @- X  ^$ g' N7 {, E, u
  530.                                                                          sampling during 4 RTCCLK cycles */9 X) d4 }7 x) A
  531. #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000)  /*!< Tamper pins are pre-charged before 3 Z: M$ k8 R, g4 Y3 w
  532.                                                                          sampling during 8 RTCCLK cycles */- L9 @$ C( _% K* l: h- K
  533. * {5 M1 a. j# r* [5 i4 Q
  534. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \
      U* n% |/ ^. X; b# X
  535.                                                     ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \
    : h0 _# `! `5 C% ^- M
  536.                                                     ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \
    $ T1 l+ b5 Q" }9 m: E. f- V) R
  537.                                                     ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK))
    ) w* P, A: c) ~2 X& H$ F" ^
  538. /**
    4 Q: U% w1 ?# Y/ q( T: d
  539.   * @}1 \& H1 D8 J8 T( n
  540.   */
    ; H1 x3 t1 h; o& T, E0 E

  541. 1 r& ~: l& I, T5 ^# Z' @; m
  542. /** @defgroup RTC_Tamper_Pins_Definitions
    ! w( f4 K' _4 \& \
  543.   * @{, D/ s+ y" }, G/ S  T2 M
  544.   */   ~# K9 n/ n8 C$ A0 r
  545. #define RTC_Tamper_1                    RTC_TAFCR_TAMP1E) Q: L( p1 R# z1 p" ?
  546. #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))
    ( a% p  l4 ~/ n$ ]5 j7 K
  547. ' S* ?6 K* t$ [; u" t
  548. /**
    / B% ~1 R) n7 s; y0 D5 g
  549.   * @}, O/ p, ]. p- v1 e, R
  550.   */
    $ B4 C* H8 g# `8 C0 _( M/ C
  551. 5 S& }- i8 E; X8 q
  552. /** @defgroup RTC_Tamper_Pin_Selection
    9 @' A" A0 q4 w5 j% w$ a* Z
  553.   * @{
    ; z9 `/ G0 b( ?4 i
  554.   */ $ [  {2 x/ c( Z! G* D, Z5 S
  555. #define RTC_TamperPin_PC13                 ((uint32_t)0x00000000)
    4 C1 N: M5 k/ t% x. O# y4 u
  556. #define RTC_TamperPin_PI8                  ((uint32_t)0x00010000)
    9 r" L6 J4 u+ q7 K
  557. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \% p# Y6 ?- q% x! ?! G
  558.                                 ((PIN) == RTC_TamperPin_PI8))( l0 |6 k' d! [& w6 R0 U+ k
  559. /**
    " ~8 k/ ]# h$ R/ R/ Y* W4 P
  560.   * @}% I2 g& @4 v( c8 g# D$ C! L8 _
  561.   */ , H, b  n8 _0 ?% V4 \; H( H

  562. " v' c9 _. ~/ Z/ `: T: O' A6 ?
  563. /** @defgroup RTC_TimeStamp_Pin_Selection
    9 |6 V& W+ C* K8 _$ y$ w
  564.   * @{  V' e8 T4 C: O
  565.   */ ; t" _- U+ Y% n/ G0 H4 S" {
  566. #define RTC_TimeStampPin_PC13              ((uint32_t)0x00000000)
    - U3 b0 C" s8 E
  567. #define RTC_TimeStampPin_PI8               ((uint32_t)0x00020000)& ^3 Q% s  d/ q0 j! \
  568. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
    / e- h$ g7 @& F; A2 {, x/ G8 j4 _; |' B
  569.                                    ((PIN) == RTC_TimeStampPin_PI8))
    # u) C2 g) E; l" N' c$ L
  570. /**
    % c8 _- N/ V1 a. y; s+ V
  571.   * @}* U. f: I1 Y% B' k7 c; |! @
  572.   */ 1 q6 W, n4 s3 D( X$ G) j

  573. 1 n% q+ z" J& l( S1 @
  574. /** @defgroup RTC_Output_Type_ALARM_OUT
    * e9 I9 k1 y* Q# x9 {  ?2 Q
  575.   * @{. m& b' ~' Z  T$ @; `$ l; ~
  576.   */
    ; h$ X) l& D4 r- @* d, B, k
  577. #define RTC_OutputType_OpenDrain           ((uint32_t)0x00000000)9 k1 ]& Z+ E+ m, z  s2 O
  578. #define RTC_OutputType_PushPull            ((uint32_t)0x00040000)
    9 L$ I3 Q: w8 P% Q! [
  579. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \( c% ]: }& L7 _2 E$ c3 _4 t+ R
  580.                                   ((TYPE) == RTC_OutputType_PushPull))% A4 g4 z9 W# z# `0 D! F

  581. 1 V0 E2 q0 ^+ T
  582. /**
    ! x* @) F) S% g" y* p3 L
  583.   * @}
    * S; Y0 P8 Y% t; A/ H! X7 P
  584.   */ ( W. i8 {& |! M( M
  585. : x5 ?* ~' c4 d
  586. /** @defgroup RTC_Add_1_Second_Parameter_Definitions
    % R0 N& G' e  L, b  K! U
  587.   * @{! E" Q( j% }4 V. X1 X; e
  588.   */ ) U( h  h  x" `; _$ l
  589. #define RTC_ShiftAdd1S_Reset      ((uint32_t)0x00000000)* v% T* q! e7 t( A6 k) P7 P
  590. #define RTC_ShiftAdd1S_Set        ((uint32_t)0x80000000)7 X4 s# q/ \5 V' r
  591. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \+ e' o: C/ r8 |+ W* A
  592.                                  ((SEL) == RTC_ShiftAdd1S_Set))
      A  X/ m; v0 B- j; k- Q
  593. /**9 P0 ^1 r. J7 K  W+ r! ~' E
  594.   * @}
    / x: f# ]) k* E1 j3 U2 W6 d
  595.   */ ! d! T- C8 v& x. T% I( N  t" t

  596. 7 ^" _( D2 h9 Q- }
  597. /** @defgroup RTC_Substract_Fraction_Of_Second_Value. W8 N/ E; Q. \8 ^# O- s
  598.   * @{' L2 l3 K1 T2 G1 N6 I# |
  599.   */ % k4 J: G  Z. X
  600. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
    3 _9 x7 @+ b6 ]

  601. " h: W+ U& _( G! h; N& g' F* x
  602. /**
    2 V* X( z( ?/ ]4 D# B0 w9 H9 b- b
  603.   * @}
    " p! @, s4 i5 e( H, e/ h
  604.   */9 r  N+ @) Z6 A* p4 D
  605. # I" b+ C, Z% Z5 ?0 W0 q* k
  606. /** @defgroup RTC_Backup_Registers_Definitions
    ; j) f; q1 Y" e8 W% f, N
  607.   * @{9 k3 X1 J4 Y* k" T" H% S, y6 F/ d
  608.   */
    ) F; w1 D) K# k. B7 }$ q$ \

  609. - F$ Z3 I% J# O+ r" Z
  610. #define RTC_BKP_DR0                       ((uint32_t)0x00000000)
    5 c* }9 W) M1 Z  W( q9 U
  611. #define RTC_BKP_DR1                       ((uint32_t)0x00000001)" ^# `- {% D5 @6 G) a7 R
  612. #define RTC_BKP_DR2                       ((uint32_t)0x00000002)1 s# i) _  y9 \2 S
  613. #define RTC_BKP_DR3                       ((uint32_t)0x00000003)
    * u/ p7 m0 q7 s0 |- k
  614. #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
    , t! R9 Q- O) ^' t1 N" G+ P
  615. #define RTC_BKP_DR5                       ((uint32_t)0x00000005), Q. h0 L& R( M2 s0 a' Y3 X
  616. #define RTC_BKP_DR6                       ((uint32_t)0x00000006)5 R; n% o0 {5 ?* Y2 F
  617. #define RTC_BKP_DR7                       ((uint32_t)0x00000007)
    ' W* C. B' H6 |' s# @) S' A
  618. #define RTC_BKP_DR8                       ((uint32_t)0x00000008)) W) s/ i- c" M" l
  619. #define RTC_BKP_DR9                       ((uint32_t)0x00000009)5 k6 E- K" h( ]' b9 j* D
  620. #define RTC_BKP_DR10                      ((uint32_t)0x0000000A)1 u% z/ z& e" e$ C4 {
  621. #define RTC_BKP_DR11                      ((uint32_t)0x0000000B)% U0 k, L' }2 N( H' m
  622. #define RTC_BKP_DR12                      ((uint32_t)0x0000000C)0 J) a' C- s+ W+ U
  623. #define RTC_BKP_DR13                      ((uint32_t)0x0000000D)
    8 P. Q' Z3 h& C5 |' T$ l. y) g
  624. #define RTC_BKP_DR14                      ((uint32_t)0x0000000E)
    5 F" t1 U3 y' Y1 h* H
  625. #define RTC_BKP_DR15                      ((uint32_t)0x0000000F)
    ) c, U0 r4 m$ |) w5 d
  626. #define RTC_BKP_DR16                      ((uint32_t)0x00000010)
    3 d3 Q7 K( y) t" `" |' x
  627. #define RTC_BKP_DR17                      ((uint32_t)0x00000011)& s& o3 Z. z; c# S* W2 q
  628. #define RTC_BKP_DR18                      ((uint32_t)0x00000012)
    . n3 r. _# l& w2 R, n
  629. #define RTC_BKP_DR19                      ((uint32_t)0x00000013)0 o, K- b* [- w( n0 d7 Y9 ?8 s( c
  630. #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0) || \
    8 e, K& y1 @5 p( l8 [
  631.                                            ((BKP) == RTC_BKP_DR1) || \
    ' `4 i+ E$ }8 @, S  \
  632.                                            ((BKP) == RTC_BKP_DR2) || \
    % y- r4 z5 ~$ _6 C! \3 w; O' u
  633.                                            ((BKP) == RTC_BKP_DR3) || \
    7 c6 W9 r- \. y* ?
  634.                                            ((BKP) == RTC_BKP_DR4) || \$ M% {$ a9 r2 P
  635.                                            ((BKP) == RTC_BKP_DR5) || \( J/ y! P' g1 W
  636.                                            ((BKP) == RTC_BKP_DR6) || \
      J% h4 v" T3 u% ~5 x% r
  637.                                            ((BKP) == RTC_BKP_DR7) || \
    5 v4 m" c  x- y; ?4 z5 d# b! `9 ^* n. A
  638.                                            ((BKP) == RTC_BKP_DR8) || \, ~( H, f5 _8 K7 R$ `
  639.                                            ((BKP) == RTC_BKP_DR9) || \; [" A8 k& R; {' M, q
  640.                                            ((BKP) == RTC_BKP_DR10) || \7 N' s4 W6 P3 M4 B/ h
  641.                                            ((BKP) == RTC_BKP_DR11) || \
    $ r; I& e7 b0 H2 f
  642.                                            ((BKP) == RTC_BKP_DR12) || \
    / I* S6 d( k+ P2 Q
  643.                                            ((BKP) == RTC_BKP_DR13) || \
    / }- E3 n3 ]/ m3 u
  644.                                            ((BKP) == RTC_BKP_DR14) || \
    2 W9 V& X0 f& a4 K$ V' N3 M4 G
  645.                                            ((BKP) == RTC_BKP_DR15) || \
    % u8 Q# h4 A/ `! R1 A" Q
  646.                                            ((BKP) == RTC_BKP_DR16) || \. E: e, E5 m; y6 `1 R  z' @
  647.                                            ((BKP) == RTC_BKP_DR17) || \1 @# |5 {5 U+ L, `4 |( {
  648.                                            ((BKP) == RTC_BKP_DR18) || \- ~" {3 Y5 ~) `* n# H; \6 n" L
  649.                                            ((BKP) == RTC_BKP_DR19))2 H/ |0 O8 Y0 M
  650. /**
    + U; o. A; {* j& v
  651.   * @}2 G2 F9 E% a* q0 P( X( l
  652.   */
    ) p3 r* F: _; G+ T% N
  653. . n  `8 D) _7 f- u& s4 A4 _
  654. /** @defgroup RTC_Input_parameter_format_definitions ) ?$ J4 y  ~& {" @; c: v
  655.   * @{( o1 i4 e, ?6 P6 x/ e2 J0 _
  656.   */
    , B9 S5 f. K( |  e; p
  657. #define RTC_Format_BIN                    ((uint32_t)0x000000000)
    ( S: ^! l5 `4 v/ {; q. S$ {
  658. #define RTC_Format_BCD                    ((uint32_t)0x000000001)
    & C" m5 J- O# ]$ _" q$ B9 Y8 B& L
  659. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))
    7 V  j5 ?, k) L% W# E3 [& r

  660. % H& z9 T4 g" u: b' @5 f
  661. /**3 q2 n2 E# o6 ~" C1 D- r
  662.   * @}0 {1 ?; D- V% V8 |% x; n( U5 H
  663.   */
    3 x( J* }) v4 t1 D& |  P
  664. * R. o5 o8 R- h; c) `( e
  665. /** @defgroup RTC_Flags_Definitions # w4 E. f& u  P) q* v; w
  666.   * @{
    3 _) e6 I4 e: {' i( q' S
  667.   */
    - H+ @! |# `, {3 y
  668. #define RTC_FLAG_RECALPF                  ((uint32_t)0x00010000)! h+ ~$ v+ z( ~3 e% m
  669. #define RTC_FLAG_TAMP1F                   ((uint32_t)0x00002000)  L9 @. I6 R# O  `- k
  670. #define RTC_FLAG_TSOVF                    ((uint32_t)0x00001000)" A6 o9 ?) m+ \* [( J7 Q- ^
  671. #define RTC_FLAG_TSF                      ((uint32_t)0x00000800)  C( S5 E4 Q! H4 l2 S
  672. #define RTC_FLAG_WUTF                     ((uint32_t)0x00000400)$ ]; O8 U( c5 y0 b0 x
  673. #define RTC_FLAG_ALRBF                    ((uint32_t)0x00000200)- ?6 p1 @1 y. Y+ E
  674. #define RTC_FLAG_ALRAF                    ((uint32_t)0x00000100)
    & F) z% t  L. {2 t: r; \) s
  675. #define RTC_FLAG_INITF                    ((uint32_t)0x00000040)
    1 q/ O3 Q) t, K# N% N% B. v
  676. #define RTC_FLAG_RSF                      ((uint32_t)0x00000020)( D" c- l. n2 J5 d7 Q: F
  677. #define RTC_FLAG_INITS                    ((uint32_t)0x00000010)
    4 y7 D0 s  y; P  \' J8 \% r, }
  678. #define RTC_FLAG_SHPF                     ((uint32_t)0x00000008)$ J4 k/ g; }: u6 f
  679. #define RTC_FLAG_WUTWF                    ((uint32_t)0x00000004)5 W1 T" V, E% a7 i
  680. #define RTC_FLAG_ALRBWF                   ((uint32_t)0x00000002)0 I& a4 K( _/ N; U) R; n, U" q% [
  681. #define RTC_FLAG_ALRAWF                   ((uint32_t)0x00000001)
    0 N& j# P5 \# W" \' p
  682. #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \
    3 n8 a. X/ n* v+ L, j7 G" q3 v  J8 {
  683.                                ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \
    2 i) ?8 U1 B* Z) S9 |: h! {
  684.                                ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
    % D& v4 Y% i( i6 |& f/ s
  685.                                ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \" G8 w4 S0 l9 E2 S8 Z$ d9 D
  686.                                ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \! a# ~* Q4 K; Z
  687.                                ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_RECALPF) || \4 R2 |, S9 \" S) v& s
  688.                                 ((FLAG) == RTC_FLAG_SHPF))
    4 e1 |* X- o' R7 G, l6 u9 q4 {
  689. #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET))3 Y% F0 Y1 R+ i) `
  690. /**
    7 w& q9 n2 u5 K, |- P, N
  691.   * @}
    # T3 d2 N5 H; m$ x, a5 f- W8 z
  692.   */
    2 S& W( Y' _8 r! W" |' @
  693. . T+ b0 |# x# H) H
  694. /** @defgroup RTC_Interrupts_Definitions
    ; D- U+ [+ X& ?8 X$ Q
  695.   * @{; B6 Z+ d+ v2 n) k0 a
  696.   */ $ K- F) j  S5 _; ]: S
  697. #define RTC_IT_TS                         ((uint32_t)0x00008000)% I; U, p% P2 R
  698. #define RTC_IT_WUT                        ((uint32_t)0x00004000)
    ) L( [/ E+ \( S" [8 m
  699. #define RTC_IT_ALRB                       ((uint32_t)0x00002000)
    + M8 U) @5 J" C0 i0 {  s5 L
  700. #define RTC_IT_ALRA                       ((uint32_t)0x00001000)2 c0 ?" |0 N) f; ~* n- ?8 v; a# _
  701. #define RTC_IT_TAMP                       ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt *// Y4 _- R2 z* m7 t7 j7 m
  702. #define RTC_IT_TAMP1                      ((uint32_t)0x00020000)9 A: J( W- X8 t/ e: f  ?' Y

  703. 5 ^$ A7 F7 k' }' o, r) l3 x
  704. #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET)). X2 f/ r5 v% H8 [- l. b
  705. #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \* N! ], t) }9 U, }9 p" V: L$ s5 L
  706.                            ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \  T0 ~6 G% I  r# E# ^6 }% [
  707.                            ((IT) == RTC_IT_TAMP1))8 ]( |" v: J2 q6 g  X
  708. #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))( e8 {# B; s7 Y) i

  709. 3 r  [" b" N  H: N6 c
  710. /**$ M6 q, x0 s6 V( z6 L
  711.   * @}% }1 N2 |) p1 a) M6 v! ^! i
  712.   */ ; z; b4 g; d7 Z! v" Z4 ]

  713. 7 b) K+ L' d# _6 P$ X% Z  q
  714. /** @defgroup RTC_Legacy
    / B" e) e+ u+ x# @3 A5 @. \5 m3 B
  715.   * @{
    , Z5 C! u6 @- @6 f$ y( y- r- @
  716.   */
    + g/ n* K% V  O' W/ }" R
  717. #define RTC_DigitalCalibConfig  RTC_CoarseCalibConfig
    5 z2 T! A1 n- H
  718. #define RTC_DigitalCalibCmd     RTC_CoarseCalibCmd
复制代码

! K9 |0 k. M4 n03. 相关函数
" \$ r* V8 w; M/ [) Z
  1. /*  Function used to set the RTC configuration to the default reset state *****/
    8 O# V7 L6 [& S# z; c8 u2 ]
  2. ErrorStatus RTC_DeInit(void);, r) [/ H' ?* _" n
  3. " X  a- p/ ^8 B" y1 m" G
  4. /* Initialization and Configuration functions *********************************/
    0 }. `2 `3 A  w- O0 `7 n6 d
  5. ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);" @7 V: [8 @" F) h/ q
  6. void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);
    ' {+ t4 e% R$ K
  7. void RTC_WriteProtectionCmd(FunctionalState NewState);, K1 G% O! O. b; i5 m
  8. ErrorStatus RTC_EnterInitMode(void);
    # [& i% g  b; ]7 Z7 [2 `2 f: ^
  9. void RTC_ExitInitMode(void);
    8 |5 L/ Z  n4 O
  10. ErrorStatus RTC_WaitForSynchro(void);% }$ F. |3 v" J2 h9 _9 e
  11. ErrorStatus RTC_RefClockCmd(FunctionalState NewState);# l9 v& _& A) Z% g7 \5 t
  12. void RTC_BypassShadowCmd(FunctionalState NewState);: B# z2 Z9 c# D* ^  \

  13. / R9 L% h. N6 l+ w+ [  c/ N
  14. /* Time and Date configuration functions **************************************/
    7 a8 r* R6 ?# `
  15. ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);" x/ a) C% B' e
  16. void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);
    , P) c* |: k# T3 V) m
  17. void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);, l4 `& s8 J# G; E1 f0 o: s
  18. uint32_t RTC_GetSubSecond(void);6 Y; p) o7 f& y9 W% ]! A
  19. ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);; M$ E0 c8 D. L: D
  20. void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);8 [9 a" T  z, c( B, S
  21. void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);  k# m  G8 B/ T4 l; f

  22. . _% ]# e# I8 B: I0 Y4 b; r
  23. /* Alarms (Alarm A and Alarm B) configuration functions  **********************/
    1 ~% ?9 q- Z+ z; j  v9 ^' Y
  24. void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
    ( V( i  f% ?& F
  25. void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);
    * ~  m( N; V- _) F
  26. void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);1 ?0 {& u& O( H3 A4 I0 ]  Y
  27. ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);
    # Z% m7 e- }1 i! t$ e# T
  28. void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask);3 F) t5 z1 y1 }* X8 l
  29. uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm);. _: t0 _* Y( O) M2 C

  30. , e: P* s& }. {# A- {$ d
  31. /* WakeUp Timer configuration functions ***************************************/
      t# E) A4 V# z6 U% x
  32. void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);- F8 {7 w5 [: O' ^
  33. void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);
    # L* y: N3 x# G4 e# z. o; |0 ?& \9 D
  34. uint32_t RTC_GetWakeUpCounter(void);
    , k+ z% C+ S) `# x- n
  35. ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);
    3 E$ o+ n: D. x* g5 ?. g

  36. % w3 F. c8 ?+ f4 d+ ?/ R* |/ A
  37. /* Daylight Saving configuration functions ************************************/. r& ], `6 U2 J1 T: N4 C0 R6 j; ]
  38. void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);
    . @7 [8 T5 B  T: Y; m/ b
  39. uint32_t RTC_GetStoreOperation(void);' D7 {* v' ~0 D% U
  40. & u% B4 m* T6 G6 O3 s  C
  41. /* Output pin Configuration function ******************************************/
    4 ]6 N& q$ F1 B, W5 }) }) S* _, Q) ^
  42. void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);! p4 A$ ]" [: Q2 c) _

  43. 5 c9 J0 ^3 h- z4 |6 E2 v4 M
  44. /* Digital Calibration configuration functions *********************************/
    ' e2 c2 @7 p, h- \! t8 H( C3 o$ a
  45. ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);6 a8 w+ j. G2 y& D1 A6 ?/ f
  46. ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);
    , _0 H# q4 p7 r/ S! F3 c  V
  47. void RTC_CalibOutputCmd(FunctionalState NewState);
    0 c. }5 W* C- `+ [3 d
  48. void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput);
    " [$ m% Q0 B9 ]2 ?$ f
  49. ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod, " T0 h9 F+ K" m# z5 d5 h" M
  50.                                   uint32_t RTC_SmoothCalibPlusPulses,
    . L1 Q" I& d( `
  51.                                   uint32_t RTC_SmouthCalibMinusPulsesValue);' T1 \. q4 B$ H1 W* L# C
  52. 1 t" c# C% c% |  R% T
  53. /* TimeStamp configuration functions ******************************************/
    , [4 V  R; s8 t. o4 D& h1 |
  54. void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);; f! I5 z0 R3 ~* E; z) J( G% m
  55. void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,6 a/ h2 N$ \* Y/ Z$ ^: [
  56.                                       RTC_DateTypeDef* RTC_StampDateStruct);6 x* K6 [; t3 N+ a: d" Q
  57. uint32_t RTC_GetTimeStampSubSecond(void);
    # Z1 W/ h! _5 e, O9 F( {6 w/ I

  58. ; b4 Z1 h8 X# _0 d
  59. /* Tampers configuration functions ********************************************/
    9 g3 S" y" {! I: {' n
  60. void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);
    * i- o- t$ L- A3 L) N8 ?
  61. void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);" P8 ^2 z" y5 a( S
  62. void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter);% J9 F/ y+ u7 \: _
  63. void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq);# [) K+ A8 }3 R! V
  64. void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration);9 {  t7 u! d8 l/ A
  65. void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState);& L) a" T1 ~/ p$ O2 p0 C3 `
  66. void RTC_TamperPullUpCmd(FunctionalState NewState);8 F. O/ B! [( K5 Y0 \) i0 X
  67. ! u+ q! e+ H- w7 x
  68. /* Backup Data Registers configuration functions ******************************// T/ @: h. G$ g" ?: X# v- _: l
  69. void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);2 f6 B: y5 m) o0 {- d  i
  70. uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
    ( O# U# z1 c0 U- z" `2 R
  71. 9 j1 `! r0 J; p/ h8 I) U
  72. /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration' t. s) }5 P# G
  73.    functions ******************************************************************/0 R6 e' `% `; k' R
  74. void RTC_TamperPinSelection(uint32_t RTC_TamperPin);
    & D* y$ S, S& S( y; p2 w
  75. void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);* W2 n6 I9 m1 [5 N) Q* B( H0 F* N1 N
  76. void RTC_OutputTypeConfig(uint32_t RTC_OutputType);* x2 b. ?# W2 ?, S

  77. 4 h6 A' V& x! @& w4 i
  78. /* RTC_Shift_control_synchonisation_functions *********************************/
    3 H- b5 M% g. Q+ p( w
  79. ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS);
    ( _7 j! o5 ~, D* t" z3 n
  80. / j- B( I. Q% }. a6 s5 Z7 f
  81. /* Interrupts and flags management functions **********************************/+ A' Z8 w. }% D: g. h9 ~
  82. void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);
      _5 Y% O4 C( \7 d2 V2 F3 j
  83. FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);: u/ l; N0 Q/ }0 |6 D( h4 P
  84. void RTC_ClearFlag(uint32_t RTC_FLAG);: N7 _4 S  D# \7 T$ @
  85. ITStatus RTC_GetITStatus(uint32_t RTC_IT);& v7 a+ ?- w) h4 k' J
  86. void RTC_ClearITPendingBit(uint32_t RTC_IT);
复制代码
4 M6 E8 v6 a; A! b9 \0 s! e% [. s
04. 结构体封装
: \. O- B* \3 B9 K
  1. /**
    2 u4 |' b, [" y4 x
  2.   * @brief Real-Time Clock
    3 k% m8 J: c3 Z
  3.   */7 U1 M2 n; r% f- N2 h7 _

  4. $ F; I& x5 J( v' O
  5. typedef struct7 a* N) u6 y5 f
  6. {) N  z4 F# c7 n
  7.   __IO uint32_t TR;      /*!< RTC time register,                                        Address offset: 0x00 */
    + g0 m' b1 X3 b8 k7 M# f- c/ P
  8.   __IO uint32_t DR;      /*!< RTC date register,                                        Address offset: 0x04 */7 W: @( }- G* ~4 j8 D+ M
  9.   __IO uint32_t CR;      /*!< RTC control register,                                     Address offset: 0x08 */+ Y: S0 c0 o/ F/ ~) n2 [
  10.   __IO uint32_t ISR;     /*!< RTC initialization and status register,                   Address offset: 0x0C */
    : E9 ?; J# n( ^9 g+ e6 v! @% E5 T& [4 G
  11.   __IO uint32_t PRER;    /*!< RTC prescaler register,                                   Address offset: 0x10 */
      |! u) r% [5 j! \/ U$ z
  12.   __IO uint32_t WUTR;    /*!< RTC wakeup timer register,                                Address offset: 0x14 */9 ^) j% x$ [7 }
  13.   __IO uint32_t CALIBR;  /*!< RTC calibration register,                                 Address offset: 0x18 */
    . i. j' {3 U) |# w4 m. z& ~! E
  14.   __IO uint32_t ALRMAR;  /*!< RTC alarm A register,                                     Address offset: 0x1C */
    ! ?3 d2 w! Z* N, q+ o, r1 M; G
  15.   __IO uint32_t ALRMBR;  /*!< RTC alarm B register,                                     Address offset: 0x20 */, y' \! E* ?3 n  h1 l9 \
  16.   __IO uint32_t WPR;     /*!< RTC write protection register,                            Address offset: 0x24 */
    + ?# y$ R( A+ r. a6 @
  17.   __IO uint32_t SSR;     /*!< RTC sub second register,                                  Address offset: 0x28 */
    1 q/ d. g- S' v. ]' n
  18.   __IO uint32_t SHIFTR;  /*!< RTC shift control register,                               Address offset: 0x2C */
    , \9 }% `0 M: L' G$ X! e( _8 J
  19.   __IO uint32_t TSTR;    /*!< RTC time stamp time register,                             Address offset: 0x30 */; f( q7 d' [/ [8 q# M8 ^' X2 z6 t! ^
  20.   __IO uint32_t TSDR;    /*!< RTC time stamp date register,                             Address offset: 0x34 */7 X4 i9 A: n9 R- w
  21.   __IO uint32_t TSSSR;   /*!< RTC time-stamp sub second register,                       Address offset: 0x38 */- E4 m) b# P# }+ m/ E+ u
  22.   __IO uint32_t CALR;    /*!< RTC calibration register,                                 Address offset: 0x3C */  J3 v+ ~" R1 z2 h, @- N# s2 L
  23.   __IO uint32_t TAFCR;   /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */
    * S$ z' H7 G3 w
  24.   __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register,                          Address offset: 0x44 */* B: K) Z) ]5 V: E4 r
  25.   __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register,                          Address offset: 0x48 */
    " v1 B" t# D( s9 s9 X: T
  26.   uint32_t RESERVED7;    /*!< Reserved, 0x4C                                                                 */
    6 O4 H; N8 e6 o. G# |: I# J1 @
  27.   __IO uint32_t BKP0R;   /*!< RTC backup register 1,                                    Address offset: 0x50 */) k: I. F( M. R/ h, w- ~) g: O  b/ H
  28.   __IO uint32_t BKP1R;   /*!< RTC backup register 1,                                    Address offset: 0x54 *// V- L8 Z; H; S2 u; O7 `- X
  29.   __IO uint32_t BKP2R;   /*!< RTC backup register 2,                                    Address offset: 0x58 */
    7 ?5 ^7 ~5 m5 D$ [
  30.   __IO uint32_t BKP3R;   /*!< RTC backup register 3,                                    Address offset: 0x5C */
    / u: Q: M* q/ w" n1 y  B7 q3 v
  31.   __IO uint32_t BKP4R;   /*!< RTC backup register 4,                                    Address offset: 0x60 */
    ( n; h2 _# c/ U4 e
  32.   __IO uint32_t BKP5R;   /*!< RTC backup register 5,                                    Address offset: 0x64 */) ?8 k& H7 k* l  o5 U4 H
  33.   __IO uint32_t BKP6R;   /*!< RTC backup register 6,                                    Address offset: 0x68 */8 v6 z% Z- G7 B  ?, L
  34.   __IO uint32_t BKP7R;   /*!< RTC backup register 7,                                    Address offset: 0x6C */4 \. e7 J2 Z0 m& o  ~
  35.   __IO uint32_t BKP8R;   /*!< RTC backup register 8,                                    Address offset: 0x70 */- J. O3 b3 E- p7 i0 G) C2 W
  36.   __IO uint32_t BKP9R;   /*!< RTC backup register 9,                                    Address offset: 0x74 */
    9 Z" U# I7 {# i; r
  37.   __IO uint32_t BKP10R;  /*!< RTC backup register 10,                                   Address offset: 0x78 */
    ; p& l3 c8 y" g- r! ^; N4 Y6 I: ]
  38.   __IO uint32_t BKP11R;  /*!< RTC backup register 11,                                   Address offset: 0x7C */2 a/ S# e, R$ U% _9 W8 e  _
  39.   __IO uint32_t BKP12R;  /*!< RTC backup register 12,                                   Address offset: 0x80 */
    & s# u( r+ z8 X* ?  J) g/ M
  40.   __IO uint32_t BKP13R;  /*!< RTC backup register 13,                                   Address offset: 0x84 */, R% w. D  E* `1 ?, j5 d$ t% u7 _
  41.   __IO uint32_t BKP14R;  /*!< RTC backup register 14,                                   Address offset: 0x88 */
    1 C: B  \. F/ ?1 A/ d% l; M2 u+ {0 ^
  42.   __IO uint32_t BKP15R;  /*!< RTC backup register 15,                                   Address offset: 0x8C */1 Q  R  k9 s# F  r( Y8 l
  43.   __IO uint32_t BKP16R;  /*!< RTC backup register 16,                                   Address offset: 0x90 */
    2 D0 n3 C+ L7 b  [9 e& v: b
  44.   __IO uint32_t BKP17R;  /*!< RTC backup register 17,                                   Address offset: 0x94 */9 a3 d8 @2 C/ L0 u/ l
  45.   __IO uint32_t BKP18R;  /*!< RTC backup register 18,                                   Address offset: 0x98 */
    ( L6 \, j1 K/ S2 L* n9 w
  46.   __IO uint32_t BKP19R;  /*!< RTC backup register 19,                                   Address offset: 0x9C */) g+ V3 }# X8 p: w- W
  47. } RTC_TypeDef;
    / A5 G# ~1 ]$ w' \0 a* A6 X
复制代码

5 W$ G7 t; s* b  a* H
% I8 C2 i3 ^" a5 c5 e7 J* E' _8 J
赞 收藏 评论0 发布时间:2022-6-14 14:01

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版