stm32f7xx_ll_rtc.h 143 KB

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