stm32g0xx_ll_rtc.h 156 KB

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