stm32f1xx_ll_rtc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_rtc.c
  4. * @author MCD Application Team
  5. * @brief RTC LL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. #if defined(USE_FULL_LL_DRIVER)
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "stm32f1xx_ll_rtc.h"
  21. #include "stm32f1xx_ll_cortex.h"
  22. #ifdef USE_FULL_ASSERT
  23. #include "stm32_assert.h"
  24. #else
  25. #define assert_param(expr) ((void)0U)
  26. #endif
  27. /** @addtogroup STM32F1xx_LL_Driver
  28. * @{
  29. */
  30. #if defined(RTC)
  31. /** @addtogroup RTC_LL
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @addtogroup RTC_LL_Private_Constants
  38. * @{
  39. */
  40. /* Default values used for prescaler */
  41. #define RTC_ASYNCH_PRESC_DEFAULT 0x00007FFFU
  42. /* Values used for timeout */
  43. #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */
  44. #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */
  45. /**
  46. * @}
  47. */
  48. /* Private macros ------------------------------------------------------------*/
  49. /** @addtogroup RTC_LL_Private_Macros
  50. * @{
  51. */
  52. #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0xFFFFFU)
  53. #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \
  54. || ((__VALUE__) == LL_RTC_FORMAT_BCD))
  55. #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
  56. #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
  57. #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
  58. #define IS_LL_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_NONE) || \
  59. ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_RTCCLOCK) || \
  60. ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_ALARM) || \
  61. ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_SECOND))
  62. /**
  63. * @}
  64. */
  65. /* Private function prototypes -----------------------------------------------*/
  66. /* Exported functions --------------------------------------------------------*/
  67. /** @addtogroup RTC_LL_Exported_Functions
  68. * @{
  69. */
  70. /** @addtogroup RTC_LL_EF_Init
  71. * @{
  72. */
  73. /**
  74. * @brief De-Initializes the RTC registers to their default reset values.
  75. * @note This function doesn't reset the RTC Clock source and RTC Backup Data
  76. * registers.
  77. * @param RTCx RTC Instance
  78. * @retval An ErrorStatus enumeration value:
  79. * - SUCCESS: RTC registers are de-initialized
  80. * - ERROR: RTC registers are not de-initialized
  81. */
  82. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx)
  83. {
  84. ErrorStatus status = ERROR;
  85. /* Check the parameter */
  86. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  87. /* Disable the write protection for RTC registers */
  88. LL_RTC_DisableWriteProtection(RTCx);
  89. /* Set Initialization mode */
  90. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  91. {
  92. LL_RTC_WriteReg(RTCx, CNTL, 0x0000);
  93. LL_RTC_WriteReg(RTCx, CNTH, 0x0000);
  94. LL_RTC_WriteReg(RTCx, PRLH, 0x0000);
  95. LL_RTC_WriteReg(RTCx, PRLL, 0x8000);
  96. LL_RTC_WriteReg(RTCx, CRH, 0x0000);
  97. LL_RTC_WriteReg(RTCx, CRL, 0x0020);
  98. /* Reset Tamper and alternate functions configuration register */
  99. LL_RTC_WriteReg(BKP, RTCCR, 0x00000000U);
  100. LL_RTC_WriteReg(BKP, CR, 0x00000000U);
  101. LL_RTC_WriteReg(BKP, CSR, 0x00000000U);
  102. /* Exit Initialization Mode */
  103. if (LL_RTC_ExitInitMode(RTCx) != ERROR)
  104. {
  105. /* Wait till the RTC RSF flag is set */
  106. status = LL_RTC_WaitForSynchro(RTCx);
  107. /* Clear RSF Flag */
  108. LL_RTC_ClearFlag_RS(RTCx);
  109. /* Enable the write protection for RTC registers */
  110. LL_RTC_EnableWriteProtection(RTCx);
  111. }
  112. }
  113. else
  114. {
  115. /* Enable the write protection for RTC registers */
  116. LL_RTC_EnableWriteProtection(RTCx);
  117. }
  118. return status;
  119. }
  120. /**
  121. * @brief Initializes the RTC registers according to the specified parameters
  122. * in RTC_InitStruct.
  123. * @param RTCx RTC Instance
  124. * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains
  125. * the configuration information for the RTC peripheral.
  126. * @note The RTC Prescaler register is write protected and can be written in
  127. * initialization mode only.
  128. * @note the user should call LL_RTC_StructInit() or the structure of Prescaler
  129. * need to be initialized before RTC init()
  130. * @retval An ErrorStatus enumeration value:
  131. * - SUCCESS: RTC registers are initialized
  132. * - ERROR: RTC registers are not initialized
  133. */
  134. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct)
  135. {
  136. ErrorStatus status = ERROR;
  137. /* Check the parameters */
  138. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  139. assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler));
  140. assert_param(IS_LL_RTC_CALIB_OUTPUT(RTC_InitStruct->OutPutSource));
  141. /* Waiting for synchro */
  142. if (LL_RTC_WaitForSynchro(RTCx) != ERROR)
  143. {
  144. /* Set Initialization mode */
  145. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  146. {
  147. /* Clear Flag Bits */
  148. LL_RTC_ClearFlag_ALR(RTCx);
  149. LL_RTC_ClearFlag_OW(RTCx);
  150. LL_RTC_ClearFlag_SEC(RTCx);
  151. if (RTC_InitStruct->OutPutSource != LL_RTC_CALIB_OUTPUT_NONE)
  152. {
  153. /* Disable the selected Tamper Pin */
  154. LL_RTC_TAMPER_Disable(BKP);
  155. }
  156. /* Set the signal which will be routed to RTC Tamper Pin */
  157. LL_RTC_SetOutputSource(BKP, RTC_InitStruct->OutPutSource);
  158. /* Configure Synchronous and Asynchronous prescaler factor */
  159. LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler);
  160. /* Exit Initialization Mode */
  161. LL_RTC_ExitInitMode(RTCx);
  162. status = SUCCESS;
  163. }
  164. }
  165. return status;
  166. }
  167. /**
  168. * @brief Set each @ref LL_RTC_InitTypeDef field to default value.
  169. * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized.
  170. * @retval None
  171. */
  172. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct)
  173. {
  174. /* Set RTC_InitStruct fields to default values */
  175. RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT;
  176. RTC_InitStruct->OutPutSource = LL_RTC_CALIB_OUTPUT_NONE;
  177. }
  178. /**
  179. * @brief Set the RTC current time.
  180. * @param RTCx RTC Instance
  181. * @param RTC_Format This parameter can be one of the following values:
  182. * @arg @ref LL_RTC_FORMAT_BIN
  183. * @arg @ref LL_RTC_FORMAT_BCD
  184. * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains
  185. * the time configuration information for the RTC.
  186. * @note The user should call LL_RTC_TIME_StructInit() or the structure
  187. * of time need to be initialized before time init()
  188. * @retval An ErrorStatus enumeration value:
  189. * - SUCCESS: RTC Time register is configured
  190. * - ERROR: RTC Time register is not configured
  191. */
  192. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct)
  193. {
  194. ErrorStatus status = ERROR;
  195. uint32_t counter_time = 0U;
  196. /* Check the parameters */
  197. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  198. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  199. if (RTC_Format == LL_RTC_FORMAT_BIN)
  200. {
  201. assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours));
  202. assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes));
  203. assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds));
  204. }
  205. else
  206. {
  207. assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
  208. assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)));
  209. assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds)));
  210. }
  211. /* Enter Initialization mode */
  212. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  213. {
  214. /* Check the input parameters format */
  215. if (RTC_Format == LL_RTC_FORMAT_BIN)
  216. {
  217. counter_time = (uint32_t)(((uint32_t)RTC_TimeStruct->Hours * 3600U) + \
  218. ((uint32_t)RTC_TimeStruct->Minutes * 60U) + \
  219. ((uint32_t)RTC_TimeStruct->Seconds));
  220. LL_RTC_TIME_Set(RTCx, counter_time);
  221. }
  222. else
  223. {
  224. counter_time = (((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)) * 3600U) + \
  225. ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)) * 60U) + \
  226. ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))));
  227. LL_RTC_TIME_Set(RTCx, counter_time);
  228. }
  229. status = SUCCESS;
  230. }
  231. /* Exit Initialization mode */
  232. LL_RTC_ExitInitMode(RTCx);
  233. return status;
  234. }
  235. /**
  236. * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec).
  237. * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized.
  238. * @retval None
  239. */
  240. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct)
  241. {
  242. /* Time = 00h:00min:00sec */
  243. RTC_TimeStruct->Hours = 0U;
  244. RTC_TimeStruct->Minutes = 0U;
  245. RTC_TimeStruct->Seconds = 0U;
  246. }
  247. /**
  248. * @brief Set the RTC Alarm.
  249. * @param RTCx RTC Instance
  250. * @param RTC_Format This parameter can be one of the following values:
  251. * @arg @ref LL_RTC_FORMAT_BIN
  252. * @arg @ref LL_RTC_FORMAT_BCD
  253. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
  254. * contains the alarm configuration parameters.
  255. * @note the user should call LL_RTC_ALARM_StructInit() or the structure
  256. * of Alarm need to be initialized before Alarm init()
  257. * @retval An ErrorStatus enumeration value:
  258. * - SUCCESS: ALARM registers are configured
  259. * - ERROR: ALARM registers are not configured
  260. */
  261. ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  262. {
  263. ErrorStatus status = ERROR;
  264. uint32_t counter_alarm = 0U;
  265. /* Check the parameters */
  266. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  267. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  268. if (RTC_Format == LL_RTC_FORMAT_BIN)
  269. {
  270. assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
  271. assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
  272. assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
  273. }
  274. else
  275. {
  276. assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
  277. assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
  278. assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
  279. }
  280. /* Enter Initialization mode */
  281. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  282. {
  283. /* Check the input parameters format */
  284. if (RTC_Format == LL_RTC_FORMAT_BIN)
  285. {
  286. counter_alarm = (uint32_t)(((uint32_t)RTC_AlarmStruct->AlarmTime.Hours * 3600U) + \
  287. ((uint32_t)RTC_AlarmStruct->AlarmTime.Minutes * 60U) + \
  288. ((uint32_t)RTC_AlarmStruct->AlarmTime.Seconds));
  289. LL_RTC_ALARM_Set(RTCx, counter_alarm);
  290. }
  291. else
  292. {
  293. counter_alarm = (((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)) * 3600U) + \
  294. ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)) * 60U) + \
  295. ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))));
  296. LL_RTC_ALARM_Set(RTCx, counter_alarm);
  297. }
  298. status = SUCCESS;
  299. }
  300. /* Exit Initialization mode */
  301. LL_RTC_ExitInitMode(RTCx);
  302. return status;
  303. }
  304. /**
  305. * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARM field to default value (Time = 00h:00mn:00sec /
  306. * Day = 1st day of the month/Mask = all fields are masked).
  307. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
  308. * @retval None
  309. */
  310. void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  311. {
  312. /* Alarm Time Settings : Time = 00h:00mn:00sec */
  313. RTC_AlarmStruct->AlarmTime.Hours = 0U;
  314. RTC_AlarmStruct->AlarmTime.Minutes = 0U;
  315. RTC_AlarmStruct->AlarmTime.Seconds = 0U;
  316. }
  317. /**
  318. * @brief Enters the RTC Initialization mode.
  319. * @param RTCx RTC Instance
  320. * @retval An ErrorStatus enumeration value:
  321. * - SUCCESS: RTC is in Init mode
  322. * - ERROR: RTC is not in Init mode
  323. */
  324. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx)
  325. {
  326. __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
  327. ErrorStatus status = SUCCESS;
  328. uint32_t tmp = 0U;
  329. /* Check the parameter */
  330. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  331. /* Wait till RTC is in INIT state and if Time out is reached exit */
  332. tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
  333. while ((timeout != 0U) && (tmp != 1U))
  334. {
  335. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  336. {
  337. timeout --;
  338. }
  339. tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
  340. if (timeout == 0U)
  341. {
  342. status = ERROR;
  343. }
  344. }
  345. /* Disable the write protection for RTC registers */
  346. LL_RTC_DisableWriteProtection(RTCx);
  347. return status;
  348. }
  349. /**
  350. * @brief Exit the RTC Initialization mode.
  351. * @note When the initialization sequence is complete, the calendar restarts
  352. * counting after 4 RTCCLK cycles.
  353. * @param RTCx RTC Instance
  354. * @retval An ErrorStatus enumeration value:
  355. * - SUCCESS: RTC exited from in Init mode
  356. * - ERROR: Not applicable
  357. */
  358. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx)
  359. {
  360. __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
  361. ErrorStatus status = SUCCESS;
  362. uint32_t tmp = 0U;
  363. /* Check the parameter */
  364. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  365. /* Disable initialization mode */
  366. LL_RTC_EnableWriteProtection(RTCx);
  367. /* Wait till RTC is in INIT state and if Time out is reached exit */
  368. tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
  369. while ((timeout != 0U) && (tmp != 1U))
  370. {
  371. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  372. {
  373. timeout --;
  374. }
  375. tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
  376. if (timeout == 0U)
  377. {
  378. status = ERROR;
  379. }
  380. }
  381. return status;
  382. }
  383. /**
  384. * @brief Set the Time Counter
  385. * @param RTCx RTC Instance
  386. * @param TimeCounter this value can be from 0 to 0xFFFFFFFF
  387. * @retval An ErrorStatus enumeration value:
  388. * - SUCCESS: RTC Counter register configured
  389. * - ERROR: Not applicable
  390. */
  391. ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter)
  392. {
  393. ErrorStatus status = ERROR;
  394. /* Check the parameter */
  395. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  396. /* Enter Initialization mode */
  397. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  398. {
  399. LL_RTC_TIME_Set(RTCx, TimeCounter);
  400. status = SUCCESS;
  401. }
  402. /* Exit Initialization mode */
  403. LL_RTC_ExitInitMode(RTCx);
  404. return status;
  405. }
  406. /**
  407. * @brief Set Alarm Counter.
  408. * @param RTCx RTC Instance
  409. * @param AlarmCounter this value can be from 0 to 0xFFFFFFFF
  410. * @retval An ErrorStatus enumeration value:
  411. * - SUCCESS: RTC exited from in Init mode
  412. * - ERROR: Not applicable
  413. */
  414. ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter)
  415. {
  416. ErrorStatus status = ERROR;
  417. /* Check the parameter */
  418. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  419. /* Enter Initialization mode */
  420. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  421. {
  422. LL_RTC_ALARM_Set(RTCx, AlarmCounter);
  423. status = SUCCESS;
  424. }
  425. /* Exit Initialization mode */
  426. LL_RTC_ExitInitMode(RTCx);
  427. return status;
  428. }
  429. /**
  430. * @brief Waits until the RTC registers are synchronized with RTC APB clock.
  431. * @note The RTC Resynchronization mode is write protected, use the
  432. * @ref LL_RTC_DisableWriteProtection before calling this function.
  433. * @param RTCx RTC Instance
  434. * @retval An ErrorStatus enumeration value:
  435. * - SUCCESS: RTC registers are synchronised
  436. * - ERROR: RTC registers are not synchronised
  437. */
  438. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx)
  439. {
  440. __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT;
  441. ErrorStatus status = SUCCESS;
  442. uint32_t tmp = 0U;
  443. /* Check the parameter */
  444. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  445. /* Clear RSF flag */
  446. LL_RTC_ClearFlag_RS(RTCx);
  447. /* Wait the registers to be synchronised */
  448. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  449. while ((timeout != 0U) && (tmp != 0U))
  450. {
  451. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  452. {
  453. timeout--;
  454. }
  455. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  456. if (timeout == 0U)
  457. {
  458. status = ERROR;
  459. }
  460. }
  461. return (status);
  462. }
  463. /**
  464. * @}
  465. */
  466. /**
  467. * @}
  468. */
  469. /**
  470. * @}
  471. */
  472. #endif /* defined(RTC) */
  473. /**
  474. * @}
  475. */
  476. #endif /* USE_FULL_LL_DRIVER */