stm32f7xx_ll_rtc.h 144 KB

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