You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32l1xx_hal_rtc_ex.h 66KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_rtc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32L1xx_HAL_RTC_EX_H
  21. #define __STM32L1xx_HAL_RTC_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32l1xx_hal_def.h"
  27. /** @addtogroup STM32L1xx_HAL_Driver
  28. * @{
  29. */
  30. /** @defgroup RTCEx RTCEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief RTC Tamper structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Tamper; /*!< Specifies the Tamper Pin.
  43. This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */
  44. uint32_t Trigger; /*!< Specifies the Tamper Trigger.
  45. This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
  46. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  47. uint32_t Filter; /*!< Specifies the RTC Filter Tamper.
  48. This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
  49. uint32_t SamplingFrequency; /*!< Specifies the sampling frequency.
  50. This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
  51. uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration .
  52. This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
  53. uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp .
  54. This parameter can be a value of @ref RTCEx_Tamper_Pull_Up_Definitions */
  55. uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection.
  56. This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
  57. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  58. } RTC_TamperTypeDef;
  59. /**
  60. * @}
  61. */
  62. /* Exported constants --------------------------------------------------------*/
  63. /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
  64. * @{
  65. */
  66. /** @defgroup RTCEx_Output_selection_Definition RTCEx Output Selection Definition
  67. * @{
  68. */
  69. #define RTC_TR_RESERVED_MASK (0x007F7F7FU)
  70. #define RTC_DR_RESERVED_MASK (0x00FFFF3FU)
  71. #define RTC_INIT_MASK (0xFFFFFFFFU)
  72. #define RTC_RSF_MASK (0xFFFFFF5FU)
  73. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  74. #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \
  75. RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \
  76. RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \
  77. RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \
  78. RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP3F | \
  79. RTC_FLAG_RECALPF))
  80. #else
  81. #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \
  82. RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \
  83. RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \
  84. RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \
  85. RTC_FLAG_TAMP1F | \
  86. RTC_FLAG_RECALPF))
  87. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  88. /**
  89. * @}
  90. */
  91. /** @defgroup RTCEx_Backup_Registers_Definition RTCEx Backup Registers Definition
  92. * @{
  93. */
  94. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  95. #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU)
  96. #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB)
  97. #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x1FFFU)
  98. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  99. /**
  100. * @}
  101. */
  102. /** @defgroup RTC_Interrupts_Definitions Interrupts Definitions
  103. * @{
  104. */
  105. #define RTC_IT_TS ((uint32_t)RTC_CR_TSIE)
  106. #define RTC_IT_WUT ((uint32_t)RTC_CR_WUTIE)
  107. #define RTC_IT_ALRB ((uint32_t)RTC_CR_ALRBIE)
  108. #define RTC_IT_ALRA ((uint32_t)RTC_CR_ALRAIE)
  109. #define RTC_IT_TAMP1 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP1E))
  110. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  111. #define RTC_IT_TAMP2 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP2E))
  112. #define RTC_IT_TAMP3 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP3E))
  113. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  114. /**
  115. * @}
  116. */
  117. /** @defgroup RTC_Flags_Definitions Flags Definitions
  118. * @{
  119. */
  120. #define RTC_FLAG_RECALPF ((uint32_t)RTC_ISR_RECALPF)
  121. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  122. #define RTC_FLAG_TAMP3F ((uint32_t)RTC_ISR_TAMP3F)
  123. #define RTC_FLAG_TAMP2F ((uint32_t)RTC_ISR_TAMP2F)
  124. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  125. #define RTC_FLAG_TAMP1F ((uint32_t)RTC_ISR_TAMP1F)
  126. #define RTC_FLAG_TSOVF ((uint32_t)RTC_ISR_TSOVF)
  127. #define RTC_FLAG_TSF ((uint32_t)RTC_ISR_TSF)
  128. #define RTC_FLAG_WUTF ((uint32_t)RTC_ISR_WUTF)
  129. #define RTC_FLAG_ALRBF ((uint32_t)RTC_ISR_ALRBF)
  130. #define RTC_FLAG_ALRAF ((uint32_t)RTC_ISR_ALRAF)
  131. #define RTC_FLAG_INITF ((uint32_t)RTC_ISR_INITF)
  132. #define RTC_FLAG_RSF ((uint32_t)RTC_ISR_RSF)
  133. #define RTC_FLAG_INITS ((uint32_t)RTC_ISR_INITS)
  134. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  135. #define RTC_FLAG_SHPF ((uint32_t)RTC_ISR_SHPF)
  136. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  137. #define RTC_FLAG_WUTWF ((uint32_t)RTC_ISR_WUTWF)
  138. #define RTC_FLAG_ALRBWF ((uint32_t)RTC_ISR_ALRBWF)
  139. #define RTC_FLAG_ALRAWF ((uint32_t)RTC_ISR_ALRAWF)
  140. /**
  141. * @}
  142. */
  143. /** @defgroup RTCEx_Output_selection_Definitions Output selection Definitions
  144. * @{
  145. */
  146. #define RTC_OUTPUT_DISABLE (0x00000000U)
  147. #define RTC_OUTPUT_ALARMA (0x00200000U)
  148. #define RTC_OUTPUT_ALARMB (0x00400000U)
  149. #define RTC_OUTPUT_WAKEUP (0x00600000U)
  150. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
  151. ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
  152. ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
  153. ((OUTPUT) == RTC_OUTPUT_WAKEUP))
  154. /**
  155. * @}
  156. */
  157. /** @defgroup RTCEx_Backup_Registers_Definitions Backup Registers Definitions
  158. * @{
  159. */
  160. #if RTC_BKP_NUMBER > 0
  161. #define RTC_BKP_DR0 (0x00000000U)
  162. #define RTC_BKP_DR1 (0x00000001U)
  163. #define RTC_BKP_DR2 (0x00000002U)
  164. #define RTC_BKP_DR3 (0x00000003U)
  165. #define RTC_BKP_DR4 (0x00000004U)
  166. #endif /* RTC_BKP_NUMBER > 0 */
  167. #if RTC_BKP_NUMBER > 5
  168. #define RTC_BKP_DR5 (0x00000005U)
  169. #define RTC_BKP_DR6 (0x00000006U)
  170. #define RTC_BKP_DR7 (0x00000007U)
  171. #define RTC_BKP_DR8 (0x00000008U)
  172. #define RTC_BKP_DR9 (0x00000009U)
  173. #define RTC_BKP_DR10 (0x0000000AU)
  174. #define RTC_BKP_DR11 (0x0000000BU)
  175. #define RTC_BKP_DR12 (0x0000000CU)
  176. #define RTC_BKP_DR13 (0x0000000DU)
  177. #define RTC_BKP_DR14 (0x0000000EU)
  178. #define RTC_BKP_DR15 (0x0000000FU)
  179. #define RTC_BKP_DR16 (0x00000010U)
  180. #define RTC_BKP_DR17 (0x00000011U)
  181. #define RTC_BKP_DR18 (0x00000012U)
  182. #define RTC_BKP_DR19 (0x00000013U)
  183. #endif /* RTC_BKP_NUMBER > 5 */
  184. #if RTC_BKP_NUMBER > 20
  185. #define RTC_BKP_DR20 (0x00000014U)
  186. #define RTC_BKP_DR21 (0x00000015U)
  187. #define RTC_BKP_DR22 (0x00000016U)
  188. #define RTC_BKP_DR23 (0x00000017U)
  189. #define RTC_BKP_DR24 (0x00000018U)
  190. #define RTC_BKP_DR25 (0x00000019U)
  191. #define RTC_BKP_DR26 (0x0000001AU)
  192. #define RTC_BKP_DR27 (0x0000001BU)
  193. #define RTC_BKP_DR28 (0x0000001CU)
  194. #define RTC_BKP_DR29 (0x0000001DU)
  195. #define RTC_BKP_DR30 (0x0000001EU)
  196. #define RTC_BKP_DR31 (0x0000001FU)
  197. #endif /* RTC_BKP_NUMBER > 20 */
  198. #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER)
  199. /**
  200. * @}
  201. */
  202. /** @defgroup RTCEx_Time_Stamp_Edges_Definitions Time Stamp Edges Definitions
  203. * @{
  204. */
  205. #define RTC_TIMESTAMPEDGE_RISING (0x00000000U)
  206. #define RTC_TIMESTAMPEDGE_FALLING (0x00000008U)
  207. #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
  208. ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
  209. /**
  210. * @}
  211. */
  212. /** @defgroup RTCEx_Tamper_Pins_Definitions Tamper Pins Definitions
  213. * @{
  214. */
  215. #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E
  216. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  217. #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E
  218. #define RTC_TAMPER_3 RTC_TAFCR_TAMP3E
  219. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  220. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  221. #define IS_RTC_TAMPER(TAMPER) (((~(RTC_TAMPER_1|RTC_TAMPER_2|RTC_TAMPER_3) & (TAMPER)) == (uint32_t)RESET) && ((TAMPER) != (uint32_t)RESET))
  222. #else
  223. #define IS_RTC_TAMPER(TAMPER) ((TAMPER) == RTC_TAMPER_1)
  224. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  225. /**
  226. * @}
  227. */
  228. /** @defgroup RTCEx_Tamper_Trigger_Definitions Tamper Trigger Definitions
  229. * @{
  230. */
  231. #define RTC_TAMPERTRIGGER_RISINGEDGE (0x00000000U)
  232. #define RTC_TAMPERTRIGGER_FALLINGEDGE (0x00000002U)
  233. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  234. #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
  235. #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
  236. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  237. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  238. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  239. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
  240. ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
  241. ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
  242. #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB)
  243. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
  244. ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE))
  245. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  246. /**
  247. * @}
  248. */
  249. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  250. /** @defgroup RTCEx_Tamper_Filter_Definitions RTCex Tamper Filter Definitions
  251. * @{
  252. */
  253. #define RTC_TAMPERFILTER_DISABLE (0x00000000U) /*!< Tamper filter is disabled */
  254. #define RTC_TAMPERFILTER_2SAMPLE (0x00000800U) /*!< Tamper is activated after 2
  255. consecutive samples at the active level */
  256. #define RTC_TAMPERFILTER_4SAMPLE (0x00001000U) /*!< Tamper is activated after 4
  257. consecutive samples at the active level */
  258. #define RTC_TAMPERFILTER_8SAMPLE (0x00001800U) /*!< Tamper is activated after 8
  259. consecutive samples at the active level. */
  260. #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
  261. ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
  262. ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
  263. ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
  264. /**
  265. * @}
  266. */
  267. /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions
  268. * @{
  269. */
  270. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 (0x00000000U) /*!< Each of the tamper inputs are sampled
  271. with a frequency = RTCCLK / 32768 */
  272. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 (0x00000100U) /*!< Each of the tamper inputs are sampled
  273. with a frequency = RTCCLK / 16384 */
  274. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 (0x00000200U) /*!< Each of the tamper inputs are sampled
  275. with a frequency = RTCCLK / 8192 */
  276. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (0x00000300U) /*!< Each of the tamper inputs are sampled
  277. with a frequency = RTCCLK / 4096 */
  278. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 (0x00000400U) /*!< Each of the tamper inputs are sampled
  279. with a frequency = RTCCLK / 2048 */
  280. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (0x00000500U) /*!< Each of the tamper inputs are sampled
  281. with a frequency = RTCCLK / 1024 */
  282. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (0x00000600U) /*!< Each of the tamper inputs are sampled
  283. with a frequency = RTCCLK / 512 */
  284. #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (0x00000700U) /*!< Each of the tamper inputs are sampled
  285. with a frequency = RTCCLK / 256 */
  286. #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
  287. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
  288. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
  289. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
  290. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
  291. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
  292. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
  293. ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
  294. /**
  295. * @}
  296. */
  297. /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions
  298. * @{
  299. */
  300. #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK (0x00000000U) /*!< Tamper pins are pre-charged before
  301. sampling during 1 RTCCLK cycle */
  302. #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK (0x00002000U) /*!< Tamper pins are pre-charged before
  303. sampling during 2 RTCCLK cycles */
  304. #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK (0x00004000U) /*!< Tamper pins are pre-charged before
  305. sampling during 4 RTCCLK cycles */
  306. #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (0x00006000U) /*!< Tamper pins are pre-charged before
  307. sampling during 8 RTCCLK cycles */
  308. #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
  309. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
  310. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
  311. ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
  312. /**
  313. * @}
  314. */
  315. /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions TimeStampOnTamperDetection Definitions
  316. * @{
  317. */
  318. #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAFCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */
  319. #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE (0x00000000U) /*!< TimeStamp on Tamper Detection event is not saved */
  320. #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
  321. ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
  322. /**
  323. * @}
  324. */
  325. /** @defgroup RTCEx_Tamper_Pull_Up_Definitions Tamper Pull-Up Definitions
  326. * @{
  327. */
  328. #define RTC_TAMPER_PULLUP_ENABLE (0x00000000U) /*!< TimeStamp on Tamper Detection event saved */
  329. #define RTC_TAMPER_PULLUP_DISABLE (RTC_TAFCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */
  330. #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
  331. ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
  332. /**
  333. * @}
  334. */
  335. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  336. /** @defgroup RTCEx_Wakeup_Timer_Definitions Wakeup Timer Definitions
  337. * @{
  338. */
  339. #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 (0x00000000U)
  340. #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 (0x00000001U)
  341. #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 (0x00000002U)
  342. #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (0x00000003U)
  343. #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS (0x00000004U)
  344. #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (0x00000006U)
  345. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
  346. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
  347. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
  348. ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
  349. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
  350. ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
  351. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
  352. /**
  353. * @}
  354. */
  355. /** @defgroup RTCEx_Digital_Calibration_Definitions Digital Calibration Definitions
  356. * @{
  357. */
  358. #define RTC_CALIBSIGN_POSITIVE (0x00000000U)
  359. #define RTC_CALIBSIGN_NEGATIVE (0x00000080U)
  360. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \
  361. ((SIGN) == RTC_CALIBSIGN_NEGATIVE))
  362. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
  363. /**
  364. * @}
  365. */
  366. /** @defgroup RTCEx_Smooth_Calib_Period_Definitions Smooth Calib Period Definitions
  367. * @{
  368. */
  369. #define RTC_SMOOTHCALIB_PERIOD_32SEC (0x00000000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation
  370. period is 32s, else 2exp20 RTCCLK seconds */
  371. #define RTC_SMOOTHCALIB_PERIOD_16SEC (0x00002000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation
  372. period is 16s, else 2exp19 RTCCLK seconds */
  373. #define RTC_SMOOTHCALIB_PERIOD_8SEC (0x00004000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation
  374. period is 8s, else 2exp18 RTCCLK seconds */
  375. #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
  376. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
  377. ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
  378. /**
  379. * @}
  380. */
  381. /** @defgroup RTCEx_Smooth_Calib_Plus_Pulses_Definitions Smooth Calib Plus Pulses Definitions
  382. * @{
  383. */
  384. #define RTC_SMOOTHCALIB_PLUSPULSES_SET (0x00008000U) /*!< The number of RTCCLK pulses added
  385. during a X -second window = Y - CALM[8:0]
  386. with Y = 512, 256, 128 when X = 32, 16, 8 */
  387. #define RTC_SMOOTHCALIB_PLUSPULSES_RESET (0x00000000U) /*!< The number of RTCCLK pulses subbstited
  388. during a 32-second window = CALM[8:0] */
  389. #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
  390. ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
  391. /**
  392. * @}
  393. */
  394. /** @defgroup RTCEx_Smooth_Calib_Minus_Pulses_Definitions Smooth Calib Minus Pulses Definitions
  395. * @{
  396. */
  397. #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FFU)
  398. /**
  399. * @}
  400. */
  401. /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions Add 1 Second Parameter Definitions
  402. * @{
  403. */
  404. #define RTC_SHIFTADD1S_RESET (0x00000000U)
  405. #define RTC_SHIFTADD1S_SET (0x80000000U)
  406. #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
  407. ((SEL) == RTC_SHIFTADD1S_SET))
  408. /**
  409. * @}
  410. */
  411. /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value Substract Fraction Of Second Value
  412. * @{
  413. */
  414. #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFFU)
  415. /**
  416. * @}
  417. */
  418. /** @defgroup RTCEx_Calib_Output_Selection_Definitions Calib Output Selection Definitions
  419. * @{
  420. */
  421. #define RTC_CALIBOUTPUT_512HZ (0x00000000U)
  422. #define RTC_CALIBOUTPUT_1HZ (0x00080000U)
  423. #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
  424. ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
  425. /**
  426. * @}
  427. */
  428. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  429. /** @defgroup RTC_Alarm_Sub_Seconds_Value Alarm Sub Seconds Value
  430. * @{
  431. */
  432. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFFU)
  433. /**
  434. * @}
  435. */
  436. /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions Alarm Sub Seconds Masks Definitions
  437. * @{
  438. */
  439. #define RTC_ALARMSUBSECONDMASK_ALL (0x00000000U) /*!< All Alarm SS fields are masked.
  440. There is no comparison on sub seconds
  441. for Alarm */
  442. #define RTC_ALARMSUBSECONDMASK_SS14_1 (0x01000000U) /*!< SS[14:1] are don't care in Alarm
  443. comparison. Only SS[0] is compared. */
  444. #define RTC_ALARMSUBSECONDMASK_SS14_2 (0x02000000U) /*!< SS[14:2] are don't care in Alarm
  445. comparison. Only SS[1:0] are compared */
  446. #define RTC_ALARMSUBSECONDMASK_SS14_3 (0x03000000U) /*!< SS[14:3] are don't care in Alarm
  447. comparison. Only SS[2:0] are compared */
  448. #define RTC_ALARMSUBSECONDMASK_SS14_4 (0x04000000U) /*!< SS[14:4] are don't care in Alarm
  449. comparison. Only SS[3:0] are compared */
  450. #define RTC_ALARMSUBSECONDMASK_SS14_5 (0x05000000U) /*!< SS[14:5] are don't care in Alarm
  451. comparison. Only SS[4:0] are compared */
  452. #define RTC_ALARMSUBSECONDMASK_SS14_6 (0x06000000U) /*!< SS[14:6] are don't care in Alarm
  453. comparison. Only SS[5:0] are compared */
  454. #define RTC_ALARMSUBSECONDMASK_SS14_7 (0x07000000U) /*!< SS[14:7] are don't care in Alarm
  455. comparison. Only SS[6:0] are compared */
  456. #define RTC_ALARMSUBSECONDMASK_SS14_8 (0x08000000U) /*!< SS[14:8] are don't care in Alarm
  457. comparison. Only SS[7:0] are compared */
  458. #define RTC_ALARMSUBSECONDMASK_SS14_9 (0x09000000U) /*!< SS[14:9] are don't care in Alarm
  459. comparison. Only SS[8:0] are compared */
  460. #define RTC_ALARMSUBSECONDMASK_SS14_10 (0x0A000000U) /*!< SS[14:10] are don't care in Alarm
  461. comparison. Only SS[9:0] are compared */
  462. #define RTC_ALARMSUBSECONDMASK_SS14_11 (0x0B000000U) /*!< SS[14:11] are don't care in Alarm
  463. comparison. Only SS[10:0] are compared */
  464. #define RTC_ALARMSUBSECONDMASK_SS14_12 (0x0C000000U) /*!< SS[14:12] are don't care in Alarm
  465. comparison.Only SS[11:0] are compared */
  466. #define RTC_ALARMSUBSECONDMASK_SS14_13 (0x0D000000U) /*!< SS[14:13] are don't care in Alarm
  467. comparison. Only SS[12:0] are compared */
  468. #define RTC_ALARMSUBSECONDMASK_SS14 (0x0E000000U) /*!< SS[14] is don't care in Alarm
  469. comparison.Only SS[13:0] are compared */
  470. #define RTC_ALARMSUBSECONDMASK_NONE (0x0F000000U) /*!< SS[14:0] are compared and must match
  471. to activate alarm. */
  472. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \
  473. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
  474. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
  475. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
  476. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
  477. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
  478. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
  479. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
  480. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
  481. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
  482. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
  483. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
  484. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
  485. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
  486. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \
  487. ((MASK) == RTC_ALARMSUBSECONDMASK_NONE))
  488. /**
  489. * @}
  490. */
  491. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  492. /**
  493. * @}
  494. */
  495. /* Exported macros -----------------------------------------------------------*/
  496. /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
  497. * @{
  498. */
  499. /* ---------------------------------WAKEUPTIMER---------------------------------*/
  500. /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer
  501. * @{
  502. */
  503. /**
  504. * @brief Enable the RTC WakeUp Timer peripheral.
  505. * @param __HANDLE__ specifies the RTC handle.
  506. * @retval None
  507. */
  508. #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
  509. /**
  510. * @brief Enable the RTC TimeStamp peripheral.
  511. * @param __HANDLE__ specifies the RTC handle.
  512. * @retval None
  513. */
  514. #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
  515. /**
  516. * @brief Disable the RTC WakeUp Timer peripheral.
  517. * @param __HANDLE__ specifies the RTC handle.
  518. * @retval None
  519. */
  520. #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
  521. /**
  522. * @brief Disable the RTC TimeStamp peripheral.
  523. * @param __HANDLE__ specifies the RTC handle.
  524. * @retval None
  525. */
  526. #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
  527. /**
  528. * @brief Enable the Coarse calibration process.
  529. * @param __HANDLE__ specifies the RTC handle.
  530. * @retval None
  531. */
  532. #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE))
  533. /**
  534. * @brief Disable the Coarse calibration process.
  535. * @param __HANDLE__ specifies the RTC handle.
  536. * @retval None
  537. */
  538. #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE))
  539. /**
  540. * @brief Enable the RTC calibration output.
  541. * @param __HANDLE__ specifies the RTC handle.
  542. * @retval None
  543. */
  544. #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
  545. /**
  546. * @brief Disable the calibration output.
  547. * @param __HANDLE__ specifies the RTC handle.
  548. * @retval None
  549. */
  550. #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
  551. /**
  552. * @brief Enable the clock reference detection.
  553. * @param __HANDLE__ specifies the RTC handle.
  554. * @retval None
  555. */
  556. #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
  557. /**
  558. * @brief Disable the clock reference detection.
  559. * @param __HANDLE__ specifies the RTC handle.
  560. * @retval None
  561. */
  562. #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
  563. /**
  564. * @brief Enable the RTC TimeStamp interrupt.
  565. * @param __HANDLE__ specifies the RTC handle.
  566. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  567. * This parameter can be:
  568. * @arg RTC_IT_TS: TimeStamp interrupt
  569. * @retval None
  570. */
  571. #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  572. /**
  573. * @brief Enable the RTC WakeUpTimer interrupt.
  574. * @param __HANDLE__ specifies the RTC handle.
  575. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  576. * This parameter can be:
  577. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  578. * @retval None
  579. */
  580. #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  581. /**
  582. * @brief Disable the RTC TimeStamp interrupt.
  583. * @param __HANDLE__ specifies the RTC handle.
  584. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  585. * This parameter can be:
  586. * @arg RTC_IT_TS: TimeStamp interrupt
  587. * @retval None
  588. */
  589. #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  590. /**
  591. * @brief Disable the RTC WakeUpTimer interrupt.
  592. * @param __HANDLE__ specifies the RTC handle.
  593. * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  594. * This parameter can be:
  595. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  596. * @retval None
  597. */
  598. #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  599. /**
  600. * @brief Enable the RTC Tamper1 input detection.
  601. * @param __HANDLE__ specifies the RTC handle.
  602. * @retval None
  603. */
  604. #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP1E)
  605. /**
  606. * @brief Disable the RTC Tamper1 input detection.
  607. * @param __HANDLE__ specifies the RTC handle.
  608. * @retval None
  609. */
  610. #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP1E)
  611. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC)\
  612. || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA)\
  613. || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA)\
  614. || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  615. /**
  616. * @brief Enable the RTC Tamper2 input detection.
  617. * @param __HANDLE__ specifies the RTC handle.
  618. * @retval None
  619. */
  620. #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP2E)
  621. /**
  622. * @brief Disable the RTC Tamper2 input detection.
  623. * @param __HANDLE__ specifies the RTC handle.
  624. * @retval None
  625. */
  626. #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP2E)
  627. /**
  628. * @brief Enable the RTC Tamper3 input detection.
  629. * @param __HANDLE__ specifies the RTC handle.
  630. * @retval None
  631. */
  632. #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP3E)
  633. /**
  634. * @brief Disable the RTC Tamper3 input detection.
  635. * @param __HANDLE__ specifies the RTC handle.
  636. * @retval None
  637. */
  638. #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP3E)
  639. /**
  640. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  641. * @param __HANDLE__ specifies the RTC handle.
  642. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  643. * This parameter can be:
  644. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  645. * @arg RTC_IT_TAMP2: Tamper2 interrupt
  646. * @arg RTC_IT_TAMP3: Tamper3 interrupt
  647. * @retval None
  648. */
  649. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP1F) != RESET) ? SET : RESET) : \
  650. ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP2F) != RESET) ? SET : RESET) : \
  651. (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP3F) != RESET) ? SET : RESET))
  652. #else
  653. /**
  654. * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
  655. * @param __HANDLE__ specifies the RTC handle.
  656. * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check.
  657. * This parameter can be:
  658. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  659. * @retval None
  660. */
  661. #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP1F) != RESET) ? SET : RESET)
  662. #endif
  663. /**
  664. * @brief Enable the RTC Tamper interrupt.
  665. * @param __HANDLE__ specifies the RTC handle.
  666. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled
  667. * This parameter can be any combination of the following values:
  668. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  669. * @arg RTC_IT_TAMP2: Tamper2 interrupt (*)
  670. * @arg RTC_IT_TAMP3: Tamper3 interrupt (*)
  671. * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC,
  672. * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA,
  673. * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE
  674. * STM32L151xDX, STM32L152xDX, STM32L162xDX
  675. * @retval None
  676. */
  677. #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT(((__HANDLE__)->Instance->TAFCR), RTC_TAFCR_TAMPIE)
  678. /**
  679. * @brief Disable the RTC Tamper interrupt.
  680. * @param __HANDLE__ specifies the RTC handle.
  681. * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled.
  682. * This parameter can be any combination of the following values:
  683. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  684. * @arg RTC_IT_TAMP2: Tamper2 interrupt (*)
  685. * @arg RTC_IT_TAMP3: Tamper3 interrupt (*)
  686. * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC,
  687. * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA,
  688. * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE
  689. * STM32L151xDX, STM32L152xDX, STM32L162xDX
  690. * @retval None
  691. */
  692. #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT(((__HANDLE__)->Instance->TAFCR), RTC_TAFCR_TAMPIE)
  693. /**
  694. * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
  695. * @param __HANDLE__ specifies the RTC handle.
  696. * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check.
  697. * This parameter can be:
  698. * @arg RTC_IT_TAMP1: Tamper1 interrupt
  699. * @arg RTC_IT_TAMP2: Tamper2 interrupt (*)
  700. * @arg RTC_IT_TAMP3: Tamper3 interrupt (*)
  701. * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC,
  702. * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA,
  703. * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE
  704. * STM32L151xDX, STM32L152xDX, STM32L162xDX
  705. * @retval None
  706. */
  707. #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAFCR) & RTC_TAFCR_TAMPIE) != RESET) ? SET : RESET)
  708. /**
  709. * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
  710. * @param __HANDLE__ specifies the RTC handle.
  711. * @param __FLAG__ specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
  712. * This parameter can be:
  713. * @arg RTC_IT_WUT: WakeUpTimer A interrupt
  714. * @retval None
  715. */
  716. #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
  717. /**
  718. * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not.
  719. * @param __HANDLE__ specifies the RTC handle.
  720. * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check.
  721. * This parameter can be:
  722. * @arg RTC_IT_WUT: WakeUpTimer interrupt
  723. * @retval None
  724. */
  725. #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  726. /**
  727. * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
  728. * @param __HANDLE__ specifies the RTC handle.
  729. * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
  730. * This parameter can be:
  731. * @arg RTC_IT_TS: TimeStamp interrupt
  732. * @retval None
  733. */
  734. #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4)) != RESET)? SET : RESET)
  735. /**
  736. * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not.
  737. * @param __HANDLE__ specifies the RTC handle.
  738. * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check.
  739. * This parameter can be:
  740. * @arg RTC_IT_TS: TimeStamp interrupt
  741. * @retval None
  742. */
  743. #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  744. /**
  745. * @brief Get the selected RTC TimeStamp's flag status.
  746. * @param __HANDLE__ specifies the RTC handle.
  747. * @param __FLAG__ specifies the RTC TimeStamp Flag sources to be enabled or disabled.
  748. * This parameter can be:
  749. * @arg RTC_FLAG_TSF
  750. * @arg RTC_FLAG_TSOVF
  751. * @retval None
  752. */
  753. #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  754. /**
  755. * @brief Get the selected RTC WakeUpTimer's flag status.
  756. * @param __HANDLE__ specifies the RTC handle.
  757. * @param __FLAG__ specifies the RTC WakeUpTimer Flag sources to be enabled or disabled.
  758. * This parameter can be:
  759. * @arg RTC_FLAG_WUTF
  760. * @arg RTC_FLAG_WUTWF
  761. * @retval None
  762. */
  763. #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  764. /**
  765. * @brief Get the selected RTC Tamper's flag status.
  766. * @param __HANDLE__ specifies the RTC handle.
  767. * @param __FLAG__ specifies the RTC Tamper Flag sources to be enabled or disabled.
  768. * This parameter can be:
  769. * @arg RTC_FLAG_TAMP1F
  770. * @arg RTC_FLAG_TAMP2F (*)
  771. * @arg RTC_FLAG_TAMP3F (*)
  772. * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC,
  773. * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA,
  774. * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE
  775. * STM32L151xDX, STM32L152xDX, STM32L162xDX
  776. * @retval None
  777. */
  778. #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  779. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC)\
  780. || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA)\
  781. || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA)\
  782. || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  783. /**
  784. * @brief Get the selected RTC shift operation's flag status.
  785. * @param __HANDLE__ specifies the RTC handle.
  786. * @param __FLAG__ specifies the RTC shift operation Flag is pending or not.
  787. * This parameter can be:
  788. * @arg RTC_FLAG_SHPF
  789. * @retval None
  790. */
  791. #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  792. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  793. /**
  794. * @brief Clear the RTC Time Stamp's pending flags.
  795. * @param __HANDLE__ specifies the RTC handle.
  796. * @param __FLAG__ specifies the RTC Alarm Flag sources to be enabled or disabled.
  797. * This parameter can be:
  798. * @arg RTC_FLAG_TSF
  799. * @retval None
  800. */
  801. #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  802. /**
  803. * @brief Clear the RTC Tamper's pending flags.
  804. * @param __HANDLE__ specifies the RTC handle.
  805. * @param __FLAG__ specifies the RTC Tamper Flag sources to be enabled or disabled.
  806. * This parameter can be:
  807. * @arg RTC_FLAG_TAMP1F
  808. * @arg RTC_FLAG_TAMP2F (*)
  809. * @arg RTC_FLAG_TAMP3F (*)
  810. * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC,
  811. * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA,
  812. * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE
  813. * STM32L151xDX, STM32L152xDX, STM32L162xDX
  814. * @retval None
  815. */
  816. #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  817. /**
  818. * @brief Clear the RTC Wake Up timer's pending flags.
  819. * @param __HANDLE__ specifies the RTC handle.
  820. * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear.
  821. * This parameter can be:
  822. * @arg RTC_FLAG_WUTF
  823. * @retval None
  824. */
  825. #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  826. /**
  827. * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line.
  828. * @retval None
  829. */
  830. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  831. /**
  832. * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line.
  833. * @retval None
  834. */
  835. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  836. /**
  837. * @brief Enable event on the RTC WakeUp Timer associated Exti line.
  838. * @retval None.
  839. */
  840. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  841. /**
  842. * @brief Disable event on the RTC WakeUp Timer associated Exti line.
  843. * @retval None.
  844. */
  845. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  846. /**
  847. * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  848. * @retval None.
  849. */
  850. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  851. /**
  852. * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
  853. * @retval None.
  854. */
  855. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  856. /**
  857. * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  858. * @retval None.
  859. */
  860. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  861. /**
  862. * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
  863. * @retval None.
  864. */
  865. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
  866. /**
  867. * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  868. * @retval None.
  869. */
  870. #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); } while(0);
  871. /**
  872. * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
  873. * This parameter can be:
  874. * @retval None.
  875. */
  876. #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); } while(0);
  877. /**
  878. * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
  879. * @retval Line Status.
  880. */
  881. #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  882. /**
  883. * @brief Clear the RTC WakeUp Timer associated Exti line flag.
  884. * @retval None.
  885. */
  886. #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  887. /**
  888. * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
  889. * @retval None.
  890. */
  891. #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
  892. /**
  893. * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
  894. * @retval None
  895. */
  896. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  897. /**
  898. * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
  899. * @retval None
  900. */
  901. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  902. /**
  903. * @brief Enable event on the RTC Tamper and Timestamp associated Exti line.
  904. * @retval None.
  905. */
  906. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  907. /**
  908. * @brief Disable event on the RTC Tamper and Timestamp associated Exti line.
  909. * @retval None.
  910. */
  911. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  912. /**
  913. * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  914. * @retval None.
  915. */
  916. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  917. /**
  918. * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  919. * @retval None.
  920. */
  921. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  922. /**
  923. * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  924. * @retval None.
  925. */
  926. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  927. /**
  928. * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
  929. * @retval None.
  930. */
  931. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
  932. /**
  933. * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  934. * @retval None.
  935. */
  936. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); } while(0);
  937. /**
  938. * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
  939. * This parameter can be:
  940. * @retval None.
  941. */
  942. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); } while(0);
  943. /**
  944. * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
  945. * @retval Line Status.
  946. */
  947. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  948. /**
  949. * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
  950. * @retval None.
  951. */
  952. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  953. /**
  954. * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
  955. * @retval None.
  956. */
  957. #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
  958. /**
  959. * @}
  960. */
  961. /* Exported functions --------------------------------------------------------*/
  962. /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
  963. * @{
  964. */
  965. /* RTC TimeStamp and Tamper functions *****************************************/
  966. /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp and Tamper functions
  967. * @{
  968. */
  969. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge);
  970. HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge);
  971. HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
  972. HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
  973. HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  974. HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper);
  975. HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
  976. void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
  977. void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
  978. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  979. void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
  980. void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
  981. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  982. void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
  983. HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  984. HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  985. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  986. HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  987. HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  988. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  989. /**
  990. * @}
  991. */
  992. /* RTC Wake-up functions ******************************************************/
  993. /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
  994. * @{
  995. */
  996. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  997. HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
  998. HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
  999. uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
  1000. void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
  1001. void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
  1002. HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1003. /**
  1004. * @}
  1005. */
  1006. /* Extended Control functions ************************************************/
  1007. /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
  1008. * @{
  1009. */
  1010. void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
  1011. uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
  1012. HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value);
  1013. HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc);
  1014. #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
  1015. HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
  1016. HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
  1017. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
  1018. #else
  1019. HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  1020. #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
  1021. HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
  1022. HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
  1023. HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
  1024. HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
  1025. HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
  1026. /**
  1027. * @}
  1028. */
  1029. /* Extended RTC features functions *******************************************/
  1030. /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
  1031. * @{
  1032. */
  1033. void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc);
  1034. HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  1035. /**
  1036. * @}
  1037. */
  1038. /**
  1039. * @}
  1040. */
  1041. /* Private types -------------------------------------------------------------*/
  1042. /* Private variables ---------------------------------------------------------*/
  1043. /* Private constants ---------------------------------------------------------*/
  1044. /** @defgroup RTCEx_Private_Constants RTCEx Private Constants
  1045. * @{
  1046. */
  1047. #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT (0x00080000U) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */
  1048. #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT (0x00100000U) /*!< External interrupt line 20 Connected to the RTC Wakeup event */
  1049. /**
  1050. * @}
  1051. */
  1052. /* Private macros ------------------------------------------------------------*/
  1053. /** @defgroup RTCEx_Private_Macros RTCEx Private Macros
  1054. * @{
  1055. */
  1056. /**
  1057. * @}
  1058. */
  1059. /**
  1060. * @}
  1061. */
  1062. /**
  1063. * @}
  1064. */
  1065. /**
  1066. * @}
  1067. */
  1068. #ifdef __cplusplus
  1069. }
  1070. #endif
  1071. #endif /* __STM32L1xx_HAL_RTC_EX_H */
  1072. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/