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

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

[复制链接]
STMCU小助手 发布时间:2022-3-29 09:37
01. 概述
5 X7 R* M+ L3 r' A  TRTC相关函数和类型主要在stm32f4xx_rtc.h和stm32f4xx_rtc.c文件中。2 \( S& R6 X" L) a
: T5 l7 w- e, e7 s" u, Z
02. 相关类型- P9 k0 O2 M! M! F+ ~
  1. /**
    ' ]* m  B6 D6 E7 N2 L: @' y
  2.   * @brief  RTC Init structures definition  
    ) t4 K5 \3 d: d8 L2 H3 R+ F3 ~# @3 u
  3.   */
    ( h% X0 n+ ]* Y- G% K
  4. typedef struct  X& H' Q' |. U' Q0 K  b0 n0 M
  5. {) m9 D2 g  x2 `
  6.   uint32_t RTC_HourFormat;   /*!< Specifies the RTC Hour Format.: [# ?: R/ r4 }. |8 D7 I
  7.                              This parameter can be a value of @ref RTC_Hour_Formats */
    ; T; B( z2 f" a6 D+ n$ g
  8. 7 R$ L5 G% x7 l; r& Q0 z' ]+ n" I
  9.   uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.8 b6 W2 W5 ]  y! F
  10.                              This parameter must be set to a value lower than 0x7F */
    : O( H- L: A0 n, B
  11. 7 A( O8 r) r0 J& }, e: M
  12.   uint32_t RTC_SynchPrediv;  /*!< Specifies the RTC Synchronous Predivider value.
    + {% ^8 O9 {8 J5 @$ {! t
  13.                              This parameter must be set to a value lower than 0x7FFF */
    $ I# {0 l- k+ U+ e" `. p
  14. }RTC_InitTypeDef;; n! x- d" J6 X

  15. : ~7 A# T# o& z6 \0 B# g( }. e
  16. /**
    , `' E8 k* ]# x7 p, P
  17.   * @brief  RTC Time structure definition  8 K( E  `, M- K8 z. J0 Z( w. Q
  18.   */- e+ T5 V+ B2 c0 Z8 t
  19. typedef struct
    + N6 l3 X+ y( N3 A
  20. {
      I& h+ k8 y9 S
  21.   uint8_t RTC_Hours;    /*!< Specifies the RTC Time Hour.
    2 a6 k* W9 s7 |+ o0 H
  22.                         This parameter must be set to a value in the 0-12 range2 O7 [& N" h. |6 ~
  23.                         if the RTC_HourFormat_12 is selected or 0-23 range if8 t3 `0 q" V$ z9 P' I4 F
  24.                         the RTC_HourFormat_24 is selected. */: R  p$ h: U" s( |1 _7 w
  25.   Y' u7 u' z9 P# {0 j2 |. j
  26.   uint8_t RTC_Minutes;  /*!< Specifies the RTC Time Minutes.1 c/ c7 T* x, k
  27.                         This parameter must be set to a value in the 0-59 range. */
    ( u' e: r) Y$ l- J- N$ c; ^  C  l
  28. . l2 ?7 Q5 @: p2 j
  29.   uint8_t RTC_Seconds;  /*!< Specifies the RTC Time Seconds.
    " }; h$ I* R0 u  i# i3 W
  30.                         This parameter must be set to a value in the 0-59 range. */. A; E4 q9 U/ }- j. e

  31. ' Q" R) g, f6 D7 M/ q) i' h7 c6 P
  32.   uint8_t RTC_H12;      /*!< Specifies the RTC AM/PM Time.
    3 o7 X; a* H( u
  33.                         This parameter can be a value of @ref RTC_AM_PM_Definitions */
    ' L, N+ h! {( E5 b
  34. }RTC_TimeTypeDef; - t+ N4 ^2 r2 ]
  35.   ]% U4 Q, \8 f( s! b' B6 [
  36. /**
    1 u( g$ O9 k3 n8 o2 c& c, M
  37.   * @brief  RTC Date structure definition  
    5 Z+ D% C2 r0 \; A% A6 Y  R
  38.   */$ j% A8 G3 X+ M
  39. typedef struct- H; O8 V& m  W- f% z  y! [% L; t
  40. {& s8 n! {, m2 D+ f! W) M6 F
  41.   uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.
    " m' _: D9 @. p/ x! ~
  42.                         This parameter can be a value of @ref RTC_WeekDay_Definitions */* h8 N1 k8 o7 m1 D# f

  43. 1 p& O- ^. d- L" h. Z5 H$ w
  44.   uint8_t RTC_Month;   /*!< Specifies the RTC Date Month (in BCD format).
    ; ~) |8 n* d& s& k3 ?1 {% z* N
  45.                         This parameter can be a value of @ref RTC_Month_Date_Definitions */) \+ A4 S- l. ^/ Z& K
  46. # E; M1 X$ X. o) ?
  47.   uint8_t RTC_Date;     /*!< Specifies the RTC Date.
    - ^0 @  ?) ^# S; l* J
  48.                         This parameter must be set to a value in the 1-31 range. */
    ! O5 i% F& o4 z
  49. * y; v8 L2 {/ [
  50.   uint8_t RTC_Year;     /*!< Specifies the RTC Date Year.
    # G; u6 y6 l; `
  51.                         This parameter must be set to a value in the 0-99 range. */7 i) |; T! o* K- d' e
  52. }RTC_DateTypeDef;: Z: P8 _2 R9 H' G

  53. " ?: o: a; K8 D" A
  54. /**
    $ @3 s  ~" x  S: H6 V
  55.   * @brief  RTC Alarm structure definition  
      L  Q' [: r( k& c- R" W
  56.   */& L$ l" T, X3 {9 N1 F
  57. typedef struct
    ; z; w' N; J6 w
  58. {
    / _* d5 }% p" e
  59.   RTC_TimeTypeDef RTC_AlarmTime;     /*!< Specifies the RTC Alarm Time members. */
    ; b  Q$ `- g# |! w- n* Q

  60. - F& t2 C% Y- x3 l
  61.   uint32_t RTC_AlarmMask;            /*!< Specifies the RTC Alarm Masks.! d! f5 Y6 q0 E% E; k- j
  62.                                      This parameter can be a value of @ref RTC_AlarmMask_Definitions */4 f: v6 Q1 f. l3 m, \# H
  63. 1 q! D1 G; g( p2 p# G
  64.   uint32_t RTC_AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.( _9 g) z4 Z: n0 E! ?' Y" F" ~
  65.                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
    " ]) `' P1 N. c& f% S' ~! Q
  66. + ^: {+ Z% u  r- q5 ]) B' f5 S
  67.   uint8_t RTC_AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.! q) _  A4 f- c$ U8 n; y
  68.                                      If the Alarm Date is selected, this parameter* U- i1 ]6 }; F" ^
  69.                                      must be set to a value in the 1-31 range.
    . @: S1 i. O- k0 I: {* {
  70.                                      If the Alarm WeekDay is selected, this
    4 j1 e& Y; ~5 L7 O, P
  71.                                      parameter can be a value of @ref RTC_WeekDay_Definitions */
    ! v# l. z( b& Y4 w* B" k
  72. }RTC_AlarmTypeDef;+ c: C! @2 }/ U, o' C6 x" r
  73. - T+ I7 p3 R0 o
  74. /* Exported constants --------------------------------------------------------*/7 I# v/ j% k' w1 v; }) E1 e

  75. : [  Q, @5 Z" S+ M: t6 ]
  76. /** @defgroup RTC_Exported_Constants* C& z# g; ^6 G8 c1 p1 {5 c
  77.   * @{
    ) ?9 _+ y( Y( b7 a- v! q* k9 p
  78.   */ ; g/ @  T; {3 C& j% E) u) u

  79. ) \( Q& R  ]/ z4 l: ^* u; ]

  80. # e* @1 M- n( |. `! q" K, {7 C
  81. /** @defgroup RTC_Hour_Formats ; n9 y1 D% z8 c2 _$ }
  82.   * @{' A" w4 t" {. m5 S% }7 L
  83.   */
    . x' T+ K+ E9 [6 L% L
  84. #define RTC_HourFormat_24              ((uint32_t)0x00000000)
    - u3 R. j  w; s6 m, x( q. M
  85. #define RTC_HourFormat_12              ((uint32_t)0x00000040)
    * j) Z6 c. D$ _, o7 i( r
  86. #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HourFormat_12) || \
      o* ~! C7 x9 n6 ~3 I
  87.                                         ((FORMAT) == RTC_HourFormat_24))5 K7 P8 o6 v+ H3 D* V4 ?
  88. /**
    2 n6 r2 `4 ]5 G) |
  89.   * @}) G1 t* r& Q* `7 p2 g
  90.   */
    - h) X4 ~5 p9 Y3 j* d3 e

  91. 1 v/ k1 _9 T) p0 }9 W' h2 F
  92. /** @defgroup RTC_Asynchronous_Predivider 8 f# W) c' A1 _& ~2 H
  93.   * @{0 k1 w3 ^; h! ^1 y
  94.   */
    3 G8 @$ H; f6 I; C
  95. #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= 0x7F)  y  \/ o  }; c/ ~
  96. - D' w# z. b: k5 c! @* k( g
  97. /**
    7 @0 C; H: |( ]  w, d# L1 c$ r
  98.   * @}9 M4 I) b2 f% Z/ [' F- F1 `+ I
  99.   */ ' j' X& G$ u! K) x7 W; N9 _: D

  100.   v: w( B$ V/ z  E. S
  101. 6 R* k* o) }" k6 T
  102. /** @defgroup RTC_Synchronous_Predivider
    6 E  R$ n- g- [7 O. B3 C$ k
  103.   * @{6 B" K. L4 x* A) G, r$ W, d
  104.   */
    ! j# D* I- h  |. t4 F$ z, ^% y
  105. #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= 0x7FFF)
    1 A) ]2 a4 D4 K, n9 e# i  _: e
  106.   ]# E/ I' T. g5 N5 M
  107. /**
    1 X6 }. u' X4 o
  108.   * @}
    6 L! b& p3 Q9 @2 v- b
  109.   */
    : c6 I' T# G: L* F
  110. $ i9 e- ^5 J3 z% ^
  111. /** @defgroup RTC_Time_Definitions 8 s, d2 S' f: v7 q4 ]
  112.   * @{. Z# O0 Q2 p6 r! w  ^
  113.   */ & m1 i) Y7 C! D% y1 e. ^
  114. #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0) && ((HOUR) <= 12))' _2 y9 a9 ^; V1 a8 X$ R% ?6 Z) L
  115. #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23)  |5 Z% t, J* P7 ^3 h, `! H" Y
  116. #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59)0 [: C; g1 p) }% X* ^" z
  117. #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59)- h# z* o0 h$ u% ?3 c& h

  118. 1 R3 Y8 F5 C1 A, l
  119. /**
    0 I0 e& T& T1 B" t
  120.   * @}
    . U8 `- x& P1 A# P1 Y
  121.   */ 9 k3 X# {; `' u9 o' K9 ~
  122. 6 C# _. U, R7 u# a: i
  123. /** @defgroup RTC_AM_PM_Definitions 2 i& O" @; R' `" H0 ^
  124.   * @{/ [6 Q6 i* i3 ~8 ]$ t
  125.   */ $ T6 j* F! L9 S* y7 Y
  126. #define RTC_H12_AM                     ((uint8_t)0x00)! H) n: ]# U$ z4 {( [' d- n! O2 f5 C
  127. #define RTC_H12_PM                     ((uint8_t)0x40)& K' R1 M( C- D; u
  128. #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))
    5 R6 ~. [3 `/ ?* u
  129. 2 o5 `8 T2 i) w7 p7 w
  130. /**5 g; r+ ]- Q' y) W  |% q6 i. i2 M
  131.   * @}3 v1 E9 u; o$ R
  132.   */
    5 V* y, f- d* M. N# C5 _! u
  133. 5 l4 y2 D- V, y+ _' f
  134. /** @defgroup RTC_Year_Date_Definitions $ v0 }2 @7 m) i8 D. Y0 l5 r
  135.   * @{% Q5 X# R6 @4 r6 }6 E: }& Y$ U
  136.   */ . A' N; R1 s% d1 l' x. {' G8 J
  137. #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99)
    ) F9 B$ V' L# ^: q4 V
  138. ' C* A% Q* b+ X" N  Z0 z
  139. /**4 q2 s. `  u8 X2 h* m
  140.   * @}4 J$ M7 t3 T3 p  ?
  141.   */ 6 R0 ?  I0 ~" q) Z$ o0 y& `
  142. 4 _3 J( h+ R7 g
  143. /** @defgroup RTC_Month_Date_Definitions
    ' w! m5 p  Y! L: T
  144.   * @{
    4 @" V; ]2 C0 e5 s1 h2 M: L
  145.   */ - x2 G5 E5 F- z! u: o. T
  146. 3 I6 F1 F( [5 V
  147. /* Coded in BCD format */* h7 l5 Q% W  I8 D  |
  148. #define RTC_Month_January              ((uint8_t)0x01)
    6 o2 t+ ?# R9 M2 V2 `( E5 I
  149. #define RTC_Month_February             ((uint8_t)0x02)0 i; Q; p: ~5 G3 d" s
  150. #define RTC_Month_March                ((uint8_t)0x03)- s! G: O& V6 k6 ?
  151. #define RTC_Month_April                ((uint8_t)0x04)$ s/ T1 O1 h  P/ k1 `: X
  152. #define RTC_Month_May                  ((uint8_t)0x05)
    ' m; n! o4 n. i% I1 J
  153. #define RTC_Month_June                 ((uint8_t)0x06)- p# u. M9 K" B1 |( R1 W
  154. #define RTC_Month_July                 ((uint8_t)0x07)
    ' p0 A4 k' G* e: \7 n
  155. #define RTC_Month_August               ((uint8_t)0x08)' L' V( V! l; ?3 ]
  156. #define RTC_Month_September            ((uint8_t)0x09)
    4 K7 i- G4 u, O% K" ^  I0 ~3 ?
  157. #define RTC_Month_October              ((uint8_t)0x10)
    7 M! a& f% \6 c
  158. #define RTC_Month_November             ((uint8_t)0x11)) \8 q( R7 L3 t0 T' d0 m- G
  159. #define RTC_Month_December             ((uint8_t)0x12)
    / A% L+ F; F6 A# Z- Q
  160. #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1) && ((MONTH) <= 12))7 d. _/ T: C4 G
  161. #define IS_RTC_DATE(DATE)              (((DATE) >= 1) && ((DATE) <= 31))
    4 n( }/ m# R  u3 }" `1 i

  162. # I* ^# F% {" E& K) s0 y0 J
  163. /**0 w9 j1 N+ g5 A5 @# d  T' H
  164.   * @}
    - W) C  _  x& u8 E: _8 P
  165.   */ / R; r1 q& B& j6 h7 @* A9 O& O

  166. 4 E( w9 K' ~" x0 q( J9 H8 z5 k
  167. /** @defgroup RTC_WeekDay_Definitions % v/ h# x. }5 m$ A6 @
  168.   * @{1 b( w" q! |1 S' v# z
  169.   */   l, R- v  i3 ~; X# ]3 h' B

  170. 2 x! {9 Q8 a* i, R- m; b; w7 Q
  171. #define RTC_Weekday_Monday             ((uint8_t)0x01)
    & e' j: X# }9 s0 H. Y
  172. #define RTC_Weekday_Tuesday            ((uint8_t)0x02)
    * O1 s# w( i& ^9 c6 ^/ q
  173. #define RTC_Weekday_Wednesday          ((uint8_t)0x03)
    ! |# ~0 c& [$ e, P
  174. #define RTC_Weekday_Thursday           ((uint8_t)0x04)
    6 R0 h: U0 ~1 r
  175. #define RTC_Weekday_Friday             ((uint8_t)0x05)- T( e4 o9 h7 W
  176. #define RTC_Weekday_Saturday           ((uint8_t)0x06)
    % L, @% _1 N* @5 |+ n7 P  M; Q  R
  177. #define RTC_Weekday_Sunday             ((uint8_t)0x07)
    9 v! [# y" Y/ `# y, K1 A, ?( Z  I
  178. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \6 \5 I- Q! B9 T* L
  179.                                  ((WEEKDAY) == RTC_Weekday_Tuesday) || \6 u' a( |$ a9 N, Z3 F' _# x& t
  180.                                  ((WEEKDAY) == RTC_Weekday_Wednesday) || \$ K( z- A0 j0 x3 y4 Z
  181.                                  ((WEEKDAY) == RTC_Weekday_Thursday) || \) p" E' G9 K. L/ _" z+ o
  182.                                  ((WEEKDAY) == RTC_Weekday_Friday) || \% a7 n  Y, Y- B: h) L
  183.                                  ((WEEKDAY) == RTC_Weekday_Saturday) || \3 ^! a2 o- R1 e/ Y1 ^2 W
  184.                                  ((WEEKDAY) == RTC_Weekday_Sunday))
    % k8 Y- z9 D6 w7 B" p9 m1 c
  185. /**) l0 V! f; Z  S$ K2 Y
  186.   * @}; c, S% c$ f6 ~" x' y# a
  187.   */
    7 B$ x6 C5 C# p& H* O, y

  188. : r0 I. K% A+ F% D

  189. # T7 y/ ^' p  S8 |: G. i
  190. /** @defgroup RTC_Alarm_Definitions
    * g4 l5 k1 {) m% C( j- |' N6 l& I, n8 j
  191.   * @{5 p4 u% n5 f9 [7 U" i/ R  z
  192.   */ $ W' T9 E5 O$ Z) w7 R' @- P
  193. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
    : i5 X2 ^9 F3 b' v4 b7 r
  194. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \5 l/ {* A7 W4 q% C" v: w" s( k
  195.                                                     ((WEEKDAY) == RTC_Weekday_Tuesday) || \. L# w  y7 _+ w, Q& P# d
  196.                                                     ((WEEKDAY) == RTC_Weekday_Wednesday) || \
    - t2 L: t1 m; n" j
  197.                                                     ((WEEKDAY) == RTC_Weekday_Thursday) || \# o! R* j9 y! b# m
  198.                                                     ((WEEKDAY) == RTC_Weekday_Friday) || \+ ]# w" L- C2 Z! [) A' l
  199.                                                     ((WEEKDAY) == RTC_Weekday_Saturday) || \
    $ [- T- h' ~' l" t" \
  200.                                                     ((WEEKDAY) == RTC_Weekday_Sunday))
    ! J6 V, F( a. C9 u- S+ }
  201. . u5 n+ }  I% ~$ ]; t+ p
  202. /**
    6 w6 H6 O7 `9 @
  203.   * @}5 U5 ^( n  }1 d, l1 g4 h8 i% h
  204.   */
    7 G9 ~2 x7 _, Q0 `

  205. / f8 K5 B1 l1 s1 o  v) u; d
  206. ; m& c. ]8 R& D5 X* h8 q* H
  207. /** @defgroup RTC_AlarmDateWeekDay_Definitions & r; r$ e" h4 p' g0 N
  208.   * @{' @/ [7 q, o5 }+ z7 P8 k  ~- o
  209.   */
    , b4 s% R6 o! |) @
  210. #define RTC_AlarmDateWeekDaySel_Date      ((uint32_t)0x00000000)
    6 i/ s: X* V7 B: k: d4 E& Q
  211. #define RTC_AlarmDateWeekDaySel_WeekDay   ((uint32_t)0x40000000)
    8 o+ X$ f, y9 V

  212. ) Z1 c" q, G: ]& W* e9 ?. E- o
  213. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
    ) x3 j) q# D) {& {7 i; J0 _9 @
  214.                                             ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))
    1 ^& r. J9 N7 G

  215. 9 |+ m8 s5 g9 W( N3 Z  j
  216. /**
    2 c7 T4 w# u4 o) z
  217.   * @}
    - @7 h$ u; |7 q9 e, J
  218.   */ , T5 E: `) K/ {
  219. ( L/ L% o, G. W, M$ T0 E

  220. 8 \3 c  |. _& u
  221. /** @defgroup RTC_AlarmMask_Definitions 0 w: t8 e$ g1 U( e6 v: H9 |$ o, H
  222.   * @{
    . s7 `/ @; a3 s. Q1 L! [
  223.   */
    1 K  @( Q0 c4 G
  224. #define RTC_AlarmMask_None                ((uint32_t)0x00000000)
    / n$ Z% _7 ~9 Q+ b
  225. #define RTC_AlarmMask_DateWeekDay         ((uint32_t)0x80000000)
    $ F9 ]0 ]1 R; U2 `7 e( Z6 m! s
  226. #define RTC_AlarmMask_Hours               ((uint32_t)0x00800000)
    6 F0 _* V- m  Y/ Z
  227. #define RTC_AlarmMask_Minutes             ((uint32_t)0x00008000)6 L2 s7 _9 R) g- P
  228. #define RTC_AlarmMask_Seconds             ((uint32_t)0x00000080)" t' |5 x( |9 Z2 \. e. ^
  229. #define RTC_AlarmMask_All                 ((uint32_t)0x80808080)+ C# T+ `# E* t% T; Y
  230. #define IS_ALARM_MASK(MASK)  (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)% K+ z4 }! l6 Y$ V  l7 v

  231. & _' @+ C0 R/ U9 V1 K4 l
  232. /**' ]3 Z" X5 J1 d2 q3 [- ~. u
  233.   * @}
    / F+ D8 Q, t( h: k( S6 [
  234.   */ 2 A: ^/ f6 d/ [0 Y8 L

  235. 2 k6 t' h  j  @: Y- c4 `2 N4 x
  236. /** @defgroup RTC_Alarms_Definitions 8 ?% k( v  A7 n
  237.   * @{
    : F- |- |# j$ n. f, x2 a1 k% Y3 c. {
  238.   */   H" A- c/ m9 s9 u* h
  239. #define RTC_Alarm_A                       ((uint32_t)0x00000100)- @& s% C" U/ T; a+ W
  240. #define RTC_Alarm_B                       ((uint32_t)0x00000200)
    - O& k  E3 V0 Y5 E
  241. #define IS_RTC_ALARM(ALARM)     (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
    6 i+ M7 N) {! ~2 W7 T+ z
  242. #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)
    3 e3 d1 G( K' ]" B% Z
  243. 0 s7 |: `% c7 c* z! O+ K
  244. /**$ Q7 v6 I0 O7 ]* X; J0 u. o/ L
  245.   * @}
    6 \; |# L7 ?2 z' E3 V
  246.   */
    . ?4 Q. o, b$ M, `  i

  247. 9 b4 j+ G3 |/ m. t
  248.   /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions2 @& s+ K8 j( n  V  s& `
  249.   * @{+ ?/ z" w0 K! X6 r7 f' T
  250.   */ 4 r0 v8 T' T( s9 t4 e6 b# u1 f
  251. #define RTC_AlarmSubSecondMask_All         ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
    / _$ n5 B1 r( a$ T/ I
  252.                                                                        There is no comparison on sub seconds 8 f2 O+ N% `: h" c" K
  253.                                                                        for Alarm */
    1 W* l) ]  T9 L
  254. #define RTC_AlarmSubSecondMask_SS14_1      ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
    + H: `5 ?9 `" w! c2 V  z
  255.                                                                        comparison. Only SS[0] is compared. */( l; R% p+ }6 t$ W( s$ v0 D. K
  256. #define RTC_AlarmSubSecondMask_SS14_2      ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm 9 {$ n$ A/ P0 ~  P. R
  257.                                                                        comparison. Only SS[1:0] are compared */& t2 q1 G6 B4 _: W
  258. #define RTC_AlarmSubSecondMask_SS14_3      ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm
    1 k/ \, N$ M9 _% Y; j" }- }# p
  259.                                                                        comparison. Only SS[2:0] are compared */: Q' u2 ^, ?. _( f5 n! z
  260. #define RTC_AlarmSubSecondMask_SS14_4      ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm 6 v! ]2 ^0 ^. v
  261.                                                                        comparison. Only SS[3:0] are compared */
    & Q2 h( L' b3 N* v4 q. d2 n) w
  262. #define RTC_AlarmSubSecondMask_SS14_5      ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm / l: h1 u+ K0 b- ~' v5 \/ [
  263.                                                                        comparison. Only SS[4:0] are compared */
    0 L5 r5 Y: G$ H& n& E& E$ k! T% ~
  264. #define RTC_AlarmSubSecondMask_SS14_6      ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm : y  {' V7 ]. B- O( ?
  265.                                                                        comparison. Only SS[5:0] are compared */
      _, O! g- _: b( p. L) N. Y6 A# E
  266. #define RTC_AlarmSubSecondMask_SS14_7      ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
    5 R1 _6 x% p% J' h! o, \
  267.                                                                        comparison. Only SS[6:0] are compared */
    ) o; t' v, z6 S: y  `$ W- P
  268. #define RTC_AlarmSubSecondMask_SS14_8      ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm ( k3 h; s& e6 K: X
  269.                                                                        comparison. Only SS[7:0] are compared */) b: [; I- r4 q. s9 @$ v
  270. #define RTC_AlarmSubSecondMask_SS14_9      ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm " r3 N$ [: w5 n. K9 F- G
  271.                                                                        comparison. Only SS[8:0] are compared */- [# K. L" e$ |( e/ Z+ d9 t: A
  272. #define RTC_AlarmSubSecondMask_SS14_10     ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
    1 P. }; D0 T. q5 S+ J2 ?3 n8 x! b
  273.                                                                        comparison. Only SS[9:0] are compared */
    6 K3 V0 r- `% Q9 A" O! Z
  274. #define RTC_AlarmSubSecondMask_SS14_11     ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm
    . O+ F' j" j' G: w
  275.                                                                        comparison. Only SS[10:0] are compared */1 L* |' j6 ?: k, q, h8 r
  276. #define RTC_AlarmSubSecondMask_SS14_12     ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm
    5 @; i5 P. I% z- D
  277.                                                                        comparison.Only SS[11:0] are compared */0 G( w* h$ }! k; n- W
  278. #define RTC_AlarmSubSecondMask_SS14_13     ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm 9 R/ k( n% Q# [
  279.                                                                        comparison. Only SS[12:0] are compared */
    4 g6 s6 W/ {3 j2 f/ Y2 ]3 o
  280. #define RTC_AlarmSubSecondMask_SS14        ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
    ; i3 X4 S2 e2 X' W; ~- G6 {
  281.                                                                        comparison.Only SS[13:0] are compared */
    : V3 ~7 w+ S9 n2 l
  282. #define RTC_AlarmSubSecondMask_None        ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match : Q! e5 v& a* Y/ B6 Z8 k
  283.                                                                        to activate alarm. */7 d7 h* J: k- p5 z( c: f8 ^# M: ~
  284. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)   (((MASK) == RTC_AlarmSubSecondMask_All) || \
    " E* Y! B% Y% l
  285.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \, w1 K" a  `( x! b& G" V
  286.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \
    % O* y; j# @& O( k, Q' r% x/ I! k
  287.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \. g, J1 L( p1 Z  {5 t; N, F
  288.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \  Z+ ?0 c# B. c
  289.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \" J" X3 |+ x3 P1 L
  290.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \
    9 Y! I6 ]6 i9 f( c0 _
  291.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \$ ~+ z5 O/ l8 Q! d6 c8 q: o
  292.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \
    7 x2 L2 b! ^6 Z/ K# x( Z5 E7 P
  293.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \$ C( Z* f9 j2 Q  q9 Z
  294.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \
    : s% F/ V3 F1 C6 x7 }
  295.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \3 E* f7 y; V! J5 m" j3 B
  296.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \
    ' j7 X3 ^0 f: e6 r6 V' a
  297.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \
    / R; N% T' Y+ P1 x
  298.                                               ((MASK) == RTC_AlarmSubSecondMask_SS14) || \  @, h" E6 x: j% }) [
  299.                                               ((MASK) == RTC_AlarmSubSecondMask_None))
    3 g, L6 \7 I2 n8 P/ M
  300. /**
    8 {6 Q3 M& k0 B) Y3 m8 [, Q% g! B
  301.   * @}) Q/ \- K9 U- t
  302.   */ * c3 @( I+ k" |" N; ~7 v) F

  303. 8 ~0 J$ o7 l/ g4 o
  304. /** @defgroup RTC_Alarm_Sub_Seconds_Value; q8 [+ Y9 O* q6 r) j7 \$ |, F( W
  305.   * @{
    9 N4 [% j( L. J" t; ]$ S2 T' o
  306.   */
    2 o6 F8 a0 e8 ~9 G" z
  307. & u  s3 j( Q' {) W5 L6 h; m4 q
  308. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF)! L! W+ s* V+ b$ e6 L- p( ?; |

  309. * s+ T6 T# |1 l
  310. /**3 p) d! e2 O8 J+ K  _1 Q
  311.   * @}$ K( U8 Z9 Y6 O' G" r
  312.   */ 9 B& ^$ R% e% [
  313. " W  B6 |: Z1 v( p( j* z9 ~' J
  314. /** @defgroup RTC_Wakeup_Timer_Definitions
    : T! d) s8 R* a: {2 Y0 `
  315.   * @{
    4 ?4 p  K7 v3 R6 G
  316.   */ ' c" n% V3 n: I: _0 }5 t' M
  317. #define RTC_WakeUpClock_RTCCLK_Div16        ((uint32_t)0x00000000)  t; p6 ]5 }7 y7 T
  318. #define RTC_WakeUpClock_RTCCLK_Div8         ((uint32_t)0x00000001)1 _9 m) `7 C; O4 i
  319. #define RTC_WakeUpClock_RTCCLK_Div4         ((uint32_t)0x00000002)+ b5 }  }, }' `2 u& `3 h8 {
  320. #define RTC_WakeUpClock_RTCCLK_Div2         ((uint32_t)0x00000003)
    0 r1 S. K, M8 b
  321. #define RTC_WakeUpClock_CK_SPRE_16bits      ((uint32_t)0x00000004)5 |* Y1 |' Q9 }  N. N" Z. A# B
  322. #define RTC_WakeUpClock_CK_SPRE_17bits      ((uint32_t)0x00000006)
    % R) I% ?4 [& g7 R4 h/ Q
  323. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
    % ?/ B( M7 ~% k
  324.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
    . i. p! s5 @' I$ E9 P/ ?3 X5 }- d- V
  325.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \2 [9 Y6 z: f4 H( ~. v8 `* V
  326.                                     ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \# L$ ^7 D! E$ [! k1 y+ W4 n
  327.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
    4 M% J3 A4 o! F" N1 s2 ~4 n
  328.                                     ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
    # E' {, C" s& v0 V8 G4 n9 a" e
  329. #define IS_RTC_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFF)* }" r+ g2 h% H6 m/ b1 X. a
  330. /**; i6 U6 h4 d' K7 _& H+ C& U# }
  331.   * @}4 c4 |) u2 f0 _/ N* ~" e4 H
  332.   */ 2 l1 u4 k$ G' `6 T6 S

  333. : U+ m' Q  |$ ~0 T+ z. O! X
  334. /** @defgroup RTC_Time_Stamp_Edges_definitions
    * K, }/ u9 ?8 g/ c( `7 ?  o
  335.   * @{
    : o) j( l4 r$ ]8 V# }
  336.   */
    7 P2 ]8 E( D) B- s
  337. #define RTC_TimeStampEdge_Rising          ((uint32_t)0x00000000)7 ?3 ]0 P) d, ~! C  Y' o. Z
  338. #define RTC_TimeStampEdge_Falling         ((uint32_t)0x00000008)- z) M' w- O2 w: z
  339. #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
    2 E, x& N& Z# Q
  340.                                      ((EDGE) == RTC_TimeStampEdge_Falling))
    5 ^7 ^2 ]; a: Z: u0 i& I, a5 }+ a
  341. /**- {9 q0 I# V) |7 f' o6 a0 j& H0 F8 i$ w
  342.   * @}
    9 f; D% O$ W+ |7 s
  343.   */
    ; I/ n& j/ h0 j  W3 Z

  344. 2 h- K9 o2 ~/ |
  345. /** @defgroup RTC_Output_selection_Definitions ! n, ?6 F- C0 W3 S8 X
  346.   * @{) k$ x8 k( P. p+ k" r$ I* h
  347.   */
    5 V: Z* _! w9 I4 j! M  ]5 L
  348. #define RTC_Output_Disable             ((uint32_t)0x00000000)5 t, J* P' q$ z. X" Y1 E9 Y1 C3 I- f
  349. #define RTC_Output_AlarmA              ((uint32_t)0x00200000)! _* r4 n( I- M) k$ G" \- s& B
  350. #define RTC_Output_AlarmB              ((uint32_t)0x00400000)
    - C$ ?! Z: z+ v8 G
  351. #define RTC_Output_WakeUp              ((uint32_t)0x00600000)6 b- @, C8 r( O# O+ s4 b

  352. ; |) T, v/ g+ G0 ^
  353. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \
      A+ G' p, V+ a! I$ T( v6 H- v: P% i
  354.                                ((OUTPUT) == RTC_Output_AlarmA) || \1 M0 R$ X" Q8 ?$ N
  355.                                ((OUTPUT) == RTC_Output_AlarmB) || \
    / h  `8 [5 K1 }/ p
  356.                                ((OUTPUT) == RTC_Output_WakeUp))
    ; p- c" {) s: ?" v+ \: z
  357.   `. P4 _- S/ M; |
  358. /**
    ; A, d. {: u: h" p
  359.   * @}
    3 Y  E8 K# o+ G5 S( R
  360.   */ . L) G8 }! M1 h, T1 y5 b. F2 O/ L

  361. 5 g3 `7 _4 e( h& Y: v% E5 q
  362. /** @defgroup RTC_Output_Polarity_Definitions ( `: ]) n, c! F7 E1 p3 N
  363.   * @{
    0 j9 E; X/ K. [" J
  364.   */ % o% Z2 g7 V6 P  _
  365. #define RTC_OutputPolarity_High           ((uint32_t)0x00000000)
    6 Y+ L8 A3 M1 e8 F
  366. #define RTC_OutputPolarity_Low            ((uint32_t)0x00100000)( n  e5 D+ M1 v5 p0 }0 _" T6 E; j
  367. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \
    / f# W/ ]& J& f
  368.                                 ((POL) == RTC_OutputPolarity_Low))  Y0 h& g7 E9 k( b, E$ l; T
  369. /**
    1 B; n% y. d3 c" h$ E
  370.   * @}
    1 |8 I& h( n% m6 O7 A8 r
  371.   */ - e* Y+ }9 F5 d0 y+ V
  372. . _7 P& x, A1 v& l$ I
  373. 0 ^3 J" s, a) r% T, {* w
  374. /** @defgroup RTC_Digital_Calibration_Definitions / ]) j( ?" r& ~
  375.   * @{
    * }& d( r+ e1 m% I7 G% b! X- {
  376.   */
    2 K6 v+ B3 E1 c2 N$ o' P
  377. #define RTC_CalibSign_Positive            ((uint32_t)0x00000000) # u- {/ b, Y. Y4 M
  378. #define RTC_CalibSign_Negative            ((uint32_t)0x00000080)3 j1 x2 A) d! B, l
  379. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
    4 w9 m3 O; d4 C, `: x1 \5 A( R' c4 C
  380.                                  ((SIGN) == RTC_CalibSign_Negative))2 z, Z+ v8 _; }3 ^" v
  381. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20). Y6 N* h0 o# o  d. _+ \8 G3 |
  382. , W3 k* E- p+ U( P6 K
  383. /**
    & s. u+ c8 ?! h
  384.   * @}, n0 v* G# P2 }  ?1 p
  385.   */
    ; J( c8 @0 U* H; A& u

  386. * F/ F+ a0 O' G
  387. /** @defgroup RTC_Calib_Output_selection_Definitions
    7 l3 z8 s/ H0 v- V( R2 V2 Q/ a
  388.   * @{2 m- b2 w+ R' O5 Q3 ?
  389.   */
    7 n; {0 `/ e6 [" T8 u
  390. #define RTC_CalibOutput_512Hz            ((uint32_t)0x00000000) ! q2 s. e$ t! w: l, D
  391. #define RTC_CalibOutput_1Hz              ((uint32_t)0x00080000)+ ^5 c4 c  x' t0 l/ }* R& D% d
  392. #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CalibOutput_512Hz) || \
    0 d9 y  m5 t' l4 L  H) o
  393.                                       ((OUTPUT) == RTC_CalibOutput_1Hz))& z* y7 M0 K2 b1 [( R
  394. /**
      _$ `/ H; d. k9 l
  395.   * @}
    : c& `! u- c* S+ n
  396.   */ ! i8 p/ y2 M: z  r4 f

  397. # d/ g0 V6 f, {
  398. /** @defgroup RTC_Smooth_calib_period_Definitions
    + A8 V7 J# C& `# C, `6 Z: Y/ [
  399.   * @{5 w( ?9 q  }* a5 ^5 W) O* `  }: g, c
  400.   */ 3 n5 }; D8 @; u2 l/ v; X& C$ ]) L8 a
  401. #define RTC_SmoothCalibPeriod_32sec   ((uint32_t)0x00000000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
    ' P" h  P3 G' s/ H, I  h/ W
  402.                                                              period is 32s,  else 2exp20 RTCCLK seconds */
    $ l1 r" P) L; N% c: q  S, A
  403. #define RTC_SmoothCalibPeriod_16sec   ((uint32_t)0x00002000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation 8 E: L5 l1 n/ j# q0 L
  404.                                                              period is 16s, else 2exp19 RTCCLK seconds */
    " J. A2 |9 Y  f0 G: I
  405. #define RTC_SmoothCalibPeriod_8sec    ((uint32_t)0x00004000) /*!<  if RTCCLK = 32768 Hz, Smooth calibation
    2 x% X& Z+ n7 d: s" p: Q
  406.                                                              period is 8s, else 2exp18 RTCCLK seconds */2 Y- q3 p! l8 K" t* `, l
  407. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \7 L6 f' f* L/ o" o; K! ^
  408.                                              ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \+ s: [6 [( G7 F* i) X9 F
  409.                                              ((PERIOD) == RTC_SmoothCalibPeriod_8sec))
    . ^' S( Q( ^" q/ W# P
  410. ; J) M# T( U. U! \; ~
  411. /**
    3 Q0 e2 d  d$ a( U
  412.   * @}
    ) y0 O# r8 T! `' e+ @5 i' _( [; T
  413.   */
    8 g/ A5 [  d( L3 V, R
  414. 5 Y5 n" P' e5 v
  415. /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions 3 x- X* J: R5 M* |3 @5 [7 Q2 R9 w- k
  416.   * @{
    7 v: F) H7 D3 j' v
  417.   */
    / w- {1 \9 Y# R; Q1 ?1 r* H
  418. #define RTC_SmoothCalibPlusPulses_Set    ((uint32_t)0x00008000) /*!<  The number of RTCCLK pulses added  ! f  q$ K- J5 H
  419.                                                                 during a X -second window = Y - CALM[8:0]. " J- \: P* ~  [* P4 c3 u' p
  420.                                                                  with Y = 512, 256, 128 when X = 32, 16, 8 */
    7 C- G3 Z. t' ]
  421. #define RTC_SmoothCalibPlusPulses_Reset  ((uint32_t)0x00000000) /*!<  The number of RTCCLK pulses subbstited- e4 I7 U  C: P7 W5 z4 `: J8 A$ x" y
  422.                                                                  during a 32-second window =   CALM[8:0]. */
    . e6 {' s2 t/ T! }0 @
  423. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \, }  W6 e' n% p0 C! T  ?5 Z# r
  424.                                          ((PLUS) == RTC_SmoothCalibPlusPulses_Reset))
    + ?4 {" _) D; K7 ?

  425. 7 q# p8 i6 m: ]$ P% Z2 }& ^" I
  426. /**3 A. Q- j) Y1 s) s) @0 L
  427.   * @}
    3 T9 l! Z$ S/ S# r2 y6 T
  428.   */ 4 X9 t( G- w3 z4 _; z5 S+ x
  429. . T2 e( c9 x' v! S
  430. /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions 8 S$ J5 o& F# [9 V" c
  431.   * @{: s$ G/ h- {: I
  432.   */
    ; ?* m: {6 O8 Z" {! H* m6 ?( T
  433. #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
    + N- \. c1 @6 H) d9 t

  434. ; X( Y. C7 Y2 D: z
  435. /**3 r5 P9 i6 @5 S+ [0 j0 E* G
  436.   * @}
    / N; f2 o6 m0 s; L
  437.   */) o7 m+ l, w+ u3 W
  438. 8 \7 J1 h4 T3 @
  439. /** @defgroup RTC_DayLightSaving_Definitions 8 m' N: }7 e4 `& _- u% R
  440.   * @{5 n0 p; N* ~% p) j
  441.   */ & U0 ~1 j) I# E/ L5 [+ P& N* R
  442. #define RTC_DayLightSaving_SUB1H   ((uint32_t)0x00020000)' E. O% M" l" i( Y9 U
  443. #define RTC_DayLightSaving_ADD1H   ((uint32_t)0x00010000)& h: I# u7 |) [3 o, B: a  Q  A
  444. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
    4 B+ ?# V) c5 X3 `
  445.                                       ((SAVE) == RTC_DayLightSaving_ADD1H))
    + J7 F9 X( _: }, I! K( t
  446. . M% [8 s, X( E  u
  447. #define RTC_StoreOperation_Reset        ((uint32_t)0x00000000)
    - o% ]$ g: `( O* \
  448. #define RTC_StoreOperation_Set          ((uint32_t)0x00040000)& Q3 C3 Q8 C8 y( |1 n
  449. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \
    1 j) B9 ~/ q/ S1 Q/ a
  450.                                            ((OPERATION) == RTC_StoreOperation_Set))( L' T  y+ l! `, a$ I3 O0 w
  451. /**
    / Q0 v' Z% a! f; V; U$ v, a" S3 J
  452.   * @}
    & G) c2 a1 v. H6 X) T
  453.   */ $ W2 N% C5 Z( ~+ B
  454. - y4 m. k( f+ u1 I* R$ t2 p0 z
  455. /** @defgroup RTC_Tamper_Trigger_Definitions
    ! p% E! O! ^6 H, C
  456.   * @{
    0 W! G" ]! O2 g) F, {
  457.   */
    ; K4 W6 U# }5 b: |2 C5 U
  458. #define RTC_TamperTrigger_RisingEdge            ((uint32_t)0x00000000)7 P5 o0 P" L0 Y
  459. #define RTC_TamperTrigger_FallingEdge           ((uint32_t)0x00000001)
    * x4 W2 N2 E$ W$ b& Q
  460. #define RTC_TamperTrigger_LowLevel              ((uint32_t)0x00000000)
    - W, m7 U5 b- E
  461. #define RTC_TamperTrigger_HighLevel             ((uint32_t)0x00000001)
    ! \$ X$ ~  W$ O& v' J" _: f
  462. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \+ _) \) R: l& U( D* H
  463.                                         ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \: g1 C" _# V, b1 a
  464.                                         ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \8 Z  V3 w2 ]8 ~9 o
  465.                                         ((TRIGGER) == RTC_TamperTrigger_HighLevel)) 6 \* G2 D: A( ?7 o/ b
  466. 8 x( s( T. K( L
  467. /**; r- ]! [  q) f" x! U' e. g
  468.   * @}
    + b6 e' F# O' F# g* M( l3 @6 X
  469.   */ / z/ d: y" ~. I

  470. . J4 X0 {' ?- E2 u! k! L" l! G3 W
  471. /** @defgroup RTC_Tamper_Filter_Definitions
    3 I1 z$ J7 j$ [5 I2 e# y
  472.   * @{/ U- _  I0 C3 N$ O% h
  473.   */
    ( i) y9 g, n. J7 o
  474. #define RTC_TamperFilter_Disable   ((uint32_t)0x00000000) /*!< Tamper filter is disabled */
    ! j2 h: @& p9 N, }7 g3 e
  475. 8 [6 S1 }5 z! t5 |: X: T( G
  476. #define RTC_TamperFilter_2Sample   ((uint32_t)0x00000800) /*!< Tamper is activated after 2
    : v  S  t- {0 s( |+ P' \- I, m
  477.                                                           consecutive samples at the active level */0 N- ~& ^- t- }6 A' S
  478. #define RTC_TamperFilter_4Sample   ((uint32_t)0x00001000) /*!< Tamper is activated after 4
    % X4 F+ `* `$ Y) J4 _
  479.                                                           consecutive samples at the active level */0 c4 Q+ S: W0 ]/ `4 V! L% a% E
  480. #define RTC_TamperFilter_8Sample   ((uint32_t)0x00001800) /*!< Tamper is activated after 8   n. g/ t( q2 ~# V! _
  481.                                                           consecutive samples at the active leve. */; k+ A+ X9 E, W8 |
  482. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \6 n' W8 C  n$ o" \" }$ A6 r
  483.                                       ((FILTER) == RTC_TamperFilter_2Sample) || \3 r. W) o% Y* f. f
  484.                                       ((FILTER) == RTC_TamperFilter_4Sample) || \7 _/ n9 q/ m, U6 J9 m+ C3 a* z
  485.                                       ((FILTER) == RTC_TamperFilter_8Sample))
      G* U8 @- a* n7 l+ U3 K* m& ?. \
  486. /**
    4 h: |) G& P0 k: n6 b
  487.   * @}
    ; o# H3 d$ b- W: |" k
  488.   */ 1 [# f1 ]) M7 U9 A0 e! m0 P/ {- z: w

  489. ) n& y6 y2 j5 l* i" A  f. N% L
  490. /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions
    7 z5 t* H8 |+ U: z7 L
  491.   * @{, A1 S2 M; U$ I. r3 G
  492.   */ 7 N9 @( m7 i9 H( w
  493. #define RTC_TamperSamplingFreq_RTCCLK_Div32768  ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled
    + j! i9 `9 L/ `9 C0 {1 L
  494.                                                                            with a frequency =  RTCCLK / 32768 */" K) R# r! K9 e% G! V
  495. #define RTC_TamperSamplingFreq_RTCCLK_Div16384  ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled
    # W% {8 f$ Y2 {' S0 F) O8 @$ h
  496.                                                                             with a frequency =  RTCCLK / 16384 */, Q- y& x" e* b
  497. #define RTC_TamperSamplingFreq_RTCCLK_Div8192   ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled2 N. b$ M% ~- u
  498.                                                                            with a frequency =  RTCCLK / 8192  */
    ) E+ w0 l+ m" D) o% r
  499. #define RTC_TamperSamplingFreq_RTCCLK_Div4096   ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled5 P- b0 Q# |5 ?3 p# m
  500.                                                                            with a frequency =  RTCCLK / 4096  */
    0 D# z; ^4 n. f7 Z7 Q
  501. #define RTC_TamperSamplingFreq_RTCCLK_Div2048   ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled$ R# w5 A9 `, `4 x0 n& I* N
  502.                                                                            with a frequency =  RTCCLK / 2048  */
    + E4 h, w+ M, g. k6 y4 B0 [
  503. #define RTC_TamperSamplingFreq_RTCCLK_Div1024   ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled
    1 f* l5 M9 \0 d) u
  504.                                                                            with a frequency =  RTCCLK / 1024  */6 O" D% k5 y. T$ R8 X$ r
  505. #define RTC_TamperSamplingFreq_RTCCLK_Div512    ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
    * g) V. ?! t' X% [: J0 L
  506.                                                                            with a frequency =  RTCCLK / 512   */
    % t% z( T7 Q' \
  507. #define RTC_TamperSamplingFreq_RTCCLK_Div256    ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
    - E/ n3 E' q" |/ G. S
  508.                                                                            with a frequency =  RTCCLK / 256   */
    7 Y2 }1 k& l" O; h& X# q# h
  509. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \3 B" ?& N, F) g! C$ q( F
  510.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \; Y8 \2 n( j- w" |3 K
  511.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \
      g9 S& _2 f" \+ ~9 W6 N1 x
  512.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \3 k" i' `) k% C
  513.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \. H) H7 _/ h! B* z$ f- Q
  514.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \
    , N) A. c* T, K4 P$ A6 p* K
  515.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \
    2 T! u( i$ D  c, B; \- H) p# |3 e1 u
  516.                                            ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256))
    9 R& x; C, i. _8 u  S

  517. / z& F4 j! C! Z
  518. /**1 Y5 N/ d$ @  m' T  \( b
  519.   * @}4 j- U, r1 G# ]$ z& ?' w' @( Z9 S! ?
  520.   */
    - B! F+ \2 I# |6 E& y
  521. : j/ w8 w8 l% s( E$ Y. s
  522.   /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions
    % l" \- z, w  G: T
  523.   * @{
    * v/ H9 Q; T8 c
  524.   */   L* j* R5 N: \4 d2 Y! p' {& w
  525. #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before
    9 G2 r0 m7 G* e- W5 i" x
  526.                                                                          sampling during 1 RTCCLK cycle */# I) U' a; U% {  D. P/ }
  527. #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000)  /*!< Tamper pins are pre-charged before
    2 j1 o  N8 m/ ?2 l; \' N2 \
  528.                                                                          sampling during 2 RTCCLK cycles */
    9 c" {2 a8 ?  y9 K2 ~* z* X. S
  529. #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000)  /*!< Tamper pins are pre-charged before   B4 V1 P( N$ ]% _
  530.                                                                          sampling during 4 RTCCLK cycles */
    1 c( g6 \  S, u1 A" ^
  531. #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000)  /*!< Tamper pins are pre-charged before
    6 j+ r) L7 _; A/ l8 B
  532.                                                                          sampling during 8 RTCCLK cycles */! I. B' X  ~) z9 t* d$ D
  533. ! m2 O' R0 O- k/ t. p' P0 _
  534. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \
    0 M) x) }2 p1 f* [: P
  535.                                                     ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \4 k- D; T+ o! L6 J0 F  e* I5 G3 [
  536.                                                     ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \& X( a9 P) \1 o8 q0 a/ y9 M5 l, l2 [
  537.                                                     ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK))/ P. V  i" |2 H; q
  538. /**/ ^- ^- c4 y9 }4 e7 Z& I; c
  539.   * @}
    $ [% [) `# V4 m6 ^
  540.   */
    / M; S' S/ ^0 `  M9 X* b

  541. 2 j: ]4 X8 X  y0 f. {# @5 ?
  542. /** @defgroup RTC_Tamper_Pins_Definitions 2 S9 L9 I# J+ S& x) m* n
  543.   * @{
    9 |9 Z9 Y: s. T- c" A
  544.   */
    + ?: |5 m$ e- U
  545. #define RTC_Tamper_1                    RTC_TAFCR_TAMP1E
    1 e2 L& D: A. x0 v  D4 h! g
  546. #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))6 K- u# C5 U: M( ~- i, ]
  547. ! _" a, k' M, X# F) J
  548. /**
    , Q1 B) z  [; C, }; B% J
  549.   * @}
    0 {& z2 A1 ~5 k7 T" l
  550.   */7 `' j: r2 H3 \; [" J$ a9 T

  551. $ C& R% c6 s5 G2 V; [
  552. /** @defgroup RTC_Tamper_Pin_Selection 8 T/ l: L2 s5 \0 M% K. l4 Z, b1 g
  553.   * @{: x3 v/ Y; X* c# h+ ^
  554.   */ # |; L6 d+ k" n6 F5 u+ C
  555. #define RTC_TamperPin_PC13                 ((uint32_t)0x00000000)
    % b, i4 O# j5 [/ x
  556. #define RTC_TamperPin_PI8                  ((uint32_t)0x00010000)
      O! f; _6 O9 r5 o+ Q% Z
  557. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \
    3 I3 A1 U# `& Y: G) {
  558.                                 ((PIN) == RTC_TamperPin_PI8))7 ^5 l7 j. u- n8 b7 g' o
  559. /**  |: g6 H5 E/ v
  560.   * @}$ M) _6 }2 u- Y2 a, D
  561.   */
    5 F" `6 g2 h# m! M# B

  562. + x6 G" F# z; F$ L: Z$ k8 c1 ]
  563. /** @defgroup RTC_TimeStamp_Pin_Selection 3 p& s! ?; E% f0 y
  564.   * @{
    & i4 Q3 a6 n3 {$ i; P+ X8 c5 i
  565.   */
    ' A+ t+ r0 W/ c8 r
  566. #define RTC_TimeStampPin_PC13              ((uint32_t)0x00000000)
    0 o! c0 c) U4 t3 `# C5 u5 E
  567. #define RTC_TimeStampPin_PI8               ((uint32_t)0x00020000)
    ; r( c& p$ V# q6 a  U8 f
  568. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \2 p6 ^, b6 O3 A" s' _0 X6 x
  569.                                    ((PIN) == RTC_TimeStampPin_PI8)), \) Q$ h4 y; N+ r& @
  570. /**" r- G0 B3 }# W( p! |6 |
  571.   * @}
      F  Q# u# V" q7 H0 p; n
  572.   */
    ) E) g8 Q% b2 `0 y* M/ ~7 A! m
  573. 1 Z& N3 H7 b8 p: S* E
  574. /** @defgroup RTC_Output_Type_ALARM_OUT
    3 t" R) g6 N& Y4 t& x# N
  575.   * @{- r7 p7 U" C; {# x" N
  576.   */ 6 n- G) i& K3 m- `  [
  577. #define RTC_OutputType_OpenDrain           ((uint32_t)0x00000000); l* u2 ?% s0 b" D. h( n
  578. #define RTC_OutputType_PushPull            ((uint32_t)0x00040000)" q' r* t+ _* M- t4 ~( V  m
  579. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \
    1 `* e- r& @2 m3 ^: _2 B0 w
  580.                                   ((TYPE) == RTC_OutputType_PushPull))2 S: w$ {9 u  X  T9 ^& _; v

  581. ; a7 p, O& B+ y: t# ^. }
  582. /**
    5 J! R4 |6 }4 S7 I8 z! E
  583.   * @}# x+ W0 o$ C7 F% N- C( `" P
  584.   */
    : S+ V; R& T9 ]+ x, ?4 U% k
  585. 0 |8 P, s6 P& |0 p. H
  586. /** @defgroup RTC_Add_1_Second_Parameter_Definitions+ v! k7 n5 x; u) o
  587.   * @{
    . X. k, B$ V# ~- F4 V1 O; Q
  588.   */
    1 C' N  E7 H; Q: s# b
  589. #define RTC_ShiftAdd1S_Reset      ((uint32_t)0x00000000). d7 T6 h$ j; s( L( k3 y
  590. #define RTC_ShiftAdd1S_Set        ((uint32_t)0x80000000). I/ v9 g# h' g9 D
  591. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \
    - K( Q1 J; }1 [4 I$ ^
  592.                                  ((SEL) == RTC_ShiftAdd1S_Set))
    / p# R. {+ o. [. d
  593. /**
    " c7 z% v1 x, ~! ^+ w5 S
  594.   * @}
    . v+ k' L- K9 t5 p* x
  595.   */
    1 A5 i" x" N1 A. ?' R

  596. $ J) L0 v( v3 I* a
  597. /** @defgroup RTC_Substract_Fraction_Of_Second_Value% h$ f  j8 @4 m# y- r
  598.   * @{
    + X. z4 B4 k0 n, g
  599.   */
    5 r/ Q0 u3 }6 a$ P
  600. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
    % [3 I; A3 k, o% B
  601. ) T7 ~& ^# X1 [
  602. /**; _4 \4 `' \/ a) h( ~9 Y0 i. Q' [
  603.   * @}
    - `( I2 C  f  Y4 x4 B
  604.   */
    7 `; T& w4 c/ H8 I

  605. 5 k$ k; Y( a8 x6 U
  606. /** @defgroup RTC_Backup_Registers_Definitions
    : O; ]8 y+ ?/ A
  607.   * @{+ V4 K$ m4 @  i
  608.   *// X. T+ x- [3 N5 ^6 P

  609. 7 n/ A3 V  K0 k, o( A& X
  610. #define RTC_BKP_DR0                       ((uint32_t)0x00000000)! J, x! N  N$ J1 [+ [: n* ^- A. Q9 q
  611. #define RTC_BKP_DR1                       ((uint32_t)0x00000001)3 p8 b9 h7 }; _5 |% u
  612. #define RTC_BKP_DR2                       ((uint32_t)0x00000002)
    3 ?( z% x4 f9 J+ d5 S; N+ Y* a
  613. #define RTC_BKP_DR3                       ((uint32_t)0x00000003). ]" f. [- X5 q
  614. #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
    # D. a+ B5 b2 I3 Y: P
  615. #define RTC_BKP_DR5                       ((uint32_t)0x00000005)
    0 x4 Z7 P- B6 S
  616. #define RTC_BKP_DR6                       ((uint32_t)0x00000006)
    : B. f8 \4 C; F2 e+ F) H7 c
  617. #define RTC_BKP_DR7                       ((uint32_t)0x00000007)
    ! h2 e; \3 ?7 p- x* q3 o% i# O. Z
  618. #define RTC_BKP_DR8                       ((uint32_t)0x00000008)
    ) B4 R2 G* ^6 @* n$ M' u
  619. #define RTC_BKP_DR9                       ((uint32_t)0x00000009)
    ) Y  D+ N7 K# r% J1 G
  620. #define RTC_BKP_DR10                      ((uint32_t)0x0000000A)
    / ^; `- n/ _: u$ _9 ~
  621. #define RTC_BKP_DR11                      ((uint32_t)0x0000000B)
    5 \7 |6 t! o  s- x) I( G2 o
  622. #define RTC_BKP_DR12                      ((uint32_t)0x0000000C)
    0 Q4 J9 N9 S# L! r7 R
  623. #define RTC_BKP_DR13                      ((uint32_t)0x0000000D)7 p* I! g7 N7 Y; ?% b
  624. #define RTC_BKP_DR14                      ((uint32_t)0x0000000E)
    $ L. C( \5 h3 \4 U
  625. #define RTC_BKP_DR15                      ((uint32_t)0x0000000F)
    - [7 v( t3 R0 R
  626. #define RTC_BKP_DR16                      ((uint32_t)0x00000010)
    % U. t% ?! @. E0 L+ C
  627. #define RTC_BKP_DR17                      ((uint32_t)0x00000011)
    ( R! v3 @& Q; T- t! d+ ]& r
  628. #define RTC_BKP_DR18                      ((uint32_t)0x00000012)6 w0 [! \% T! B8 y' P" {
  629. #define RTC_BKP_DR19                      ((uint32_t)0x00000013)
    5 t) ~( `4 V5 J% c8 L. M& C
  630. #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0) || \7 k: y1 k9 Z) W6 d! y
  631.                                            ((BKP) == RTC_BKP_DR1) || \0 Z% [7 l$ h# S  d: w$ h
  632.                                            ((BKP) == RTC_BKP_DR2) || \
    0 w) V4 @+ l8 J" D7 L# l8 \; X
  633.                                            ((BKP) == RTC_BKP_DR3) || \' Z+ {7 \1 [. q$ v) B: T8 G  s. d5 Q
  634.                                            ((BKP) == RTC_BKP_DR4) || \$ b; c$ k# D+ {, ^* a: [
  635.                                            ((BKP) == RTC_BKP_DR5) || \5 t  y! z% l7 F; S. g. E+ N  I+ |
  636.                                            ((BKP) == RTC_BKP_DR6) || \) y* Z" ^, y* t" ~8 v- v- F, s
  637.                                            ((BKP) == RTC_BKP_DR7) || \
    , t7 p$ x( m& p. l6 L
  638.                                            ((BKP) == RTC_BKP_DR8) || \1 r5 C- i3 t! j1 o; X
  639.                                            ((BKP) == RTC_BKP_DR9) || \
    9 P" ?" V$ b: L- F! c: t
  640.                                            ((BKP) == RTC_BKP_DR10) || \
    1 M. I! [7 R7 i" a* U
  641.                                            ((BKP) == RTC_BKP_DR11) || \( S3 d9 ~2 [% \9 t% j
  642.                                            ((BKP) == RTC_BKP_DR12) || \
    " z1 B1 l- @  K% `0 F4 w& Q
  643.                                            ((BKP) == RTC_BKP_DR13) || \0 e6 n$ g. i% v; t  x
  644.                                            ((BKP) == RTC_BKP_DR14) || \* y- e& ]/ ?4 I! p! _* J2 ?8 E
  645.                                            ((BKP) == RTC_BKP_DR15) || \
    ! ^- U3 H4 B. z" Y
  646.                                            ((BKP) == RTC_BKP_DR16) || \. ]) ?1 W3 N; ^3 L: k* G3 j4 J
  647.                                            ((BKP) == RTC_BKP_DR17) || \
    : N3 J' A6 @  `. s0 f
  648.                                            ((BKP) == RTC_BKP_DR18) || \. p( x, q/ P5 P3 Z0 ^6 _, I$ O& o2 c
  649.                                            ((BKP) == RTC_BKP_DR19))
    . A# {7 d  Y6 @( H/ O
  650. /**' g" k8 Q! X3 C
  651.   * @}* C  u& {# S) }- r9 R0 b
  652.   */ 7 b. F# f$ S( w, z4 r% N+ L

  653. + N/ ]( G; w" f$ |4 S: a, B9 }; Q
  654. /** @defgroup RTC_Input_parameter_format_definitions
    9 l) m* L" S% f
  655.   * @{6 }) f! l% y; N' B. X
  656.   */
    . N/ f3 C$ W& s$ p
  657. #define RTC_Format_BIN                    ((uint32_t)0x000000000)# u0 v3 \. F6 u+ g1 a
  658. #define RTC_Format_BCD                    ((uint32_t)0x000000001): B2 w- ~3 E/ U- U
  659. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))
    2 T0 ?4 K, J3 O9 j: y5 Z
  660. 6 o, I) S1 d9 M. I
  661. /**0 G/ M8 {* ~( f# Z
  662.   * @}
    % z5 ^5 Q" I, Z8 r
  663.   */
    5 e0 V# z: ^( U- D2 d' w
  664. / A: {$ Y! R  G& ~8 n, k( j
  665. /** @defgroup RTC_Flags_Definitions
    . F9 G$ a0 Y: u- u3 U8 X
  666.   * @{9 |0 e, F% d0 f$ ~+ B% u  _) W) Y, Z: d
  667.   */ . ]9 A- ^+ j9 p# d- e
  668. #define RTC_FLAG_RECALPF                  ((uint32_t)0x00010000). o. i0 ~/ D' s1 S
  669. #define RTC_FLAG_TAMP1F                   ((uint32_t)0x00002000)
    ' L9 X) P8 F5 V; D) ^/ U% O5 L
  670. #define RTC_FLAG_TSOVF                    ((uint32_t)0x00001000)
    ; `1 w! X' S; q/ ~# a/ W
  671. #define RTC_FLAG_TSF                      ((uint32_t)0x00000800)
      S+ _* r9 z" Z
  672. #define RTC_FLAG_WUTF                     ((uint32_t)0x00000400)
    5 I' W, m+ K! M8 W+ ^
  673. #define RTC_FLAG_ALRBF                    ((uint32_t)0x00000200)
    * _/ u) H: d1 `5 ?/ V
  674. #define RTC_FLAG_ALRAF                    ((uint32_t)0x00000100)1 b: x) k8 K# }1 j
  675. #define RTC_FLAG_INITF                    ((uint32_t)0x00000040)' M, p: G& P/ s  ~9 `
  676. #define RTC_FLAG_RSF                      ((uint32_t)0x00000020)
    5 O* J9 a9 R# Y+ F/ _5 r, p) c& r
  677. #define RTC_FLAG_INITS                    ((uint32_t)0x00000010)/ k$ P7 _% X4 t) C( w$ k- u+ X2 q" s% D3 X
  678. #define RTC_FLAG_SHPF                     ((uint32_t)0x00000008)
    + e# L" w2 H% ?$ P' f1 C1 G
  679. #define RTC_FLAG_WUTWF                    ((uint32_t)0x00000004)  x" a" Z$ n2 ?; o, s6 G+ d
  680. #define RTC_FLAG_ALRBWF                   ((uint32_t)0x00000002)
    & V( A, B# V9 P5 F2 e
  681. #define RTC_FLAG_ALRAWF                   ((uint32_t)0x00000001)
    5 R# i' Y% C' L  N, q$ {$ n. u: S& N+ g
  682. #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \* `: P6 q( f6 ^
  683.                                ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \2 ^" z% Q- g; K& k
  684.                                ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
    8 x) |- G0 T! z; h- X: z& m
  685.                                ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \
    6 l8 G$ [% L* ~' D* @4 t
  686.                                ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \* u; {7 k6 ]9 J; J. d' {) y, s+ Y" ?# T
  687.                                ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_RECALPF) || \& G: m1 d1 J) K" l
  688.                                 ((FLAG) == RTC_FLAG_SHPF))
    5 P' d! A0 B( ~2 ?% |; b9 {; H
  689. #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET))
    % A; o1 w1 `0 ^7 i
  690. /**
      @! b! w# ?; ~1 T- B
  691.   * @}! b6 x! ?; T' Q+ G4 `% S
  692.   */
    0 Y# M' n' [& D8 C# j6 D8 f

  693. & t0 i1 u4 N$ t3 R/ o8 n: x
  694. /** @defgroup RTC_Interrupts_Definitions
    1 D4 N3 X* G; T& G' ^
  695.   * @{
    - W4 x7 c, p9 i5 U
  696.   */
    & l+ k" r. q" E3 R
  697. #define RTC_IT_TS                         ((uint32_t)0x00008000)4 j: v; s. U% q' g+ O! S5 ~
  698. #define RTC_IT_WUT                        ((uint32_t)0x00004000)7 F6 W) w$ Q" @  u) z
  699. #define RTC_IT_ALRB                       ((uint32_t)0x00002000)8 g. b4 @8 b) X" _8 Z( o
  700. #define RTC_IT_ALRA                       ((uint32_t)0x00001000)
    ( B/ j/ Y& t6 }+ Y# P
  701. #define RTC_IT_TAMP                       ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */4 y( `& e% m7 v$ S1 l+ G' z, `$ J
  702. #define RTC_IT_TAMP1                      ((uint32_t)0x00020000)
    4 w, X+ s/ Z: E' f7 P

  703. ; g6 Q& l# c2 `
  704. #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))
    * l" e! {! N/ a7 L2 X
  705. #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \1 D% U8 W6 h: Z6 p" ~& {2 K
  706.                            ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \
    + T! v/ H1 I" h. p
  707.                            ((IT) == RTC_IT_TAMP1))$ x" H# N. [4 \  k0 K2 L% O
  708. #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))
    , A4 _* V/ u" `6 s
  709. 4 N; J2 V" U2 e3 O' ?
  710. /**+ i. Q: |: A% U+ K' d# }) I9 }* ^+ f+ Y
  711.   * @}. r; K7 B6 H, [0 Q8 b3 P- L
  712.   */ & |( _! D. w8 S" z) _& m- c

  713. 8 g) [/ H1 I. g
  714. /** @defgroup RTC_Legacy 9 I9 J- E, r* D, L2 n2 j8 p
  715.   * @{
    , q7 P. {; T) v9 A. G
  716.   */
    ! B; A8 C. l% e
  717. #define RTC_DigitalCalibConfig  RTC_CoarseCalibConfig  c1 h2 d) d2 y  ^; M- B
  718. #define RTC_DigitalCalibCmd     RTC_CoarseCalibCmd7 U6 d3 `! i( o
复制代码
. Z: @* C: x0 d) i9 P8 B
03. 相关函数
) \2 T! v1 o, C6 \5 [1 C4 c
  1. /*  Function used to set the RTC configuration to the default reset state *****/
    2 \' _6 v: n1 u/ A0 |
  2. ErrorStatus RTC_DeInit(void);
    % t0 c8 y9 b- B+ t  H
  3. . k! _9 g$ g& s" s4 \4 Z. |
  4. /* Initialization and Configuration functions *********************************/$ [& x& c' h+ J( I/ T
  5. ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);" g8 |* r# X  [) h7 V8 K
  6. void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);+ K. Y. X- B1 i; ?
  7. void RTC_WriteProtectionCmd(FunctionalState NewState);
    , M' v' |4 Y% L+ I  t6 I" p+ |
  8. ErrorStatus RTC_EnterInitMode(void);% z7 {! b; m$ d* C
  9. void RTC_ExitInitMode(void);
    ! c7 k/ E- y0 z$ d
  10. ErrorStatus RTC_WaitForSynchro(void);# u% x6 |  T- W
  11. ErrorStatus RTC_RefClockCmd(FunctionalState NewState);
    0 q/ ]% |' J' Z2 S/ z
  12. void RTC_BypassShadowCmd(FunctionalState NewState);; d3 T, a1 O& `. k9 P: N) @; j5 K
  13.   G6 z# r4 {+ G- X* U! A
  14. /* Time and Date configuration functions **************************************/( g9 e7 \* q2 w9 ?! B! M, T
  15. ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
    " N4 u- n. d2 k! f) ~% ~1 [
  16. void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);
    / e, W# g% K; y) a* H: E+ u
  17. void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);  L& p0 Y* h; w9 P5 m& u9 F
  18. uint32_t RTC_GetSubSecond(void);7 |$ p# N! O; V+ S1 K" Z' ]
  19. ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
    3 C( [  Q" M. {
  20. void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);5 l5 ~) G& |0 F/ B
  21. void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);0 ~- C$ S. e# A, R: s' ^

  22. 8 w* q( D2 _+ g4 S$ M: ]
  23. /* Alarms (Alarm A and Alarm B) configuration functions  **********************/3 z0 r0 A$ X3 S
  24. void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
    ) L9 r/ I( L& D8 _
  25. void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);: ?1 P0 a( Y0 W" f2 G! C: b/ E( {) x
  26. void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);/ g2 w( @# ]9 z& [$ x9 t
  27. ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);1 b8 w) _2 c8 i& M6 }% Y
  28. void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask);9 T, X. @. R3 O" A% P
  29. uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm);
    / l1 d" Z) ?9 s& `. O

  30. " J8 Q/ L8 v; A0 g
  31. /* WakeUp Timer configuration functions ***************************************/
    ; I' E; x9 j+ _! l  ?) v
  32. void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);
    ; b! O. F5 C; v$ f- w
  33. void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);
    3 C3 t0 n! D! Y! `" q
  34. uint32_t RTC_GetWakeUpCounter(void);3 B; L9 ]4 L8 [3 M' j7 S0 }! r
  35. ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);
      i6 g& N$ V  {
  36. 3 `4 ]" t( E0 G1 x
  37. /* Daylight Saving configuration functions ************************************/6 X) R) Q. M" ?
  38. void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);
    ; \9 r. e& y0 k( h3 B  _% @8 |/ @
  39. uint32_t RTC_GetStoreOperation(void);8 z7 L9 K4 n2 k; g0 _, r3 J9 d

  40. 4 _8 T+ |: }4 ]8 u, y
  41. /* Output pin Configuration function ******************************************/
    $ [* {: |( O2 D3 _2 [
  42. void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);
    ) ~3 g3 ~* z- ~0 p1 Z; Z

  43. . T; {" T! g8 d( R
  44. /* Digital Calibration configuration functions *********************************/
    * K2 @& I4 p9 D  s2 N
  45. ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);1 M! O& ^' B5 r* \4 }8 u$ e
  46. ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);/ k8 H, X# g% _7 G
  47. void RTC_CalibOutputCmd(FunctionalState NewState);
    . u1 ^5 [; o' G- @. |' m
  48. void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput);
    8 K8 r" }0 \6 v7 Z1 l' z1 G; F+ E
  49. ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
    7 f* [( u  S# p) Z; O5 J
  50.                                   uint32_t RTC_SmoothCalibPlusPulses,- L) @0 M$ e( u% E) o
  51.                                   uint32_t RTC_SmouthCalibMinusPulsesValue);
    , _" L" T$ Q* D; E& ?7 l, j  E

  52. ( D3 y9 Z, f" ]2 {0 v
  53. /* TimeStamp configuration functions ******************************************// q  E1 f, \. h4 |
  54. void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);4 X& I+ X9 r. e. V+ j' O2 Y1 d
  55. void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,3 p( t0 B8 M9 N' E( B& ]
  56.                                       RTC_DateTypeDef* RTC_StampDateStruct);
    ' j8 [6 ?  S8 Z5 b- {. T. e) r
  57. uint32_t RTC_GetTimeStampSubSecond(void);$ D  x! [+ F. C$ V% L% h3 N& R

  58. ( I# z" ?3 T1 x; [* g9 D
  59. /* Tampers configuration functions ********************************************/
    ( y5 a. R8 L2 j, h6 W
  60. void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);
    / W& J0 }4 E; i: C3 ^% C# R
  61. void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);( g9 x. g3 w3 }" ^/ R# n7 B
  62. void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter);- s5 q; J" J+ _% Z. `
  63. void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq);
    4 w7 K6 z9 o- x* w
  64. void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration);: i" @* z$ z/ j, \
  65. void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState);' E' ]3 j* c. j5 |  F
  66. void RTC_TamperPullUpCmd(FunctionalState NewState);
    . _* w. t$ ~, C4 O" T5 d! l2 ?  Q" P9 @

  67. " s; U: e5 Y3 v0 _8 t# v- o+ W
  68. /* Backup Data Registers configuration functions ******************************/. p# N* Q0 i8 j& o2 ]/ a! i. I
  69. void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);& P; ^3 B" t  @: V, q" I
  70. uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);, q  i8 g8 P  |  C9 \
  71. * ^& _/ e, c# x& j# I
  72. /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration
    " S: K2 v) c) @% y- v! R. F
  73.    functions ******************************************************************/! `0 Y4 |0 a* i) b8 k
  74. void RTC_TamperPinSelection(uint32_t RTC_TamperPin);2 c: H- ^/ a- ~
  75. void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);
    8 {  b# N  ]9 h7 b0 J% r
  76. void RTC_OutputTypeConfig(uint32_t RTC_OutputType);
    0 Q8 j: R, C8 \* S

  77. ' y6 P& w1 t$ M7 p9 `! p, z
  78. /* RTC_Shift_control_synchonisation_functions *********************************/
    & B" N! s' M. I
  79. ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS);7 K/ C( ~' x! G2 t/ M6 r+ E
  80. & c- _+ }( \; y7 H4 a, q" o4 S
  81. /* Interrupts and flags management functions **********************************/
    ' m. S5 n( P  U: l' f
  82. void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);, _2 k8 j1 i1 ^! K7 q) y
  83. FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);7 {9 B2 [/ ?, v1 j1 r
  84. void RTC_ClearFlag(uint32_t RTC_FLAG);! @3 t% B: t) f# I  W2 L) h! a& k- ^
  85. ITStatus RTC_GetITStatus(uint32_t RTC_IT);
    0 _2 T! ]6 g& s5 N
  86. void RTC_ClearITPendingBit(uint32_t RTC_IT);7 _  l% O. \4 O3 m( ?6 f  K$ m
复制代码

5 E  ]- e2 y3 e6 w04. 结构体封装
9 ]0 C4 m( ^- t" S! H2 Q. {
  1. /** $ W( v. i+ U1 `+ U) S; f2 {
  2.   * @brief Real-Time Clock
    - n. D* r& w6 ]) b, `+ ~
  3.   */; s: [8 ]. K# Y% T

  4. + d& K* `, _! }
  5. typedef struct% |# J' D5 d2 _6 |1 ?. k/ W6 e2 U$ G
  6. {
    8 ?) V% Y+ n* p6 H9 C7 L9 m
  7.   __IO uint32_t TR;      /*!< RTC time register,                                        Address offset: 0x00 */8 Y4 _3 n+ M. r" m3 q$ w5 z0 T
  8.   __IO uint32_t DR;      /*!< RTC date register,                                        Address offset: 0x04 */
    % i, I$ Q0 _5 l1 w+ M$ I$ Z1 z5 a+ c2 d
  9.   __IO uint32_t CR;      /*!< RTC control register,                                     Address offset: 0x08 *// Z9 u" D- ]7 P* J9 N+ _% O
  10.   __IO uint32_t ISR;     /*!< RTC initialization and status register,                   Address offset: 0x0C */
    ' i+ I/ ]- y# {5 {6 z+ g6 |
  11.   __IO uint32_t PRER;    /*!< RTC prescaler register,                                   Address offset: 0x10 */5 f4 y& m0 N$ B4 f& l3 Y- `
  12.   __IO uint32_t WUTR;    /*!< RTC wakeup timer register,                                Address offset: 0x14 */
    2 T8 l! R+ T: Y* ?8 ]$ W4 P$ K
  13.   __IO uint32_t CALIBR;  /*!< RTC calibration register,                                 Address offset: 0x18 */$ q2 w9 }' L) W* g
  14.   __IO uint32_t ALRMAR;  /*!< RTC alarm A register,                                     Address offset: 0x1C */
    - ]& k) V4 G+ u  L# u
  15.   __IO uint32_t ALRMBR;  /*!< RTC alarm B register,                                     Address offset: 0x20 */7 t3 k- q4 l" ^. g9 q( G
  16.   __IO uint32_t WPR;     /*!< RTC write protection register,                            Address offset: 0x24 */% n. g0 W0 P5 a$ ]8 P" |
  17.   __IO uint32_t SSR;     /*!< RTC sub second register,                                  Address offset: 0x28 */$ g  K" s, v' ]7 d  j1 w9 ~4 H2 h' y
  18.   __IO uint32_t SHIFTR;  /*!< RTC shift control register,                               Address offset: 0x2C */7 U+ L+ m$ y. F# Z( p
  19.   __IO uint32_t TSTR;    /*!< RTC time stamp time register,                             Address offset: 0x30 */
    " o0 n' z1 e7 L9 F5 k- t
  20.   __IO uint32_t TSDR;    /*!< RTC time stamp date register,                             Address offset: 0x34 */
    ( K$ [9 z; v; t& I- L/ f; A, _% K
  21.   __IO uint32_t TSSSR;   /*!< RTC time-stamp sub second register,                       Address offset: 0x38 */: f: p7 q( t3 J1 b) w$ V
  22.   __IO uint32_t CALR;    /*!< RTC calibration register,                                 Address offset: 0x3C */& r0 a  R$ F: z* |2 R7 K
  23.   __IO uint32_t TAFCR;   /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */. A8 Q& w: T1 z: y) \' i$ w
  24.   __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register,                          Address offset: 0x44 */8 U6 ^1 y: Y) @" s& G
  25.   __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register,                          Address offset: 0x48 */2 S5 g' u( v3 V3 I/ w- E! j  ^" F
  26.   uint32_t RESERVED7;    /*!< Reserved, 0x4C                                                                 */
    6 O) C$ |9 h5 Q
  27.   __IO uint32_t BKP0R;   /*!< RTC backup register 1,                                    Address offset: 0x50 */( t, G8 U. Z. X2 w
  28.   __IO uint32_t BKP1R;   /*!< RTC backup register 1,                                    Address offset: 0x54 */
    : d5 C. S  {' q3 r- l7 z: o' F
  29.   __IO uint32_t BKP2R;   /*!< RTC backup register 2,                                    Address offset: 0x58 */1 i7 F) V& t; ~2 t$ U& J* p5 [
  30.   __IO uint32_t BKP3R;   /*!< RTC backup register 3,                                    Address offset: 0x5C */0 N' e# O4 a1 Q& x) B# I
  31.   __IO uint32_t BKP4R;   /*!< RTC backup register 4,                                    Address offset: 0x60 */7 n3 f' A( M( t9 [+ m) g
  32.   __IO uint32_t BKP5R;   /*!< RTC backup register 5,                                    Address offset: 0x64 */: q& Z, C! N1 o, |8 H/ U3 x8 C# h5 s
  33.   __IO uint32_t BKP6R;   /*!< RTC backup register 6,                                    Address offset: 0x68 */- M& J* ]1 O5 g; h% F/ l
  34.   __IO uint32_t BKP7R;   /*!< RTC backup register 7,                                    Address offset: 0x6C */
    . e& _6 A- J$ I- K6 ~  A+ g, |7 k/ e
  35.   __IO uint32_t BKP8R;   /*!< RTC backup register 8,                                    Address offset: 0x70 */! e; F. K" I6 _3 |* Q3 o% p# B
  36.   __IO uint32_t BKP9R;   /*!< RTC backup register 9,                                    Address offset: 0x74 */
    + R! a) f0 P+ _7 T0 r9 |
  37.   __IO uint32_t BKP10R;  /*!< RTC backup register 10,                                   Address offset: 0x78 */
    4 e' I. D. Z$ d
  38.   __IO uint32_t BKP11R;  /*!< RTC backup register 11,                                   Address offset: 0x7C */! ?9 W  j( V9 u" C
  39.   __IO uint32_t BKP12R;  /*!< RTC backup register 12,                                   Address offset: 0x80 */
    : i; L( F5 h6 j$ I& V
  40.   __IO uint32_t BKP13R;  /*!< RTC backup register 13,                                   Address offset: 0x84 */0 D, r, u$ w. C* f
  41.   __IO uint32_t BKP14R;  /*!< RTC backup register 14,                                   Address offset: 0x88 */( s- S6 `1 X6 _- e
  42.   __IO uint32_t BKP15R;  /*!< RTC backup register 15,                                   Address offset: 0x8C */; E- O9 U# L8 M# q4 W
  43.   __IO uint32_t BKP16R;  /*!< RTC backup register 16,                                   Address offset: 0x90 */+ h, p+ S7 b- \2 a6 [3 h: e
  44.   __IO uint32_t BKP17R;  /*!< RTC backup register 17,                                   Address offset: 0x94 */% ~5 a! {+ ~( \
  45.   __IO uint32_t BKP18R;  /*!< RTC backup register 18,                                   Address offset: 0x98 */
    # H2 T4 L0 T3 U  a) {* ~5 G9 @
  46.   __IO uint32_t BKP19R;  /*!< RTC backup register 19,                                   Address offset: 0x9C */6 Y9 E$ b- e& i; o: Y7 ^
  47. } RTC_TypeDef;
复制代码
# q1 }5 B% d0 M' Q. D7 z, ]
赞 收藏 评论0 发布时间:2022-3-29 09:37

举报

0个回答

所属标签

相似技术帖

官网相关资源

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