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

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

[复制链接]
STMCU小助手 发布时间:2022-6-14 14:01
01. 概述- I& Q+ c& w( N3 b
RTC相关函数和类型主要在stm32f4xx_rtc.h和stm32f4xx_rtc.c文件中。' K$ N- W5 F$ k' k3 e2 o8 ?
0 ]' _& i8 Y( f6 \2 S5 ~$ p0 W# e
02. 相关类型) b8 z4 D7 N+ h5 M& D5 `
  1. /** 9 c) Q' R$ i8 e, T
  2.   * @brief  RTC Init structures definition  
    2 r$ B" G( e- X- k# X
  3.   */ ; [4 ]6 h  e3 K
  4. typedef struct
    . z. Q: v. Y( s8 v7 L) E
  5. {
    9 h" _. R2 l6 i9 x# [5 O0 Q
  6.   uint32_t RTC_HourFormat;   /*!< Specifies the RTC Hour Format.# x% H% k) v9 x0 E
  7.                              This parameter can be a value of @ref RTC_Hour_Formats */. N" c9 X" [- |5 I5 m" C' P

  8. 9 f" _; n+ [- n. r* h
  9.   uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value." k. @8 z4 W5 `5 J# @
  10.                              This parameter must be set to a value lower than 0x7F */
    ( O* x) Z- A8 w. D

  11. 7 [5 B9 u% d" l, k; x4 T
  12.   uint32_t RTC_SynchPrediv;  /*!< Specifies the RTC Synchronous Predivider value.2 _4 w, s  _/ q( G
  13.                              This parameter must be set to a value lower than 0x7FFF */
    ; R6 }: ]5 V, E- x% K
  14. }RTC_InitTypeDef;/ r) {; E! J  P9 z4 B

  15. 8 E/ o  A" Y  v) h" e# C
  16. /** ( q+ O' d7 o$ }
  17.   * @brief  RTC Time structure definition  
    % P  e* a4 G' m3 E" Y# z
  18.   */4 P; N4 j8 x4 c2 [9 O2 M" O6 H
  19. typedef struct
    8 y- U+ i( I% S
  20. {; q& D+ B4 k+ N6 a% T6 f$ C6 G, n
  21.   uint8_t RTC_Hours;    /*!< Specifies the RTC Time Hour.1 E! `5 c- ^, x. ?2 Q2 y1 V- E
  22.                         This parameter must be set to a value in the 0-12 range
    0 c2 H- f5 |- R# ~: z0 I
  23.                         if the RTC_HourFormat_12 is selected or 0-23 range if
    6 a, x+ H8 D: G7 j" L" L8 L% C$ h
  24.                         the RTC_HourFormat_24 is selected. */
    : M7 f! k7 i; i) \. D; L2 H
  25. * t, A; H; ~$ u# w5 C
  26.   uint8_t RTC_Minutes;  /*!< Specifies the RTC Time Minutes.# q+ G9 i) A. ?( Q
  27.                         This parameter must be set to a value in the 0-59 range. */# H+ `5 i3 D' e; u) t- B
  28. ' m) n0 |8 K7 I/ {
  29.   uint8_t RTC_Seconds;  /*!< Specifies the RTC Time Seconds.
    6 D' f2 x/ c9 Q# ^
  30.                         This parameter must be set to a value in the 0-59 range. */( D# c% w. w; O/ @7 @

  31. , Y! v4 A& w2 u# g8 U
  32.   uint8_t RTC_H12;      /*!< Specifies the RTC AM/PM Time.  D9 t( O. Y* W# x* ]- y
  33.                         This parameter can be a value of @ref RTC_AM_PM_Definitions */
    6 x) `- H( \+ k1 Y8 c! c
  34. }RTC_TimeTypeDef; , P( M% Y) n; c: p3 q) a3 `
  35. , z+ m: }5 B( ]6 y8 p" z8 v
  36. /** ) o7 A" X, I+ e" M1 w6 Z& O
  37.   * @brief  RTC Date structure definition  
    % ?4 S: D0 t3 H; K
  38.   */) X  W# R7 r& ^( G
  39. typedef struct
    8 p" N* R  Y# i" s  w5 y3 l1 G5 i6 e
  40. {. [- A- b, ]; n0 `0 e
  41.   uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.# U" o2 P& R/ Z0 P- A% [# a
  42.                         This parameter can be a value of @ref RTC_WeekDay_Definitions */: P. _, N0 v( u7 ]

  43. 8 [3 U+ y0 V9 E7 e. r4 M; K- p
  44.   uint8_t RTC_Month;   /*!< Specifies the RTC Date Month (in BCD format).: B' K" V& y/ a9 D3 U% A/ W  Q5 N
  45.                         This parameter can be a value of @ref RTC_Month_Date_Definitions */
    9 ^0 t0 h* o" {* U4 ~! p
  46. - `6 M/ ~6 l: O+ y( d* `9 N# p$ J
  47.   uint8_t RTC_Date;     /*!< Specifies the RTC Date.
    " {! @+ a  F" [; W5 V3 ?! i" k
  48.                         This parameter must be set to a value in the 1-31 range. */
    1 z9 p0 W# \) f+ `7 @/ Q. F

  49. ! D: Z5 m: L& V
  50.   uint8_t RTC_Year;     /*!< Specifies the RTC Date Year." b2 ^% S7 {4 v" y' c0 n9 t6 G1 Y* N
  51.                         This parameter must be set to a value in the 0-99 range. */
    0 b" Z  ^8 X- x% m7 J, z
  52. }RTC_DateTypeDef;7 Q0 b1 U3 o* Z$ h3 W; J& a/ [

  53. - _! T& I& E& o6 _0 K+ W
  54. /** ) P2 M2 g9 h2 @2 l4 ?! T
  55.   * @brief  RTC Alarm structure definition  
    $ M5 ^& r( r! m6 v6 E. G
  56.   */4 }# g$ j( j  a1 O1 a5 p- V/ b
  57. typedef struct
    1 V$ M6 L1 N+ a# f9 `, Z
  58. {
    % Z4 r3 v7 O( z" A
  59.   RTC_TimeTypeDef RTC_AlarmTime;     /*!< Specifies the RTC Alarm Time members. */
    5 l5 M9 {+ N- \% e

  60. ( n  A8 x" c# c+ Q& l: G! k+ q6 }) M
  61.   uint32_t RTC_AlarmMask;            /*!< Specifies the RTC Alarm Masks.
    6 o. H! W7 r7 P. `
  62.                                      This parameter can be a value of @ref RTC_AlarmMask_Definitions */
    " Z" W$ R7 s) P

  63. 8 m& D5 F$ H1 b7 O( h2 w
  64.   uint32_t RTC_AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.0 B. U: \, ?! S
  65.                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */8 y  V9 G( L  M, m! `! O' V4 [9 ]

  66. ) k; y( @& e1 d, [2 E
  67.   uint8_t RTC_AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.; ]; ]0 C3 y6 `! d$ l( x$ j, U
  68.                                      If the Alarm Date is selected, this parameter2 I7 Y4 P. U, [3 K! k1 A
  69.                                      must be set to a value in the 1-31 range.# D: S' c1 i& _, l
  70.                                      If the Alarm WeekDay is selected, this
    1 T* L/ f% u9 s- p8 |7 A/ `7 R
  71.                                      parameter can be a value of @ref RTC_WeekDay_Definitions */: @2 l2 p+ }, F* g, t& P/ J
  72. }RTC_AlarmTypeDef;
    . X" i+ f7 Y  M; m3 J

  73. , D9 h* u$ L% c1 C0 `/ G
  74. /* Exported constants --------------------------------------------------------*/1 S  a0 k0 z8 _

  75. 7 F: x' a- Y% l4 L6 z
  76. /** @defgroup RTC_Exported_Constants
    " N( [/ ]0 H( \: ~/ E
  77.   * @{
    & [7 S7 X4 W: k/ i9 L9 {
  78.   */
    ; }8 Y+ i' T) K4 r1 ]6 Z
  79. 5 s; D/ @& ?- }7 c2 x

  80. ) v6 X: \, ^  o- b) M1 \
  81. /** @defgroup RTC_Hour_Formats
    7 y1 D* L7 h+ P
  82.   * @{
    ( c# ^( g! c8 {, s4 F! J9 e
  83.   */ ( O. y( K+ J* K" s4 k8 L1 i
  84. #define RTC_HourFormat_24              ((uint32_t)0x00000000)
    6 c. o1 g/ r2 }0 Z+ n  r: M
  85. #define RTC_HourFormat_12              ((uint32_t)0x00000040)
      j& K* O* j; K0 w( e! O' t: ]9 p
  86. #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HourFormat_12) || \0 Y( Q! q( [- c( I" p) t
  87.                                         ((FORMAT) == RTC_HourFormat_24))
    1 D" M8 g# l0 l) b
  88. /**
    7 t" S5 x% O" y; {2 r; w
  89.   * @}
    0 k5 ]4 l# i& ~2 z
  90.   */ 6 O& I! m& |/ L) D5 p  e3 u) v" I
  91. 5 M2 i9 F, V/ S' j0 O  x" @
  92. /** @defgroup RTC_Asynchronous_Predivider " }* w3 ~  i# ]. @' I
  93.   * @{
    . v3 _! w& d- g7 ]/ }. |
  94.   */ - C8 {6 j, a3 N" y3 L1 p2 G; O
  95. #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= 0x7F)( y/ u% o  e" e; i  F& r8 `3 U

  96. 6 {" |9 Z) f# `+ _0 _4 v
  97. /**
    5 |. w# m) _8 j& ?( Z0 @
  98.   * @}) Y# r* [+ z" j  P
  99.   */
    # L- _4 m* t% R- s7 M
  100. . {, [! b% W  P! d2 v
  101. / V7 i8 Q* ]7 ~4 a. ^1 {; w' Y7 p
  102. /** @defgroup RTC_Synchronous_Predivider / [/ u# A6 o7 `% u+ H7 }# Q
  103.   * @{' N. G$ t' C" H% w( s- [  Z
  104.   */
    ) E: |5 E0 C! g$ r( K
  105. #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= 0x7FFF)
    + E% r5 |3 s  X( d5 A

  106. + P9 `+ y( t0 [  B
  107. /**; v7 ~) j( W0 e* y
  108.   * @}0 V7 b0 x1 w2 F& c5 @. P; q) L
  109.   */
    + S4 Y& _% S: \  c8 g0 G% I
  110. 0 w$ O7 k* b# J5 d
  111. /** @defgroup RTC_Time_Definitions 6 C3 M( x# n- @' U
  112.   * @{
      `1 X$ J7 d4 O& E, n  R7 C0 ]
  113.   */ $ J' w' v5 v: f, e9 }
  114. #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0) && ((HOUR) <= 12))
    7 t3 [+ O6 ]9 v$ R
  115. #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23)1 ^5 ]9 D5 X1 Z! E  O! E) c
  116. #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59)
    ; \) b8 y4 v4 J' H. S
  117. #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59)9 l9 j# Z1 D! l1 ]# X
  118. 1 _- J1 r; J4 \9 q3 ~2 [, @. j
  119. /**& R3 P: V. T  |% g
  120.   * @}9 x: {8 C# c( C0 _( s4 _  X5 J2 m2 e
  121.   */
    6 J8 u: ^6 B* h
  122.   D; G. m& @3 q
  123. /** @defgroup RTC_AM_PM_Definitions
    0 g8 N' B# w  c2 O
  124.   * @{) ^) m0 u' z) j/ v# Q' j
  125.   */   D/ ~7 T* T5 j2 \
  126. #define RTC_H12_AM                     ((uint8_t)0x00)
    4 M. }2 w* |) v
  127. #define RTC_H12_PM                     ((uint8_t)0x40)
    8 l! }! S$ V' j; H1 ~7 \
  128. #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))
    : Y" I  C0 U! V& D$ p% h4 ~; M: I

  129. 2 S  k: Y  O; D
  130. /**
    & |$ _  ^; |- O$ q5 V0 M& v
  131.   * @}
    / [6 b/ q$ `9 m2 B+ ]1 g1 V
  132.   */ $ D" K+ Y2 @! Y8 P1 N# p

  133. 6 l3 O/ [5 F! `  h
  134. /** @defgroup RTC_Year_Date_Definitions
    9 @3 e% U. {- m7 A
  135.   * @{
    6 ]2 _. J2 }5 ^
  136.   */
    ) _# n( \  ^+ ^  P7 ~
  137. #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99); t$ {$ }. @$ W+ q2 ]% v
  138. 1 Y0 v/ D; F9 R, i. i" _
  139. /**' P1 |$ A6 L8 D. ?. c# A2 t
  140.   * @}) V. `& p& {, Y: }+ b3 a* y6 }( m! Y
  141.   */ ) X, I6 e6 Y+ E( }/ o3 e

  142. : r  d- H3 w. m2 e7 e8 r- U, m# K( L
  143. /** @defgroup RTC_Month_Date_Definitions
    & B" ^' W3 K+ H* P/ I5 s% G# s
  144.   * @{
    % n0 [  R' M3 f# j4 X' j$ m5 o7 Y
  145.   */
    ' }. I+ J5 n  L- M8 M2 W$ K( u& U. p
  146. ' ?6 R# w. d4 j! W
  147. /* Coded in BCD format */! W4 s8 d, D% @4 t! W) M; m
  148. #define RTC_Month_January              ((uint8_t)0x01)
    # Z1 f/ b+ D4 s1 g& p- o
  149. #define RTC_Month_February             ((uint8_t)0x02)
    * u; ~* I: E: z# U; j# g: }
  150. #define RTC_Month_March                ((uint8_t)0x03)
    ( g' \. P% }- e& _7 P$ C( Q
  151. #define RTC_Month_April                ((uint8_t)0x04)* F& v* B. B" X0 {! `/ \
  152. #define RTC_Month_May                  ((uint8_t)0x05)) [% z3 i. z/ W! k) J7 [3 n+ ]! v* r: J
  153. #define RTC_Month_June                 ((uint8_t)0x06)& I  C" d8 G$ b' {+ @+ ]
  154. #define RTC_Month_July                 ((uint8_t)0x07)
    # w: O- P" X7 s( F5 o8 G2 j( h$ B
  155. #define RTC_Month_August               ((uint8_t)0x08)
    7 Z! d# L$ ~+ \/ o8 ~- C! |# t9 [* t
  156. #define RTC_Month_September            ((uint8_t)0x09)
    : w  Y& J; M) l  @8 |$ M
  157. #define RTC_Month_October              ((uint8_t)0x10)
    4 ?' Z: A$ |, m1 j2 Z2 c
  158. #define RTC_Month_November             ((uint8_t)0x11)
    3 ?: a* P( h7 L3 z2 N1 ]  O1 W' S
  159. #define RTC_Month_December             ((uint8_t)0x12)
    ; O2 |1 n4 U; j4 m. v( K
  160. #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1) && ((MONTH) <= 12))7 B! {6 W! f2 p( U' |6 P+ k
  161. #define IS_RTC_DATE(DATE)              (((DATE) >= 1) && ((DATE) <= 31))) Y5 j' h/ N# N- ]
  162. 9 A. {7 y0 P9 d5 N7 x" m
  163. /**" v2 X0 ~9 C0 k  N
  164.   * @}  [5 d- P  F8 z3 x
  165.   */
    % Z# _* O% e+ X

  166. 5 p: U/ ?$ E7 J2 \( m* O- p0 `$ i
  167. /** @defgroup RTC_WeekDay_Definitions ; B+ K! m( h0 O1 r  B1 [/ h. b/ z
  168.   * @{+ S8 a( ^3 n; c% t/ o4 P% ^
  169.   */
    . `8 e0 q" K% a* z. z

  170. % J  X' M+ }/ a; Z9 P- B
  171. #define RTC_Weekday_Monday             ((uint8_t)0x01)# r" y; C8 o/ @' ?$ L1 u
  172. #define RTC_Weekday_Tuesday            ((uint8_t)0x02)( l' i  ?3 L: _  f7 h2 v
  173. #define RTC_Weekday_Wednesday          ((uint8_t)0x03)9 Z6 h# Z) x6 h! N8 X& }7 i
  174. #define RTC_Weekday_Thursday           ((uint8_t)0x04)" X3 U, M7 y2 d0 v( b
  175. #define RTC_Weekday_Friday             ((uint8_t)0x05)4 y. \5 l/ n0 n5 D
  176. #define RTC_Weekday_Saturday           ((uint8_t)0x06)
      G6 |. ?7 k' G+ X6 f
  177. #define RTC_Weekday_Sunday             ((uint8_t)0x07)- U4 ~" f) T% M6 P# }. s
  178. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
    ' E  Y0 L. }7 }' m* ]
  179.                                  ((WEEKDAY) == RTC_Weekday_Tuesday) || \2 S# ^( U4 F6 i! f1 ^
  180.                                  ((WEEKDAY) == RTC_Weekday_Wednesday) || \/ X* ~+ b( G% W, n3 [
  181.                                  ((WEEKDAY) == RTC_Weekday_Thursday) || \$ x  b/ L2 N2 I0 P6 F
  182.                                  ((WEEKDAY) == RTC_Weekday_Friday) || \' z- {# E* M1 h0 i* }) i
  183.                                  ((WEEKDAY) == RTC_Weekday_Saturday) || \7 ^, O% v; c$ ~0 _# S
  184.                                  ((WEEKDAY) == RTC_Weekday_Sunday))
    ' Q. N4 Q7 \- N5 x5 A; }
  185. /**0 h; q" p8 W: a" \2 _' a
  186.   * @}
    ! G( e; c& Q1 e8 O0 n9 L6 m9 D& }
  187.   */
    ( z8 M* U0 C3 X5 ?) \2 ^. v) I

  188. 7 r4 P& E* o3 ^+ G; [/ z
  189. : N3 j# P: {1 g- L* X
  190. /** @defgroup RTC_Alarm_Definitions
    . x9 M. b- Q. C: e+ v
  191.   * @{
    2 t; R& H/ d: ~3 a" S& G$ D$ V7 d+ I
  192.   */ ( X- y* C! i3 f; i: U: ?( T# z
  193. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
    4 G+ c* e) i8 _9 [6 E, o
  194. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \( d* u/ X, t# h8 ]! y, O
  195.                                                     ((WEEKDAY) == RTC_Weekday_Tuesday) || \
    4 F4 F2 m8 h- q2 A! J
  196.                                                     ((WEEKDAY) == RTC_Weekday_Wednesday) || \
    - L+ u" f( `! g/ A& ^3 W( \2 C
  197.                                                     ((WEEKDAY) == RTC_Weekday_Thursday) || \
    1 b/ @* P+ v  p* ~2 T; I
  198.                                                     ((WEEKDAY) == RTC_Weekday_Friday) || \
    : {0 T/ g3 M& r( f
  199.                                                     ((WEEKDAY) == RTC_Weekday_Saturday) || \9 d( V+ K* C) O5 M! U
  200.                                                     ((WEEKDAY) == RTC_Weekday_Sunday))
    ( G- p! M& S; O% J2 h

  201. ( |5 ^2 _. r1 J$ P
  202. /**
    ! d# l' H1 Q- I8 k& x% M
  203.   * @}
    : O: V# f2 h( F- k
  204.   */
    5 j4 @# q6 F( [. X/ {
  205. $ Z/ x' L2 ?8 A0 A. h- i
  206. 1 Y/ O- @/ l3 E
  207. /** @defgroup RTC_AlarmDateWeekDay_Definitions
    , u" @& `! P* g( S2 p  |, c/ p/ Q
  208.   * @{
    - j7 C# @* ~0 A8 ?& e1 x9 t3 ^
  209.   */ . T. A* a9 O" o6 f
  210. #define RTC_AlarmDateWeekDaySel_Date      ((uint32_t)0x00000000)! o- F: Y2 x9 N% v/ ^
  211. #define RTC_AlarmDateWeekDaySel_WeekDay   ((uint32_t)0x40000000)- r' K" z# D& X/ ?/ d7 ]
  212. - o9 O( j( u0 ]+ D
  213. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \6 h4 [% u0 f& ^8 y
  214.                                             ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))' [# b- m7 _6 {# V5 L6 c
  215. - ]* d' P; D* Z+ z; T* `/ c  u; X
  216. /**# {7 J2 W; d% b+ D+ T- v1 x4 H
  217.   * @}/ I, s! [* l+ j5 V! L
  218.   */
    ; p( L2 Y- E! Q$ i, R0 L

  219. ' l+ _5 r/ k$ O

  220. # C, J) W+ `% M" B. N9 G! X
  221. /** @defgroup RTC_AlarmMask_Definitions
    6 s9 W+ X( f/ V
  222.   * @{
    # J0 H: I: K" U1 A8 i: A
  223.   */
    " o5 q( T- N& C
  224. #define RTC_AlarmMask_None                ((uint32_t)0x00000000)
    ' h; g7 k( o& K+ z& }/ `/ |
  225. #define RTC_AlarmMask_DateWeekDay         ((uint32_t)0x80000000)& B  u' T+ Q. {
  226. #define RTC_AlarmMask_Hours               ((uint32_t)0x00800000)
      Z2 c: n9 Y  ~4 \+ f
  227. #define RTC_AlarmMask_Minutes             ((uint32_t)0x00008000)2 ?9 Y) L( }# ]$ B
  228. #define RTC_AlarmMask_Seconds             ((uint32_t)0x00000080)$ p1 z3 W& T9 N5 @1 N
  229. #define RTC_AlarmMask_All                 ((uint32_t)0x80808080)- @( R/ ~- ^  E% k5 z/ w) w7 n+ y
  230. #define IS_ALARM_MASK(MASK)  (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET), B4 H; h/ q3 U# [4 X/ N
  231. $ j: d1 n& a& M( h
  232. /**
    9 b1 F/ J% d, [0 c1 }, G
  233.   * @}: I( m. O- D5 T2 a0 |
  234.   */ 6 V; ]8 F5 {1 s' b% y8 o) |, v3 a
  235. ( X* M+ i# x8 S( n* y
  236. /** @defgroup RTC_Alarms_Definitions : x" P+ r8 I9 W  d' _& M& J
  237.   * @{
    : l) d3 L; V3 g7 h, z. o
  238.   */ $ m  @/ o) K# U
  239. #define RTC_Alarm_A                       ((uint32_t)0x00000100)
    4 Y! `* [4 t8 J
  240. #define RTC_Alarm_B                       ((uint32_t)0x00000200)
    ( U  B* U% i% \) v% b
  241. #define IS_RTC_ALARM(ALARM)     (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))  Z0 f; }6 t4 m
  242. #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)4 F% _1 A% o" W- O. h5 n$ [) I# g
  243. * D7 _5 T& h1 {& n' o. p
  244. /**
    7 P. h: m; B) ~' R8 f: L4 a! u5 e
  245.   * @}
    0 S3 E  ]  S$ s- {7 d% n
  246.   */
    ( c% }' V! s7 T3 m7 M9 l5 J4 I

  247. 3 a0 v$ X) D7 q8 [) w
  248.   /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions0 n6 Q$ J2 A( f
  249.   * @{
    / }! N7 n' R  {% y: J$ }
  250.   */ ) b! j- y$ f  _8 I! L) i
  251. #define RTC_AlarmSubSecondMask_All         ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
    & o/ O0 Q! v' [
  252.                                                                        There is no comparison on sub seconds
    4 ]5 T7 o- ?2 Z  r$ M5 f
  253.                                                                        for Alarm */
    9 g* W: O3 }& W& B8 ]1 z1 T4 s: X
  254. #define RTC_AlarmSubSecondMask_SS14_1      ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
    " B4 u5 ]5 A6 y5 F
  255.                                                                        comparison. Only SS[0] is compared. */
    * |1 Y/ }& S6 C" O) E6 z
  256. #define RTC_AlarmSubSecondMask_SS14_2      ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
    * L: [2 c, ]6 B' G& y- l! r3 c
  257.                                                                        comparison. Only SS[1:0] are compared */3 x3 i% t' _6 S2 a( T
  258. #define RTC_AlarmSubSecondMask_SS14_3      ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm 4 ]2 I/ ?- o. J8 g( H
  259.                                                                        comparison. Only SS[2:0] are compared */  z8 U- g+ K3 W. ~
  260. #define RTC_AlarmSubSecondMask_SS14_4      ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm ; Y1 x) L+ [8 c3 w# t! y
  261.                                                                        comparison. Only SS[3:0] are compared */% v- `. P  g0 p/ p
  262. #define RTC_AlarmSubSecondMask_SS14_5      ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm 8 e! ]6 h$ V1 Y7 p& G7 a
  263.                                                                        comparison. Only SS[4:0] are compared */
    " o3 a' _" G& {5 `4 J% O' W
  264. #define RTC_AlarmSubSecondMask_SS14_6      ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm # l% D9 e( @5 {, c# m
  265.                                                                        comparison. Only SS[5:0] are compared */% w0 D$ l0 t8 L9 ]- S" |' }/ B
  266. #define RTC_AlarmSubSecondMask_SS14_7      ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm . }$ X( ~8 `8 t9 G0 R$ A
  267.                                                                        comparison. Only SS[6:0] are compared */
    - H5 \+ a! f" {4 F/ b
  268. #define RTC_AlarmSubSecondMask_SS14_8      ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm 8 y8 q5 d) t2 o2 F
  269.                                                                        comparison. Only SS[7:0] are compared */
    - C, m, P) e6 r. W4 i1 y1 h; u
  270. #define RTC_AlarmSubSecondMask_SS14_9      ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm 4 T; x# T/ U+ B! f' J7 N- X  W0 w
  271.                                                                        comparison. Only SS[8:0] are compared */
    / z" j# L) f. Q3 Y8 [
  272. #define RTC_AlarmSubSecondMask_SS14_10     ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
    " p  W4 }4 L( e/ K8 x+ x3 ]! ~7 R6 n
  273.                                                                        comparison. Only SS[9:0] are compared */
    ( {" R& g9 j/ @2 p+ A" t8 y9 D
  274. #define RTC_AlarmSubSecondMask_SS14_11     ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm . P, \+ T! y7 _  ?
  275.                                                                        comparison. Only SS[10:0] are compared */
    . j2 y' x/ a3 Q* S
  276. #define RTC_AlarmSubSecondMask_SS14_12     ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm - y& H, z+ ?3 u% z3 P- _
  277.                                                                        comparison.Only SS[11:0] are compared */
    $ {  O* f3 k$ E
  278. #define RTC_AlarmSubSecondMask_SS14_13     ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
    / U% Q) ^+ O2 z" d9 s  h
  279.                                                                        comparison. Only SS[12:0] are compared */8 a$ U# I2 ^4 B7 v4 P
  280. #define RTC_AlarmSubSecondMask_SS14        ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
    - B4 k/ t, b) f7 T& g- a; W1 Q
  281.                                                                        comparison.Only SS[13:0] are compared */
    # {: G& o  A+ \: l# r) J
  282. #define RTC_AlarmSubSecondMask_None        ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match 1 B2 B8 s3 L9 F3 X7 E8 N# \; X) Q
  283.                                                                        to activate alarm. */
    % b. N5 K5 \. X2 E1 Y: g- N8 t$ S8 D/ Z
  284. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)   (((MASK) == RTC_AlarmSubSecondMask_All) || \* w7 H* I9 _  _" n- Z& ?2 ^
  285.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \
    ' j2 z" p1 D! D- e* M- U3 G! @
  286.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \
    , j" L$ V. V- [
  287.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \3 x$ N; e  s6 w! f+ B+ h
  288.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \! i* \% q5 e7 R; \( ^% u- E% A
  289.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \( I$ T* T! ~! H0 a
  290.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \: W: R: i( K- T- K/ p% L
  291.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \# r' }/ u; l# n
  292.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \6 z* g* t3 G8 }; B$ r+ \6 X
  293.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \# y0 B  U1 _; Q: g
  294.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \
    % A& F* G/ `3 ]& A& N& ?
  295.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \$ O& k3 G6 ~6 u9 L* t' r% y
  296.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \9 b3 J6 `4 j* B
  297.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \
    0 m9 x. `$ i7 F' V8 a2 W) K
  298.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14) || \. C% i# l3 f" [- b3 a, t3 j
  299.                                               ((MASK) == RTC_AlarmSubSecondMask_None))
    & r  T: H" z0 @  M
  300. /**
    1 a$ P* ~& m( ?4 a
  301.   * @}
    1 f0 z  W* l: y8 y& E
  302.   */ : _' p* {0 _; O) P

  303. 5 M7 Q( l& x$ L% O9 |" q
  304. /** @defgroup RTC_Alarm_Sub_Seconds_Value
    8 v2 M& n0 s6 J4 ~. C# n/ j, n
  305.   * @{
    7 h9 C0 }: _& W: m# s8 ]
  306.   */
    ( b( g. `! c+ T

  307. 7 C0 v) s6 E) Z/ N' f
  308. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF)& @+ W9 ~9 F" Y7 V% ]0 c

  309. ' C+ q" A2 a5 n5 F( T1 @7 s
  310. /**. S# p  b& S6 a2 d
  311.   * @}
    , c9 R$ }- K7 S3 @' P# n
  312.   */ : G' \$ d$ Z/ z7 E0 D, K
  313. % T' A4 S2 Z1 Y) z  t
  314. /** @defgroup RTC_Wakeup_Timer_Definitions 2 a, o  E" Q/ |
  315.   * @{& z0 F4 p+ s0 k% R: ^
  316.   */
    0 n* g4 j, u4 ^# v  g. j
  317. #define RTC_WakeUpClock_RTCCLK_Div16        ((uint32_t)0x00000000)
    4 W2 v) R, m5 H( ~% y3 S1 Y+ n% {- g
  318. #define RTC_WakeUpClock_RTCCLK_Div8         ((uint32_t)0x00000001)" t" C( G$ E1 T" M' X
  319. #define RTC_WakeUpClock_RTCCLK_Div4         ((uint32_t)0x00000002)
    5 Z7 ~+ p! F; X8 T% h3 R
  320. #define RTC_WakeUpClock_RTCCLK_Div2         ((uint32_t)0x00000003)6 G- ^# u) x5 i) K1 D; M) t; N
  321. #define RTC_WakeUpClock_CK_SPRE_16bits      ((uint32_t)0x00000004)6 I& [, S; F' `+ }- i( S
  322. #define RTC_WakeUpClock_CK_SPRE_17bits      ((uint32_t)0x00000006). x) `% Y) ^9 |3 X
  323. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
      ^8 p8 F) @. r5 \0 U
  324.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
    : |7 r' E, S3 ^, s
  325.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \/ f0 }! U* {7 {! |3 o! h5 U  ]
  326.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
    ; K7 _0 k/ Z( O3 u8 F0 Z- _. C4 W
  327.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \4 w9 z/ C1 M& ]8 F6 G* g5 p! A' n8 w1 L
  328.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits)): t1 ]: ~# V0 e2 ?8 ]" e
  329. #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFF)
      ^. v' D3 d0 l
  330. /**
    5 p$ @! U4 `. M. u% P
  331.   * @}6 k0 c& M& T9 \
  332.   */
    4 `) L2 b( k) ?" ?  g

  333. , R0 K& r# l) }) Z( F3 Z" O
  334. /** @defgroup RTC_Time_Stamp_Edges_definitions
    : U/ S8 C& k: N4 v+ _- h6 p
  335.   * @{
    3 b6 M) m2 n) D
  336.   */ 9 O5 l8 R* Z8 Z0 F7 U# T" b' V9 F$ c, O
  337. #define RTC_TimeStampEdge_Rising          ((uint32_t)0x00000000)" p8 T& g$ X' S7 k. N6 p; n' ?  R9 I
  338. #define RTC_TimeStampEdge_Falling         ((uint32_t)0x00000008)/ E9 T3 M9 v5 G1 Q2 L
  339. #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \. V* m6 E: w! ^+ j8 y3 W' h
  340.                                      ((EDGE) == RTC_TimeStampEdge_Falling))% @3 l* }9 W) z9 y
  341. /**
    ( O' d- W  h0 d( p0 C' S  f1 ]
  342.   * @}
    5 [2 l' P7 g3 A( C- S
  343.   */
    ( {4 W, X" X0 u9 H0 K
  344. ) X$ u& Q  g3 E( ~2 G; X7 A
  345. /** @defgroup RTC_Output_selection_Definitions
    / ]. D- @, s6 b3 k% e
  346.   * @{% m& m- ~; [+ i: D2 C
  347.   */ 4 [$ U6 x, F1 d& ~' b
  348. #define RTC_Output_Disable             ((uint32_t)0x00000000)' [* X' o5 l/ l; }# v  D$ a1 Z8 y
  349. #define RTC_Output_AlarmA              ((uint32_t)0x00200000); _3 q5 @/ |( q
  350. #define RTC_Output_AlarmB              ((uint32_t)0x00400000)8 z4 c* ~3 P' e0 W# k
  351. #define RTC_Output_WakeUp              ((uint32_t)0x00600000)
    ! C5 H6 ~* w0 W7 H9 H' G5 Z
  352. $ y- m5 S3 T5 ], R' \2 w: B2 q; B
  353. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \! n7 |1 K; W7 h& n" N1 N! p
  354.                                ((OUTPUT) == RTC_Output_AlarmA) || \# Y+ U, C$ }# e$ U6 Z. @
  355.                                ((OUTPUT) == RTC_Output_AlarmB) || \
    : E5 _+ @" L1 m/ e5 n: w
  356.                                ((OUTPUT) == RTC_Output_WakeUp))% @$ f* ?/ D. H( Z' m
  357. * H' B; e# O+ Y2 Y+ E9 z
  358. /**3 |) F# v) M$ S& j. B' ~
  359.   * @}
    / N+ C5 x8 p: v- A; h
  360.   */ 9 I) D: E7 G/ q4 f- j

  361. . @9 M0 j, F$ ^5 A* w9 _+ ]7 s* N
  362. /** @defgroup RTC_Output_Polarity_Definitions
    " o: ~2 t" R6 k; ?
  363.   * @{7 D! j5 x8 `  A1 l$ I# G
  364.   */ ! n% s9 F- W, S
  365. #define RTC_OutputPolarity_High           ((uint32_t)0x00000000)1 u4 }0 p# d' m; Z8 X
  366. #define RTC_OutputPolarity_Low            ((uint32_t)0x00100000)
    ' x1 S3 M( M# x# J* ]
  367. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \8 u1 e& h, a9 j! P
  368.                                 ((POL) == RTC_OutputPolarity_Low))0 \- D# `* `8 a0 o8 m2 u* M# ?2 u
  369. /**
    + [; r1 l: p) v2 Z% _. q: K
  370.   * @}
    8 r$ B/ L8 D6 Q. h- w" ?
  371.   */
    4 ^- i7 q( t1 K1 \0 H
  372. % ?) @& K5 a! D& D: H4 {! d: |6 X! z
  373. $ u: c* \: z8 @5 C& j. k* {2 j, f
  374. /** @defgroup RTC_Digital_Calibration_Definitions
    3 C; O/ p2 m3 K7 Q. `+ T
  375.   * @{
    ) |1 k, S9 {  J/ c
  376.   */
    ) X2 X* e3 k. H+ v. D: ?
  377. #define RTC_CalibSign_Positive            ((uint32_t)0x00000000)
    * S6 G- n" ]/ \3 y* |
  378. #define RTC_CalibSign_Negative            ((uint32_t)0x00000080)
    ' i( I" ]/ H  i  B! h0 A* q
  379. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
    # G; T/ {' J) c& o9 G7 _& l
  380.                                  ((SIGN) == RTC_CalibSign_Negative))) Z! i( e3 c: F
  381. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
    $ t1 ]0 B! ?& L9 g# D* S6 }- h

  382. 5 v8 J5 D7 q% k# |
  383. /**5 |6 C* c2 B. n, ]6 [" n7 D' \$ A
  384.   * @}
    ( d4 D* I: a4 K0 r4 l1 Q& W+ T* [8 N: [
  385.   */
    ' ^: z' N' I8 o$ g+ f8 `% ^
  386. 6 ]+ t6 N% N2 [( F
  387. /** @defgroup RTC_Calib_Output_selection_Definitions 9 v. J2 f. r7 Z' y/ @8 m) u! p
  388.   * @{( J( h1 b: N+ A# t
  389.   */ . Q+ [" r  J/ p# K% t" i
  390. #define RTC_CalibOutput_512Hz            ((uint32_t)0x00000000)
    % g, @$ Z  W: S! c
  391. #define RTC_CalibOutput_1Hz              ((uint32_t)0x00080000)2 g5 o+ t, A# r6 I0 g' w/ _) R
  392. #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CalibOutput_512Hz) || \
    ) D* @, R2 B9 W" o' e$ y" f
  393.                                       ((OUTPUT) == RTC_CalibOutput_1Hz))
    5 h" U2 ]; i; g$ E. X7 S: w
  394. /**" D8 R- f/ |' r+ A8 _4 q
  395.   * @}8 G  z' s! k$ t# D; J4 Z4 C7 T
  396.   */ " B& f% ]  s# ~7 n* ^& s

  397. . S8 S! A/ s( Z2 n5 B% U" {, g3 F
  398. /** @defgroup RTC_Smooth_calib_period_Definitions   o) G+ B; u' T
  399.   * @{
    5 A8 _" S4 w$ ^  F
  400.   */ , s9 R" h+ J! C5 D
  401. #define RTC_SmoothCalibPeriod_32sec   ((uint32_t)0x00000000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation+ i7 I& ?9 k. w0 P
  402.                                                              period is 32s,  else 2exp20 RTCCLK seconds */- h. C+ w! W+ F1 S; u
  403. #define RTC_SmoothCalibPeriod_16sec   ((uint32_t)0x00002000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
    % W5 G& M6 X$ r  F7 V7 j1 F4 m- h' C
  404.                                                              period is 16s, else 2exp19 RTCCLK seconds */
    : q' }, ?& s, `9 d
  405. #define RTC_SmoothCalibPeriod_8sec    ((uint32_t)0x00004000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation 3 M9 V6 j' b( ]5 \, o: w; B/ M) M
  406.                                                              period is 8s, else 2exp18 RTCCLK seconds */
    " h3 Z) T* c8 B: F- w" A
  407. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \- x9 n1 u. x) {
  408.                                              ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \
    5 O$ v5 d1 w% }4 W
  409.                                              ((PERIOD) == RTC_SmoothCalibPeriod_8sec))* O/ n6 W) [' s# T
  410. / @$ Y# x1 d: k
  411. /**
    3 I7 z6 z1 B$ @3 D9 t
  412.   * @}
    % r1 B2 e# g, H1 ?; ]
  413.   */
    ! r) y" ^" j8 ^" a2 A: h, _
  414. 8 j3 V2 [4 B- ~' b; h2 Y% f
  415. /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions ' U. ]( |! `3 O2 `, A; C+ A! N
  416.   * @{4 V0 t6 P! c+ s+ C
  417.   */ ! J) E6 M& Q1 M; N4 r
  418. #define RTC_SmoothCalibPlusPulses_Set    ((uint32_t)0x00008000) /*!<  The number of RTCCLK pulses added  
    9 D3 g1 T& q- @" h0 l8 {& R
  419.                                                                 during a X -second window = Y - CALM[8:0].
    $ s6 |- n9 v/ }7 ~4 z
  420.                                                                  with Y = 512, 256, 128 when X = 32, 16, 8 */
    . g$ O. ]; o/ a" H
  421. #define RTC_SmoothCalibPlusPulses_Reset  ((uint32_t)0x00000000) /*!<  The number of RTCCLK pulses subbstited
    ' N/ J, \+ S' j: e) F3 r2 a
  422.                                                                  during a 32-second window =   CALM[8:0]. */
    0 A" l2 [& ~& x, N0 X+ A* _
  423. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \( Z5 Z' ?& J; B: @
  424.                                          ((PLUS) == RTC_SmoothCalibPlusPulses_Reset)), ~- _9 J  ~4 w9 \" v
  425. : n" C4 o) C, m7 e& N7 i5 ]
  426. /**
    - h& H+ i! V: O1 q9 Y0 Y( D
  427.   * @}6 }/ B/ ^- `/ s/ q
  428.   */ + ~) G( t; Y% Y% X

  429. . @+ m, R; m( J2 c
  430. /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions 0 M4 R# p/ d" A$ |+ k8 @9 {
  431.   * @{3 p* d0 {* |5 {6 x' [
  432.   */
    + P/ t* W1 @& a; f: O- A
  433. #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)3 i+ u5 F- K8 F" f( ^& T
  434. ! M& @- R2 U1 h, c
  435. /**
    7 a* K" ?& k! B  c& z$ d/ Z
  436.   * @}( H2 n. a2 y$ ^
  437.   */% `7 ~3 n: E. ]- d2 q: B- M

  438. + q) N) g3 r# I# U1 R1 |
  439. /** @defgroup RTC_DayLightSaving_Definitions * l, M! @% a2 \
  440.   * @{# H9 l6 w7 G9 G$ t
  441.   */
    ; C& z: O6 u; d+ }2 V
  442. #define RTC_DayLightSaving_SUB1H   ((uint32_t)0x00020000), O3 l+ Q) w3 |
  443. #define RTC_DayLightSaving_ADD1H   ((uint32_t)0x00010000)% s) T, B( a' D1 l
  444. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
      B& C* r* Z- P
  445.                                       ((SAVE) == RTC_DayLightSaving_ADD1H))
    / `" v5 \  D* u- c4 O

  446. " h) C' \" g0 a: @# W+ c6 e
  447. #define RTC_StoreOperation_Reset        ((uint32_t)0x00000000)9 `& v( N2 R$ M. r" n: A' \
  448. #define RTC_StoreOperation_Set          ((uint32_t)0x00040000)
    ! I% Y1 ?+ K+ Y9 W2 A* H
  449. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \- E4 U4 |" N! p% `# ^
  450.                                            ((OPERATION) == RTC_StoreOperation_Set))
    / a% S2 I' W! o3 i# ~) X
  451. /**
    " J9 |9 |2 }3 j4 W. S  v
  452.   * @}
    - ?' B: N6 L6 r! J0 l7 d& `
  453.   */ ) q/ \5 c( m5 m) M5 O  B9 G! C7 S0 A

  454. 7 z" e; P' c* r' c. ^  J; \4 {: T
  455. /** @defgroup RTC_Tamper_Trigger_Definitions
    . O& T2 v# t8 K. Q
  456.   * @{4 u9 G: o% r: t2 h
  457.   */
    9 f  S9 @6 e* Y- k& _8 N: B) q) f5 h
  458. #define RTC_TamperTrigger_RisingEdge            ((uint32_t)0x00000000)
    4 d7 `3 z( h; ^& O6 P: y
  459. #define RTC_TamperTrigger_FallingEdge           ((uint32_t)0x00000001)
    7 X  X5 e: X( }) @0 ]. ~
  460. #define RTC_TamperTrigger_LowLevel              ((uint32_t)0x00000000)
    ' R1 L: C" V8 d3 s; A6 F' K6 X  I
  461. #define RTC_TamperTrigger_HighLevel             ((uint32_t)0x00000001)
    , }4 V8 h! m$ y0 P
  462. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \- I' ~) _8 H# T' S
  463.                                         ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \! i/ m0 r: {5 E5 o3 x
  464.                                         ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \( A  g$ f) U9 o3 y* D8 l' D# ], c
  465.                                         ((TRIGGER) == RTC_TamperTrigger_HighLevel))
    ) E" _6 g" e) u2 s

  466. + e: Y" _8 A5 K. S
  467. /**
    , M7 x" g. M) z! T
  468.   * @}
    2 F) l7 q# p: `9 t
  469.   */ : W4 \6 H  i1 Q& ~! H3 [2 k! s" _) Y* h
  470. + H0 U$ K& [( X, W$ O, \; ?* D
  471. /** @defgroup RTC_Tamper_Filter_Definitions ' @' W& z9 ^! \
  472.   * @{
    6 w3 d5 J& X# k; f5 {
  473.   */ 4 T! f  l5 E5 A0 o1 g3 f. P
  474. #define RTC_TamperFilter_Disable   ((uint32_t)0x00000000) /*!< Tamper filter is disabled *// {' m$ T, Y  \! x6 x* r
  475. 8 x2 W, t3 W5 \* M5 U- I
  476. #define RTC_TamperFilter_2Sample   ((uint32_t)0x00000800) /*!< Tamper is activated after 2
    * D' ]! o! k/ Q
  477.                                                           consecutive samples at the active level */
    4 {- y: o; o. z' _/ l
  478. #define RTC_TamperFilter_4Sample   ((uint32_t)0x00001000) /*!< Tamper is activated after 4
    ( B# w- I+ f( i9 J$ W5 k
  479.                                                           consecutive samples at the active level */
    : k  R3 t$ I4 _0 ?, T8 {0 b
  480. #define RTC_TamperFilter_8Sample   ((uint32_t)0x00001800) /*!< Tamper is activated after 8
    2 g, c1 L& X$ R$ [/ e: X
  481.                                                           consecutive samples at the active leve. */
    8 S3 o9 b9 C% g/ u. P
  482. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \
    . z4 K7 J: P4 K! a4 `$ d, r
  483.                                       ((FILTER) == RTC_TamperFilter_2Sample) || \
    # {; e( ]! m. ~+ E
  484.                                       ((FILTER) == RTC_TamperFilter_4Sample) || \  n' P' I) d4 ^' N
  485.                                       ((FILTER) == RTC_TamperFilter_8Sample))+ ^7 M* y, y4 w5 |7 ]& N/ m7 x
  486. /*** C) Y+ O% T! E, g. K) c9 T
  487.   * @}
    * o2 R2 F5 a( L* _7 m" j: x
  488.   */
    4 J3 Q( S* G- [. @

  489. - |2 F+ H/ ~( f" ]; Z" {. q
  490. /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions , S" x, }, ]4 M' A5 q+ X1 k& p( o
  491.   * @{
    8 @/ `0 l6 [( q
  492.   */
    . w6 P) |  f$ L; _" G6 z3 u, r
  493. #define RTC_TamperSamplingFreq_RTCCLK_Div32768  ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled" q: Y% v3 m; n: _
  494.                                                                            with a frequency =  RTCCLK / 32768 */
    , Z# T; W  n0 B& v2 j7 X
  495. #define RTC_TamperSamplingFreq_RTCCLK_Div16384  ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled: `1 L3 V9 e2 H9 |. u5 W, G
  496.                                                                             with a frequency =  RTCCLK / 16384 */
    0 L+ r6 Q5 P2 a0 \; l. \
  497. #define RTC_TamperSamplingFreq_RTCCLK_Div8192   ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled+ V& Y6 I* B2 B4 i$ ~8 e9 S/ S
  498.                                                                            with a frequency =  RTCCLK / 8192  */
    6 Q% c" P2 {$ v; a9 U- R7 r
  499. #define RTC_TamperSamplingFreq_RTCCLK_Div4096   ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled" [9 l! ^# X. N) N- w- t* |
  500.                                                                            with a frequency =  RTCCLK / 4096  */
    7 {9 ^: X1 I) w0 n, N" u8 C# H& g
  501. #define RTC_TamperSamplingFreq_RTCCLK_Div2048   ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled5 a% Z* @* _& i* P0 u& Z1 U
  502.                                                                            with a frequency =  RTCCLK / 2048  */
    % `" j+ V$ o( ?! R3 X; \
  503. #define RTC_TamperSamplingFreq_RTCCLK_Div1024   ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled% d, a8 e  x' h) S
  504.                                                                            with a frequency =  RTCCLK / 1024  */
    4 |) V- z" m3 ]! S
  505. #define RTC_TamperSamplingFreq_RTCCLK_Div512    ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled6 f  f: Z( [8 g4 d8 E
  506.                                                                            with a frequency =  RTCCLK / 512   */) g7 e; r& m$ U- n8 b- D
  507. #define RTC_TamperSamplingFreq_RTCCLK_Div256    ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled5 o( Q. P- g  q7 ~) D% i7 l6 D
  508.                                                                            with a frequency =  RTCCLK / 256   */
    1 O; @. J1 _* n
  509. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \1 ?) |9 Y: c6 s. @* ]
  510.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \1 U& w6 b' L7 j6 c6 n; Y! P
  511.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \  Z  y  W5 }& k  _; Z
  512.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \5 G  O( d: Q6 _8 U
  513.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \
    - ~; U- u  F! z+ N
  514.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \6 ?3 @" ^8 V1 I9 R* u; U5 N
  515.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \( w, i3 t, E; e. J+ A) @2 G
  516.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256))/ X, H4 }0 K2 w. Z

  517. ! S5 V) k2 e" u- l  a! l
  518. /**
    3 j5 N9 O( t" I, G' M+ w
  519.   * @}2 m/ e$ }, Q  @$ v2 }/ n
  520.   */
    3 O! P; p3 p; ^! O- s2 B% H
  521. 0 X8 K- q5 k3 T
  522.   /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions ! u( s$ W2 C- i3 ^( u; O* |
  523.   * @{
    9 P8 C6 e" [/ e! L$ |0 I# B3 Q
  524.   */ # o0 m8 }, i- i. K. K
  525. #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before   R: E! r& k! N  \: ]; [% J
  526.                                                                          sampling during 1 RTCCLK cycle */3 h$ Z9 s: Z# B) Y' m1 j
  527. #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000)  /*!< Tamper pins are pre-charged before 0 ]9 B3 n) ^! G- g3 l5 a
  528.                                                                          sampling during 2 RTCCLK cycles */4 u$ z  _, `6 L
  529. #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000)  /*!< Tamper pins are pre-charged before
    7 b4 M  M1 n/ ]* }; d! r. n
  530.                                                                          sampling during 4 RTCCLK cycles */' }. `3 J$ q% U; w
  531. #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000)  /*!< Tamper pins are pre-charged before ' P; q' T1 z( q4 x
  532.                                                                          sampling during 8 RTCCLK cycles */- `5 y2 N1 d: U: s% i
  533. 6 ?" _- P1 [0 k
  534. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \) L) a1 M. R; a1 H
  535.                                                     ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \' n+ M/ t2 u5 R$ _: y4 K% H
  536.                                                     ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \. G, l2 M; L; E4 k, \5 ~) `
  537.                                                     ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK))
      |8 x5 B8 M* J7 C7 T: j
  538. /**2 P2 [/ D0 ?& y- w* {' Z
  539.   * @}& K# u% ?( D& W0 N
  540.   */
    4 y: @* g$ E: i" L5 i, K$ X

  541. # d7 Q# O/ `# m  E" `, J( s
  542. /** @defgroup RTC_Tamper_Pins_Definitions . s' a% Q% U/ o8 t! Z
  543.   * @{
    $ ]3 H* i- m9 x5 M" F" w
  544.   */
    1 F) ~1 N; b; [( g, s8 f
  545. #define RTC_Tamper_1                    RTC_TAFCR_TAMP1E) Z; B* V* y( |( S: F* h
  546. #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))
    / }5 [$ X+ k, c( f4 R# t7 T, |9 x9 ]& |

  547. 9 r$ D* a0 l+ Y* D
  548. /**
    * d( z& z) ~3 y+ `6 a
  549.   * @}, K, K- [. Z5 j" [# w
  550.   */9 Z0 i7 t. r( ]* I0 }' q
  551. 6 T% z& G0 S! ^7 X  E, F
  552. /** @defgroup RTC_Tamper_Pin_Selection # K7 x' d; X7 Q5 ?! ~2 v
  553.   * @{
    4 M/ T! u9 b% |+ U
  554.   */ 3 L" o% c- ^4 A0 g: w
  555. #define RTC_TamperPin_PC13                 ((uint32_t)0x00000000)5 H3 A* Q7 v0 z- s6 H% @: G4 T" H. n
  556. #define RTC_TamperPin_PI8                  ((uint32_t)0x00010000)9 m! @; B$ G+ i) `% f( i( u
  557. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \, e5 B' U5 z% p+ Z/ a) A
  558.                                 ((PIN) == RTC_TamperPin_PI8))# _* }8 Q4 H+ D) w. x
  559. /**
    , U8 @) X: o: U; c' C8 Q
  560.   * @}
    & U+ P5 f+ X9 q: Q
  561.   */
    & n+ y2 h$ f4 j4 Y, I% Q" z

  562. ( n# T! h; b% _. Y7 N7 V$ W
  563. /** @defgroup RTC_TimeStamp_Pin_Selection ( @0 @( d( e" o1 O3 g+ Q
  564.   * @{
    6 r$ t$ b! m% j0 D% v% j4 ]$ k
  565.   */
    9 v" j! j8 {. s+ Z
  566. #define RTC_TimeStampPin_PC13              ((uint32_t)0x00000000)$ R1 a( Q" y6 w9 n; h
  567. #define RTC_TimeStampPin_PI8               ((uint32_t)0x00020000)0 o8 F8 j6 Q+ [1 a( ?+ R$ w3 v2 t7 I: V
  568. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
    ! @5 G6 T3 n" Y  I7 K
  569.                                    ((PIN) == RTC_TimeStampPin_PI8))
    ' Z; w9 z$ V/ W7 Z9 B
  570. /**' _1 R' K: I; C" T+ U, j% S( T& H
  571.   * @}. H. `' Y' ]8 ^# Q' Z
  572.   */ ; B: C/ V/ [8 X- R8 c
  573. 6 X, v6 y) J8 J& m
  574. /** @defgroup RTC_Output_Type_ALARM_OUT
    2 E& y, g: ~6 {" j3 V' ?" P
  575.   * @{- m7 T3 z4 C- Q: Y- i/ ?* i
  576.   */ 7 D1 g# t# n1 [* c1 o4 |* O2 ]( z/ W
  577. #define RTC_OutputType_OpenDrain           ((uint32_t)0x00000000)
    ( G) y3 j& P% w: S8 H: e
  578. #define RTC_OutputType_PushPull            ((uint32_t)0x00040000)
    ; Y7 u' |* [5 x6 X
  579. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \4 u# b6 p, W4 ~$ u0 C6 e+ G, d) D, N+ Y
  580.                                   ((TYPE) == RTC_OutputType_PushPull)); R. k! @9 j6 L

  581. / W* }( g+ L/ Y2 M' d& O
  582. /**2 t' Z$ S- v( g6 X( Z2 {& Y
  583.   * @}
    : j1 }5 W& L) Y7 K  h
  584.   */
    5 @( v, e) Y( }0 X9 U0 U* J

  585. 0 e! ?9 \4 O+ o* l& _
  586. /** @defgroup RTC_Add_1_Second_Parameter_Definitions
    & \  V; |4 f: d
  587.   * @{1 b, T7 ?- S' t8 H: |  Z6 z
  588.   */
    : W: r9 D, \# ]& b
  589. #define RTC_ShiftAdd1S_Reset      ((uint32_t)0x00000000)' D/ }& g2 Q8 V
  590. #define RTC_ShiftAdd1S_Set        ((uint32_t)0x80000000)5 Z2 |! W" X0 P2 E/ L' z
  591. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \$ {- ?" m7 D$ G
  592.                                  ((SEL) == RTC_ShiftAdd1S_Set))
    , h6 a* E" \+ @9 r6 s! n4 t$ m
  593. /**4 e: H. u/ P1 E2 }$ b& z
  594.   * @}$ c: i- R$ Z. r8 |$ J7 ~
  595.   */
    % Z5 g0 d0 s5 z

  596. , y, }) U; \% M
  597. /** @defgroup RTC_Substract_Fraction_Of_Second_Value2 G9 ]* }0 _, [* P
  598.   * @{4 z# C3 F6 O' x* ^7 B( |- f; ?+ K
  599.   */
    ( c+ Y3 j- z% \" t! |
  600. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)% @" a3 _7 Y) L

  601. $ x9 h( B2 V' u0 @: D9 L, I2 u: g
  602. /**# H  ~# Q5 U5 s) a* y6 a$ L3 R
  603.   * @}" v* d6 W7 E% y" D6 \, C
  604.   */  v! R) w2 e; h6 u2 w6 y  r$ y% E

  605. ' B+ @; z9 n9 |  ?8 z
  606. /** @defgroup RTC_Backup_Registers_Definitions 5 V  C* M1 @' @
  607.   * @{$ l  j( T: G! v
  608.   */4 k( i; _7 j0 X8 B

  609. $ g3 o, u; }6 i
  610. #define RTC_BKP_DR0                       ((uint32_t)0x00000000)+ J! }7 e. b& s) J) x" X* n
  611. #define RTC_BKP_DR1                       ((uint32_t)0x00000001)1 u0 M1 ~# o  l7 V! P
  612. #define RTC_BKP_DR2                       ((uint32_t)0x00000002)
    " l% O1 f: {, `! G4 G7 s
  613. #define RTC_BKP_DR3                       ((uint32_t)0x00000003)
    ! e( F) U4 q# z  Q1 `6 w
  614. #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
    3 F( S- W: M/ |/ g( ~
  615. #define RTC_BKP_DR5                       ((uint32_t)0x00000005)5 W5 W+ l2 ]9 y4 D+ q2 Q
  616. #define RTC_BKP_DR6                       ((uint32_t)0x00000006)
    : ], @& d8 ]. b1 [+ T
  617. #define RTC_BKP_DR7                       ((uint32_t)0x00000007)
    * X6 M  ]; k/ ]9 D4 q; o; ?/ A
  618. #define RTC_BKP_DR8                       ((uint32_t)0x00000008)
    ! |( k% I" C; w0 z; N
  619. #define RTC_BKP_DR9                       ((uint32_t)0x00000009)
    , j: j" v& C+ i" `& w, y+ M! _
  620. #define RTC_BKP_DR10                      ((uint32_t)0x0000000A)( Y* V6 K, J. a  z0 G" r7 [
  621. #define RTC_BKP_DR11                      ((uint32_t)0x0000000B)
    0 D6 }0 e! }, ]! t! K
  622. #define RTC_BKP_DR12                      ((uint32_t)0x0000000C)7 X* f3 w' K, x* b. r8 G1 \
  623. #define RTC_BKP_DR13                      ((uint32_t)0x0000000D)
    * D& v, [$ Z( H4 Y0 W: l
  624. #define RTC_BKP_DR14                      ((uint32_t)0x0000000E)
    # [1 L, W' K8 F1 a5 L
  625. #define RTC_BKP_DR15                      ((uint32_t)0x0000000F)
    6 x* X9 j4 a/ ?/ i3 V
  626. #define RTC_BKP_DR16                      ((uint32_t)0x00000010)# ~& v7 A4 q" C! g% R
  627. #define RTC_BKP_DR17                      ((uint32_t)0x00000011)9 j& {' k/ O% c1 P
  628. #define RTC_BKP_DR18                      ((uint32_t)0x00000012)
    0 C$ c5 e# P/ P3 `0 |  r
  629. #define RTC_BKP_DR19                      ((uint32_t)0x00000013)
    7 `8 W$ T& M' C. M- ^. F
  630. #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0) || \' i2 }! e: I& h) ?( i0 _4 i: X" @
  631.                                            ((BKP) == RTC_BKP_DR1) || \. Z% Y9 x; U% W
  632.                                            ((BKP) == RTC_BKP_DR2) || \
    1 b+ D+ G0 ~" j1 w: j* b( u5 h
  633.                                            ((BKP) == RTC_BKP_DR3) || \
    : b- K5 ]& v, v$ B/ e
  634.                                            ((BKP) == RTC_BKP_DR4) || \
    0 k% U; k3 u, a+ o  z7 Q9 l
  635.                                            ((BKP) == RTC_BKP_DR5) || \7 Y* n5 z) k3 {% c* |! ~/ ~( k3 ?
  636.                                            ((BKP) == RTC_BKP_DR6) || \
    . @3 S  Q3 S$ C
  637.                                            ((BKP) == RTC_BKP_DR7) || \
    ' t1 O+ {* n- X6 r+ F$ l& \, l1 ?" X$ X
  638.                                            ((BKP) == RTC_BKP_DR8) || \7 u! {. _9 p# j. @/ X5 J- O6 Z: R
  639.                                            ((BKP) == RTC_BKP_DR9) || \
    2 s8 p4 N2 |5 }4 w( R' z$ h
  640.                                            ((BKP) == RTC_BKP_DR10) || \% S* H* D% d; _2 i
  641.                                            ((BKP) == RTC_BKP_DR11) || \# o5 i1 I1 ]$ {; l
  642.                                            ((BKP) == RTC_BKP_DR12) || \7 ?: X$ X. O  \1 i, d
  643.                                            ((BKP) == RTC_BKP_DR13) || \
    4 i5 [4 ?6 ?) O3 l& z
  644.                                            ((BKP) == RTC_BKP_DR14) || \
    4 m# Q2 n7 S" h, E- _$ h
  645.                                            ((BKP) == RTC_BKP_DR15) || \) D& Z" k3 u1 Y4 \. b9 z
  646.                                            ((BKP) == RTC_BKP_DR16) || \8 y% M' v0 L5 b
  647.                                            ((BKP) == RTC_BKP_DR17) || \
    4 v5 A+ r. d0 l) X- c& {. l
  648.                                            ((BKP) == RTC_BKP_DR18) || \; x% |4 d3 O3 f9 E% o
  649.                                            ((BKP) == RTC_BKP_DR19))5 O+ {4 D9 E  ?9 Z4 @9 c% {5 ~7 c
  650. /**/ ~  o% w7 R/ d
  651.   * @}
      E# g( S7 A' d3 O# {5 h
  652.   */
    7 C; P3 l! o) W, b" M

  653. , x0 Q5 ^. Y; t& O
  654. /** @defgroup RTC_Input_parameter_format_definitions 6 q8 l; X( M2 G) }' ~
  655.   * @{
    & u+ u. `1 s% T; Z
  656.   */ ) F5 a5 C& M$ q
  657. #define RTC_Format_BIN                    ((uint32_t)0x000000000)
    4 x% L8 |( p* g, W: U: g
  658. #define RTC_Format_BCD                    ((uint32_t)0x000000001)0 i5 V9 x! i- X% A0 T' Q/ M" d6 B
  659. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))) U4 w6 {/ B% i" e6 q
  660. 2 ~' [" Z; o- k4 Z# O% g
  661. /**
    % P0 p; k3 s9 W& |- Y
  662.   * @}+ y# V0 P2 K9 _+ r$ m1 q: f" S
  663.   */
    9 X7 Q0 P8 A* |' U7 \/ w4 Q& H; F
  664. 0 ?; a4 @& W3 H+ f; \* V1 T# K
  665. /** @defgroup RTC_Flags_Definitions , ?& D9 c5 {( H% _1 H7 Z
  666.   * @{
    . B5 z, K  S: y8 S1 x% f
  667.   */
    * l$ w% {, h1 u' v  x
  668. #define RTC_FLAG_RECALPF                  ((uint32_t)0x00010000)4 f! J8 B2 Q- w  z
  669. #define RTC_FLAG_TAMP1F                   ((uint32_t)0x00002000)
    7 Q. _+ M* I# e! u6 Y  P
  670. #define RTC_FLAG_TSOVF                    ((uint32_t)0x00001000)  K$ V; b! |% |; w2 J$ o
  671. #define RTC_FLAG_TSF                      ((uint32_t)0x00000800)
    0 s+ H% |5 `0 c9 `0 B
  672. #define RTC_FLAG_WUTF                     ((uint32_t)0x00000400)$ L* t+ T- \" ~5 `- L
  673. #define RTC_FLAG_ALRBF                    ((uint32_t)0x00000200)8 [5 F- N7 @  S# J
  674. #define RTC_FLAG_ALRAF                    ((uint32_t)0x00000100)+ z5 P/ f3 W- w' `; {5 `
  675. #define RTC_FLAG_INITF                    ((uint32_t)0x00000040)* F5 s5 E) I+ h& [
  676. #define RTC_FLAG_RSF                      ((uint32_t)0x00000020)0 T% M7 U4 y' Q: m
  677. #define RTC_FLAG_INITS                    ((uint32_t)0x00000010)
    - C1 D4 j) c2 B$ d! ]1 \
  678. #define RTC_FLAG_SHPF                     ((uint32_t)0x00000008)
    ( ?2 _3 R" w/ c) I5 c1 z* [
  679. #define RTC_FLAG_WUTWF                    ((uint32_t)0x00000004)
    - L3 e5 g6 d4 k3 g  M  G
  680. #define RTC_FLAG_ALRBWF                   ((uint32_t)0x00000002)
    $ V5 \# n0 S3 B' w
  681. #define RTC_FLAG_ALRAWF                   ((uint32_t)0x00000001)* K' n7 d* {& h$ R
  682. #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \6 ~: R! b# E4 w9 z7 J
  683.                                ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \& f' d8 {5 _, I5 N4 v2 I' e* @
  684.                                ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \9 E  v+ z  A& v) l0 a+ {" G
  685.                                ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \& I/ ]. o# G1 e4 L. I) x: D
  686.                                ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \$ ~" r7 Y. e- @$ P0 K
  687.                                ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_RECALPF) || \7 F! s5 Z# Z2 @
  688.                                 ((FLAG) == RTC_FLAG_SHPF))
    2 q. b7 Q( g5 s1 v. o7 B
  689. #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET))
    6 J( P6 u' q- V+ U' y
  690. /**) M" r! ]- F' e7 H/ a/ \: C
  691.   * @}' ?) e/ m1 w2 M, I
  692.   */ 1 C8 b" R6 A! y; N  e

  693. ) a! Y1 d8 O3 l  |3 d: @/ o
  694. /** @defgroup RTC_Interrupts_Definitions
    1 B; x$ E3 K4 ?+ {' f
  695.   * @{- ~3 L) d6 G5 a+ j9 O) E/ l) V) `* b
  696.   */ $ c# v  e: s8 W8 N" w& e9 [
  697. #define RTC_IT_TS                         ((uint32_t)0x00008000)
    4 \# I: S, O6 e- ~
  698. #define RTC_IT_WUT                        ((uint32_t)0x00004000)
    1 e$ V( @& i' s* C9 X2 v
  699. #define RTC_IT_ALRB                       ((uint32_t)0x00002000)2 V. X7 g/ X' d
  700. #define RTC_IT_ALRA                       ((uint32_t)0x00001000)7 v. R! O4 P5 B7 ?4 N+ J& |
  701. #define RTC_IT_TAMP                       ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */
    6 w( Z6 P; z/ |2 z+ I, L+ X
  702. #define RTC_IT_TAMP1                      ((uint32_t)0x00020000)
    $ {  J' N1 l# M* U
  703. * S2 F, @  U" N9 u( C5 H
  704. #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))/ `% L* F$ T  R5 C0 c& G
  705. #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \" U% W* x4 }9 ~5 c! l  _5 t
  706.                            ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \. P' n9 r# ~" m6 ?0 h
  707.                            ((IT) == RTC_IT_TAMP1))
    % L# k. ]4 E& v# O# ^# J0 Z* @. y
  708. #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))$ [/ b* s1 ~3 k$ L# }# }

  709. # j" }# W' u: O3 A
  710. /**
    ' h. o1 u7 x$ V; u
  711.   * @}+ e& c4 N+ R8 f' G' u) J1 t
  712.   */ % W& j* F2 ^) ^% f( R5 ^! h' S
  713. . _/ Y$ y! u# h
  714. /** @defgroup RTC_Legacy 0 S# ]# b2 t' ^- J, \$ r
  715.   * @{
    ! e8 d: i" A4 z  @2 C
  716.   */ : }+ G9 i- D7 k( d
  717. #define RTC_DigitalCalibConfig  RTC_CoarseCalibConfig
    " q, P( T  k1 n6 M; P9 S
  718. #define RTC_DigitalCalibCmd     RTC_CoarseCalibCmd
复制代码

/ B8 \+ X5 q, Y6 l# H9 `03. 相关函数  |: V- E& L" d9 }5 E5 U
  1. /*  Function used to set the RTC configuration to the default reset state *****/& K* ]* v9 i7 x6 r4 C& x
  2. ErrorStatus RTC_DeInit(void);2 c/ y/ Z3 L% ~0 ?

  3. 2 ?" T9 @' u( Q& C
  4. /* Initialization and Configuration functions *********************************/
    6 D, j5 C: N3 D- k, _: G" l
  5. ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);9 Z' b+ P/ E7 W
  6. void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);9 a! a! ?: A* ?; s$ S
  7. void RTC_WriteProtectionCmd(FunctionalState NewState);/ J7 }# [9 A) `5 @* R5 P3 d% N6 W
  8. ErrorStatus RTC_EnterInitMode(void);
    5 \) o3 f% k' p1 n' y* W% a/ y5 V  e7 I
  9. void RTC_ExitInitMode(void);7 ~. `5 h) T$ O( p# M! n" N$ _' R
  10. ErrorStatus RTC_WaitForSynchro(void);. F. l5 A$ H( c4 ^; A1 C
  11. ErrorStatus RTC_RefClockCmd(FunctionalState NewState);1 z: w- B; f, m: l9 @9 X! q
  12. void RTC_BypassShadowCmd(FunctionalState NewState);
    + b% d0 W6 f. ]  q$ Z/ q* o( M! C! q

  13. & o. Y; S3 B( G. Z; ?* o
  14. /* Time and Date configuration functions **************************************/6 n2 ^/ G( S( r" |4 b& b
  15. ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
    ' @; p9 V1 |+ ?0 C6 H
  16. void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);7 R# m- W* p+ x5 R( ^( f
  17. void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);- g- Z  e2 h0 E
  18. uint32_t RTC_GetSubSecond(void);! z- i$ c& a- o% S3 s+ t
  19. ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);& N# b* ^, p2 [8 q- r7 e
  20. void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);
    5 N8 `, Z# O" O- Y$ X
  21. void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
    % _; {, ^2 D# \0 K; {& F

  22. , [) a4 f3 e0 r% q8 h% n
  23. /* Alarms (Alarm A and Alarm B) configuration functions  **********************/
    ) T# N3 b* ?: D/ g! p( [
  24. void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
    3 l: L- C& j+ g) \, p
  25. void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);; H( K0 k1 f' t* x
  26. void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
    # t; ]2 G! ]$ m$ P2 N) I
  27. ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);, b! U) q: r) Y; y7 ~* ~
  28. void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask);
    4 \  `# n5 E& a  T
  29. uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm);, e& }2 F/ o6 u3 E7 z) E: B- G

  30. ; D% p  @1 c) a& ?2 y+ b" c
  31. /* WakeUp Timer configuration functions ***************************************/" k9 |# t. i5 t) M
  32. void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);  a) |& ~6 E- F3 v; `; l" o
  33. void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);5 M  ~+ g, U* ^5 @% G
  34. uint32_t RTC_GetWakeUpCounter(void);
    / w, X! V7 C6 S+ E# I( p
  35. ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);0 ~8 t6 R2 d- m& ]- \2 X; c" F
  36. ) q8 V0 @) ^+ o1 k+ i, k/ b) }7 e
  37. /* Daylight Saving configuration functions ************************************// k" e: n$ h: X2 V! V
  38. void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);. t1 B: U% q: Y) G" d& G/ D2 C
  39. uint32_t RTC_GetStoreOperation(void);# u$ f+ Q8 X+ B) u5 t7 u' K, I
  40. . W6 ^9 p8 f9 m3 E
  41. /* Output pin Configuration function ******************************************/6 C3 f& H% K' q
  42. void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);5 V0 |' D1 r3 r" S8 K* U/ |) O
  43. - p2 @' ^+ T3 F/ I9 T$ J& K0 x
  44. /* Digital Calibration configuration functions *********************************/1 }3 X9 H% }5 m9 }4 {2 k
  45. ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);$ W" R+ b+ v1 y( C
  46. ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);
    / a' O: b/ r% n( a; i
  47. void RTC_CalibOutputCmd(FunctionalState NewState);
    $ ^  }  T! v; w9 W" w1 P7 R4 Y
  48. void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput);/ Y0 H( i' c' Q7 m" `* o" x
  49. ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
    5 \' A, V4 y+ v/ _
  50.                                   uint32_t RTC_SmoothCalibPlusPulses,
    8 M! X+ I0 `0 s
  51.                                   uint32_t RTC_SmouthCalibMinusPulsesValue);
    ! e7 u% c0 q( N- G3 `% T; v

  52. ( r: u- V. J5 Q! E/ ?4 t6 s1 [
  53. /* TimeStamp configuration functions ******************************************/* o, E8 E' f8 t8 D0 C1 m/ ~
  54. void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);
    ! \! V! |) ^) Z3 {' [! v5 i) @
  55. void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct," i8 {( A4 a2 y. E9 N
  56.                                       RTC_DateTypeDef* RTC_StampDateStruct);
      ~  `! m( B8 U* t0 B+ F4 t
  57. uint32_t RTC_GetTimeStampSubSecond(void);
    4 M9 r6 P: Q" S- ]+ n- `
  58. % \7 _# R1 W5 g
  59. /* Tampers configuration functions ********************************************/, r. V: u0 ~& p7 j
  60. void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);/ a4 v' f# ]# t* @; m3 \! p
  61. void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);( i' f) g7 D2 a9 o- `
  62. void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter);
    . E% Q! [( c6 ?2 M/ z+ J- ^1 G
  63. void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq);
    ' f4 s; _+ [3 b6 E- X& s
  64. void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration);
    - o  X5 A5 a  n- P* h' w
  65. void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState);
    3 g# P, e5 W6 l# ?! P4 C
  66. void RTC_TamperPullUpCmd(FunctionalState NewState);
    - v* P1 I6 i8 k8 H" i) n

  67. ) ]. @# m" g! T& Q% x6 e: p2 N7 F: v
  68. /* Backup Data Registers configuration functions ******************************/! d  ]3 R4 V, p, W) r* S
  69. void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
    0 Z$ S9 H3 G( t; Y' ]! j- E$ c
  70. uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
    & m* x( |/ V& K* I) s
  71.   j5 b* F6 N6 }: E$ q( {8 \4 T
  72. /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration- H1 U# O" Z/ l+ f
  73.    functions ******************************************************************/
    8 {3 ]( u. e, S" g6 n8 z( g
  74. void RTC_TamperPinSelection(uint32_t RTC_TamperPin);
    5 a" U4 [3 O# R, z: Y
  75. void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);0 r" s4 w" _4 S$ _
  76. void RTC_OutputTypeConfig(uint32_t RTC_OutputType);1 A8 n8 c/ J/ d- b% t2 H
  77. 7 Q/ e1 u/ G: @" F) J. \
  78. /* RTC_Shift_control_synchonisation_functions *********************************/* l: u* h: {+ m5 k
  79. ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS);
    5 @& I. s5 T' ?0 U% e0 ^
  80. 4 W5 y/ C! |0 Y. i
  81. /* Interrupts and flags management functions **********************************/5 o+ B: x6 r' ^; P, v( `
  82. void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);
    + D4 V8 j/ D; o! s) Z# N
  83. FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);
    ; D% v) g% e( F  G1 P
  84. void RTC_ClearFlag(uint32_t RTC_FLAG);
    4 u* r* _! B6 ~& m
  85. ITStatus RTC_GetITStatus(uint32_t RTC_IT);
    " D& z" w: T) ]* S- \1 h8 v8 p
  86. void RTC_ClearITPendingBit(uint32_t RTC_IT);
复制代码

2 y! s# t; w/ a, r/ l04. 结构体封装& Q& L( D* y  k: ?' L% @
  1. /** " `& G) C# Y2 P# j3 m: C( j3 a
  2.   * @brief Real-Time Clock
    : |2 s0 ^( R* o! a$ h
  3.   */
    - N8 A2 _$ ^$ u4 o- p" C- m, [
  4. 0 N3 I/ s" @8 `& h  N! Q
  5. typedef struct1 [% }( }% k7 r' Q7 @* f
  6. {
    - R0 p/ y' y4 m. \* j$ _
  7.   __IO uint32_t TR;      /*!< RTC time register,                                        Address offset: 0x00 */5 m/ ?5 O( Q& d$ ]' @
  8.   __IO uint32_t DR;      /*!< RTC date register,                                        Address offset: 0x04 */
    , v6 j9 ?/ l4 D% L
  9.   __IO uint32_t CR;      /*!< RTC control register,                                     Address offset: 0x08 */+ n) h' ?3 [0 T9 S
  10.   __IO uint32_t ISR;     /*!< RTC initialization and status register,                   Address offset: 0x0C */
    5 N6 @8 u& _2 ?% n7 z
  11.   __IO uint32_t PRER;    /*!< RTC prescaler register,                                   Address offset: 0x10 */* X& o5 V: N4 J2 @. e* c+ m
  12.   __IO uint32_t WUTR;    /*!< RTC wakeup timer register,                                Address offset: 0x14 *// n1 K, ]3 C* I  t9 d* Q
  13.   __IO uint32_t CALIBR;  /*!< RTC calibration register,                                 Address offset: 0x18 */# j; A% q$ R' k- @6 f! t
  14.   __IO uint32_t ALRMAR;  /*!< RTC alarm A register,                                     Address offset: 0x1C */
    0 k. ?, h+ Z" I4 C6 Q
  15.   __IO uint32_t ALRMBR;  /*!< RTC alarm B register,                                     Address offset: 0x20 */
    # P. h  b- \. z1 w% K. [$ W5 k
  16.   __IO uint32_t WPR;     /*!< RTC write protection register,                            Address offset: 0x24 */
    $ K. k7 e# @% {9 k6 G: z
  17.   __IO uint32_t SSR;     /*!< RTC sub second register,                                  Address offset: 0x28 */3 X: n; \. \5 ^! P* H1 E
  18.   __IO uint32_t SHIFTR;  /*!< RTC shift control register,                               Address offset: 0x2C */+ G  M0 f5 Z4 o1 |# @5 a0 J
  19.   __IO uint32_t TSTR;    /*!< RTC time stamp time register,                             Address offset: 0x30 */
    8 E5 j/ d+ @6 c2 l- u
  20.   __IO uint32_t TSDR;    /*!< RTC time stamp date register,                             Address offset: 0x34 */
    1 H+ n( V% [* v& o
  21.   __IO uint32_t TSSSR;   /*!< RTC time-stamp sub second register,                       Address offset: 0x38 */
    , D' K$ ^1 C9 ^( U2 A
  22.   __IO uint32_t CALR;    /*!< RTC calibration register,                                 Address offset: 0x3C */$ u6 r9 _& a) [6 L8 k0 n4 J8 P: ~% G4 t
  23.   __IO uint32_t TAFCR;   /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */  A4 f% G, @* t2 A; d
  24.   __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register,                          Address offset: 0x44 */
    ' }6 x7 k1 R# Z- |" r# H
  25.   __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register,                          Address offset: 0x48 */
    . S8 O3 u$ t3 k0 C6 Z7 E9 ^% w
  26.   uint32_t RESERVED7;    /*!< Reserved, 0x4C                                                                 *// b4 G! K  Y% L' W& c7 \
  27.   __IO uint32_t BKP0R;   /*!< RTC backup register 1,                                    Address offset: 0x50 */
    # q8 v% p$ `  ~; _! \, X
  28.   __IO uint32_t BKP1R;   /*!< RTC backup register 1,                                    Address offset: 0x54 */
    & T# u; }6 I. k  D
  29.   __IO uint32_t BKP2R;   /*!< RTC backup register 2,                                    Address offset: 0x58 */
    1 D" N6 b7 ~" l/ T, n7 \/ ?
  30.   __IO uint32_t BKP3R;   /*!< RTC backup register 3,                                    Address offset: 0x5C */1 l8 x* ~/ B1 g9 p/ D6 C
  31.   __IO uint32_t BKP4R;   /*!< RTC backup register 4,                                    Address offset: 0x60 */: |/ ]1 c8 G) Z3 N0 U3 v
  32.   __IO uint32_t BKP5R;   /*!< RTC backup register 5,                                    Address offset: 0x64 */
    8 @' x- h: l8 S3 `; }  O
  33.   __IO uint32_t BKP6R;   /*!< RTC backup register 6,                                    Address offset: 0x68 */
    2 w* y- p8 c( M& ^
  34.   __IO uint32_t BKP7R;   /*!< RTC backup register 7,                                    Address offset: 0x6C */# ~& ^9 }* ]5 V; h( b
  35.   __IO uint32_t BKP8R;   /*!< RTC backup register 8,                                    Address offset: 0x70 */
    4 a) u1 n( f) ~+ D' E( {5 B1 q
  36.   __IO uint32_t BKP9R;   /*!< RTC backup register 9,                                    Address offset: 0x74 */
    ; `% W( y- x, I% \" G4 s5 J
  37.   __IO uint32_t BKP10R;  /*!< RTC backup register 10,                                   Address offset: 0x78 */
    ; p: y- @' C0 H
  38.   __IO uint32_t BKP11R;  /*!< RTC backup register 11,                                   Address offset: 0x7C */$ G9 J- a' u; B
  39.   __IO uint32_t BKP12R;  /*!< RTC backup register 12,                                   Address offset: 0x80 */: Z' j& n9 I) Q
  40.   __IO uint32_t BKP13R;  /*!< RTC backup register 13,                                   Address offset: 0x84 */
    ( o) q, o: [8 u: `9 n2 r2 r
  41.   __IO uint32_t BKP14R;  /*!< RTC backup register 14,                                   Address offset: 0x88 */7 \% m! M' V4 F* r* r0 ~5 O
  42.   __IO uint32_t BKP15R;  /*!< RTC backup register 15,                                   Address offset: 0x8C */2 |6 j1 S3 R# S! z# T2 a
  43.   __IO uint32_t BKP16R;  /*!< RTC backup register 16,                                   Address offset: 0x90 */: d0 V4 k4 k7 q: c0 S2 P" `3 _( c
  44.   __IO uint32_t BKP17R;  /*!< RTC backup register 17,                                   Address offset: 0x94 */
    1 l% ~' \. \/ J4 A& m5 @( v5 ]# h
  45.   __IO uint32_t BKP18R;  /*!< RTC backup register 18,                                   Address offset: 0x98 */
    & e5 H2 e* |* ^$ t* W+ X" h4 e0 R
  46.   __IO uint32_t BKP19R;  /*!< RTC backup register 19,                                   Address offset: 0x9C */
    ! R# A- M& Y: Q, }  U
  47. } RTC_TypeDef;% e- o/ Q: c, f) z
复制代码
! e$ _  f: h, l
2 v& y2 }0 B/ o
赞 收藏 评论0 发布时间:2022-6-14 14:01

举报

0个回答

所属标签

相似技术帖

官网相关资源

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