stm32l4xx_ll_rtc.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_rtc.c
  4. * @author MCD Application Team
  5. * @brief RTC LL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. #if defined(USE_FULL_LL_DRIVER)
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "stm32l4xx_ll_rtc.h"
  38. #include "stm32l4xx_ll_cortex.h"
  39. #ifdef USE_FULL_ASSERT
  40. #include "stm32_assert.h"
  41. #else
  42. #define assert_param(expr) ((void)0U)
  43. #endif
  44. /** @addtogroup STM32L4xx_LL_Driver
  45. * @{
  46. */
  47. #if defined(RTC)
  48. /** @addtogroup RTC_LL
  49. * @{
  50. */
  51. /* Private types -------------------------------------------------------------*/
  52. /* Private variables ---------------------------------------------------------*/
  53. /* Private constants ---------------------------------------------------------*/
  54. /** @addtogroup RTC_LL_Private_Constants
  55. * @{
  56. */
  57. /* Default values used for prescaler */
  58. #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU
  59. #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU
  60. /* Values used for timeout */
  61. #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */
  62. #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */
  63. /**
  64. * @}
  65. */
  66. /* Private macros ------------------------------------------------------------*/
  67. /** @addtogroup RTC_LL_Private_Macros
  68. * @{
  69. */
  70. #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \
  71. || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM))
  72. #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU)
  73. #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU)
  74. #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \
  75. || ((__VALUE__) == LL_RTC_FORMAT_BCD))
  76. #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \
  77. || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM))
  78. #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
  79. #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
  80. #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
  81. #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
  82. #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \
  83. || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \
  84. || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \
  85. || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \
  86. || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \
  87. || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \
  88. || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY))
  89. #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U))
  90. #define IS_LL_RTC_MONTH(__VALUE__) (((__VALUE__) == LL_RTC_MONTH_JANUARY) \
  91. || ((__VALUE__) == LL_RTC_MONTH_FEBRUARY) \
  92. || ((__VALUE__) == LL_RTC_MONTH_MARCH) \
  93. || ((__VALUE__) == LL_RTC_MONTH_APRIL) \
  94. || ((__VALUE__) == LL_RTC_MONTH_MAY) \
  95. || ((__VALUE__) == LL_RTC_MONTH_JUNE) \
  96. || ((__VALUE__) == LL_RTC_MONTH_JULY) \
  97. || ((__VALUE__) == LL_RTC_MONTH_AUGUST) \
  98. || ((__VALUE__) == LL_RTC_MONTH_SEPTEMBER) \
  99. || ((__VALUE__) == LL_RTC_MONTH_OCTOBER) \
  100. || ((__VALUE__) == LL_RTC_MONTH_NOVEMBER) \
  101. || ((__VALUE__) == LL_RTC_MONTH_DECEMBER))
  102. #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
  103. #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \
  104. || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \
  105. || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \
  106. || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \
  107. || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \
  108. || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL))
  109. #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \
  110. || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \
  111. || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \
  112. || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \
  113. || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \
  114. || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL))
  115. #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \
  116. ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY))
  117. #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \
  118. ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY))
  119. /**
  120. * @}
  121. */
  122. /* Private function prototypes -----------------------------------------------*/
  123. /* Exported functions --------------------------------------------------------*/
  124. /** @addtogroup RTC_LL_Exported_Functions
  125. * @{
  126. */
  127. /** @addtogroup RTC_LL_EF_Init
  128. * @{
  129. */
  130. /**
  131. * @brief De-Initializes the RTC registers to their default reset values.
  132. * @note This function doesn't reset the RTC Clock source and RTC Backup Data
  133. * registers.
  134. * @param RTCx RTC Instance
  135. * @retval An ErrorStatus enumeration value:
  136. * - SUCCESS: RTC registers are de-initialized
  137. * - ERROR: RTC registers are not de-initialized
  138. */
  139. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx)
  140. {
  141. ErrorStatus status = ERROR;
  142. /* Check the parameter */
  143. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  144. /* Disable the write protection for RTC registers */
  145. LL_RTC_DisableWriteProtection(RTCx);
  146. /* Set Initialization mode */
  147. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  148. {
  149. /* Reset TR, DR and CR registers */
  150. LL_RTC_WriteReg(RTCx, TR, 0x00000000U);
  151. #if defined(RTC_WAKEUP_SUPPORT)
  152. LL_RTC_WriteReg(RTCx, WUTR, RTC_WUTR_WUT);
  153. #endif /* RTC_WAKEUP_SUPPORT */
  154. LL_RTC_WriteReg(RTCx, DR , (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0));
  155. /* Reset All CR bits except CR[2:0] */
  156. #if defined(RTC_WAKEUP_SUPPORT)
  157. LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL));
  158. #else
  159. LL_RTC_WriteReg(RTCx, CR, 0x00000000U);
  160. #endif /* RTC_WAKEUP_SUPPORT */
  161. LL_RTC_WriteReg(RTCx, PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT));
  162. LL_RTC_WriteReg(RTCx, ALRMAR, 0x00000000U);
  163. LL_RTC_WriteReg(RTCx, ALRMBR, 0x00000000U);
  164. LL_RTC_WriteReg(RTCx, SHIFTR, 0x00000000U);
  165. LL_RTC_WriteReg(RTCx, CALR, 0x00000000U);
  166. LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U);
  167. LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U);
  168. /* Reset ISR register and exit initialization mode */
  169. LL_RTC_WriteReg(RTCx, ISR, 0x00000000U);
  170. /* Reset Tamper and alternate functions configuration register */
  171. LL_RTC_WriteReg(RTCx, TAMPCR, 0x00000000U);
  172. /* Reset Option register */
  173. LL_RTC_WriteReg(RTCx, OR, 0x00000000U);
  174. /* Wait till the RTC RSF flag is set */
  175. status = LL_RTC_WaitForSynchro(RTCx);
  176. }
  177. /* Enable the write protection for RTC registers */
  178. LL_RTC_EnableWriteProtection(RTCx);
  179. return status;
  180. }
  181. /**
  182. * @brief Initializes the RTC registers according to the specified parameters
  183. * in RTC_InitStruct.
  184. * @param RTCx RTC Instance
  185. * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains
  186. * the configuration information for the RTC peripheral.
  187. * @note The RTC Prescaler register is write protected and can be written in
  188. * initialization mode only.
  189. * @retval An ErrorStatus enumeration value:
  190. * - SUCCESS: RTC registers are initialized
  191. * - ERROR: RTC registers are not initialized
  192. */
  193. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct)
  194. {
  195. ErrorStatus status = ERROR;
  196. /* Check the parameters */
  197. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  198. assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat));
  199. assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler));
  200. assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler));
  201. /* Disable the write protection for RTC registers */
  202. LL_RTC_DisableWriteProtection(RTCx);
  203. /* Set Initialization mode */
  204. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  205. {
  206. /* Set Hour Format */
  207. LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat);
  208. /* Configure Synchronous and Asynchronous prescaler factor */
  209. LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler);
  210. LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler);
  211. /* Exit Initialization mode */
  212. LL_RTC_DisableInitMode(RTCx);
  213. status = SUCCESS;
  214. }
  215. /* Enable the write protection for RTC registers */
  216. LL_RTC_EnableWriteProtection(RTCx);
  217. return status;
  218. }
  219. /**
  220. * @brief Set each @ref LL_RTC_InitTypeDef field to default value.
  221. * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized.
  222. * @retval None
  223. */
  224. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct)
  225. {
  226. /* Set RTC_InitStruct fields to default values */
  227. RTC_InitStruct->HourFormat = LL_RTC_HOURFORMAT_24HOUR;
  228. RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT;
  229. RTC_InitStruct->SynchPrescaler = RTC_SYNCH_PRESC_DEFAULT;
  230. }
  231. /**
  232. * @brief Set the RTC current time.
  233. * @param RTCx RTC Instance
  234. * @param RTC_Format This parameter can be one of the following values:
  235. * @arg @ref LL_RTC_FORMAT_BIN
  236. * @arg @ref LL_RTC_FORMAT_BCD
  237. * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains
  238. * the time configuration information for the RTC.
  239. * @retval An ErrorStatus enumeration value:
  240. * - SUCCESS: RTC Time register is configured
  241. * - ERROR: RTC Time register is not configured
  242. */
  243. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct)
  244. {
  245. ErrorStatus status = ERROR;
  246. /* Check the parameters */
  247. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  248. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  249. if (RTC_Format == LL_RTC_FORMAT_BIN)
  250. {
  251. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  252. {
  253. assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours));
  254. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat));
  255. }
  256. else
  257. {
  258. RTC_TimeStruct->TimeFormat = 0x00U;
  259. assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours));
  260. }
  261. assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes));
  262. assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds));
  263. }
  264. else
  265. {
  266. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  267. {
  268. assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
  269. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat));
  270. }
  271. else
  272. {
  273. RTC_TimeStruct->TimeFormat = 0x00U;
  274. assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
  275. }
  276. assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)));
  277. assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds)));
  278. }
  279. /* Disable the write protection for RTC registers */
  280. LL_RTC_DisableWriteProtection(RTCx);
  281. /* Set Initialization mode */
  282. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  283. {
  284. /* Check the input parameters format */
  285. if (RTC_Format != LL_RTC_FORMAT_BIN)
  286. {
  287. LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours,
  288. RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds);
  289. }
  290. else
  291. {
  292. LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours),
  293. __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes),
  294. __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds));
  295. }
  296. /* Exit Initialization mode */
  297. LL_RTC_DisableInitMode(RTC);
  298. /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
  299. if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U)
  300. {
  301. status = LL_RTC_WaitForSynchro(RTCx);
  302. }
  303. else
  304. {
  305. status = SUCCESS;
  306. }
  307. }
  308. /* Enable the write protection for RTC registers */
  309. LL_RTC_EnableWriteProtection(RTCx);
  310. return status;
  311. }
  312. /**
  313. * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec).
  314. * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized.
  315. * @retval None
  316. */
  317. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct)
  318. {
  319. /* Time = 00h:00min:00sec */
  320. RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24;
  321. RTC_TimeStruct->Hours = 0U;
  322. RTC_TimeStruct->Minutes = 0U;
  323. RTC_TimeStruct->Seconds = 0U;
  324. }
  325. /**
  326. * @brief Set the RTC current date.
  327. * @param RTCx RTC Instance
  328. * @param RTC_Format This parameter can be one of the following values:
  329. * @arg @ref LL_RTC_FORMAT_BIN
  330. * @arg @ref LL_RTC_FORMAT_BCD
  331. * @param RTC_DateStruct: pointer to a RTC_DateTypeDef structure that contains
  332. * the date configuration information for the RTC.
  333. * @retval An ErrorStatus enumeration value:
  334. * - SUCCESS: RTC Day register is configured
  335. * - ERROR: RTC Day register is not configured
  336. */
  337. ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct)
  338. {
  339. ErrorStatus status = ERROR;
  340. /* Check the parameters */
  341. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  342. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  343. if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U))
  344. {
  345. RTC_DateStruct->Month = (RTC_DateStruct->Month & (uint32_t)~(0x10U)) + 0x0AU;
  346. }
  347. if (RTC_Format == LL_RTC_FORMAT_BIN)
  348. {
  349. assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year));
  350. assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month));
  351. assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day));
  352. }
  353. else
  354. {
  355. assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year)));
  356. assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month)));
  357. assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day)));
  358. }
  359. assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay));
  360. /* Disable the write protection for RTC registers */
  361. LL_RTC_DisableWriteProtection(RTCx);
  362. /* Set Initialization mode */
  363. if (LL_RTC_EnterInitMode(RTCx) != ERROR)
  364. {
  365. /* Check the input parameters format */
  366. if (RTC_Format != LL_RTC_FORMAT_BIN)
  367. {
  368. LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year);
  369. }
  370. else
  371. {
  372. LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day),
  373. __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year));
  374. }
  375. /* Exit Initialization mode */
  376. LL_RTC_DisableInitMode(RTC);
  377. /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
  378. if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U)
  379. {
  380. status = LL_RTC_WaitForSynchro(RTCx);
  381. }
  382. else
  383. {
  384. status = SUCCESS;
  385. }
  386. }
  387. /* Enable the write protection for RTC registers */
  388. LL_RTC_EnableWriteProtection(RTCx);
  389. return status;
  390. }
  391. /**
  392. * @brief Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00)
  393. * @param RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized.
  394. * @retval None
  395. */
  396. void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct)
  397. {
  398. /* Monday, January 01 xx00 */
  399. RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY;
  400. RTC_DateStruct->Day = 1U;
  401. RTC_DateStruct->Month = LL_RTC_MONTH_JANUARY;
  402. RTC_DateStruct->Year = 0U;
  403. }
  404. /**
  405. * @brief Set the RTC Alarm A.
  406. * @note The Alarm register can only be written when the corresponding Alarm
  407. * is disabled (Use @ref LL_RTC_ALMA_Disable function).
  408. * @param RTCx RTC Instance
  409. * @param RTC_Format This parameter can be one of the following values:
  410. * @arg @ref LL_RTC_FORMAT_BIN
  411. * @arg @ref LL_RTC_FORMAT_BCD
  412. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
  413. * contains the alarm configuration parameters.
  414. * @retval An ErrorStatus enumeration value:
  415. * - SUCCESS: ALARMA registers are configured
  416. * - ERROR: ALARMA registers are not configured
  417. */
  418. ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  419. {
  420. /* Check the parameters */
  421. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  422. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  423. assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask));
  424. assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel));
  425. if (RTC_Format == LL_RTC_FORMAT_BIN)
  426. {
  427. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  428. {
  429. assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours));
  430. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
  431. }
  432. else
  433. {
  434. RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
  435. assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
  436. }
  437. assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
  438. assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
  439. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
  440. {
  441. assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay));
  442. }
  443. else
  444. {
  445. assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay));
  446. }
  447. }
  448. else
  449. {
  450. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  451. {
  452. assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
  453. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
  454. }
  455. else
  456. {
  457. RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
  458. assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
  459. }
  460. assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
  461. assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
  462. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
  463. {
  464. assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
  465. }
  466. else
  467. {
  468. assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
  469. }
  470. }
  471. /* Disable the write protection for RTC registers */
  472. LL_RTC_DisableWriteProtection(RTCx);
  473. /* Select weekday selection */
  474. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
  475. {
  476. /* Set the date for ALARM */
  477. LL_RTC_ALMA_DisableWeekday(RTCx);
  478. if (RTC_Format != LL_RTC_FORMAT_BIN)
  479. {
  480. LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
  481. }
  482. else
  483. {
  484. LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay));
  485. }
  486. }
  487. else
  488. {
  489. /* Set the week day for ALARM */
  490. LL_RTC_ALMA_EnableWeekday(RTCx);
  491. LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
  492. }
  493. /* Configure the Alarm register */
  494. if (RTC_Format != LL_RTC_FORMAT_BIN)
  495. {
  496. LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours,
  497. RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds);
  498. }
  499. else
  500. {
  501. LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat,
  502. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours),
  503. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes),
  504. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds));
  505. }
  506. /* Set ALARM mask */
  507. LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask);
  508. /* Enable the write protection for RTC registers */
  509. LL_RTC_EnableWriteProtection(RTCx);
  510. return SUCCESS;
  511. }
  512. /**
  513. * @brief Set the RTC Alarm B.
  514. * @note The Alarm register can only be written when the corresponding Alarm
  515. * is disabled (@ref LL_RTC_ALMB_Disable function).
  516. * @param RTCx RTC Instance
  517. * @param RTC_Format This parameter can be one of the following values:
  518. * @arg @ref LL_RTC_FORMAT_BIN
  519. * @arg @ref LL_RTC_FORMAT_BCD
  520. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
  521. * contains the alarm configuration parameters.
  522. * @retval An ErrorStatus enumeration value:
  523. * - SUCCESS: ALARMB registers are configured
  524. * - ERROR: ALARMB registers are not configured
  525. */
  526. ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  527. {
  528. /* Check the parameters */
  529. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  530. assert_param(IS_LL_RTC_FORMAT(RTC_Format));
  531. assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask));
  532. assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel));
  533. if (RTC_Format == LL_RTC_FORMAT_BIN)
  534. {
  535. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  536. {
  537. assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours));
  538. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
  539. }
  540. else
  541. {
  542. RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
  543. assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
  544. }
  545. assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
  546. assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
  547. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
  548. {
  549. assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay));
  550. }
  551. else
  552. {
  553. assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay));
  554. }
  555. }
  556. else
  557. {
  558. if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
  559. {
  560. assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
  561. assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
  562. }
  563. else
  564. {
  565. RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
  566. assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
  567. }
  568. assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
  569. assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
  570. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
  571. {
  572. assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
  573. }
  574. else
  575. {
  576. assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
  577. }
  578. }
  579. /* Disable the write protection for RTC registers */
  580. LL_RTC_DisableWriteProtection(RTCx);
  581. /* Select weekday selection */
  582. if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
  583. {
  584. /* Set the date for ALARM */
  585. LL_RTC_ALMB_DisableWeekday(RTCx);
  586. if (RTC_Format != LL_RTC_FORMAT_BIN)
  587. {
  588. LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
  589. }
  590. else
  591. {
  592. LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay));
  593. }
  594. }
  595. else
  596. {
  597. /* Set the week day for ALARM */
  598. LL_RTC_ALMB_EnableWeekday(RTCx);
  599. LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
  600. }
  601. /* Configure the Alarm register */
  602. if (RTC_Format != LL_RTC_FORMAT_BIN)
  603. {
  604. LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours,
  605. RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds);
  606. }
  607. else
  608. {
  609. LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat,
  610. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours),
  611. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes),
  612. __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds));
  613. }
  614. /* Set ALARM mask */
  615. LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask);
  616. /* Enable the write protection for RTC registers */
  617. LL_RTC_EnableWriteProtection(RTCx);
  618. return SUCCESS;
  619. }
  620. /**
  621. * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec /
  622. * Day = 1st day of the month/Mask = all fields are masked).
  623. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
  624. * @retval None
  625. */
  626. void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  627. {
  628. /* Alarm Time Settings : Time = 00h:00mn:00sec */
  629. RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM;
  630. RTC_AlarmStruct->AlarmTime.Hours = 0U;
  631. RTC_AlarmStruct->AlarmTime.Minutes = 0U;
  632. RTC_AlarmStruct->AlarmTime.Seconds = 0U;
  633. /* Alarm Day Settings : Day = 1st day of the month */
  634. RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE;
  635. RTC_AlarmStruct->AlarmDateWeekDay = 1U;
  636. /* Alarm Masks Settings : Mask = all fields are not masked */
  637. RTC_AlarmStruct->AlarmMask = LL_RTC_ALMA_MASK_NONE;
  638. }
  639. /**
  640. * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec /
  641. * Day = 1st day of the month/Mask = all fields are masked).
  642. * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
  643. * @retval None
  644. */
  645. void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
  646. {
  647. /* Alarm Time Settings : Time = 00h:00mn:00sec */
  648. RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM;
  649. RTC_AlarmStruct->AlarmTime.Hours = 0U;
  650. RTC_AlarmStruct->AlarmTime.Minutes = 0U;
  651. RTC_AlarmStruct->AlarmTime.Seconds = 0U;
  652. /* Alarm Day Settings : Day = 1st day of the month */
  653. RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE;
  654. RTC_AlarmStruct->AlarmDateWeekDay = 1U;
  655. /* Alarm Masks Settings : Mask = all fields are not masked */
  656. RTC_AlarmStruct->AlarmMask = LL_RTC_ALMB_MASK_NONE;
  657. }
  658. /**
  659. * @brief Enters the RTC Initialization mode.
  660. * @note The RTC Initialization mode is write protected, use the
  661. * @ref LL_RTC_DisableWriteProtection before calling this function.
  662. * @param RTCx RTC Instance
  663. * @retval An ErrorStatus enumeration value:
  664. * - SUCCESS: RTC is in Init mode
  665. * - ERROR: RTC is not in Init mode
  666. */
  667. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx)
  668. {
  669. __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
  670. ErrorStatus status = SUCCESS;
  671. uint32_t tmp = 0U;
  672. /* Check the parameter */
  673. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  674. /* Check if the Initialization mode is set */
  675. if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U)
  676. {
  677. /* Set the Initialization mode */
  678. LL_RTC_EnableInitMode(RTCx);
  679. /* Wait till RTC is in INIT state and if Time out is reached exit */
  680. tmp = LL_RTC_IsActiveFlag_INIT(RTCx);
  681. while ((timeout != 0U) && (tmp != 1U))
  682. {
  683. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  684. {
  685. timeout --;
  686. }
  687. tmp = LL_RTC_IsActiveFlag_INIT(RTCx);
  688. if (timeout == 0U)
  689. {
  690. status = ERROR;
  691. }
  692. }
  693. }
  694. return status;
  695. }
  696. /**
  697. * @brief Exit the RTC Initialization mode.
  698. * @note When the initialization sequence is complete, the calendar restarts
  699. * counting after 4 RTCCLK cycles.
  700. * @note The RTC Initialization mode is write protected, use the
  701. * @ref LL_RTC_DisableWriteProtection before calling this function.
  702. * @param RTCx RTC Instance
  703. * @retval An ErrorStatus enumeration value:
  704. * - SUCCESS: RTC exited from in Init mode
  705. * - ERROR: Not applicable
  706. */
  707. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx)
  708. {
  709. /* Check the parameter */
  710. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  711. /* Disable initialization mode */
  712. LL_RTC_DisableInitMode(RTCx);
  713. return SUCCESS;
  714. }
  715. /**
  716. * @brief Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are
  717. * synchronized with RTC APB clock.
  718. * @note The RTC Resynchronization mode is write protected, use the
  719. * @ref LL_RTC_DisableWriteProtection before calling this function.
  720. * @note To read the calendar through the shadow registers after Calendar
  721. * initialization, calendar update or after wakeup from low power modes
  722. * the software must first clear the RSF flag.
  723. * The software must then wait until it is set again before reading
  724. * the calendar, which means that the calendar registers have been
  725. * correctly copied into the RTC_TR and RTC_DR shadow registers.
  726. * @param RTCx RTC Instance
  727. * @retval An ErrorStatus enumeration value:
  728. * - SUCCESS: RTC registers are synchronised
  729. * - ERROR: RTC registers are not synchronised
  730. */
  731. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx)
  732. {
  733. __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT;
  734. ErrorStatus status = SUCCESS;
  735. uint32_t tmp = 0U;
  736. /* Check the parameter */
  737. assert_param(IS_RTC_ALL_INSTANCE(RTCx));
  738. /* Clear RSF flag */
  739. LL_RTC_ClearFlag_RS(RTCx);
  740. /* Wait the registers to be synchronised */
  741. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  742. while ((timeout != 0U) && (tmp != 0U))
  743. {
  744. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  745. {
  746. timeout--;
  747. }
  748. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  749. if (timeout == 0U)
  750. {
  751. status = ERROR;
  752. }
  753. }
  754. if (status != ERROR)
  755. {
  756. timeout = RTC_SYNCHRO_TIMEOUT;
  757. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  758. while ((timeout != 0U) && (tmp != 1U))
  759. {
  760. if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
  761. {
  762. timeout--;
  763. }
  764. tmp = LL_RTC_IsActiveFlag_RS(RTCx);
  765. if (timeout == 0U)
  766. {
  767. status = ERROR;
  768. }
  769. }
  770. }
  771. return (status);
  772. }
  773. /**
  774. * @}
  775. */
  776. /**
  777. * @}
  778. */
  779. /**
  780. * @}
  781. */
  782. #endif /* defined(RTC) */
  783. /**
  784. * @}
  785. */
  786. #endif /* USE_FULL_LL_DRIVER */
  787. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/