stm32l0xx_ll_rtc.h 140 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_ll_rtc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC LL module.
  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. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L0xx_LL_RTC_H
  20. #define STM32L0xx_LL_RTC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l0xx.h"
  26. /** @addtogroup STM32L0xx_LL_Driver
  27. * @{
  28. */
  29. #if defined(RTC)
  30. /** @defgroup RTC_LL RTC
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /** @defgroup RTC_LL_Private_Constants RTC Private Constants
  37. * @{
  38. */
  39. /* Masks Definition */
  40. #define RTC_INIT_MASK 0xFFFFFFFFU
  41. #define RTC_RSF_MASK ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF))
  42. /* Write protection defines */
  43. #define RTC_WRITE_PROTECTION_DISABLE ((uint8_t)0xFFU)
  44. #define RTC_WRITE_PROTECTION_ENABLE_1 ((uint8_t)0xCAU)
  45. #define RTC_WRITE_PROTECTION_ENABLE_2 ((uint8_t)0x53U)
  46. /* Defines used to combine date & time */
  47. #define RTC_OFFSET_WEEKDAY 24U
  48. #define RTC_OFFSET_DAY 16U
  49. #define RTC_OFFSET_MONTH 8U
  50. #define RTC_OFFSET_HOUR 16U
  51. #define RTC_OFFSET_MINUTE 8U
  52. /**
  53. * @}
  54. */
  55. /* Private macros ------------------------------------------------------------*/
  56. #if defined(USE_FULL_LL_DRIVER)
  57. /** @defgroup RTC_LL_Private_Macros RTC Private Macros
  58. * @{
  59. */
  60. /**
  61. * @}
  62. */
  63. #endif /*USE_FULL_LL_DRIVER*/
  64. /* Exported types ------------------------------------------------------------*/
  65. #if defined(USE_FULL_LL_DRIVER)
  66. /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
  67. * @{
  68. */
  69. /**
  70. * @brief RTC Init structures definition
  71. */
  72. typedef struct
  73. {
  74. uint32_t HourFormat; /*!< Specifies the RTC Hours Format.
  75. This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
  76. This feature can be modified afterwards using unitary function
  77. @ref LL_RTC_SetHourFormat(). */
  78. uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
  79. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
  80. This feature can be modified afterwards using unitary function
  81. @ref LL_RTC_SetAsynchPrescaler(). */
  82. uint32_t SynchPrescaler; /*!< Specifies the RTC Synchronous Predivider value.
  83. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
  84. This feature can be modified afterwards using unitary function
  85. @ref LL_RTC_SetSynchPrescaler(). */
  86. } LL_RTC_InitTypeDef;
  87. /**
  88. * @brief RTC Time structure definition
  89. */
  90. typedef struct
  91. {
  92. uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
  93. This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
  94. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
  95. uint8_t Hours; /*!< Specifies the RTC Time Hours.
  96. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
  97. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the @ref LL_RTC_TIME_FORMAT_AM_OR_24 is selected.
  98. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
  99. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  100. This parameter must be a number between Min_Data = 0 and Max_Data = 59
  101. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
  102. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  103. This parameter must be a number between Min_Data = 0 and Max_Data = 59
  104. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
  105. } LL_RTC_TimeTypeDef;
  106. /**
  107. * @brief RTC Date structure definition
  108. */
  109. typedef struct
  110. {
  111. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
  112. This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
  113. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
  114. uint8_t Month; /*!< Specifies the RTC Date Month.
  115. This parameter can be a value of @ref RTC_LL_EC_MONTH
  116. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
  117. uint8_t Day; /*!< Specifies the RTC Date Day.
  118. This parameter must be a number between Min_Data = 1 and Max_Data = 31
  119. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
  120. uint8_t Year; /*!< Specifies the RTC Date Year.
  121. This parameter must be a number between Min_Data = 0 and Max_Data = 99
  122. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
  123. } LL_RTC_DateTypeDef;
  124. /**
  125. * @brief RTC Alarm structure definition
  126. */
  127. typedef struct
  128. {
  129. LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */
  130. uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
  131. This parameter can be a value of @ref RTC_LL_EC_ALMA_MASK for ALARM A or @ref RTC_LL_EC_ALMB_MASK for ALARM B.
  132. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask() for ALARM A
  133. or @ref LL_RTC_ALMB_SetMask() for ALARM B.
  134. */
  135. uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on day or WeekDay.
  136. This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION for ALARM A or @ref RTC_LL_EC_ALMB_WEEKDAY_SELECTION for ALARM B
  137. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday()
  138. for ALARM A or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday() for ALARM B
  139. */
  140. uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Day/WeekDay.
  141. If AlarmDateWeekDaySel set to day, this parameter must be a number between Min_Data = 1 and Max_Data = 31.
  142. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay()
  143. for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
  144. If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
  145. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay()
  146. for ALARM A or @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
  147. */
  148. } LL_RTC_AlarmTypeDef;
  149. /**
  150. * @}
  151. */
  152. #endif /* USE_FULL_LL_DRIVER */
  153. /* Exported constants --------------------------------------------------------*/
  154. /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
  155. * @{
  156. */
  157. #if defined(USE_FULL_LL_DRIVER)
  158. /** @defgroup RTC_LL_EC_FORMAT FORMAT
  159. * @{
  160. */
  161. #define LL_RTC_FORMAT_BIN 0x00000000U /*!< Binary data format */
  162. #define LL_RTC_FORMAT_BCD 0x00000001U /*!< BCD data format */
  163. /**
  164. * @}
  165. */
  166. /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
  167. * @{
  168. */
  169. #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm A Date is selected */
  170. #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL /*!< Alarm A WeekDay is selected */
  171. /**
  172. * @}
  173. */
  174. /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
  175. * @{
  176. */
  177. #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm B Date is selected */
  178. #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL /*!< Alarm B WeekDay is selected */
  179. /**
  180. * @}
  181. */
  182. #endif /* USE_FULL_LL_DRIVER */
  183. /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
  184. * @brief Flags defines which can be used with LL_RTC_ReadReg function
  185. * @{
  186. */
  187. #define LL_RTC_ISR_RECALPF RTC_ISR_RECALPF
  188. #if defined(RTC_TAMPER3_SUPPORT)
  189. #define LL_RTC_ISR_TAMP3F RTC_ISR_TAMP3F
  190. #endif /* RTC_TAMPER3_SUPPORT */
  191. #define LL_RTC_ISR_TAMP2F RTC_ISR_TAMP2F
  192. #if defined(RTC_TAMPER1_SUPPORT)
  193. #define LL_RTC_ISR_TAMP1F RTC_ISR_TAMP1F
  194. #endif /* RTC_TAMPER1_SUPPORT */
  195. #define LL_RTC_ISR_TSOVF RTC_ISR_TSOVF
  196. #define LL_RTC_ISR_TSF RTC_ISR_TSF
  197. #define LL_RTC_ISR_WUTF RTC_ISR_WUTF
  198. #define LL_RTC_ISR_ALRBF RTC_ISR_ALRBF
  199. #define LL_RTC_ISR_ALRAF RTC_ISR_ALRAF
  200. #define LL_RTC_ISR_INITF RTC_ISR_INITF
  201. #define LL_RTC_ISR_RSF RTC_ISR_RSF
  202. #define LL_RTC_ISR_INITS RTC_ISR_INITS
  203. #define LL_RTC_ISR_SHPF RTC_ISR_SHPF
  204. #define LL_RTC_ISR_WUTWF RTC_ISR_WUTWF
  205. #define LL_RTC_ISR_ALRBWF RTC_ISR_ALRBWF
  206. #define LL_RTC_ISR_ALRAWF RTC_ISR_ALRAWF
  207. /**
  208. * @}
  209. */
  210. /** @defgroup RTC_LL_EC_IT IT Defines
  211. * @brief IT defines which can be used with LL_RTC_ReadReg and LL_RTC_WriteReg functions
  212. * @{
  213. */
  214. #define LL_RTC_CR_TSIE RTC_CR_TSIE
  215. #define LL_RTC_CR_WUTIE RTC_CR_WUTIE
  216. #define LL_RTC_CR_ALRBIE RTC_CR_ALRBIE
  217. #define LL_RTC_CR_ALRAIE RTC_CR_ALRAIE
  218. #if defined(RTC_TAMPER3_SUPPORT)
  219. #define LL_RTC_TAMPCR_TAMP3IE RTC_TAMPCR_TAMP3IE
  220. #endif /* RTC_TAMPER3_SUPPORT */
  221. #define LL_RTC_TAMPCR_TAMP2IE RTC_TAMPCR_TAMP2IE
  222. #if defined(RTC_TAMPER1_SUPPORT)
  223. #define LL_RTC_TAMPCR_TAMP1IE RTC_TAMPCR_TAMP1IE
  224. #endif /* RTC_TAMPER1_SUPPORT */
  225. #define LL_RTC_TAMPCR_TAMPIE RTC_TAMPCR_TAMPIE
  226. /**
  227. * @}
  228. */
  229. /** @defgroup RTC_LL_EC_WEEKDAY WEEK DAY
  230. * @{
  231. */
  232. #define LL_RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) /*!< Monday */
  233. #define LL_RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) /*!< Tuesday */
  234. #define LL_RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) /*!< Wednesday */
  235. #define LL_RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) /*!< Thrusday */
  236. #define LL_RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) /*!< Friday */
  237. #define LL_RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) /*!< Saturday */
  238. #define LL_RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) /*!< Sunday */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup RTC_LL_EC_MONTH MONTH
  243. * @{
  244. */
  245. #define LL_RTC_MONTH_JANUARY ((uint8_t)0x01U) /*!< January */
  246. #define LL_RTC_MONTH_FEBRUARY ((uint8_t)0x02U) /*!< February */
  247. #define LL_RTC_MONTH_MARCH ((uint8_t)0x03U) /*!< March */
  248. #define LL_RTC_MONTH_APRIL ((uint8_t)0x04U) /*!< April */
  249. #define LL_RTC_MONTH_MAY ((uint8_t)0x05U) /*!< May */
  250. #define LL_RTC_MONTH_JUNE ((uint8_t)0x06U) /*!< June */
  251. #define LL_RTC_MONTH_JULY ((uint8_t)0x07U) /*!< July */
  252. #define LL_RTC_MONTH_AUGUST ((uint8_t)0x08U) /*!< August */
  253. #define LL_RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) /*!< September */
  254. #define LL_RTC_MONTH_OCTOBER ((uint8_t)0x10U) /*!< October */
  255. #define LL_RTC_MONTH_NOVEMBER ((uint8_t)0x11U) /*!< November */
  256. #define LL_RTC_MONTH_DECEMBER ((uint8_t)0x12U) /*!< December */
  257. /**
  258. * @}
  259. */
  260. /** @defgroup RTC_LL_EC_HOURFORMAT HOUR FORMAT
  261. * @{
  262. */
  263. #define LL_RTC_HOURFORMAT_24HOUR 0x00000000U /*!< 24 hour/day format */
  264. #define LL_RTC_HOURFORMAT_AMPM RTC_CR_FMT /*!< AM/PM hour format */
  265. /**
  266. * @}
  267. */
  268. /** @defgroup RTC_LL_EC_ALARMOUT ALARM OUTPUT
  269. * @{
  270. */
  271. #define LL_RTC_ALARMOUT_DISABLE 0x00000000U /*!< Output disabled */
  272. #define LL_RTC_ALARMOUT_ALMA RTC_CR_OSEL_0 /*!< Alarm A output enabled */
  273. #define LL_RTC_ALARMOUT_ALMB RTC_CR_OSEL_1 /*!< Alarm B output enabled */
  274. #define LL_RTC_ALARMOUT_WAKEUP RTC_CR_OSEL /*!< Wakeup output enabled */
  275. /**
  276. * @}
  277. */
  278. /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE ALARM OUTPUT TYPE
  279. * @{
  280. */
  281. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN 0x00000000U /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
  282. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL RTC_OR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
  283. /**
  284. * @}
  285. */
  286. /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN OUTPUT POLARITY PIN
  287. * @{
  288. */
  289. #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH 0x00000000U /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
  290. #define LL_RTC_OUTPUTPOLARITY_PIN_LOW RTC_CR_POL /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
  291. /**
  292. * @}
  293. */
  294. /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
  295. * @{
  296. */
  297. #define LL_RTC_TIME_FORMAT_AM_OR_24 0x00000000U /*!< AM or 24-hour format */
  298. #define LL_RTC_TIME_FORMAT_PM RTC_TR_PM /*!< PM */
  299. /**
  300. * @}
  301. */
  302. /** @defgroup RTC_LL_EC_SHIFT_SECOND SHIFT SECOND
  303. * @{
  304. */
  305. #define LL_RTC_SHIFT_SECOND_DELAY 0x00000000U /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
  306. #define LL_RTC_SHIFT_SECOND_ADVANCE RTC_SHIFTR_ADD1S /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
  307. /**
  308. * @}
  309. */
  310. /** @defgroup RTC_LL_EC_ALMA_MASK ALARMA MASK
  311. * @{
  312. */
  313. #define LL_RTC_ALMA_MASK_NONE 0x00000000U /*!< No masks applied on Alarm A*/
  314. #define LL_RTC_ALMA_MASK_DATEWEEKDAY RTC_ALRMAR_MSK4 /*!< Date/day do not care in Alarm A comparison */
  315. #define LL_RTC_ALMA_MASK_HOURS RTC_ALRMAR_MSK3 /*!< Hours do not care in Alarm A comparison */
  316. #define LL_RTC_ALMA_MASK_MINUTES RTC_ALRMAR_MSK2 /*!< Minutes do not care in Alarm A comparison */
  317. #define LL_RTC_ALMA_MASK_SECONDS RTC_ALRMAR_MSK1 /*!< Seconds do not care in Alarm A comparison */
  318. #define LL_RTC_ALMA_MASK_ALL (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
  319. /**
  320. * @}
  321. */
  322. /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT ALARMA TIME FORMAT
  323. * @{
  324. */
  325. #define LL_RTC_ALMA_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  326. #define LL_RTC_ALMA_TIME_FORMAT_PM RTC_ALRMAR_PM /*!< PM */
  327. /**
  328. * @}
  329. */
  330. /** @defgroup RTC_LL_EC_ALMB_MASK ALARMB MASK
  331. * @{
  332. */
  333. #define LL_RTC_ALMB_MASK_NONE 0x00000000U /*!< No masks applied on Alarm B */
  334. #define LL_RTC_ALMB_MASK_DATEWEEKDAY RTC_ALRMBR_MSK4 /*!< Date/day do not care in Alarm B comparison */
  335. #define LL_RTC_ALMB_MASK_HOURS RTC_ALRMBR_MSK3 /*!< Hours do not care in Alarm B comparison */
  336. #define LL_RTC_ALMB_MASK_MINUTES RTC_ALRMBR_MSK2 /*!< Minutes do not care in Alarm B comparison */
  337. #define LL_RTC_ALMB_MASK_SECONDS RTC_ALRMBR_MSK1 /*!< Seconds do not care in Alarm B comparison */
  338. #define LL_RTC_ALMB_MASK_ALL (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
  339. /**
  340. * @}
  341. */
  342. /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT ALARMB TIME FORMAT
  343. * @{
  344. */
  345. #define LL_RTC_ALMB_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  346. #define LL_RTC_ALMB_TIME_FORMAT_PM RTC_ALRMBR_PM /*!< PM */
  347. /**
  348. * @}
  349. */
  350. /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE TIMESTAMP EDGE
  351. * @{
  352. */
  353. #define LL_RTC_TIMESTAMP_EDGE_RISING 0x00000000U /*!< RTC_TS input rising edge generates a time-stamp event */
  354. #define LL_RTC_TIMESTAMP_EDGE_FALLING RTC_CR_TSEDGE /*!< RTC_TS input falling edge generates a time-stamp even */
  355. /**
  356. * @}
  357. */
  358. /** @defgroup RTC_LL_EC_TS_TIME_FORMAT TIMESTAMP TIME FORMAT
  359. * @{
  360. */
  361. #define LL_RTC_TS_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  362. #define LL_RTC_TS_TIME_FORMAT_PM RTC_TSTR_PM /*!< PM */
  363. /**
  364. * @}
  365. */
  366. /** @defgroup RTC_LL_EC_TAMPER TAMPER
  367. * @{
  368. */
  369. #if defined(RTC_TAMPER1_SUPPORT)
  370. #define LL_RTC_TAMPER_1 RTC_TAMPCR_TAMP1E /*!< RTC_TAMP1 input detection */
  371. #endif /* RTC_TAMPER1_SUPPORT */
  372. #define LL_RTC_TAMPER_2 RTC_TAMPCR_TAMP2E /*!< RTC_TAMP2 input detection */
  373. #if defined(RTC_TAMPER3_SUPPORT)
  374. #define LL_RTC_TAMPER_3 RTC_TAMPCR_TAMP3E /*!< RTC_TAMP3 input detection */
  375. #endif /* RTC_TAMPER3_SUPPORT */
  376. /**
  377. * @}
  378. */
  379. /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
  380. * @{
  381. */
  382. #if defined(RTC_TAMPER1_SUPPORT)
  383. #define LL_RTC_TAMPER_MASK_TAMPER1 RTC_TAMPCR_TAMP1MF /*!< Tamper 1 event generates a trigger event. TAMP1F is masked and internally cleared by hardware.The backup registers are not erased */
  384. #endif /* RTC_TAMPER1_SUPPORT */
  385. #define LL_RTC_TAMPER_MASK_TAMPER2 RTC_TAMPCR_TAMP2MF /*!< Tamper 2 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
  386. #if defined(RTC_TAMPER3_SUPPORT)
  387. #define LL_RTC_TAMPER_MASK_TAMPER3 RTC_TAMPCR_TAMP3MF /*!< Tamper 3 event generates a trigger event. TAMP3F is masked and internally cleared by hardware. The backup registers are not erased */
  388. #endif /* RTC_TAMPER3_SUPPORT */
  389. /**
  390. * @}
  391. */
  392. /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
  393. * @{
  394. */
  395. #if defined(RTC_TAMPER1_SUPPORT)
  396. #define LL_RTC_TAMPER_NOERASE_TAMPER1 RTC_TAMPCR_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
  397. #endif /* RTC_TAMPER1_SUPPORT */
  398. #define LL_RTC_TAMPER_NOERASE_TAMPER2 RTC_TAMPCR_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
  399. #if defined(RTC_TAMPER3_SUPPORT)
  400. #define LL_RTC_TAMPER_NOERASE_TAMPER3 RTC_TAMPCR_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
  401. #endif /* RTC_TAMPER3_SUPPORT */
  402. /**
  403. * @}
  404. */
  405. /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
  406. * @{
  407. */
  408. #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
  409. #define LL_RTC_TAMPER_DURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  410. #define LL_RTC_TAMPER_DURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  411. #define LL_RTC_TAMPER_DURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  412. /**
  413. * @}
  414. */
  415. /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
  416. * @{
  417. */
  418. #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  419. #define LL_RTC_TAMPER_FILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
  420. #define LL_RTC_TAMPER_FILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
  421. #define LL_RTC_TAMPER_FILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
  422. /**
  423. * @}
  424. */
  425. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
  426. * @{
  427. */
  428. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
  429. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
  430. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
  431. #define LL_RTC_TAMPER_SAMPLFREQDIV_4096 (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 */
  432. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
  433. #define LL_RTC_TAMPER_SAMPLFREQDIV_1024 (RTC_TAMPCR_TAMPFREQ_2 | RTC_TAMPCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 */
  434. #define LL_RTC_TAMPER_SAMPLFREQDIV_512 (RTC_TAMPCR_TAMPFREQ_2 | RTC_TAMPCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 512 */
  435. #define LL_RTC_TAMPER_SAMPLFREQDIV_256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
  436. /**
  437. * @}
  438. */
  439. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
  440. * @{
  441. */
  442. #if defined(RTC_TAMPER1_SUPPORT)
  443. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 RTC_TAMPCR_TAMP1TRG /*!< RTC_TAMP1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  444. #endif /* RTC_TAMPER1_SUPPORT */
  445. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 RTC_TAMPCR_TAMP2TRG /*!< RTC_TAMP2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  446. #if defined(RTC_TAMPER3_SUPPORT)
  447. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 RTC_TAMPCR_TAMP3TRG /*!< RTC_TAMP3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  448. #endif /* RTC_TAMPER3_SUPPORT */
  449. /**
  450. * @}
  451. */
  452. /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV WAKEUP CLOCK DIV
  453. * @{
  454. */
  455. #define LL_RTC_WAKEUPCLOCK_DIV_16 0x00000000U /*!< RTC/16 clock is selected */
  456. #define LL_RTC_WAKEUPCLOCK_DIV_8 (RTC_CR_WUCKSEL_0) /*!< RTC/8 clock is selected */
  457. #define LL_RTC_WAKEUPCLOCK_DIV_4 (RTC_CR_WUCKSEL_1) /*!< RTC/4 clock is selected */
  458. #define LL_RTC_WAKEUPCLOCK_DIV_2 (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
  459. #define LL_RTC_WAKEUPCLOCK_CKSPRE (RTC_CR_WUCKSEL_2) /*!< ck_spre (usually 1 Hz) clock is selected */
  460. #define LL_RTC_WAKEUPCLOCK_CKSPRE_WUT (RTC_CR_WUCKSEL_2 | RTC_CR_WUCKSEL_1) /*!< ck_spre (usually 1 Hz) clock is selected and 2exp16 is added to the WUT counter value*/
  461. /**
  462. * @}
  463. */
  464. /** @defgroup RTC_LL_EC_BKP BACKUP
  465. * @{
  466. */
  467. #define LL_RTC_BKP_DR0 0x00000000U
  468. #define LL_RTC_BKP_DR1 0x00000001U
  469. #define LL_RTC_BKP_DR2 0x00000002U
  470. #define LL_RTC_BKP_DR3 0x00000003U
  471. #define LL_RTC_BKP_DR4 0x00000004U
  472. /**
  473. * @}
  474. */
  475. /** @defgroup RTC_LL_EC_CALIB_OUTPUT Calibration output
  476. * @{
  477. */
  478. #define LL_RTC_CALIB_OUTPUT_NONE 0x00000000U /*!< Calibration output disabled */
  479. #define LL_RTC_CALIB_OUTPUT_1HZ (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
  480. #define LL_RTC_CALIB_OUTPUT_512HZ (RTC_CR_COE) /*!< Calibration output is 512 Hz */
  481. /**
  482. * @}
  483. */
  484. /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE Calibration pulse insertion
  485. * @{
  486. */
  487. #define LL_RTC_CALIB_INSERTPULSE_NONE 0x00000000U /*!< No RTCCLK pulses are added */
  488. #define LL_RTC_CALIB_INSERTPULSE_SET RTC_CALR_CALP /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
  489. /**
  490. * @}
  491. */
  492. /** @defgroup RTC_LL_EC_CALIB_PERIOD Calibration period
  493. * @{
  494. */
  495. #define LL_RTC_CALIB_PERIOD_32SEC 0x00000000U /*!< Use a 32-second calibration cycle period */
  496. #define LL_RTC_CALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< Use a 16-second calibration cycle period */
  497. #define LL_RTC_CALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< Use a 8-second calibration cycle period */
  498. /**
  499. * @}
  500. */
  501. /**
  502. * @}
  503. */
  504. /* Exported macro ------------------------------------------------------------*/
  505. /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
  506. * @{
  507. */
  508. /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
  509. * @{
  510. */
  511. /**
  512. * @brief Write a value in RTC register
  513. * @param __INSTANCE__ RTC Instance
  514. * @param __REG__ Register to be written
  515. * @param __VALUE__ Value to be written in the register
  516. * @retval None
  517. */
  518. #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  519. /**
  520. * @brief Read a value in RTC register
  521. * @param __INSTANCE__ RTC Instance
  522. * @param __REG__ Register to be read
  523. * @retval Register value
  524. */
  525. #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  526. /**
  527. * @}
  528. */
  529. /** @defgroup RTC_LL_EM_Convert Convert helper Macros
  530. * @{
  531. */
  532. /**
  533. * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
  534. * @param __VALUE__ Byte to be converted
  535. * @retval Converted byte
  536. */
  537. #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
  538. /**
  539. * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
  540. * @param __VALUE__ BCD value to be converted
  541. * @retval Converted byte
  542. */
  543. #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
  544. /**
  545. * @}
  546. */
  547. /** @defgroup RTC_LL_EM_Date Date helper Macros
  548. * @{
  549. */
  550. /**
  551. * @brief Helper macro to retrieve weekday.
  552. * @param __RTC_DATE__ Date returned by @ref LL_RTC_DATE_Get function.
  553. * @retval Returned value can be one of the following values:
  554. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  555. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  556. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  557. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  558. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  559. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  560. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  561. */
  562. #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
  563. /**
  564. * @brief Helper macro to retrieve Year in BCD format
  565. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  566. * @retval Year in BCD format (0x00 . . . 0x99)
  567. */
  568. #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
  569. /**
  570. * @brief Helper macro to retrieve Month in BCD format
  571. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  572. * @retval Returned value can be one of the following values:
  573. * @arg @ref LL_RTC_MONTH_JANUARY
  574. * @arg @ref LL_RTC_MONTH_FEBRUARY
  575. * @arg @ref LL_RTC_MONTH_MARCH
  576. * @arg @ref LL_RTC_MONTH_APRIL
  577. * @arg @ref LL_RTC_MONTH_MAY
  578. * @arg @ref LL_RTC_MONTH_JUNE
  579. * @arg @ref LL_RTC_MONTH_JULY
  580. * @arg @ref LL_RTC_MONTH_AUGUST
  581. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  582. * @arg @ref LL_RTC_MONTH_OCTOBER
  583. * @arg @ref LL_RTC_MONTH_NOVEMBER
  584. * @arg @ref LL_RTC_MONTH_DECEMBER
  585. */
  586. #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
  587. /**
  588. * @brief Helper macro to retrieve Day in BCD format
  589. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  590. * @retval Day in BCD format (0x01 . . . 0x31)
  591. */
  592. #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
  593. /**
  594. * @}
  595. */
  596. /** @defgroup RTC_LL_EM_Time Time helper Macros
  597. * @{
  598. */
  599. /**
  600. * @brief Helper macro to retrieve hour in BCD format
  601. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  602. * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
  603. */
  604. #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
  605. /**
  606. * @brief Helper macro to retrieve minute in BCD format
  607. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  608. * @retval Minutes in BCD format (0x00. . .0x59)
  609. */
  610. #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
  611. /**
  612. * @brief Helper macro to retrieve second in BCD format
  613. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  614. * @retval Seconds in format (0x00. . .0x59)
  615. */
  616. #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
  617. /**
  618. * @}
  619. */
  620. /**
  621. * @}
  622. */
  623. /* Exported functions --------------------------------------------------------*/
  624. /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
  625. * @{
  626. */
  627. /** @defgroup RTC_LL_EF_Configuration Configuration
  628. * @{
  629. */
  630. /**
  631. * @brief Set Hours format (24 hour/day or AM/PM hour format)
  632. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  633. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  634. * @rmtoll CR FMT LL_RTC_SetHourFormat
  635. * @param RTCx RTC Instance
  636. * @param HourFormat This parameter can be one of the following values:
  637. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  638. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  639. * @retval None
  640. */
  641. __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
  642. {
  643. MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
  644. }
  645. /**
  646. * @brief Get Hours format (24 hour/day or AM/PM hour format)
  647. * @rmtoll CR FMT LL_RTC_GetHourFormat
  648. * @param RTCx RTC Instance
  649. * @retval Returned value can be one of the following values:
  650. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  651. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  652. */
  653. __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
  654. {
  655. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
  656. }
  657. /**
  658. * @brief Select the flag to be routed to RTC_ALARM output
  659. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  660. * @rmtoll CR OSEL LL_RTC_SetAlarmOutEvent
  661. * @param RTCx RTC Instance
  662. * @param AlarmOutput This parameter can be one of the following values:
  663. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  664. * @arg @ref LL_RTC_ALARMOUT_ALMA
  665. * @arg @ref LL_RTC_ALARMOUT_ALMB
  666. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  667. * @retval None
  668. */
  669. __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
  670. {
  671. MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
  672. }
  673. /**
  674. * @brief Get the flag to be routed to RTC_ALARM output
  675. * @rmtoll CR OSEL LL_RTC_GetAlarmOutEvent
  676. * @param RTCx RTC Instance
  677. * @retval Returned value can be one of the following values:
  678. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  679. * @arg @ref LL_RTC_ALARMOUT_ALMA
  680. * @arg @ref LL_RTC_ALARMOUT_ALMB
  681. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  682. */
  683. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
  684. {
  685. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
  686. }
  687. /**
  688. * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  689. * @note Used only when RTC_ALARM is mapped on PC13
  690. * @rmtoll OR ALARMOUTTYPE LL_RTC_SetAlarmOutputType
  691. * @param RTCx RTC Instance
  692. * @param Output This parameter can be one of the following values:
  693. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  694. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  698. {
  699. MODIFY_REG(RTCx->OR, RTC_OR_ALARMOUTTYPE, Output);
  700. }
  701. /**
  702. * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  703. * @note used only when RTC_ALARM is mapped on PC13
  704. * @rmtoll OR ALARMOUTTYPE LL_RTC_GetAlarmOutputType
  705. * @param RTCx RTC Instance
  706. * @retval Returned value can be one of the following values:
  707. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  708. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  709. */
  710. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  711. {
  712. return (uint32_t)(READ_BIT(RTCx->OR, RTC_OR_ALARMOUTTYPE));
  713. }
  714. /**
  715. * @brief Enable initialization mode
  716. * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  717. * and prescaler register (RTC_PRER).
  718. * Counters are stopped and start counting from the new value when INIT is reset.
  719. * @rmtoll ISR INIT LL_RTC_EnableInitMode
  720. * @param RTCx RTC Instance
  721. * @retval None
  722. */
  723. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  724. {
  725. /* Set the Initialization mode */
  726. WRITE_REG(RTCx->ISR, RTC_INIT_MASK);
  727. }
  728. /**
  729. * @brief Disable initialization mode (Free running mode)
  730. * @rmtoll ISR INIT LL_RTC_DisableInitMode
  731. * @param RTCx RTC Instance
  732. * @retval None
  733. */
  734. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  735. {
  736. /* Exit Initialization mode */
  737. WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
  738. }
  739. /**
  740. * @brief Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
  741. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  742. * @rmtoll CR POL LL_RTC_SetOutputPolarity
  743. * @param RTCx RTC Instance
  744. * @param Polarity This parameter can be one of the following values:
  745. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  746. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  747. * @retval None
  748. */
  749. __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
  750. {
  751. MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
  752. }
  753. /**
  754. * @brief Get Output polarity
  755. * @rmtoll CR POL LL_RTC_GetOutputPolarity
  756. * @param RTCx RTC Instance
  757. * @retval Returned value can be one of the following values:
  758. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  759. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  760. */
  761. __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
  762. {
  763. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
  764. }
  765. /**
  766. * @brief Enable Bypass the shadow registers
  767. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  768. * @rmtoll CR BYPSHAD LL_RTC_EnableShadowRegBypass
  769. * @param RTCx RTC Instance
  770. * @retval None
  771. */
  772. __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
  773. {
  774. SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  775. }
  776. /**
  777. * @brief Disable Bypass the shadow registers
  778. * @rmtoll CR BYPSHAD LL_RTC_DisableShadowRegBypass
  779. * @param RTCx RTC Instance
  780. * @retval None
  781. */
  782. __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
  783. {
  784. CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  785. }
  786. /**
  787. * @brief Check if Shadow registers bypass is enabled or not.
  788. * @rmtoll CR BYPSHAD LL_RTC_IsShadowRegBypassEnabled
  789. * @param RTCx RTC Instance
  790. * @retval State of bit (1 or 0).
  791. */
  792. __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
  793. {
  794. return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
  795. }
  796. /**
  797. * @brief Enable RTC_REFIN reference clock detection (50 or 60 Hz)
  798. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  799. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  800. * @rmtoll CR REFCKON LL_RTC_EnableRefClock
  801. * @param RTCx RTC Instance
  802. * @retval None
  803. */
  804. __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
  805. {
  806. SET_BIT(RTCx->CR, RTC_CR_REFCKON);
  807. }
  808. /**
  809. * @brief Disable RTC_REFIN reference clock detection (50 or 60 Hz)
  810. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  811. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  812. * @rmtoll CR REFCKON LL_RTC_DisableRefClock
  813. * @param RTCx RTC Instance
  814. * @retval None
  815. */
  816. __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
  817. {
  818. CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
  819. }
  820. /**
  821. * @brief Set Asynchronous prescaler factor
  822. * @rmtoll PRER PREDIV_A LL_RTC_SetAsynchPrescaler
  823. * @param RTCx RTC Instance
  824. * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
  825. * @retval None
  826. */
  827. __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
  828. {
  829. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
  830. }
  831. /**
  832. * @brief Set Synchronous prescaler factor
  833. * @rmtoll PRER PREDIV_S LL_RTC_SetSynchPrescaler
  834. * @param RTCx RTC Instance
  835. * @param SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
  836. * @retval None
  837. */
  838. __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
  839. {
  840. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
  841. }
  842. /**
  843. * @brief Get Asynchronous prescaler factor
  844. * @rmtoll PRER PREDIV_A LL_RTC_GetAsynchPrescaler
  845. * @param RTCx RTC Instance
  846. * @retval Value between Min_Data = 0 and Max_Data = 0x7F
  847. */
  848. __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
  849. {
  850. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
  851. }
  852. /**
  853. * @brief Get Synchronous prescaler factor
  854. * @rmtoll PRER PREDIV_S LL_RTC_GetSynchPrescaler
  855. * @param RTCx RTC Instance
  856. * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
  857. */
  858. __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
  859. {
  860. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
  861. }
  862. /**
  863. * @brief Enable the write protection for RTC registers.
  864. * @rmtoll WPR KEY LL_RTC_EnableWriteProtection
  865. * @param RTCx RTC Instance
  866. * @retval None
  867. */
  868. __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
  869. {
  870. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
  871. }
  872. /**
  873. * @brief Disable the write protection for RTC registers.
  874. * @rmtoll WPR KEY LL_RTC_DisableWriteProtection
  875. * @param RTCx RTC Instance
  876. * @retval None
  877. */
  878. __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
  879. {
  880. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
  881. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
  882. }
  883. /**
  884. * @brief Enable RTC_OUT remap
  885. * @rmtoll OR OUT_RMP LL_RTC_EnableOutRemap
  886. * @param RTCx RTC Instance
  887. * @retval None
  888. */
  889. __STATIC_INLINE void LL_RTC_EnableOutRemap(RTC_TypeDef *RTCx)
  890. {
  891. SET_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  892. }
  893. /**
  894. * @brief Disable RTC_OUT remap
  895. * @rmtoll OR OUT_RMP LL_RTC_DisableOutRemap
  896. * @param RTCx RTC Instance
  897. * @retval None
  898. */
  899. __STATIC_INLINE void LL_RTC_DisableOutRemap(RTC_TypeDef *RTCx)
  900. {
  901. CLEAR_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  902. }
  903. /**
  904. * @}
  905. */
  906. /** @defgroup RTC_LL_EF_Time Time
  907. * @{
  908. */
  909. /**
  910. * @brief Set time format (AM/24-hour or PM notation)
  911. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  912. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  913. * @rmtoll TR PM LL_RTC_TIME_SetFormat
  914. * @param RTCx RTC Instance
  915. * @param TimeFormat This parameter can be one of the following values:
  916. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  917. * @arg @ref LL_RTC_TIME_FORMAT_PM
  918. * @retval None
  919. */
  920. __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  921. {
  922. MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
  923. }
  924. /**
  925. * @brief Get time format (AM or PM notation)
  926. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  927. * before reading this bit
  928. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  929. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  930. * @rmtoll TR PM LL_RTC_TIME_GetFormat
  931. * @param RTCx RTC Instance
  932. * @retval Returned value can be one of the following values:
  933. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  934. * @arg @ref LL_RTC_TIME_FORMAT_PM
  935. */
  936. __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
  937. {
  938. return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
  939. }
  940. /**
  941. * @brief Set Hours in BCD format
  942. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  943. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  944. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
  945. * @rmtoll TR HT LL_RTC_TIME_SetHour\n
  946. * TR HU LL_RTC_TIME_SetHour
  947. * @param RTCx RTC Instance
  948. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  949. * @retval None
  950. */
  951. __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  952. {
  953. MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
  954. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
  955. }
  956. /**
  957. * @brief Get Hours in BCD format
  958. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  959. * before reading this bit
  960. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  961. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  962. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
  963. * Binary format
  964. * @rmtoll TR HT LL_RTC_TIME_GetHour\n
  965. * TR HU LL_RTC_TIME_GetHour
  966. * @param RTCx RTC Instance
  967. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  968. */
  969. __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
  970. {
  971. return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
  972. }
  973. /**
  974. * @brief Set Minutes in BCD format
  975. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  976. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  977. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  978. * @rmtoll TR MNT LL_RTC_TIME_SetMinute\n
  979. * TR MNU LL_RTC_TIME_SetMinute
  980. * @param RTCx RTC Instance
  981. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  982. * @retval None
  983. */
  984. __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  985. {
  986. MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
  987. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
  988. }
  989. /**
  990. * @brief Get Minutes in BCD format
  991. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  992. * before reading this bit
  993. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  994. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  995. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
  996. * to Binary format
  997. * @rmtoll TR MNT LL_RTC_TIME_GetMinute\n
  998. * TR MNU LL_RTC_TIME_GetMinute
  999. * @param RTCx RTC Instance
  1000. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1001. */
  1002. __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
  1003. {
  1004. return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
  1005. }
  1006. /**
  1007. * @brief Set Seconds in BCD format
  1008. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1009. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1010. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1011. * @rmtoll TR ST LL_RTC_TIME_SetSecond\n
  1012. * TR SU LL_RTC_TIME_SetSecond
  1013. * @param RTCx RTC Instance
  1014. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1015. * @retval None
  1016. */
  1017. __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1018. {
  1019. MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
  1020. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
  1021. }
  1022. /**
  1023. * @brief Get Seconds in BCD format
  1024. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1025. * before reading this bit
  1026. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1027. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1028. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
  1029. * to Binary format
  1030. * @rmtoll TR ST LL_RTC_TIME_GetSecond\n
  1031. * TR SU LL_RTC_TIME_GetSecond
  1032. * @param RTCx RTC Instance
  1033. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1034. */
  1035. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
  1036. {
  1037. return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
  1038. }
  1039. /**
  1040. * @brief Set time (hour, minute and second) in BCD format
  1041. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1042. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1043. * @note TimeFormat and Hours should follow the same format
  1044. * @rmtoll TR PM LL_RTC_TIME_Config\n
  1045. * TR HT LL_RTC_TIME_Config\n
  1046. * TR HU LL_RTC_TIME_Config\n
  1047. * TR MNT LL_RTC_TIME_Config\n
  1048. * TR MNU LL_RTC_TIME_Config\n
  1049. * TR ST LL_RTC_TIME_Config\n
  1050. * TR SU LL_RTC_TIME_Config
  1051. * @param RTCx RTC Instance
  1052. * @param Format12_24 This parameter can be one of the following values:
  1053. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1054. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1055. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1056. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1057. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1058. * @retval None
  1059. */
  1060. __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1061. {
  1062. uint32_t temp;
  1063. temp = Format12_24 | \
  1064. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
  1065. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
  1066. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
  1067. MODIFY_REG(RTCx->TR, (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU), temp);
  1068. }
  1069. /**
  1070. * @brief Get time (hour, minute and second) in BCD format
  1071. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1072. * before reading this bit
  1073. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1074. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1075. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1076. * are available to get independently each parameter.
  1077. * @rmtoll TR HT LL_RTC_TIME_Get\n
  1078. * TR HU LL_RTC_TIME_Get\n
  1079. * TR MNT LL_RTC_TIME_Get\n
  1080. * TR MNU LL_RTC_TIME_Get\n
  1081. * TR ST LL_RTC_TIME_Get\n
  1082. * TR SU LL_RTC_TIME_Get
  1083. * @param RTCx RTC Instance
  1084. * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
  1085. */
  1086. __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
  1087. {
  1088. return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU)));
  1089. }
  1090. /**
  1091. * @brief Memorize whether the daylight saving time change has been performed
  1092. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1093. * @rmtoll CR BKP LL_RTC_TIME_EnableDayLightStore
  1094. * @param RTCx RTC Instance
  1095. * @retval None
  1096. */
  1097. __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
  1098. {
  1099. SET_BIT(RTCx->CR, RTC_CR_BKP);
  1100. }
  1101. /**
  1102. * @brief Disable memorization whether the daylight saving time change has been performed.
  1103. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1104. * @rmtoll CR BKP LL_RTC_TIME_DisableDayLightStore
  1105. * @param RTCx RTC Instance
  1106. * @retval None
  1107. */
  1108. __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
  1109. {
  1110. CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
  1111. }
  1112. /**
  1113. * @brief Check if RTC Day Light Saving stored operation has been enabled or not
  1114. * @rmtoll CR BKP LL_RTC_TIME_IsDayLightStoreEnabled
  1115. * @param RTCx RTC Instance
  1116. * @retval State of bit (1 or 0).
  1117. */
  1118. __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
  1119. {
  1120. return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
  1121. }
  1122. /**
  1123. * @brief Subtract 1 hour (winter time change)
  1124. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1125. * @rmtoll CR SUB1H LL_RTC_TIME_DecHour
  1126. * @param RTCx RTC Instance
  1127. * @retval None
  1128. */
  1129. __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
  1130. {
  1131. SET_BIT(RTCx->CR, RTC_CR_SUB1H);
  1132. }
  1133. /**
  1134. * @brief Add 1 hour (summer time change)
  1135. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1136. * @rmtoll CR ADD1H LL_RTC_TIME_IncHour
  1137. * @param RTCx RTC Instance
  1138. * @retval None
  1139. */
  1140. __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
  1141. {
  1142. SET_BIT(RTCx->CR, RTC_CR_ADD1H);
  1143. }
  1144. /**
  1145. * @brief Get subseconds value in the synchronous prescaler counter.
  1146. * @note You can use both SubSeconds value and SecondFraction (PREDIV_S through
  1147. * LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
  1148. * SubSeconds value in second fraction ratio with time unit following
  1149. * generic formula:
  1150. * ==> Seconds fraction ratio * time_unit =
  1151. * [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
  1152. * This conversion can be performed only if no shift operation is pending
  1153. * (ie. SHFP=0) when PREDIV_S >= SS.
  1154. * @rmtoll SSR SS LL_RTC_TIME_GetSubSecond
  1155. * @param RTCx RTC Instance
  1156. * @retval Subseconds value (number between 0 and 65535)
  1157. */
  1158. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
  1159. {
  1160. return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
  1161. }
  1162. /**
  1163. * @brief Synchronize to a remote clock with a high degree of precision.
  1164. * @note This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
  1165. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1166. * @note When REFCKON is set, firmware must not write to Shift control register.
  1167. * @rmtoll SHIFTR ADD1S LL_RTC_TIME_Synchronize\n
  1168. * SHIFTR SUBFS LL_RTC_TIME_Synchronize
  1169. * @param RTCx RTC Instance
  1170. * @param ShiftSecond This parameter can be one of the following values:
  1171. * @arg @ref LL_RTC_SHIFT_SECOND_DELAY
  1172. * @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
  1173. * @param Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
  1174. * @retval None
  1175. */
  1176. __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
  1177. {
  1178. WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
  1179. }
  1180. /**
  1181. * @}
  1182. */
  1183. /** @defgroup RTC_LL_EF_Date Date
  1184. * @{
  1185. */
  1186. /**
  1187. * @brief Set Year in BCD format
  1188. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
  1189. * @rmtoll DR YT LL_RTC_DATE_SetYear\n
  1190. * DR YU LL_RTC_DATE_SetYear
  1191. * @param RTCx RTC Instance
  1192. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1193. * @retval None
  1194. */
  1195. __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
  1196. {
  1197. MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
  1198. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
  1199. }
  1200. /**
  1201. * @brief Get Year in BCD format
  1202. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1203. * before reading this bit
  1204. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
  1205. * @rmtoll DR YT LL_RTC_DATE_GetYear\n
  1206. * DR YU LL_RTC_DATE_GetYear
  1207. * @param RTCx RTC Instance
  1208. * @retval Value between Min_Data=0x00 and Max_Data=0x99
  1209. */
  1210. __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
  1211. {
  1212. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
  1213. }
  1214. /**
  1215. * @brief Set Week day
  1216. * @rmtoll DR WDU LL_RTC_DATE_SetWeekDay
  1217. * @param RTCx RTC Instance
  1218. * @param WeekDay This parameter can be one of the following values:
  1219. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1220. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1221. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1222. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1223. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1224. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1225. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1226. * @retval None
  1227. */
  1228. __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1229. {
  1230. MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
  1231. }
  1232. /**
  1233. * @brief Get Week day
  1234. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1235. * before reading this bit
  1236. * @rmtoll DR WDU LL_RTC_DATE_GetWeekDay
  1237. * @param RTCx RTC Instance
  1238. * @retval Returned value can be one of the following values:
  1239. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1240. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1241. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1242. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1243. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1244. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1245. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1246. */
  1247. __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
  1248. {
  1249. return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
  1250. }
  1251. /**
  1252. * @brief Set Month in BCD format
  1253. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
  1254. * @rmtoll DR MT LL_RTC_DATE_SetMonth\n
  1255. * DR MU LL_RTC_DATE_SetMonth
  1256. * @param RTCx RTC Instance
  1257. * @param Month This parameter can be one of the following values:
  1258. * @arg @ref LL_RTC_MONTH_JANUARY
  1259. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1260. * @arg @ref LL_RTC_MONTH_MARCH
  1261. * @arg @ref LL_RTC_MONTH_APRIL
  1262. * @arg @ref LL_RTC_MONTH_MAY
  1263. * @arg @ref LL_RTC_MONTH_JUNE
  1264. * @arg @ref LL_RTC_MONTH_JULY
  1265. * @arg @ref LL_RTC_MONTH_AUGUST
  1266. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1267. * @arg @ref LL_RTC_MONTH_OCTOBER
  1268. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1269. * @arg @ref LL_RTC_MONTH_DECEMBER
  1270. * @retval None
  1271. */
  1272. __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
  1273. {
  1274. MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
  1275. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
  1276. }
  1277. /**
  1278. * @brief Get Month in BCD format
  1279. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1280. * before reading this bit
  1281. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  1282. * @rmtoll DR MT LL_RTC_DATE_GetMonth\n
  1283. * DR MU LL_RTC_DATE_GetMonth
  1284. * @param RTCx RTC Instance
  1285. * @retval Returned value can be one of the following values:
  1286. * @arg @ref LL_RTC_MONTH_JANUARY
  1287. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1288. * @arg @ref LL_RTC_MONTH_MARCH
  1289. * @arg @ref LL_RTC_MONTH_APRIL
  1290. * @arg @ref LL_RTC_MONTH_MAY
  1291. * @arg @ref LL_RTC_MONTH_JUNE
  1292. * @arg @ref LL_RTC_MONTH_JULY
  1293. * @arg @ref LL_RTC_MONTH_AUGUST
  1294. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1295. * @arg @ref LL_RTC_MONTH_OCTOBER
  1296. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1297. * @arg @ref LL_RTC_MONTH_DECEMBER
  1298. */
  1299. __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
  1300. {
  1301. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
  1302. }
  1303. /**
  1304. * @brief Set Day in BCD format
  1305. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1306. * @rmtoll DR DT LL_RTC_DATE_SetDay\n
  1307. * DR DU LL_RTC_DATE_SetDay
  1308. * @param RTCx RTC Instance
  1309. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1310. * @retval None
  1311. */
  1312. __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1313. {
  1314. MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
  1315. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
  1316. }
  1317. /**
  1318. * @brief Get Day in BCD format
  1319. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1320. * before reading this bit
  1321. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1322. * @rmtoll DR DT LL_RTC_DATE_GetDay\n
  1323. * DR DU LL_RTC_DATE_GetDay
  1324. * @param RTCx RTC Instance
  1325. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1326. */
  1327. __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
  1328. {
  1329. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
  1330. }
  1331. /**
  1332. * @brief Set date (WeekDay, Day, Month and Year) in BCD format
  1333. * @rmtoll DR WDU LL_RTC_DATE_Config\n
  1334. * DR MT LL_RTC_DATE_Config\n
  1335. * DR MU LL_RTC_DATE_Config\n
  1336. * DR DT LL_RTC_DATE_Config\n
  1337. * DR DU LL_RTC_DATE_Config\n
  1338. * DR YT LL_RTC_DATE_Config\n
  1339. * DR YU LL_RTC_DATE_Config
  1340. * @param RTCx RTC Instance
  1341. * @param WeekDay This parameter can be one of the following values:
  1342. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1343. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1344. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1345. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1346. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1347. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1348. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1349. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1350. * @param Month This parameter can be one of the following values:
  1351. * @arg @ref LL_RTC_MONTH_JANUARY
  1352. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1353. * @arg @ref LL_RTC_MONTH_MARCH
  1354. * @arg @ref LL_RTC_MONTH_APRIL
  1355. * @arg @ref LL_RTC_MONTH_MAY
  1356. * @arg @ref LL_RTC_MONTH_JUNE
  1357. * @arg @ref LL_RTC_MONTH_JULY
  1358. * @arg @ref LL_RTC_MONTH_AUGUST
  1359. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1360. * @arg @ref LL_RTC_MONTH_OCTOBER
  1361. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1362. * @arg @ref LL_RTC_MONTH_DECEMBER
  1363. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1364. * @retval None
  1365. */
  1366. __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
  1367. {
  1368. uint32_t temp;
  1369. temp = ( WeekDay << RTC_DR_WDU_Pos) | \
  1370. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)) | \
  1371. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
  1372. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
  1373. MODIFY_REG(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU), temp);
  1374. }
  1375. /**
  1376. * @brief Get date (WeekDay, Day, Month and Year) in BCD format
  1377. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1378. * before reading this bit
  1379. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
  1380. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  1381. * @rmtoll DR WDU LL_RTC_DATE_Get\n
  1382. * DR MT LL_RTC_DATE_Get\n
  1383. * DR MU LL_RTC_DATE_Get\n
  1384. * DR DT LL_RTC_DATE_Get\n
  1385. * DR DU LL_RTC_DATE_Get\n
  1386. * DR YT LL_RTC_DATE_Get\n
  1387. * DR YU LL_RTC_DATE_Get
  1388. * @param RTCx RTC Instance
  1389. * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
  1390. */
  1391. __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
  1392. {
  1393. uint32_t temp;
  1394. temp = READ_BIT(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU));
  1395. return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
  1396. (((temp & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos) << RTC_OFFSET_DAY) | \
  1397. (((temp & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos) << RTC_OFFSET_MONTH) | \
  1398. ((temp & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos));
  1399. }
  1400. /**
  1401. * @}
  1402. */
  1403. /** @defgroup RTC_LL_EF_ALARMA ALARMA
  1404. * @{
  1405. */
  1406. /**
  1407. * @brief Enable Alarm A
  1408. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1409. * @rmtoll CR ALRAE LL_RTC_ALMA_Enable
  1410. * @param RTCx RTC Instance
  1411. * @retval None
  1412. */
  1413. __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
  1414. {
  1415. SET_BIT(RTCx->CR, RTC_CR_ALRAE);
  1416. }
  1417. /**
  1418. * @brief Disable Alarm A
  1419. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1420. * @rmtoll CR ALRAE LL_RTC_ALMA_Disable
  1421. * @param RTCx RTC Instance
  1422. * @retval None
  1423. */
  1424. __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
  1425. {
  1426. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
  1427. }
  1428. /**
  1429. * @brief Specify the Alarm A masks.
  1430. * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_SetMask\n
  1431. * ALRMAR MSK3 LL_RTC_ALMA_SetMask\n
  1432. * ALRMAR MSK2 LL_RTC_ALMA_SetMask\n
  1433. * ALRMAR MSK1 LL_RTC_ALMA_SetMask
  1434. * @param RTCx RTC Instance
  1435. * @param Mask This parameter can be a combination of the following values:
  1436. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1437. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1438. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1439. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1440. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1441. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1442. * @retval None
  1443. */
  1444. __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1445. {
  1446. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
  1447. }
  1448. /**
  1449. * @brief Get the Alarm A masks.
  1450. * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_GetMask\n
  1451. * ALRMAR MSK3 LL_RTC_ALMA_GetMask\n
  1452. * ALRMAR MSK2 LL_RTC_ALMA_GetMask\n
  1453. * ALRMAR MSK1 LL_RTC_ALMA_GetMask
  1454. * @param RTCx RTC Instance
  1455. * @retval Returned value can be can be a combination of the following values:
  1456. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1457. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1458. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1459. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1460. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1461. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1462. */
  1463. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
  1464. {
  1465. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
  1466. }
  1467. /**
  1468. * @brief Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  1469. * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_EnableWeekday
  1470. * @param RTCx RTC Instance
  1471. * @retval None
  1472. */
  1473. __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
  1474. {
  1475. SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1476. }
  1477. /**
  1478. * @brief Disable AlarmA Week day selection (DU[3:0] represents the date )
  1479. * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_DisableWeekday
  1480. * @param RTCx RTC Instance
  1481. * @retval None
  1482. */
  1483. __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
  1484. {
  1485. CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1486. }
  1487. /**
  1488. * @brief Set ALARM A Day in BCD format
  1489. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1490. * @rmtoll ALRMAR DT LL_RTC_ALMA_SetDay\n
  1491. * ALRMAR DU LL_RTC_ALMA_SetDay
  1492. * @param RTCx RTC Instance
  1493. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1494. * @retval None
  1495. */
  1496. __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1497. {
  1498. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
  1499. (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
  1500. }
  1501. /**
  1502. * @brief Get ALARM A Day in BCD format
  1503. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1504. * @rmtoll ALRMAR DT LL_RTC_ALMA_GetDay\n
  1505. * ALRMAR DU LL_RTC_ALMA_GetDay
  1506. * @param RTCx RTC Instance
  1507. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1508. */
  1509. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
  1510. {
  1511. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
  1512. }
  1513. /**
  1514. * @brief Set ALARM A Weekday
  1515. * @rmtoll ALRMAR DU LL_RTC_ALMA_SetWeekDay
  1516. * @param RTCx RTC Instance
  1517. * @param WeekDay This parameter can be one of the following values:
  1518. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1519. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1520. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1521. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1522. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1523. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1524. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1525. * @retval None
  1526. */
  1527. __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1528. {
  1529. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
  1530. }
  1531. /**
  1532. * @brief Get ALARM A Weekday
  1533. * @rmtoll ALRMAR DU LL_RTC_ALMA_GetWeekDay
  1534. * @param RTCx RTC Instance
  1535. * @retval Returned value can be one of the following values:
  1536. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1537. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1538. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1539. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1540. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1541. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1542. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1543. */
  1544. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
  1545. {
  1546. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
  1547. }
  1548. /**
  1549. * @brief Set Alarm A time format (AM/24-hour or PM notation)
  1550. * @rmtoll ALRMAR PM LL_RTC_ALMA_SetTimeFormat
  1551. * @param RTCx RTC Instance
  1552. * @param TimeFormat This parameter can be one of the following values:
  1553. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1554. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1555. * @retval None
  1556. */
  1557. __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1558. {
  1559. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
  1560. }
  1561. /**
  1562. * @brief Get Alarm A time format (AM or PM notation)
  1563. * @rmtoll ALRMAR PM LL_RTC_ALMA_GetTimeFormat
  1564. * @param RTCx RTC Instance
  1565. * @retval Returned value can be one of the following values:
  1566. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1567. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1568. */
  1569. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
  1570. {
  1571. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
  1572. }
  1573. /**
  1574. * @brief Set ALARM A Hours in BCD format
  1575. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  1576. * @rmtoll ALRMAR HT LL_RTC_ALMA_SetHour\n
  1577. * ALRMAR HU LL_RTC_ALMA_SetHour
  1578. * @param RTCx RTC Instance
  1579. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1580. * @retval None
  1581. */
  1582. __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1583. {
  1584. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
  1585. (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
  1586. }
  1587. /**
  1588. * @brief Get ALARM A Hours in BCD format
  1589. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  1590. * @rmtoll ALRMAR HT LL_RTC_ALMA_GetHour\n
  1591. * ALRMAR HU LL_RTC_ALMA_GetHour
  1592. * @param RTCx RTC Instance
  1593. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1594. */
  1595. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
  1596. {
  1597. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
  1598. }
  1599. /**
  1600. * @brief Set ALARM A Minutes in BCD format
  1601. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1602. * @rmtoll ALRMAR MNT LL_RTC_ALMA_SetMinute\n
  1603. * ALRMAR MNU LL_RTC_ALMA_SetMinute
  1604. * @param RTCx RTC Instance
  1605. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1606. * @retval None
  1607. */
  1608. __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1609. {
  1610. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
  1611. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
  1612. }
  1613. /**
  1614. * @brief Get ALARM A Minutes in BCD format
  1615. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  1616. * @rmtoll ALRMAR MNT LL_RTC_ALMA_GetMinute\n
  1617. * ALRMAR MNU LL_RTC_ALMA_GetMinute
  1618. * @param RTCx RTC Instance
  1619. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1620. */
  1621. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
  1622. {
  1623. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
  1624. }
  1625. /**
  1626. * @brief Set ALARM A Seconds in BCD format
  1627. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1628. * @rmtoll ALRMAR ST LL_RTC_ALMA_SetSecond\n
  1629. * ALRMAR SU LL_RTC_ALMA_SetSecond
  1630. * @param RTCx RTC Instance
  1631. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1632. * @retval None
  1633. */
  1634. __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1635. {
  1636. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
  1637. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
  1638. }
  1639. /**
  1640. * @brief Get ALARM A Seconds in BCD format
  1641. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  1642. * @rmtoll ALRMAR ST LL_RTC_ALMA_GetSecond\n
  1643. * ALRMAR SU LL_RTC_ALMA_GetSecond
  1644. * @param RTCx RTC Instance
  1645. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1646. */
  1647. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
  1648. {
  1649. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
  1650. }
  1651. /**
  1652. * @brief Set Alarm A Time (hour, minute and second) in BCD format
  1653. * @rmtoll ALRMAR PM LL_RTC_ALMA_ConfigTime\n
  1654. * ALRMAR HT LL_RTC_ALMA_ConfigTime\n
  1655. * ALRMAR HU LL_RTC_ALMA_ConfigTime\n
  1656. * ALRMAR MNT LL_RTC_ALMA_ConfigTime\n
  1657. * ALRMAR MNU LL_RTC_ALMA_ConfigTime\n
  1658. * ALRMAR ST LL_RTC_ALMA_ConfigTime\n
  1659. * ALRMAR SU LL_RTC_ALMA_ConfigTime
  1660. * @param RTCx RTC Instance
  1661. * @param Format12_24 This parameter can be one of the following values:
  1662. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1663. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1664. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1665. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1666. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1667. * @retval None
  1668. */
  1669. __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1670. {
  1671. uint32_t temp;
  1672. temp = Format12_24 | \
  1673. (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)) | \
  1674. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
  1675. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
  1676. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM | RTC_ALRMAR_HT | RTC_ALRMAR_HU | RTC_ALRMAR_MNT | RTC_ALRMAR_MNU | RTC_ALRMAR_ST | RTC_ALRMAR_SU, temp);
  1677. }
  1678. /**
  1679. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  1680. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1681. * are available to get independently each parameter.
  1682. * @rmtoll ALRMAR HT LL_RTC_ALMA_GetTime\n
  1683. * ALRMAR HU LL_RTC_ALMA_GetTime\n
  1684. * ALRMAR MNT LL_RTC_ALMA_GetTime\n
  1685. * ALRMAR MNU LL_RTC_ALMA_GetTime\n
  1686. * ALRMAR ST LL_RTC_ALMA_GetTime\n
  1687. * ALRMAR SU LL_RTC_ALMA_GetTime
  1688. * @param RTCx RTC Instance
  1689. * @retval Combination of hours, minutes and seconds.
  1690. */
  1691. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
  1692. {
  1693. return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
  1694. }
  1695. /**
  1696. * @brief Mask the most-significant bits of the subseconds field starting from
  1697. * the bit specified in parameter Mask
  1698. * @note This register can be written only when ALRAE is reset in RTC_CR register,
  1699. * or in initialization mode.
  1700. * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_SetSubSecondMask
  1701. * @param RTCx RTC Instance
  1702. * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
  1703. * @retval None
  1704. */
  1705. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1706. {
  1707. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
  1708. }
  1709. /**
  1710. * @brief Get Alarm A subseconds mask
  1711. * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_GetSubSecondMask
  1712. * @param RTCx RTC Instance
  1713. * @retval Value between Min_Data=0x00 and Max_Data=0xF
  1714. */
  1715. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
  1716. {
  1717. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
  1718. }
  1719. /**
  1720. * @brief Set Alarm A subseconds value
  1721. * @rmtoll ALRMASSR SS LL_RTC_ALMA_SetSubSecond
  1722. * @param RTCx RTC Instance
  1723. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  1724. * @retval None
  1725. */
  1726. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  1727. {
  1728. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
  1729. }
  1730. /**
  1731. * @brief Get Alarm A subseconds value
  1732. * @rmtoll ALRMASSR SS LL_RTC_ALMA_GetSubSecond
  1733. * @param RTCx RTC Instance
  1734. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  1735. */
  1736. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
  1737. {
  1738. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
  1739. }
  1740. /**
  1741. * @}
  1742. */
  1743. /** @defgroup RTC_LL_EF_ALARMB ALARMB
  1744. * @{
  1745. */
  1746. /**
  1747. * @brief Enable Alarm B
  1748. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1749. * @rmtoll CR ALRBE LL_RTC_ALMB_Enable
  1750. * @param RTCx RTC Instance
  1751. * @retval None
  1752. */
  1753. __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
  1754. {
  1755. SET_BIT(RTCx->CR, RTC_CR_ALRBE);
  1756. }
  1757. /**
  1758. * @brief Disable Alarm B
  1759. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1760. * @rmtoll CR ALRBE LL_RTC_ALMB_Disable
  1761. * @param RTCx RTC Instance
  1762. * @retval None
  1763. */
  1764. __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
  1765. {
  1766. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
  1767. }
  1768. /**
  1769. * @brief Specify the Alarm B masks.
  1770. * @rmtoll ALRMBR MSK4 LL_RTC_ALMB_SetMask\n
  1771. * ALRMBR MSK3 LL_RTC_ALMB_SetMask\n
  1772. * ALRMBR MSK2 LL_RTC_ALMB_SetMask\n
  1773. * ALRMBR MSK1 LL_RTC_ALMB_SetMask
  1774. * @param RTCx RTC Instance
  1775. * @param Mask This parameter can be a combination of the following values:
  1776. * @arg @ref LL_RTC_ALMB_MASK_NONE
  1777. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  1778. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  1779. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  1780. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  1781. * @arg @ref LL_RTC_ALMB_MASK_ALL
  1782. * @retval None
  1783. */
  1784. __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1785. {
  1786. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
  1787. }
  1788. /**
  1789. * @brief Get the Alarm B masks.
  1790. * @rmtoll ALRMBR MSK4 LL_RTC_ALMB_GetMask\n
  1791. * ALRMBR MSK3 LL_RTC_ALMB_GetMask\n
  1792. * ALRMBR MSK2 LL_RTC_ALMB_GetMask\n
  1793. * ALRMBR MSK1 LL_RTC_ALMB_GetMask
  1794. * @param RTCx RTC Instance
  1795. * @retval Returned value can be can be a combination of the following values:
  1796. * @arg @ref LL_RTC_ALMB_MASK_NONE
  1797. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  1798. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  1799. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  1800. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  1801. * @arg @ref LL_RTC_ALMB_MASK_ALL
  1802. */
  1803. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
  1804. {
  1805. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
  1806. }
  1807. /**
  1808. * @brief Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  1809. * @rmtoll ALRMBR WDSEL LL_RTC_ALMB_EnableWeekday
  1810. * @param RTCx RTC Instance
  1811. * @retval None
  1812. */
  1813. __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
  1814. {
  1815. SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  1816. }
  1817. /**
  1818. * @brief Disable AlarmB Week day selection (DU[3:0] represents the date )
  1819. * @rmtoll ALRMBR WDSEL LL_RTC_ALMB_DisableWeekday
  1820. * @param RTCx RTC Instance
  1821. * @retval None
  1822. */
  1823. __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
  1824. {
  1825. CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  1826. }
  1827. /**
  1828. * @brief Set ALARM B Day in BCD format
  1829. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1830. * @rmtoll ALRMBR DT LL_RTC_ALMB_SetDay\n
  1831. * ALRMBR DU LL_RTC_ALMB_SetDay
  1832. * @param RTCx RTC Instance
  1833. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1834. * @retval None
  1835. */
  1836. __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1837. {
  1838. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
  1839. (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
  1840. }
  1841. /**
  1842. * @brief Get ALARM B Day in BCD format
  1843. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1844. * @rmtoll ALRMBR DT LL_RTC_ALMB_GetDay\n
  1845. * ALRMBR DU LL_RTC_ALMB_GetDay
  1846. * @param RTCx RTC Instance
  1847. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1848. */
  1849. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
  1850. {
  1851. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
  1852. }
  1853. /**
  1854. * @brief Set ALARM B Weekday
  1855. * @rmtoll ALRMBR DU LL_RTC_ALMB_SetWeekDay
  1856. * @param RTCx RTC Instance
  1857. * @param WeekDay This parameter can be one of the following values:
  1858. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1859. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1860. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1861. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1862. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1863. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1864. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1865. * @retval None
  1866. */
  1867. __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1868. {
  1869. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
  1870. }
  1871. /**
  1872. * @brief Get ALARM B Weekday
  1873. * @rmtoll ALRMBR DU LL_RTC_ALMB_GetWeekDay
  1874. * @param RTCx RTC Instance
  1875. * @retval Returned value can be one of the following values:
  1876. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1877. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1878. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1879. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1880. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1881. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1882. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1883. */
  1884. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
  1885. {
  1886. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
  1887. }
  1888. /**
  1889. * @brief Set ALARM B time format (AM/24-hour or PM notation)
  1890. * @rmtoll ALRMBR PM LL_RTC_ALMB_SetTimeFormat
  1891. * @param RTCx RTC Instance
  1892. * @param TimeFormat This parameter can be one of the following values:
  1893. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  1894. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  1895. * @retval None
  1896. */
  1897. __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1898. {
  1899. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
  1900. }
  1901. /**
  1902. * @brief Get ALARM B time format (AM or PM notation)
  1903. * @rmtoll ALRMBR PM LL_RTC_ALMB_GetTimeFormat
  1904. * @param RTCx RTC Instance
  1905. * @retval Returned value can be one of the following values:
  1906. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  1907. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  1908. */
  1909. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
  1910. {
  1911. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
  1912. }
  1913. /**
  1914. * @brief Set ALARM B Hours in BCD format
  1915. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  1916. * @rmtoll ALRMBR HT LL_RTC_ALMB_SetHour\n
  1917. * ALRMBR HU LL_RTC_ALMB_SetHour
  1918. * @param RTCx RTC Instance
  1919. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1920. * @retval None
  1921. */
  1922. __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1923. {
  1924. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
  1925. (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
  1926. }
  1927. /**
  1928. * @brief Get ALARM B Hours in BCD format
  1929. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  1930. * @rmtoll ALRMBR HT LL_RTC_ALMB_GetHour\n
  1931. * ALRMBR HU LL_RTC_ALMB_GetHour
  1932. * @param RTCx RTC Instance
  1933. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1934. */
  1935. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
  1936. {
  1937. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
  1938. }
  1939. /**
  1940. * @brief Set ALARM B Minutes in BCD format
  1941. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1942. * @rmtoll ALRMBR MNT LL_RTC_ALMB_SetMinute\n
  1943. * ALRMBR MNU LL_RTC_ALMB_SetMinute
  1944. * @param RTCx RTC Instance
  1945. * @param Minutes between Min_Data=0x00 and Max_Data=0x59
  1946. * @retval None
  1947. */
  1948. __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1949. {
  1950. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
  1951. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
  1952. }
  1953. /**
  1954. * @brief Get ALARM B Minutes in BCD format
  1955. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  1956. * @rmtoll ALRMBR MNT LL_RTC_ALMB_GetMinute\n
  1957. * ALRMBR MNU LL_RTC_ALMB_GetMinute
  1958. * @param RTCx RTC Instance
  1959. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1960. */
  1961. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
  1962. {
  1963. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
  1964. }
  1965. /**
  1966. * @brief Set ALARM B Seconds in BCD format
  1967. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1968. * @rmtoll ALRMBR ST LL_RTC_ALMB_SetSecond\n
  1969. * ALRMBR SU LL_RTC_ALMB_SetSecond
  1970. * @param RTCx RTC Instance
  1971. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1972. * @retval None
  1973. */
  1974. __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1975. {
  1976. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
  1977. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
  1978. }
  1979. /**
  1980. * @brief Get ALARM B Seconds in BCD format
  1981. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  1982. * @rmtoll ALRMBR ST LL_RTC_ALMB_GetSecond\n
  1983. * ALRMBR SU LL_RTC_ALMB_GetSecond
  1984. * @param RTCx RTC Instance
  1985. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1986. */
  1987. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
  1988. {
  1989. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
  1990. }
  1991. /**
  1992. * @brief Set Alarm B Time (hour, minute and second) in BCD format
  1993. * @rmtoll ALRMBR PM LL_RTC_ALMB_ConfigTime\n
  1994. * ALRMBR HT LL_RTC_ALMB_ConfigTime\n
  1995. * ALRMBR HU LL_RTC_ALMB_ConfigTime\n
  1996. * ALRMBR MNT LL_RTC_ALMB_ConfigTime\n
  1997. * ALRMBR MNU LL_RTC_ALMB_ConfigTime\n
  1998. * ALRMBR ST LL_RTC_ALMB_ConfigTime\n
  1999. * ALRMBR SU LL_RTC_ALMB_ConfigTime
  2000. * @param RTCx RTC Instance
  2001. * @param Format12_24 This parameter can be one of the following values:
  2002. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2003. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2004. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2005. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2006. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2007. * @retval None
  2008. */
  2009. __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2010. {
  2011. uint32_t temp;
  2012. temp = Format12_24 | \
  2013. (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)) | \
  2014. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
  2015. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
  2016. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM | RTC_ALRMBR_HT | RTC_ALRMBR_HU | RTC_ALRMBR_MNT | RTC_ALRMBR_MNU | RTC_ALRMBR_ST | RTC_ALRMBR_SU, temp);
  2017. }
  2018. /**
  2019. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  2020. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2021. * are available to get independently each parameter.
  2022. * @rmtoll ALRMBR HT LL_RTC_ALMB_GetTime\n
  2023. * ALRMBR HU LL_RTC_ALMB_GetTime\n
  2024. * ALRMBR MNT LL_RTC_ALMB_GetTime\n
  2025. * ALRMBR MNU LL_RTC_ALMB_GetTime\n
  2026. * ALRMBR ST LL_RTC_ALMB_GetTime\n
  2027. * ALRMBR SU LL_RTC_ALMB_GetTime
  2028. * @param RTCx RTC Instance
  2029. * @retval Combination of hours, minutes and seconds.
  2030. */
  2031. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
  2032. {
  2033. return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
  2034. }
  2035. /**
  2036. * @brief Mask the most-significant bits of the subseconds field starting from
  2037. * the bit specified in parameter Mask
  2038. * @note This register can be written only when ALRBE is reset in RTC_CR register,
  2039. * or in initialization mode.
  2040. * @rmtoll ALRMBSSR MASKSS LL_RTC_ALMB_SetSubSecondMask
  2041. * @param RTCx RTC Instance
  2042. * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
  2043. * @retval None
  2044. */
  2045. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2046. {
  2047. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
  2048. }
  2049. /**
  2050. * @brief Get Alarm B subseconds mask
  2051. * @rmtoll ALRMBSSR MASKSS LL_RTC_ALMB_GetSubSecondMask
  2052. * @param RTCx RTC Instance
  2053. * @retval Value between Min_Data=0x00 and Max_Data=0xF
  2054. */
  2055. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
  2056. {
  2057. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS) >> RTC_ALRMBSSR_MASKSS_Pos);
  2058. }
  2059. /**
  2060. * @brief Set Alarm B subseconds value
  2061. * @rmtoll ALRMBSSR SS LL_RTC_ALMB_SetSubSecond
  2062. * @param RTCx RTC Instance
  2063. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2064. * @retval None
  2065. */
  2066. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2067. {
  2068. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
  2069. }
  2070. /**
  2071. * @brief Get Alarm B subseconds value
  2072. * @rmtoll ALRMBSSR SS LL_RTC_ALMB_GetSubSecond
  2073. * @param RTCx RTC Instance
  2074. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2075. */
  2076. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
  2077. {
  2078. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
  2079. }
  2080. /**
  2081. * @}
  2082. */
  2083. /** @defgroup RTC_LL_EF_Timestamp Timestamp
  2084. * @{
  2085. */
  2086. /**
  2087. * @brief Enable Timestamp
  2088. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2089. * @rmtoll CR TSE LL_RTC_TS_Enable
  2090. * @param RTCx RTC Instance
  2091. * @retval None
  2092. */
  2093. __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
  2094. {
  2095. SET_BIT(RTCx->CR, RTC_CR_TSE);
  2096. }
  2097. /**
  2098. * @brief Disable Timestamp
  2099. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2100. * @rmtoll CR TSE LL_RTC_TS_Disable
  2101. * @param RTCx RTC Instance
  2102. * @retval None
  2103. */
  2104. __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
  2105. {
  2106. CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
  2107. }
  2108. /**
  2109. * @brief Set Time-stamp event active edge
  2110. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2111. * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
  2112. * @rmtoll CR TSEDGE LL_RTC_TS_SetActiveEdge
  2113. * @param RTCx RTC Instance
  2114. * @param Edge This parameter can be one of the following values:
  2115. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2116. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2117. * @retval None
  2118. */
  2119. __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
  2120. {
  2121. MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
  2122. }
  2123. /**
  2124. * @brief Get Time-stamp event active edge
  2125. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2126. * @rmtoll CR TSEDGE LL_RTC_TS_GetActiveEdge
  2127. * @param RTCx RTC Instance
  2128. * @retval Returned value can be one of the following values:
  2129. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2130. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2131. */
  2132. __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
  2133. {
  2134. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
  2135. }
  2136. /**
  2137. * @brief Get Timestamp AM/PM notation (AM or 24-hour format)
  2138. * @rmtoll TSTR PM LL_RTC_TS_GetTimeFormat
  2139. * @param RTCx RTC Instance
  2140. * @retval Returned value can be one of the following values:
  2141. * @arg @ref LL_RTC_TS_TIME_FORMAT_AM
  2142. * @arg @ref LL_RTC_TS_TIME_FORMAT_PM
  2143. */
  2144. __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
  2145. {
  2146. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
  2147. }
  2148. /**
  2149. * @brief Get Timestamp Hours in BCD format
  2150. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2151. * @rmtoll TSTR HT LL_RTC_TS_GetHour\n
  2152. * TSTR HU LL_RTC_TS_GetHour
  2153. * @param RTCx RTC Instance
  2154. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2155. */
  2156. __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
  2157. {
  2158. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
  2159. }
  2160. /**
  2161. * @brief Get Timestamp Minutes in BCD format
  2162. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2163. * @rmtoll TSTR MNT LL_RTC_TS_GetMinute\n
  2164. * TSTR MNU LL_RTC_TS_GetMinute
  2165. * @param RTCx RTC Instance
  2166. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2167. */
  2168. __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
  2169. {
  2170. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
  2171. }
  2172. /**
  2173. * @brief Get Timestamp Seconds in BCD format
  2174. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2175. * @rmtoll TSTR ST LL_RTC_TS_GetSecond\n
  2176. * TSTR SU LL_RTC_TS_GetSecond
  2177. * @param RTCx RTC Instance
  2178. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2179. */
  2180. __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
  2181. {
  2182. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
  2183. }
  2184. /**
  2185. * @brief Get Timestamp time (hour, minute and second) in BCD format
  2186. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2187. * are available to get independently each parameter.
  2188. * @rmtoll TSTR HT LL_RTC_TS_GetTime\n
  2189. * TSTR HU LL_RTC_TS_GetTime\n
  2190. * TSTR MNT LL_RTC_TS_GetTime\n
  2191. * TSTR MNU LL_RTC_TS_GetTime\n
  2192. * TSTR ST LL_RTC_TS_GetTime\n
  2193. * TSTR SU LL_RTC_TS_GetTime
  2194. * @param RTCx RTC Instance
  2195. * @retval Combination of hours, minutes and seconds.
  2196. */
  2197. __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
  2198. {
  2199. return (uint32_t)(READ_BIT(RTCx->TSTR,
  2200. RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
  2201. }
  2202. /**
  2203. * @brief Get Timestamp Week day
  2204. * @rmtoll TSDR WDU LL_RTC_TS_GetWeekDay
  2205. * @param RTCx RTC Instance
  2206. * @retval Returned value can be one of the following values:
  2207. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2208. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2209. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2210. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2211. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2212. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2213. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2214. */
  2215. __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
  2216. {
  2217. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
  2218. }
  2219. /**
  2220. * @brief Get Timestamp Month in BCD format
  2221. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  2222. * @rmtoll TSDR MT LL_RTC_TS_GetMonth\n
  2223. * TSDR MU LL_RTC_TS_GetMonth
  2224. * @param RTCx RTC Instance
  2225. * @retval Returned value can be one of the following values:
  2226. * @arg @ref LL_RTC_MONTH_JANUARY
  2227. * @arg @ref LL_RTC_MONTH_FEBRUARY
  2228. * @arg @ref LL_RTC_MONTH_MARCH
  2229. * @arg @ref LL_RTC_MONTH_APRIL
  2230. * @arg @ref LL_RTC_MONTH_MAY
  2231. * @arg @ref LL_RTC_MONTH_JUNE
  2232. * @arg @ref LL_RTC_MONTH_JULY
  2233. * @arg @ref LL_RTC_MONTH_AUGUST
  2234. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  2235. * @arg @ref LL_RTC_MONTH_OCTOBER
  2236. * @arg @ref LL_RTC_MONTH_NOVEMBER
  2237. * @arg @ref LL_RTC_MONTH_DECEMBER
  2238. */
  2239. __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
  2240. {
  2241. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
  2242. }
  2243. /**
  2244. * @brief Get Timestamp Day in BCD format
  2245. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2246. * @rmtoll TSDR DT LL_RTC_TS_GetDay\n
  2247. * TSDR DU LL_RTC_TS_GetDay
  2248. * @param RTCx RTC Instance
  2249. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2250. */
  2251. __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
  2252. {
  2253. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
  2254. }
  2255. /**
  2256. * @brief Get Timestamp date (WeekDay, Day and Month) in BCD format
  2257. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
  2258. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  2259. * @rmtoll TSDR WDU LL_RTC_TS_GetDate\n
  2260. * TSDR MT LL_RTC_TS_GetDate\n
  2261. * TSDR MU LL_RTC_TS_GetDate\n
  2262. * TSDR DT LL_RTC_TS_GetDate\n
  2263. * TSDR DU LL_RTC_TS_GetDate
  2264. * @param RTCx RTC Instance
  2265. * @retval Combination of Weekday, Day and Month
  2266. */
  2267. __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
  2268. {
  2269. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
  2270. }
  2271. /**
  2272. * @brief Get time-stamp subseconds value
  2273. * @rmtoll TSSSR SS LL_RTC_TS_GetSubSecond
  2274. * @param RTCx RTC Instance
  2275. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2276. */
  2277. __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
  2278. {
  2279. return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
  2280. }
  2281. #if defined(RTC_TAMPCR_TAMPTS)
  2282. /**
  2283. * @brief Activate timestamp on tamper detection event
  2284. * @rmtoll TAMPCR TAMPTS LL_RTC_TS_EnableOnTamper
  2285. * @param RTCx RTC Instance
  2286. * @retval None
  2287. */
  2288. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  2289. {
  2290. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  2291. }
  2292. /**
  2293. * @brief Disable timestamp on tamper detection event
  2294. * @rmtoll TAMPCR TAMPTS LL_RTC_TS_DisableOnTamper
  2295. * @param RTCx RTC Instance
  2296. * @retval None
  2297. */
  2298. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  2299. {
  2300. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  2301. }
  2302. #endif /* RTC_TAMPCR_TAMPTS */
  2303. /**
  2304. * @}
  2305. */
  2306. /** @defgroup RTC_LL_EF_Tamper Tamper
  2307. * @{
  2308. */
  2309. /**
  2310. * @brief Enable RTC_TAMPx input detection
  2311. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Enable\n
  2312. * TAMPCR TAMP2E LL_RTC_TAMPER_Enable\n
  2313. * TAMPCR TAMP3E LL_RTC_TAMPER_Enable
  2314. * @param RTCx RTC Instance
  2315. * @param Tamper This parameter can be a combination of the following values:
  2316. * @arg @ref LL_RTC_TAMPER_1 (*)
  2317. * @arg @ref LL_RTC_TAMPER_2
  2318. * @arg @ref LL_RTC_TAMPER_3 (*)
  2319. *
  2320. * (*) value not applicable to all devices.
  2321. * @retval None
  2322. */
  2323. __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2324. {
  2325. SET_BIT(RTCx->TAMPCR, Tamper);
  2326. }
  2327. /**
  2328. * @brief Clear RTC_TAMPx input detection
  2329. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Disable\n
  2330. * TAMPCR TAMP2E LL_RTC_TAMPER_Disable\n
  2331. * TAMPCR TAMP3E LL_RTC_TAMPER_Disable
  2332. * @param RTCx RTC Instance
  2333. * @param Tamper This parameter can be a combination of the following values:
  2334. * @arg @ref LL_RTC_TAMPER_1 (*)
  2335. * @arg @ref LL_RTC_TAMPER_2
  2336. * @arg @ref LL_RTC_TAMPER_3 (*)
  2337. *
  2338. * (*) value not applicable to all devices.
  2339. * @retval None
  2340. */
  2341. __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2342. {
  2343. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  2344. }
  2345. /**
  2346. * @brief Enable Tamper mask flag
  2347. * @note Associated Tamper IT must not enabled when tamper mask is set.
  2348. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_EnableMask\n
  2349. * TAMPCR TAMP2MF LL_RTC_TAMPER_EnableMask\n
  2350. * TAMPCR TAMP3MF LL_RTC_TAMPER_EnableMask
  2351. * @param RTCx RTC Instance
  2352. * @param Mask This parameter can be a combination of the following values:
  2353. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1 (*)
  2354. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  2355. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3 (*)
  2356. *
  2357. * (*) value not applicable to all devices.
  2358. * @retval None
  2359. */
  2360. __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2361. {
  2362. SET_BIT(RTCx->TAMPCR, Mask);
  2363. }
  2364. /**
  2365. * @brief Disable Tamper mask flag
  2366. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_DisableMask\n
  2367. * TAMPCR TAMP2MF LL_RTC_TAMPER_DisableMask\n
  2368. * TAMPCR TAMP3MF LL_RTC_TAMPER_DisableMask
  2369. * @param RTCx RTC Instance
  2370. * @param Mask This parameter can be a combination of the following values:
  2371. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1 (*)
  2372. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  2373. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3 (*)
  2374. *
  2375. * (*) value not applicable to all devices.
  2376. * @retval None
  2377. */
  2378. __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2379. {
  2380. CLEAR_BIT(RTCx->TAMPCR, Mask);
  2381. }
  2382. /**
  2383. * @brief Enable backup register erase after Tamper event detection
  2384. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
  2385. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
  2386. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_EnableEraseBKP
  2387. * @param RTCx RTC Instance
  2388. * @param Tamper This parameter can be a combination of the following values:
  2389. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1 (*)
  2390. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  2391. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3 (*)
  2392. *
  2393. * (*) value not applicable to all devices.
  2394. * @retval None
  2395. */
  2396. __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  2397. {
  2398. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  2399. }
  2400. /**
  2401. * @brief Disable backup register erase after Tamper event detection
  2402. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
  2403. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
  2404. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_DisableEraseBKP
  2405. * @param RTCx RTC Instance
  2406. * @param Tamper This parameter can be a combination of the following values:
  2407. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1 (*)
  2408. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  2409. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3 (*)
  2410. *
  2411. * (*) value not applicable to all devices.
  2412. * @retval None
  2413. */
  2414. __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  2415. {
  2416. SET_BIT(RTCx->TAMPCR, Tamper);
  2417. }
  2418. /**
  2419. * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  2420. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
  2421. * @param RTCx RTC Instance
  2422. * @retval None
  2423. */
  2424. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
  2425. {
  2426. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  2427. }
  2428. /**
  2429. * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
  2430. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
  2431. * @param RTCx RTC Instance
  2432. * @retval None
  2433. */
  2434. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
  2435. {
  2436. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  2437. }
  2438. /**
  2439. * @brief Set RTC_TAMPx precharge duration
  2440. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
  2441. * @param RTCx RTC Instance
  2442. * @param Duration This parameter can be one of the following values:
  2443. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2444. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2445. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2446. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2447. * @retval None
  2448. */
  2449. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
  2450. {
  2451. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH, Duration);
  2452. }
  2453. /**
  2454. * @brief Get RTC_TAMPx precharge duration
  2455. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
  2456. * @param RTCx RTC Instance
  2457. * @retval Returned value can be one of the following values:
  2458. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2459. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2460. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2461. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2462. */
  2463. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
  2464. {
  2465. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH));
  2466. }
  2467. /**
  2468. * @brief Set RTC_TAMPx filter count
  2469. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
  2470. * @param RTCx RTC Instance
  2471. * @param FilterCount This parameter can be one of the following values:
  2472. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2473. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2474. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2475. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2476. * @retval None
  2477. */
  2478. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
  2479. {
  2480. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT, FilterCount);
  2481. }
  2482. /**
  2483. * @brief Get RTC_TAMPx filter count
  2484. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
  2485. * @param RTCx RTC Instance
  2486. * @retval Returned value can be one of the following values:
  2487. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2488. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2489. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2490. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2491. */
  2492. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
  2493. {
  2494. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT));
  2495. }
  2496. /**
  2497. * @brief Set Tamper sampling frequency
  2498. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
  2499. * @param RTCx RTC Instance
  2500. * @param SamplingFreq This parameter can be one of the following values:
  2501. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2502. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2503. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2504. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2505. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2506. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2507. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2508. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2509. * @retval None
  2510. */
  2511. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
  2512. {
  2513. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ, SamplingFreq);
  2514. }
  2515. /**
  2516. * @brief Get Tamper sampling frequency
  2517. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
  2518. * @param RTCx RTC Instance
  2519. * @retval Returned value can be one of the following values:
  2520. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2521. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2522. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2523. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2524. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2525. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2526. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2527. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2528. */
  2529. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
  2530. {
  2531. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ));
  2532. }
  2533. /**
  2534. * @brief Enable Active level for Tamper input
  2535. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel\n
  2536. * TAMPCR TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel\n
  2537. * TAMPCR TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
  2538. * @param RTCx RTC Instance
  2539. * @param Tamper This parameter can be a combination of the following values:
  2540. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 (*)
  2541. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  2542. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
  2543. *
  2544. * (*) value not applicable to all devices.
  2545. * @retval None
  2546. */
  2547. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2548. {
  2549. SET_BIT(RTCx->TAMPCR, Tamper);
  2550. }
  2551. /**
  2552. * @brief Disable Active level for Tamper input
  2553. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel\n
  2554. * TAMPCR TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel\n
  2555. * TAMPCR TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
  2556. * @param RTCx RTC Instance
  2557. * @param Tamper This parameter can be a combination of the following values:
  2558. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 (*)
  2559. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  2560. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
  2561. *
  2562. * (*) value not applicable to all devices.
  2563. * @retval None
  2564. */
  2565. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2566. {
  2567. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  2568. }
  2569. /**
  2570. * @}
  2571. */
  2572. /** @defgroup RTC_LL_EF_Wakeup Wakeup
  2573. * @{
  2574. */
  2575. /**
  2576. * @brief Enable Wakeup timer
  2577. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2578. * @rmtoll CR WUTE LL_RTC_WAKEUP_Enable
  2579. * @param RTCx RTC Instance
  2580. * @retval None
  2581. */
  2582. __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
  2583. {
  2584. SET_BIT(RTCx->CR, RTC_CR_WUTE);
  2585. }
  2586. /**
  2587. * @brief Disable Wakeup timer
  2588. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2589. * @rmtoll CR WUTE LL_RTC_WAKEUP_Disable
  2590. * @param RTCx RTC Instance
  2591. * @retval None
  2592. */
  2593. __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
  2594. {
  2595. CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
  2596. }
  2597. /**
  2598. * @brief Check if Wakeup timer is enabled or not
  2599. * @rmtoll CR WUTE LL_RTC_WAKEUP_IsEnabled
  2600. * @param RTCx RTC Instance
  2601. * @retval State of bit (1 or 0).
  2602. */
  2603. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
  2604. {
  2605. return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
  2606. }
  2607. /**
  2608. * @brief Select Wakeup clock
  2609. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2610. * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
  2611. * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_SetClock
  2612. * @param RTCx RTC Instance
  2613. * @param WakeupClock This parameter can be one of the following values:
  2614. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2615. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2616. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2617. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2618. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2619. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2620. * @retval None
  2621. */
  2622. __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
  2623. {
  2624. MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
  2625. }
  2626. /**
  2627. * @brief Get Wakeup clock
  2628. * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_GetClock
  2629. * @param RTCx RTC Instance
  2630. * @retval Returned value can be one of the following values:
  2631. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2632. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2633. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2634. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2635. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2636. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2637. */
  2638. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
  2639. {
  2640. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
  2641. }
  2642. /**
  2643. * @brief Set Wakeup auto-reload value
  2644. * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
  2645. * @rmtoll WUTR WUT LL_RTC_WAKEUP_SetAutoReload
  2646. * @param RTCx RTC Instance
  2647. * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
  2648. * @retval None
  2649. */
  2650. __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
  2651. {
  2652. MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
  2653. }
  2654. /**
  2655. * @brief Get Wakeup auto-reload value
  2656. * @rmtoll WUTR WUT LL_RTC_WAKEUP_GetAutoReload
  2657. * @param RTCx RTC Instance
  2658. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2659. */
  2660. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
  2661. {
  2662. return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
  2663. }
  2664. /**
  2665. * @}
  2666. */
  2667. /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
  2668. * @{
  2669. */
  2670. /**
  2671. * @brief Writes a data in a specified RTC Backup data register.
  2672. * @rmtoll BKPxR BKP LL_RTC_BAK_SetRegister
  2673. * @param RTCx RTC Instance
  2674. * @param BackupRegister This parameter can be one of the following values:
  2675. * @arg @ref LL_RTC_BKP_DR0
  2676. * @arg @ref LL_RTC_BKP_DR1
  2677. * @arg @ref LL_RTC_BKP_DR2
  2678. * @arg @ref LL_RTC_BKP_DR3
  2679. * @arg @ref LL_RTC_BKP_DR4
  2680. * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  2681. * @retval None
  2682. */
  2683. __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
  2684. {
  2685. uint32_t temp;
  2686. temp = (uint32_t)(&(RTCx->BKP0R));
  2687. temp += (BackupRegister * 4U);
  2688. /* Write the specified register */
  2689. *(__IO uint32_t *)temp = (uint32_t)Data;
  2690. }
  2691. /**
  2692. * @brief Reads data from the specified RTC Backup data Register.
  2693. * @rmtoll BKPxR BKP LL_RTC_BAK_GetRegister
  2694. * @param RTCx RTC Instance
  2695. * @param BackupRegister This parameter can be one of the following values:
  2696. * @arg @ref LL_RTC_BKP_DR0
  2697. * @arg @ref LL_RTC_BKP_DR1
  2698. * @arg @ref LL_RTC_BKP_DR2
  2699. * @arg @ref LL_RTC_BKP_DR3
  2700. * @arg @ref LL_RTC_BKP_DR4
  2701. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  2702. */
  2703. __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
  2704. {
  2705. uint32_t temp;
  2706. temp = (uint32_t)(&(RTCx->BKP0R));
  2707. temp += (BackupRegister * 4U);
  2708. /* Read the specified register */
  2709. return (*(__IO uint32_t *)temp);
  2710. }
  2711. /**
  2712. * @}
  2713. */
  2714. /** @defgroup RTC_LL_EF_Calibration Calibration
  2715. * @{
  2716. */
  2717. /**
  2718. * @brief Set Calibration output frequency (1 Hz or 512 Hz)
  2719. * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2720. * @rmtoll CR COE LL_RTC_CAL_SetOutputFreq\n
  2721. * CR COSEL LL_RTC_CAL_SetOutputFreq
  2722. * @param RTCx RTC Instance
  2723. * @param Frequency This parameter can be one of the following values:
  2724. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  2725. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  2726. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  2727. *
  2728. * @retval None
  2729. */
  2730. __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
  2731. {
  2732. MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
  2733. }
  2734. /**
  2735. * @brief Get Calibration output frequency (1 Hz or 512 Hz)
  2736. * @rmtoll CR COE LL_RTC_CAL_GetOutputFreq\n
  2737. * CR COSEL LL_RTC_CAL_GetOutputFreq
  2738. * @param RTCx RTC Instance
  2739. * @retval Returned value can be one of the following values:
  2740. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  2741. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  2742. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  2743. *
  2744. */
  2745. __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
  2746. {
  2747. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
  2748. }
  2749. /**
  2750. * @brief Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
  2751. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2752. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  2753. * @rmtoll CALR CALP LL_RTC_CAL_SetPulse
  2754. * @param RTCx RTC Instance
  2755. * @param Pulse This parameter can be one of the following values:
  2756. * @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
  2757. * @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
  2758. * @retval None
  2759. */
  2760. __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
  2761. {
  2762. MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
  2763. }
  2764. /**
  2765. * @brief Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
  2766. * @rmtoll CALR CALP LL_RTC_CAL_IsPulseInserted
  2767. * @param RTCx RTC Instance
  2768. * @retval State of bit (1 or 0).
  2769. */
  2770. __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
  2771. {
  2772. return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
  2773. }
  2774. /**
  2775. * @brief Set smooth calibration cycle period
  2776. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2777. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  2778. * @rmtoll CALR CALW8 LL_RTC_CAL_SetPeriod\n
  2779. * CALR CALW16 LL_RTC_CAL_SetPeriod
  2780. * @param RTCx RTC Instance
  2781. * @param Period This parameter can be one of the following values:
  2782. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  2783. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  2784. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  2785. * @retval None
  2786. */
  2787. __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
  2788. {
  2789. MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
  2790. }
  2791. /**
  2792. * @brief Get smooth calibration cycle period
  2793. * @rmtoll CALR CALW8 LL_RTC_CAL_GetPeriod\n
  2794. * CALR CALW16 LL_RTC_CAL_GetPeriod
  2795. * @param RTCx RTC Instance
  2796. * @retval Returned value can be one of the following values:
  2797. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  2798. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  2799. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  2800. */
  2801. __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
  2802. {
  2803. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
  2804. }
  2805. /**
  2806. * @brief Set smooth Calibration minus
  2807. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2808. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  2809. * @rmtoll CALR CALM LL_RTC_CAL_SetMinus
  2810. * @param RTCx RTC Instance
  2811. * @param CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
  2812. * @retval None
  2813. */
  2814. __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
  2815. {
  2816. MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
  2817. }
  2818. /**
  2819. * @brief Get smooth Calibration minus
  2820. * @rmtoll CALR CALM LL_RTC_CAL_GetMinus
  2821. * @param RTCx RTC Instance
  2822. * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
  2823. */
  2824. __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
  2825. {
  2826. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
  2827. }
  2828. /**
  2829. * @}
  2830. */
  2831. /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
  2832. * @{
  2833. */
  2834. /**
  2835. * @brief Get Recalibration pending Flag
  2836. * @rmtoll ISR RECALPF LL_RTC_IsActiveFlag_RECALP
  2837. * @param RTCx RTC Instance
  2838. * @retval State of bit (1 or 0).
  2839. */
  2840. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  2841. {
  2842. return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
  2843. }
  2844. #if defined(RTC_TAMPER3_SUPPORT)
  2845. /**
  2846. * @brief Get RTC_TAMP3 detection flag
  2847. * @rmtoll ISR TAMP3F LL_RTC_IsActiveFlag_TAMP3
  2848. * @param RTCx RTC Instance
  2849. * @retval State of bit (1 or 0).
  2850. */
  2851. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
  2852. {
  2853. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F)) ? 1UL : 0UL);
  2854. }
  2855. #endif /* RTC_TAMPER3_SUPPORT */
  2856. /**
  2857. * @brief Get RTC_TAMP2 detection flag
  2858. * @rmtoll ISR TAMP2F LL_RTC_IsActiveFlag_TAMP2
  2859. * @param RTCx RTC Instance
  2860. * @retval State of bit (1 or 0).
  2861. */
  2862. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
  2863. {
  2864. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F)) ? 1UL : 0UL);
  2865. }
  2866. #if defined(RTC_TAMPER1_SUPPORT)
  2867. /**
  2868. * @brief Get RTC_TAMP1 detection flag
  2869. * @rmtoll ISR TAMP1F LL_RTC_IsActiveFlag_TAMP1
  2870. * @param RTCx RTC Instance
  2871. * @retval State of bit (1 or 0).
  2872. */
  2873. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
  2874. {
  2875. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F)) ? 1UL : 0UL);
  2876. }
  2877. #endif /* RTC_TAMPER1_SUPPORT */
  2878. /**
  2879. * @brief Get Time-stamp overflow flag
  2880. * @rmtoll ISR TSOVF LL_RTC_IsActiveFlag_TSOV
  2881. * @param RTCx RTC Instance
  2882. * @retval State of bit (1 or 0).
  2883. */
  2884. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  2885. {
  2886. return ((READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF)) ? 1UL : 0UL);
  2887. }
  2888. /**
  2889. * @brief Get Time-stamp flag
  2890. * @rmtoll ISR TSF LL_RTC_IsActiveFlag_TS
  2891. * @param RTCx RTC Instance
  2892. * @retval State of bit (1 or 0).
  2893. */
  2894. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  2895. {
  2896. return ((READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF)) ? 1UL : 0UL);
  2897. }
  2898. /**
  2899. * @brief Get Wakeup timer flag
  2900. * @rmtoll ISR WUTF LL_RTC_IsActiveFlag_WUT
  2901. * @param RTCx RTC Instance
  2902. * @retval State of bit (1 or 0).
  2903. */
  2904. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  2905. {
  2906. return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
  2907. }
  2908. /**
  2909. * @brief Get Alarm B flag
  2910. * @rmtoll ISR ALRBF LL_RTC_IsActiveFlag_ALRB
  2911. * @param RTCx RTC Instance
  2912. * @retval State of bit (1 or 0).
  2913. */
  2914. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  2915. {
  2916. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBF) == (RTC_ISR_ALRBF)) ? 1UL : 0UL);
  2917. }
  2918. /**
  2919. * @brief Get Alarm A flag
  2920. * @rmtoll ISR ALRAF LL_RTC_IsActiveFlag_ALRA
  2921. * @param RTCx RTC Instance
  2922. * @retval State of bit (1 or 0).
  2923. */
  2924. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  2925. {
  2926. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
  2927. }
  2928. #if defined(RTC_TAMPER3_SUPPORT)
  2929. /**
  2930. * @brief Clear RTC_TAMP3 detection flag
  2931. * @rmtoll ISR TAMP3F LL_RTC_ClearFlag_TAMP3
  2932. * @param RTCx RTC Instance
  2933. * @retval None
  2934. */
  2935. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
  2936. {
  2937. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2938. }
  2939. #endif /* RTC_TAMPER3_SUPPORT */
  2940. /**
  2941. * @brief Clear RTC_TAMP2 detection flag
  2942. * @rmtoll ISR TAMP2F LL_RTC_ClearFlag_TAMP2
  2943. * @param RTCx RTC Instance
  2944. * @retval None
  2945. */
  2946. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
  2947. {
  2948. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2949. }
  2950. #if defined(RTC_TAMPER1_SUPPORT)
  2951. /**
  2952. * @brief Clear RTC_TAMP1 detection flag
  2953. * @rmtoll ISR TAMP1F LL_RTC_ClearFlag_TAMP1
  2954. * @param RTCx RTC Instance
  2955. * @retval None
  2956. */
  2957. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
  2958. {
  2959. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2960. }
  2961. #endif /* RTC_TAMPER1_SUPPORT */
  2962. /**
  2963. * @brief Clear Time-stamp overflow flag
  2964. * @rmtoll ISR TSOVF LL_RTC_ClearFlag_TSOV
  2965. * @param RTCx RTC Instance
  2966. * @retval None
  2967. */
  2968. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  2969. {
  2970. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2971. }
  2972. /**
  2973. * @brief Clear Time-stamp flag
  2974. * @rmtoll ISR TSF LL_RTC_ClearFlag_TS
  2975. * @param RTCx RTC Instance
  2976. * @retval None
  2977. */
  2978. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  2979. {
  2980. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2981. }
  2982. /**
  2983. * @brief Clear Wakeup timer flag
  2984. * @rmtoll ISR WUTF LL_RTC_ClearFlag_WUT
  2985. * @param RTCx RTC Instance
  2986. * @retval None
  2987. */
  2988. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  2989. {
  2990. WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  2991. }
  2992. /**
  2993. * @brief Clear Alarm B flag
  2994. * @rmtoll ISR ALRBF LL_RTC_ClearFlag_ALRB
  2995. * @param RTCx RTC Instance
  2996. * @retval None
  2997. */
  2998. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  2999. {
  3000. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRBF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3001. }
  3002. /**
  3003. * @brief Clear Alarm A flag
  3004. * @rmtoll ISR ALRAF LL_RTC_ClearFlag_ALRA
  3005. * @param RTCx RTC Instance
  3006. * @retval None
  3007. */
  3008. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  3009. {
  3010. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3011. }
  3012. /**
  3013. * @brief Get Initialization flag
  3014. * @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT
  3015. * @param RTCx RTC Instance
  3016. * @retval State of bit (1 or 0).
  3017. */
  3018. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  3019. {
  3020. return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
  3021. }
  3022. /**
  3023. * @brief Get Registers synchronization flag
  3024. * @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS
  3025. * @param RTCx RTC Instance
  3026. * @retval State of bit (1 or 0).
  3027. */
  3028. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  3029. {
  3030. return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
  3031. }
  3032. /**
  3033. * @brief Clear Registers synchronization flag
  3034. * @rmtoll ISR RSF LL_RTC_ClearFlag_RS
  3035. * @param RTCx RTC Instance
  3036. * @retval None
  3037. */
  3038. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  3039. {
  3040. WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3041. }
  3042. /**
  3043. * @brief Get Initialization status flag
  3044. * @rmtoll ISR INITS LL_RTC_IsActiveFlag_INITS
  3045. * @param RTCx RTC Instance
  3046. * @retval State of bit (1 or 0).
  3047. */
  3048. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  3049. {
  3050. return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
  3051. }
  3052. /**
  3053. * @brief Get Shift operation pending flag
  3054. * @rmtoll ISR SHPF LL_RTC_IsActiveFlag_SHP
  3055. * @param RTCx RTC Instance
  3056. * @retval State of bit (1 or 0).
  3057. */
  3058. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  3059. {
  3060. return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
  3061. }
  3062. /**
  3063. * @brief Get Wakeup timer write flag
  3064. * @rmtoll ISR WUTWF LL_RTC_IsActiveFlag_WUTW
  3065. * @param RTCx RTC Instance
  3066. * @retval State of bit (1 or 0).
  3067. */
  3068. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  3069. {
  3070. return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
  3071. }
  3072. /**
  3073. * @brief Get Alarm B write flag
  3074. * @rmtoll ISR ALRBWF LL_RTC_IsActiveFlag_ALRBW
  3075. * @param RTCx RTC Instance
  3076. * @retval State of bit (1 or 0).
  3077. */
  3078. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
  3079. {
  3080. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBWF) == (RTC_ISR_ALRBWF)) ? 1UL : 0UL);
  3081. }
  3082. /**
  3083. * @brief Get Alarm A write flag
  3084. * @rmtoll ISR ALRAWF LL_RTC_IsActiveFlag_ALRAW
  3085. * @param RTCx RTC Instance
  3086. * @retval State of bit (1 or 0).
  3087. */
  3088. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
  3089. {
  3090. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
  3091. }
  3092. /**
  3093. * @}
  3094. */
  3095. /** @defgroup RTC_LL_EF_IT_Management IT_Management
  3096. * @{
  3097. */
  3098. /**
  3099. * @brief Enable Time-stamp interrupt
  3100. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3101. * @rmtoll CR TSIE LL_RTC_EnableIT_TS
  3102. * @param RTCx RTC Instance
  3103. * @retval None
  3104. */
  3105. __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
  3106. {
  3107. SET_BIT(RTCx->CR, RTC_CR_TSIE);
  3108. }
  3109. /**
  3110. * @brief Disable Time-stamp interrupt
  3111. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3112. * @rmtoll CR TSIE LL_RTC_DisableIT_TS
  3113. * @param RTCx RTC Instance
  3114. * @retval None
  3115. */
  3116. __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
  3117. {
  3118. CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
  3119. }
  3120. /**
  3121. * @brief Enable Wakeup timer interrupt
  3122. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3123. * @rmtoll CR WUTIE LL_RTC_EnableIT_WUT
  3124. * @param RTCx RTC Instance
  3125. * @retval None
  3126. */
  3127. __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
  3128. {
  3129. SET_BIT(RTCx->CR, RTC_CR_WUTIE);
  3130. }
  3131. /**
  3132. * @brief Disable Wakeup timer interrupt
  3133. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3134. * @rmtoll CR WUTIE LL_RTC_DisableIT_WUT
  3135. * @param RTCx RTC Instance
  3136. * @retval None
  3137. */
  3138. __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
  3139. {
  3140. CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
  3141. }
  3142. /**
  3143. * @brief Enable Alarm B interrupt
  3144. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3145. * @rmtoll CR ALRBIE LL_RTC_EnableIT_ALRB
  3146. * @param RTCx RTC Instance
  3147. * @retval None
  3148. */
  3149. __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
  3150. {
  3151. SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3152. }
  3153. /**
  3154. * @brief Disable Alarm B interrupt
  3155. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3156. * @rmtoll CR ALRBIE LL_RTC_DisableIT_ALRB
  3157. * @param RTCx RTC Instance
  3158. * @retval None
  3159. */
  3160. __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
  3161. {
  3162. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3163. }
  3164. /**
  3165. * @brief Enable Alarm A interrupt
  3166. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3167. * @rmtoll CR ALRAIE LL_RTC_EnableIT_ALRA
  3168. * @param RTCx RTC Instance
  3169. * @retval None
  3170. */
  3171. __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
  3172. {
  3173. SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3174. }
  3175. /**
  3176. * @brief Disable Alarm A interrupt
  3177. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3178. * @rmtoll CR ALRAIE LL_RTC_DisableIT_ALRA
  3179. * @param RTCx RTC Instance
  3180. * @retval None
  3181. */
  3182. __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
  3183. {
  3184. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3185. }
  3186. #if defined(RTC_TAMPER3_SUPPORT)
  3187. /**
  3188. * @brief Enable Tamper 3 interrupt
  3189. * @rmtoll TAMPCR TAMP3IE LL_RTC_EnableIT_TAMP3
  3190. * @param RTCx RTC Instance
  3191. * @retval None
  3192. */
  3193. __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(RTC_TypeDef *RTCx)
  3194. {
  3195. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  3196. }
  3197. /**
  3198. * @brief Disable Tamper 3 interrupt
  3199. * @rmtoll TAMPCR TAMP3IE LL_RTC_DisableIT_TAMP3
  3200. * @param RTCx RTC Instance
  3201. * @retval None
  3202. */
  3203. __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(RTC_TypeDef *RTCx)
  3204. {
  3205. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  3206. }
  3207. #endif /* RTC_TAMPER3_SUPPORT */
  3208. /**
  3209. * @brief Enable Tamper 2 interrupt
  3210. * @rmtoll TAMPCR TAMP2IE LL_RTC_EnableIT_TAMP2
  3211. * @param RTCx RTC Instance
  3212. * @retval None
  3213. */
  3214. __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(RTC_TypeDef *RTCx)
  3215. {
  3216. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  3217. }
  3218. /**
  3219. * @brief Disable Tamper 2 interrupt
  3220. * @rmtoll TAMPCR TAMP2IE LL_RTC_DisableIT_TAMP2
  3221. * @param RTCx RTC Instance
  3222. * @retval None
  3223. */
  3224. __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(RTC_TypeDef *RTCx)
  3225. {
  3226. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  3227. }
  3228. #if defined(RTC_TAMPER1_SUPPORT)
  3229. /**
  3230. * @brief Enable Tamper 1 interrupt
  3231. * @rmtoll TAMPCR TAMP1IE LL_RTC_EnableIT_TAMP1
  3232. * @param RTCx RTC Instance
  3233. * @retval None
  3234. */
  3235. __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(RTC_TypeDef *RTCx)
  3236. {
  3237. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  3238. }
  3239. /**
  3240. * @brief Disable Tamper 1 interrupt
  3241. * @rmtoll TAMPCR TAMP1IE LL_RTC_DisableIT_TAMP1
  3242. * @param RTCx RTC Instance
  3243. * @retval None
  3244. */
  3245. __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(RTC_TypeDef *RTCx)
  3246. {
  3247. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  3248. }
  3249. #endif /* RTC_TAMPER1_SUPPORT */
  3250. /**
  3251. * @brief Enable all Tamper Interrupt
  3252. * @rmtoll TAMPCR TAMPIE LL_RTC_EnableIT_TAMP
  3253. * @param RTCx RTC Instance
  3254. * @retval None
  3255. */
  3256. __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
  3257. {
  3258. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  3259. }
  3260. /**
  3261. * @brief Disable all Tamper Interrupt
  3262. * @rmtoll TAMPCR TAMPIE LL_RTC_DisableIT_TAMP
  3263. * @param RTCx RTC Instance
  3264. * @retval None
  3265. */
  3266. __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
  3267. {
  3268. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  3269. }
  3270. /**
  3271. * @brief Check if Time-stamp interrupt is enabled or not
  3272. * @rmtoll CR TSIE LL_RTC_IsEnabledIT_TS
  3273. * @param RTCx RTC Instance
  3274. * @retval State of bit (1 or 0).
  3275. */
  3276. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
  3277. {
  3278. return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1UL : 0UL);
  3279. }
  3280. /**
  3281. * @brief Check if Wakeup timer interrupt is enabled or not
  3282. * @rmtoll CR WUTIE LL_RTC_IsEnabledIT_WUT
  3283. * @param RTCx RTC Instance
  3284. * @retval State of bit (1 or 0).
  3285. */
  3286. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
  3287. {
  3288. return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
  3289. }
  3290. /**
  3291. * @brief Check if Alarm B interrupt is enabled or not
  3292. * @rmtoll CR ALRBIE LL_RTC_IsEnabledIT_ALRB
  3293. * @param RTCx RTC Instance
  3294. * @retval State of bit (1 or 0).
  3295. */
  3296. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
  3297. {
  3298. return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1UL : 0UL);
  3299. }
  3300. /**
  3301. * @brief Check if Alarm A interrupt is enabled or not
  3302. * @rmtoll CR ALRAIE LL_RTC_IsEnabledIT_ALRA
  3303. * @param RTCx RTC Instance
  3304. * @retval State of bit (1 or 0).
  3305. */
  3306. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
  3307. {
  3308. return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
  3309. }
  3310. #if defined(RTC_TAMPER3_SUPPORT)
  3311. /**
  3312. * @brief Check if Tamper 3 interrupt is enabled or not
  3313. * @rmtoll TAMPCR TAMP3IE LL_RTC_IsEnabledIT_TAMP3
  3314. * @param RTCx RTC Instance
  3315. * @retval State of bit (1 or 0).
  3316. */
  3317. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef *RTCx)
  3318. {
  3319. return ((READ_BIT(RTCx->TAMPCR,
  3320. RTC_TAMPCR_TAMP3IE) == (RTC_TAMPCR_TAMP3IE)) ? 1UL : 0UL);
  3321. }
  3322. #endif /* RTC_TAMPER3_SUPPORT */
  3323. /**
  3324. * @brief Check if Tamper 2 interrupt is enabled or not
  3325. * @rmtoll TAMPCR TAMP2IE LL_RTC_IsEnabledIT_TAMP2
  3326. * @param RTCx RTC Instance
  3327. * @retval State of bit (1 or 0).
  3328. */
  3329. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef *RTCx)
  3330. {
  3331. return ((READ_BIT(RTCx->TAMPCR,
  3332. RTC_TAMPCR_TAMP2IE) == (RTC_TAMPCR_TAMP2IE)) ? 1UL : 0UL);
  3333. }
  3334. #if defined(RTC_TAMPER1_SUPPORT)
  3335. /**
  3336. * @brief Check if Tamper 1 interrupt is enabled or not
  3337. * @rmtoll TAMPCR TAMP1IE LL_RTC_IsEnabledIT_TAMP1
  3338. * @param RTCx RTC Instance
  3339. * @retval State of bit (1 or 0).
  3340. */
  3341. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef *RTCx)
  3342. {
  3343. return ((READ_BIT(RTCx->TAMPCR,
  3344. RTC_TAMPCR_TAMP1IE) == (RTC_TAMPCR_TAMP1IE)) ? 1UL : 0UL);
  3345. }
  3346. #endif /* RTC_TAMPER1_SUPPORT */
  3347. /**
  3348. * @brief Check if all the TAMPER interrupts are enabled or not
  3349. * @rmtoll TAMPCR TAMPIE LL_RTC_IsEnabledIT_TAMP
  3350. * @param RTCx RTC Instance
  3351. * @retval State of bit (1 or 0).
  3352. */
  3353. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
  3354. {
  3355. return ((READ_BIT(RTCx->TAMPCR,
  3356. RTC_TAMPCR_TAMPIE) == (RTC_TAMPCR_TAMPIE)) ? 1UL : 0UL);
  3357. }
  3358. /**
  3359. * @}
  3360. */
  3361. #if defined(USE_FULL_LL_DRIVER)
  3362. /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
  3363. * @{
  3364. */
  3365. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
  3366. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
  3367. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
  3368. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
  3369. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
  3370. ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
  3371. void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
  3372. ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3373. ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3374. void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3375. void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3376. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
  3377. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
  3378. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
  3379. /**
  3380. * @}
  3381. */
  3382. #endif /* USE_FULL_LL_DRIVER */
  3383. /**
  3384. * @}
  3385. */
  3386. /**
  3387. * @}
  3388. */
  3389. #endif /* defined(RTC) */
  3390. /**
  3391. * @}
  3392. */
  3393. #ifdef __cplusplus
  3394. }
  3395. #endif
  3396. #endif /* STM32L0xx_LL_RTC_H */