stm32l4xx_ll_rtc.h 201 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_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 STM32L4xx_LL_RTC_H
  20. #define STM32L4xx_LL_RTC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx.h"
  26. /** @addtogroup STM32L4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined(RTC)
  30. /** @defgroup RTC_LL RTC
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /** @defgroup RTC_LL_Private_Constants RTC Private Constants
  37. * @{
  38. */
  39. /* Masks Definition */
  40. #define RTC_LL_INIT_MASK 0xFFFFFFFFU
  41. #define RTC_LL_RSF_MASK 0xFFFFFF5FU
  42. /* Write protection defines */
  43. #define RTC_WRITE_PROTECTION_DISABLE 0xFFU
  44. #define RTC_WRITE_PROTECTION_ENABLE_1 0xCAU
  45. #define RTC_WRITE_PROTECTION_ENABLE_2 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. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  188. #define LL_RTC_SCR_ITSF RTC_SCR_CITSF
  189. #define LL_RTC_SCR_TSOVF RTC_SCR_CTSOVF
  190. #define LL_RTC_SCR_TSF RTC_SCR_CTSF
  191. #define LL_RTC_SCR_WUTF RTC_SCR_CWUTF
  192. #define LL_RTC_SCR_ALRBF RTC_SCR_CALRBF
  193. #define LL_RTC_SCR_ALRAF RTC_SCR_CALRAF
  194. #define LL_RTC_ICSR_RECALPF RTC_ICSR_RECALPF
  195. #define LL_RTC_ICSR_INITF RTC_ICSR_INITF
  196. #define LL_RTC_ICSR_RSF RTC_ICSR_RSF
  197. #define LL_RTC_ICSR_INITS RTC_ICSR_INITS
  198. #define LL_RTC_ICSR_SHPF RTC_ICSR_SHPF
  199. #define LL_RTC_ICSR_WUTWF RTC_ICSR_WUTWF
  200. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  201. #define LL_RTC_ISR_ITSF RTC_ISR_ITSF
  202. #define LL_RTC_ISR_RECALPF RTC_ISR_RECALPF
  203. #define LL_RTC_ISR_TAMP3F RTC_ISR_TAMP3F
  204. #define LL_RTC_ISR_TAMP2F RTC_ISR_TAMP2F
  205. #define LL_RTC_ISR_TAMP1F RTC_ISR_TAMP1F
  206. #define LL_RTC_ISR_TSOVF RTC_ISR_TSOVF
  207. #define LL_RTC_ISR_TSF RTC_ISR_TSF
  208. #define LL_RTC_ISR_WUTF RTC_ISR_WUTF
  209. #define LL_RTC_ISR_ALRBF RTC_ISR_ALRBF
  210. #define LL_RTC_ISR_ALRAF RTC_ISR_ALRAF
  211. #define LL_RTC_ISR_INITF RTC_ISR_INITF
  212. #define LL_RTC_ISR_RSF RTC_ISR_RSF
  213. #define LL_RTC_ISR_INITS RTC_ISR_INITS
  214. #define LL_RTC_ISR_SHPF RTC_ISR_SHPF
  215. #define LL_RTC_ISR_WUTWF RTC_ISR_WUTWF
  216. #define LL_RTC_ISR_ALRBWF RTC_ISR_ALRBWF
  217. #define LL_RTC_ISR_ALRAWF RTC_ISR_ALRAWF
  218. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  219. /**
  220. * @}
  221. */
  222. /** @defgroup RTC_LL_EC_IT IT Defines
  223. * @brief IT defines which can be used with LL_RTC_ReadReg and LL_RTC_WriteReg functions
  224. * @{
  225. */
  226. #define LL_RTC_CR_TSIE RTC_CR_TSIE
  227. #define LL_RTC_CR_WUTIE RTC_CR_WUTIE
  228. #define LL_RTC_CR_ALRBIE RTC_CR_ALRBIE
  229. #define LL_RTC_CR_ALRAIE RTC_CR_ALRAIE
  230. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  231. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  232. #define LL_RTC_TAMPCR_TAMP3IE RTC_TAMPCR_TAMP3IE
  233. #define LL_RTC_TAMPCR_TAMP2IE RTC_TAMPCR_TAMP2IE
  234. #define LL_RTC_TAMPCR_TAMP1IE RTC_TAMPCR_TAMP1IE
  235. #define LL_RTC_TAMPCR_TAMPIE RTC_TAMPCR_TAMPIE
  236. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  237. /**
  238. * @}
  239. */
  240. /** @defgroup RTC_LL_EC_WEEKDAY WEEK DAY
  241. * @{
  242. */
  243. #define LL_RTC_WEEKDAY_MONDAY (uint8_t)0x01 /*!< Monday */
  244. #define LL_RTC_WEEKDAY_TUESDAY (uint8_t)0x02 /*!< Tuesday */
  245. #define LL_RTC_WEEKDAY_WEDNESDAY (uint8_t)0x03 /*!< Wednesday */
  246. #define LL_RTC_WEEKDAY_THURSDAY (uint8_t)0x04 /*!< Thrusday */
  247. #define LL_RTC_WEEKDAY_FRIDAY (uint8_t)0x05 /*!< Friday */
  248. #define LL_RTC_WEEKDAY_SATURDAY (uint8_t)0x06 /*!< Saturday */
  249. #define LL_RTC_WEEKDAY_SUNDAY (uint8_t)0x07 /*!< Sunday */
  250. /**
  251. * @}
  252. */
  253. /** @defgroup RTC_LL_EC_MONTH MONTH
  254. * @{
  255. */
  256. #define LL_RTC_MONTH_JANUARY (uint8_t)0x01 /*!< January */
  257. #define LL_RTC_MONTH_FEBRUARY (uint8_t)0x02 /*!< February */
  258. #define LL_RTC_MONTH_MARCH (uint8_t)0x03 /*!< March */
  259. #define LL_RTC_MONTH_APRIL (uint8_t)0x04 /*!< April */
  260. #define LL_RTC_MONTH_MAY (uint8_t)0x05 /*!< May */
  261. #define LL_RTC_MONTH_JUNE (uint8_t)0x06 /*!< June */
  262. #define LL_RTC_MONTH_JULY (uint8_t)0x07 /*!< July */
  263. #define LL_RTC_MONTH_AUGUST (uint8_t)0x08 /*!< August */
  264. #define LL_RTC_MONTH_SEPTEMBER (uint8_t)0x09 /*!< September */
  265. #define LL_RTC_MONTH_OCTOBER (uint8_t)0x10 /*!< October */
  266. #define LL_RTC_MONTH_NOVEMBER (uint8_t)0x11 /*!< November */
  267. #define LL_RTC_MONTH_DECEMBER (uint8_t)0x12 /*!< December */
  268. /**
  269. * @}
  270. */
  271. /** @defgroup RTC_LL_EC_HOURFORMAT HOUR FORMAT
  272. * @{
  273. */
  274. #define LL_RTC_HOURFORMAT_24HOUR 0x00000000U /*!< 24 hour/day format */
  275. #define LL_RTC_HOURFORMAT_AMPM RTC_CR_FMT /*!< AM/PM hour format */
  276. /**
  277. * @}
  278. */
  279. /** @defgroup RTC_LL_EC_ALARMOUT ALARM OUTPUT
  280. * @{
  281. */
  282. #define LL_RTC_ALARMOUT_DISABLE 0x00000000U /*!< Output disabled */
  283. #define LL_RTC_ALARMOUT_ALMA RTC_CR_OSEL_0 /*!< Alarm A output enabled */
  284. #define LL_RTC_ALARMOUT_ALMB RTC_CR_OSEL_1 /*!< Alarm B output enabled */
  285. #define LL_RTC_ALARMOUT_WAKEUP RTC_CR_OSEL /*!< Wakeup output enabled */
  286. /**
  287. * @}
  288. */
  289. /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE ALARM OUTPUT TYPE
  290. * @{
  291. */
  292. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  293. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE /*!< RTC_ALARM is open-drain output */
  294. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL 0x00000000U /*!< RTC_ALARM is push-pull output */
  295. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  296. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN 0x00000000U /*!< RTC_ALARM is open-drain output */
  297. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL RTC_OR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
  298. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  299. /**
  300. * @}
  301. */
  302. /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN OUTPUT POLARITY PIN
  303. * @{
  304. */
  305. #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH 0x00000000U /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
  306. #define LL_RTC_OUTPUTPOLARITY_PIN_LOW RTC_CR_POL /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
  307. /**
  308. * @}
  309. */
  310. /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
  311. * @{
  312. */
  313. #define LL_RTC_TIME_FORMAT_AM_OR_24 0x00000000U /*!< AM or 24-hour format */
  314. #define LL_RTC_TIME_FORMAT_PM RTC_TR_PM /*!< PM */
  315. /**
  316. * @}
  317. */
  318. /** @defgroup RTC_LL_EC_SHIFT_SECOND SHIFT SECOND
  319. * @{
  320. */
  321. #define LL_RTC_SHIFT_SECOND_DELAY 0x00000000U /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
  322. #define LL_RTC_SHIFT_SECOND_ADVANCE RTC_SHIFTR_ADD1S /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
  323. /**
  324. * @}
  325. */
  326. /** @defgroup RTC_LL_EC_ALMA_MASK ALARMA MASK
  327. * @{
  328. */
  329. #define LL_RTC_ALMA_MASK_NONE 0x00000000U /*!< No masks applied on Alarm A*/
  330. #define LL_RTC_ALMA_MASK_DATEWEEKDAY RTC_ALRMAR_MSK4 /*!< Date/day do not care in Alarm A comparison */
  331. #define LL_RTC_ALMA_MASK_HOURS RTC_ALRMAR_MSK3 /*!< Hours do not care in Alarm A comparison */
  332. #define LL_RTC_ALMA_MASK_MINUTES RTC_ALRMAR_MSK2 /*!< Minutes do not care in Alarm A comparison */
  333. #define LL_RTC_ALMA_MASK_SECONDS RTC_ALRMAR_MSK1 /*!< Seconds do not care in Alarm A comparison */
  334. #define LL_RTC_ALMA_MASK_ALL (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
  335. /**
  336. * @}
  337. */
  338. /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT ALARMA TIME FORMAT
  339. * @{
  340. */
  341. #define LL_RTC_ALMA_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  342. #define LL_RTC_ALMA_TIME_FORMAT_PM RTC_ALRMAR_PM /*!< PM */
  343. /**
  344. * @}
  345. */
  346. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  347. /** @defgroup RTC_ALMA_SUBSECONDBIN_AUTOCLR RTCEx_AlarmA_Sub_Seconds_binary_Clear_Definitions RTC Alarm Sub Seconds with binary mode auto clear Definitions
  348. * @{
  349. */
  350. #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO 0UL /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
  351. #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES RTC_ALRMASSR_SSCLR /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to
  352. RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF
  353. when reaching RTC_ALRMABINR -> SS[31:0]. */
  354. /**
  355. * @}
  356. */
  357. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  358. /** @defgroup RTC_LL_EC_ALMB_MASK ALARMB MASK
  359. * @{
  360. */
  361. #define LL_RTC_ALMB_MASK_NONE 0x00000000U /*!< No masks applied on Alarm B*/
  362. #define LL_RTC_ALMB_MASK_DATEWEEKDAY RTC_ALRMBR_MSK4 /*!< Date/day do not care in Alarm B comparison */
  363. #define LL_RTC_ALMB_MASK_HOURS RTC_ALRMBR_MSK3 /*!< Hours do not care in Alarm B comparison */
  364. #define LL_RTC_ALMB_MASK_MINUTES RTC_ALRMBR_MSK2 /*!< Minutes do not care in Alarm B comparison */
  365. #define LL_RTC_ALMB_MASK_SECONDS RTC_ALRMBR_MSK1 /*!< Seconds do not care in Alarm B comparison */
  366. #define LL_RTC_ALMB_MASK_ALL (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
  367. /**
  368. * @}
  369. */
  370. /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT ALARMB TIME FORMAT
  371. * @{
  372. */
  373. #define LL_RTC_ALMB_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  374. #define LL_RTC_ALMB_TIME_FORMAT_PM RTC_ALRMBR_PM /*!< PM */
  375. /**
  376. * @}
  377. */
  378. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  379. /** @defgroup RTC_ALMB_SUBSECONDBIN_AUTOCLR RTCEx_AlarmB_Sub_Seconds_binary_Clear_Definitions RTC Alarm Sub Seconds with binary mode auto clear Definitions
  380. * @{
  381. */
  382. #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO 0UL /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
  383. #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES RTC_ALRMBSSR_SSCLR /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to
  384. RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF
  385. when reaching RTC_ALRMABINR -> SS[31:0]. */
  386. /**
  387. * @}
  388. */
  389. /** @defgroup RTC_ALMB_FLAG_AUTOCLR RTCEx_Alarm_Flag_Clear_Definitions RTC Alarm Flag auto clear Definitions
  390. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  391. * @{
  392. */
  393. #define LL_RTC_ALMB_FLAG_AUTOCLR_NO 0UL /*!< */
  394. #define LL_RTC_ALMB_FLAG_AUTOCLR_YES RTC_CR_ALRBMSK /*!< */
  395. /**
  396. * @}
  397. */
  398. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  399. /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE TIMESTAMP EDGE
  400. * @{
  401. */
  402. #define LL_RTC_TIMESTAMP_EDGE_RISING 0x00000000U /*!< RTC_TS input rising edge generates a time-stamp event */
  403. #define LL_RTC_TIMESTAMP_EDGE_FALLING RTC_CR_TSEDGE /*!< RTC_TS input falling edge generates a time-stamp even */
  404. /**
  405. * @}
  406. */
  407. /** @defgroup RTC_LL_EC_TS_TIME_FORMAT TIMESTAMP TIME FORMAT
  408. * @{
  409. */
  410. #define LL_RTC_TS_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  411. #define LL_RTC_TS_TIME_FORMAT_PM RTC_TSTR_PM /*!< PM */
  412. /**
  413. * @}
  414. */
  415. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  416. /** @defgroup RTC_LL_EC_TAMPER TAMPER
  417. * @{
  418. */
  419. #define LL_RTC_TAMPER_1 TAMP_CR1_TAMP1E /*!< Tamper 1 input detection */
  420. #define LL_RTC_TAMPER_2 TAMP_CR1_TAMP2E /*!< Tamper 2 input detection */
  421. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  422. #define LL_RTC_TAMPER_3 TAMP_CR1_TAMP3E /*!< Tamper 3 input detection */
  423. #endif
  424. /**
  425. * @}
  426. */
  427. /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
  428. * @{
  429. */
  430. #define LL_RTC_TAMPER_MASK_TAMPER1 TAMP_CR2_TAMP1MSK /*!< Tamper 1 event generates a trigger event. TAMP1F is masked and internally cleared by hardware.The backup registers are not erased */
  431. #define LL_RTC_TAMPER_MASK_TAMPER2 TAMP_CR2_TAMP2MSK /*!< Tamper 2 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
  432. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  433. #define LL_RTC_TAMPER_MASK_TAMPER3 TAMP_CR2_TAMP3MSK /*!< Tamper 3 event generates a trigger event. TAMP3F is masked and internally cleared by hardware. The backup registers are not erased. */
  434. #endif
  435. /**
  436. * @}
  437. */
  438. /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
  439. * @{
  440. */
  441. #define LL_RTC_TAMPER_NOERASE_TAMPER1 TAMP_CR2_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
  442. #define LL_RTC_TAMPER_NOERASE_TAMPER2 TAMP_CR2_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
  443. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  444. #define LL_RTC_TAMPER_NOERASE_TAMPER3 TAMP_CR2_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
  445. #endif
  446. /**
  447. * @}
  448. */
  449. /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
  450. * @{
  451. */
  452. #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
  453. #define LL_RTC_TAMPER_DURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  454. #define LL_RTC_TAMPER_DURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  455. #define LL_RTC_TAMPER_DURATION_8RTCCLK TAMP_FLTCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  456. /**
  457. * @}
  458. */
  459. /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
  460. * @{
  461. */
  462. #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  463. #define LL_RTC_TAMPER_FILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
  464. #define LL_RTC_TAMPER_FILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
  465. #define LL_RTC_TAMPER_FILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
  466. /**
  467. * @}
  468. */
  469. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
  470. * @{
  471. */
  472. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
  473. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
  474. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
  475. #define LL_RTC_TAMPER_SAMPLFREQDIV_4096 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 */
  476. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
  477. #define LL_RTC_TAMPER_SAMPLFREQDIV_1024 (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 */
  478. #define LL_RTC_TAMPER_SAMPLFREQDIV_512 (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 512 */
  479. #define LL_RTC_TAMPER_SAMPLFREQDIV_256 TAMP_FLTCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
  480. /**
  481. * @}
  482. */
  483. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
  484. * @{
  485. */
  486. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 TAMP_CR2_TAMP1TRG /*!< Tamper 1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  487. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 TAMP_CR2_TAMP2TRG /*!< Tamper 2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  488. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  489. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 TAMP_CR2_TAMP3TRG /*!< Tamper 3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  490. #endif
  491. /**
  492. * @}
  493. */
  494. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  495. /** @defgroup RTC_LL_EC_TAMPER TAMPER
  496. * @{
  497. */
  498. #if defined(RTC_TAMPER1_SUPPORT)
  499. #define LL_RTC_TAMPER_1 RTC_TAMPCR_TAMP1E /*!< RTC_TAMP1 input detection */
  500. #endif /* RTC_TAMPER1_SUPPORT */
  501. #if defined(RTC_TAMPER2_SUPPORT)
  502. #define LL_RTC_TAMPER_2 RTC_TAMPCR_TAMP2E /*!< RTC_TAMP2 input detection */
  503. #endif /* RTC_TAMPER2_SUPPORT */
  504. #if defined(RTC_TAMPER3_SUPPORT)
  505. #define LL_RTC_TAMPER_3 RTC_TAMPCR_TAMP3E /*!< RTC_TAMP3 input detection */
  506. #endif /* RTC_TAMPER3_SUPPORT */
  507. /**
  508. * @}
  509. */
  510. /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
  511. * @{
  512. */
  513. #if defined(RTC_TAMPER1_SUPPORT)
  514. #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 */
  515. #endif /* RTC_TAMPER1_SUPPORT */
  516. #if defined(RTC_TAMPER2_SUPPORT)
  517. #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. */
  518. #endif /* RTC_TAMPER2_SUPPORT */
  519. #if defined(RTC_TAMPER3_SUPPORT)
  520. #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 */
  521. #endif /* RTC_TAMPER3_SUPPORT */
  522. /**
  523. * @}
  524. */
  525. /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
  526. * @{
  527. */
  528. #if defined(RTC_TAMPER1_SUPPORT)
  529. #define LL_RTC_TAMPER_NOERASE_TAMPER1 RTC_TAMPCR_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
  530. #endif /* RTC_TAMPER1_SUPPORT */
  531. #if defined(RTC_TAMPER2_SUPPORT)
  532. #define LL_RTC_TAMPER_NOERASE_TAMPER2 RTC_TAMPCR_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
  533. #endif /* RTC_TAMPER2_SUPPORT */
  534. #if defined(RTC_TAMPER3_SUPPORT)
  535. #define LL_RTC_TAMPER_NOERASE_TAMPER3 RTC_TAMPCR_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
  536. #endif /* RTC_TAMPER3_SUPPORT */
  537. /**
  538. * @}
  539. */
  540. #if defined(RTC_TAMPCR_TAMPPRCH)
  541. /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
  542. * @{
  543. */
  544. #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
  545. #define LL_RTC_TAMPER_DURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  546. #define LL_RTC_TAMPER_DURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  547. #define LL_RTC_TAMPER_DURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  548. /**
  549. * @}
  550. */
  551. #endif /* RTC_TAMPCR_TAMPPRCH */
  552. #if defined(RTC_TAMPCR_TAMPFLT)
  553. /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
  554. * @{
  555. */
  556. #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  557. #define LL_RTC_TAMPER_FILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
  558. #define LL_RTC_TAMPER_FILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
  559. #define LL_RTC_TAMPER_FILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
  560. /**
  561. * @}
  562. */
  563. #endif /* RTC_TAMPCR_TAMPFLT */
  564. #if defined(RTC_TAMPCR_TAMPFREQ)
  565. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
  566. * @{
  567. */
  568. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
  569. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
  570. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
  571. #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 */
  572. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
  573. #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 */
  574. #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 */
  575. #define LL_RTC_TAMPER_SAMPLFREQDIV_256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
  576. /**
  577. * @}
  578. */
  579. #endif /* RTC_TAMPCR_TAMPFREQ */
  580. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
  581. * @{
  582. */
  583. #if defined(RTC_TAMPER1_SUPPORT)
  584. #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*/
  585. #endif /* RTC_TAMPER1_SUPPORT */
  586. #if defined(RTC_TAMPER2_SUPPORT)
  587. #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*/
  588. #endif /* RTC_TAMPER2_SUPPORT */
  589. #if defined(RTC_TAMPER3_SUPPORT)
  590. #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*/
  591. #endif /* RTC_TAMPER3_SUPPORT */
  592. /**
  593. * @}
  594. */
  595. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  596. /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV WAKEUP CLOCK DIV
  597. * @{
  598. */
  599. #define LL_RTC_WAKEUPCLOCK_DIV_16 0x00000000U /*!< RTC/16 clock is selected */
  600. #define LL_RTC_WAKEUPCLOCK_DIV_8 RTC_CR_WUCKSEL_0 /*!< RTC/8 clock is selected */
  601. #define LL_RTC_WAKEUPCLOCK_DIV_4 RTC_CR_WUCKSEL_1 /*!< RTC/4 clock is selected */
  602. #define LL_RTC_WAKEUPCLOCK_DIV_2 (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
  603. #define LL_RTC_WAKEUPCLOCK_CKSPRE RTC_CR_WUCKSEL_2 /*!< ck_spre (usually 1 Hz) clock is selected */
  604. #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*/
  605. /**
  606. * @}
  607. */
  608. #if defined(RTC_BACKUP_SUPPORT)
  609. /** @defgroup RTC_LL_EC_BKP BACKUP
  610. * @{
  611. */
  612. #define LL_RTC_BKP_DR0 0x00000000U
  613. #define LL_RTC_BKP_DR1 0x00000001U
  614. #define LL_RTC_BKP_DR2 0x00000002U
  615. #define LL_RTC_BKP_DR3 0x00000003U
  616. #define LL_RTC_BKP_DR4 0x00000004U
  617. #if RTC_BKP_NUMBER > 5
  618. #define LL_RTC_BKP_DR5 0x00000005U
  619. #define LL_RTC_BKP_DR6 0x00000006U
  620. #define LL_RTC_BKP_DR7 0x00000007U
  621. #define LL_RTC_BKP_DR8 0x00000008U
  622. #define LL_RTC_BKP_DR9 0x00000009U
  623. #define LL_RTC_BKP_DR10 0x0000000AU
  624. #define LL_RTC_BKP_DR11 0x0000000BU
  625. #define LL_RTC_BKP_DR12 0x0000000CU
  626. #define LL_RTC_BKP_DR13 0x0000000DU
  627. #define LL_RTC_BKP_DR14 0x0000000EU
  628. #define LL_RTC_BKP_DR15 0x0000000FU
  629. #endif /* RTC_BKP_NUMBER > 5 */
  630. #if RTC_BKP_NUMBER > 16
  631. #define LL_RTC_BKP_DR16 0x00000010U
  632. #define LL_RTC_BKP_DR17 0x00000011U
  633. #define LL_RTC_BKP_DR18 0x00000012U
  634. #define LL_RTC_BKP_DR19 0x00000013U
  635. #endif /* RTC_BKP_NUMBER > 16 */
  636. #if RTC_BKP_NUMBER > 20
  637. #define LL_RTC_BKP_DR20 0x00000014U
  638. #define LL_RTC_BKP_DR21 0x00000015U
  639. #define LL_RTC_BKP_DR22 0x00000016U
  640. #define LL_RTC_BKP_DR23 0x00000017U
  641. #define LL_RTC_BKP_DR24 0x00000018U
  642. #define LL_RTC_BKP_DR25 0x00000019U
  643. #define LL_RTC_BKP_DR26 0x0000001AU
  644. #define LL_RTC_BKP_DR27 0x0000001BU
  645. #define LL_RTC_BKP_DR28 0x0000001CU
  646. #define LL_RTC_BKP_DR29 0x0000001DU
  647. #define LL_RTC_BKP_DR30 0x0000001EU
  648. #define LL_RTC_BKP_DR31 0x0000001FU
  649. #endif /* RTC_BKP_NUMBER > 20 */
  650. /**
  651. * @}
  652. */
  653. #endif /* RTC_BACKUP_SUPPORT */
  654. /** @defgroup RTC_LL_EC_CALIB_OUTPUT Calibration output
  655. * @{
  656. */
  657. #define LL_RTC_CALIB_OUTPUT_NONE 0x00000000U /*!< Calibration output disabled */
  658. #define LL_RTC_CALIB_OUTPUT_1HZ (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
  659. #define LL_RTC_CALIB_OUTPUT_512HZ RTC_CR_COE /*!< Calibration output is 512 Hz */
  660. /**
  661. * @}
  662. */
  663. /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE Calibration pulse insertion
  664. * @{
  665. */
  666. #define LL_RTC_CALIB_INSERTPULSE_NONE 0x00000000U /*!< No RTCCLK pulses are added */
  667. #define LL_RTC_CALIB_INSERTPULSE_SET RTC_CALR_CALP /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
  668. /**
  669. * @}
  670. */
  671. /** @defgroup RTC_LL_EC_CALIB_PERIOD Calibration period
  672. * @{
  673. */
  674. #define LL_RTC_CALIB_PERIOD_32SEC 0x00000000U /*!< Use a 32-second calibration cycle period */
  675. #define LL_RTC_CALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< Use a 16-second calibration cycle period */
  676. #define LL_RTC_CALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< Use a 8-second calibration cycle period */
  677. /**
  678. * @}
  679. */
  680. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  681. /** @defgroup RTC_LL_EC_CALIB_LOWPOWER Calibration low power
  682. * @{
  683. */
  684. #define LL_RTC_CALIB_LOWPOWER_NONE 0x00000000U /*!< High conso mode */
  685. #define LL_RTC_CALIB_LOWPOWER_SET RTC_CALR_LPCAL /*!< low power mode */
  686. /**
  687. * @}
  688. */
  689. /** @defgroup RTC_LL_EC_BINARY_MODE Binary mode (Sub Second Register)
  690. * @{
  691. */
  692. #define LL_RTC_BINARY_NONE 0x00000000U /*!< Free running BCD calendar mode (Binary mode disabled). */
  693. #define LL_RTC_BINARY_ONLY RTC_ICSR_BIN_0 /*!< Free running Binary mode (BCD mode disabled) */
  694. #define LL_RTC_BINARY_MIX RTC_ICSR_BIN_1 /*!< Free running BCD calendar and Binary mode enable */
  695. /**
  696. * @}
  697. */
  698. /** @defgroup RTC_LL_EC_BINARY_MIX_BCDU Calendar second incrementation in Binary mix mode
  699. * @{
  700. */
  701. #define LL_RTC_BINARY_MIX_BCDU_0 0x00000000u /*!< 1s calendar increment is generated each time SS[7:0] = 0 */
  702. #define LL_RTC_BINARY_MIX_BCDU_1 (0x1UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[8:0] = 0 */
  703. #define LL_RTC_BINARY_MIX_BCDU_2 (0x2UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[9:0] = 0 */
  704. #define LL_RTC_BINARY_MIX_BCDU_3 (0x3UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[10:0] = 0 */
  705. #define LL_RTC_BINARY_MIX_BCDU_4 (0x4UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[11:0] = 0 */
  706. #define LL_RTC_BINARY_MIX_BCDU_5 (0x5UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[12:0] = 0 */
  707. #define LL_RTC_BINARY_MIX_BCDU_6 (0x6UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[13:0] = 0 */
  708. #define LL_RTC_BINARY_MIX_BCDU_7 (0x7UL << RTC_ICSR_BCDU_Pos) /*!< 1s calendar increment is generated each time SS[14:0] = 0 */
  709. /**
  710. * @}
  711. */
  712. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  713. /**
  714. * @}
  715. */
  716. /* Exported macro ------------------------------------------------------------*/
  717. /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
  718. * @{
  719. */
  720. /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
  721. * @{
  722. */
  723. /**
  724. * @brief Write a value in RTC register
  725. * @param __INSTANCE__ RTC Instance
  726. * @param __REG__ Register to be written
  727. * @param __VALUE__ Value to be written in the register
  728. * @retval None
  729. */
  730. #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  731. /**
  732. * @brief Read a value in RTC register
  733. * @param __INSTANCE__ RTC Instance
  734. * @param __REG__ Register to be read
  735. * @retval Register value
  736. */
  737. #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  738. /**
  739. * @}
  740. */
  741. /** @defgroup RTC_LL_EM_Convert Convert helper Macros
  742. * @{
  743. */
  744. /**
  745. * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
  746. * @param __VALUE__ Byte to be converted
  747. * @retval Converted byte
  748. */
  749. #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
  750. /**
  751. * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
  752. * @param __VALUE__ BCD value to be converted
  753. * @retval Converted byte
  754. */
  755. #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
  756. /**
  757. * @}
  758. */
  759. /** @defgroup RTC_LL_EM_Date Date helper Macros
  760. * @{
  761. */
  762. /**
  763. * @brief Helper macro to retrieve weekday.
  764. * @param __RTC_DATE__ Date returned by @ref LL_RTC_DATE_Get function.
  765. * @retval Returned value can be one of the following values:
  766. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  767. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  768. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  769. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  770. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  771. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  772. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  773. */
  774. #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
  775. /**
  776. * @brief Helper macro to retrieve Year in BCD format
  777. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  778. * @retval Year in BCD format (0x00 . . . 0x99)
  779. */
  780. #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
  781. /**
  782. * @brief Helper macro to retrieve Month in BCD format
  783. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  784. * @retval Returned value can be one of the following values:
  785. * @arg @ref LL_RTC_MONTH_JANUARY
  786. * @arg @ref LL_RTC_MONTH_FEBRUARY
  787. * @arg @ref LL_RTC_MONTH_MARCH
  788. * @arg @ref LL_RTC_MONTH_APRIL
  789. * @arg @ref LL_RTC_MONTH_MAY
  790. * @arg @ref LL_RTC_MONTH_JUNE
  791. * @arg @ref LL_RTC_MONTH_JULY
  792. * @arg @ref LL_RTC_MONTH_AUGUST
  793. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  794. * @arg @ref LL_RTC_MONTH_OCTOBER
  795. * @arg @ref LL_RTC_MONTH_NOVEMBER
  796. * @arg @ref LL_RTC_MONTH_DECEMBER
  797. */
  798. #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
  799. /**
  800. * @brief Helper macro to retrieve Day in BCD format
  801. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  802. * @retval Day in BCD format (0x01 . . . 0x31)
  803. */
  804. #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
  805. /**
  806. * @}
  807. */
  808. /** @defgroup RTC_LL_EM_Time Time helper Macros
  809. * @{
  810. */
  811. /**
  812. * @brief Helper macro to retrieve hour in BCD format
  813. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  814. * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
  815. */
  816. #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
  817. /**
  818. * @brief Helper macro to retrieve minute in BCD format
  819. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  820. * @retval Minutes in BCD format (0x00. . .0x59)
  821. */
  822. #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
  823. /**
  824. * @brief Helper macro to retrieve second in BCD format
  825. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  826. * @retval Seconds in format (0x00. . .0x59)
  827. */
  828. #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
  829. /**
  830. * @}
  831. */
  832. /**
  833. * @}
  834. */
  835. /* Exported functions --------------------------------------------------------*/
  836. /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
  837. * @{
  838. */
  839. /** @defgroup RTC_LL_EF_Configuration Configuration
  840. * @{
  841. */
  842. /**
  843. * @brief Set Hours format (24 hour/day or AM/PM hour format)
  844. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  845. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  846. * @rmtoll RTC_CR FMT LL_RTC_SetHourFormat
  847. * @param RTCx RTC Instance
  848. * @param HourFormat This parameter can be one of the following values:
  849. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  850. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  851. * @retval None
  852. */
  853. __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
  854. {
  855. MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
  856. }
  857. /**
  858. * @brief Get Hours format (24 hour/day or AM/PM hour format)
  859. * @rmtoll RTC_CR FMT LL_RTC_GetHourFormat
  860. * @param RTCx RTC Instance
  861. * @retval Returned value can be one of the following values:
  862. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  863. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  864. */
  865. __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
  866. {
  867. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
  868. }
  869. /**
  870. * @brief Select the flag to be routed to RTC_ALARM output
  871. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  872. * @rmtoll RTC_CR OSEL LL_RTC_SetAlarmOutEvent
  873. * @param RTCx RTC Instance
  874. * @param AlarmOutput This parameter can be one of the following values:
  875. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  876. * @arg @ref LL_RTC_ALARMOUT_ALMA
  877. * @arg @ref LL_RTC_ALARMOUT_ALMB
  878. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  879. * @retval None
  880. */
  881. __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
  882. {
  883. MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
  884. }
  885. /**
  886. * @brief Get the flag to be routed to RTC_ALARM output
  887. * @rmtoll RTC_CR OSEL LL_RTC_GetAlarmOutEvent
  888. * @param RTCx RTC Instance
  889. * @retval Returned value can be one of the following values:
  890. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  891. * @arg @ref LL_RTC_ALARMOUT_ALMA
  892. * @arg @ref LL_RTC_ALARMOUT_ALMB
  893. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  894. */
  895. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
  896. {
  897. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
  898. }
  899. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  900. /**
  901. * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  902. * @rmtoll RTC_CR TAMPALRM_TYPE LL_RTC_SetAlarmOutputType
  903. * @param RTCx RTC Instance
  904. * @param Output This parameter can be one of the following values:
  905. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  906. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  907. * @retval None
  908. */
  909. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  910. {
  911. MODIFY_REG(RTCx->CR, RTC_CR_TAMPALRM_TYPE, Output);
  912. }
  913. /**
  914. * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  915. * @rmtoll RTC_CR TAMPALRM_TYPE LL_RTC_SetAlarmOutputType
  916. * @param RTCx RTC Instance
  917. * @retval Returned value can be one of the following values:
  918. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  919. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  920. */
  921. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  922. {
  923. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_TYPE));
  924. }
  925. /**
  926. * @brief Enable initialization mode
  927. * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  928. * and prescaler register (RTC_PRER).
  929. * Counters are stopped and start counting from the new value when INIT is reset.
  930. * @rmtoll RTC_ICSR INIT LL_RTC_EnableInitMode
  931. * @param RTCx RTC Instance
  932. * @retval None
  933. */
  934. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  935. {
  936. /* Set the Initialization mode */
  937. SET_BIT(RTCx->ICSR, RTC_ICSR_INIT);
  938. }
  939. /**
  940. * @brief Disable initialization mode (Free running mode)
  941. * @rmtoll RTC_ICSR INIT LL_RTC_DisableInitMode
  942. * @param RTCx RTC Instance
  943. * @retval None
  944. */
  945. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  946. {
  947. /* Exit Initialization mode */
  948. CLEAR_BIT(RTCx->ICSR, RTC_ICSR_INIT);
  949. }
  950. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  951. /**
  952. * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  953. * @note Used only when RTC_ALARM is mapped on PC13
  954. * @rmtoll OR ALARMOUTTYPE LL_RTC_SetAlarmOutputType
  955. * @param RTCx RTC Instance
  956. * @param Output This parameter can be one of the following values:
  957. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  958. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  959. * @retval None
  960. */
  961. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  962. {
  963. MODIFY_REG(RTCx->OR, RTC_OR_ALARMOUTTYPE, Output);
  964. }
  965. /**
  966. * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  967. * @note used only when RTC_ALARM is mapped on PC13
  968. * @rmtoll OR ALARMOUTTYPE LL_RTC_GetAlarmOutputType
  969. * @param RTCx RTC Instance
  970. * @retval Returned value can be one of the following values:
  971. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  972. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  973. */
  974. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  975. {
  976. return (uint32_t)(READ_BIT(RTCx->OR, RTC_OR_ALARMOUTTYPE));
  977. }
  978. /**
  979. * @brief Enable initialization mode
  980. * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  981. * and prescaler register (RTC_PRER).
  982. * Counters are stopped and start counting from the new value when INIT is reset.
  983. * @rmtoll ISR INIT LL_RTC_EnableInitMode
  984. * @param RTCx RTC Instance
  985. * @retval None
  986. */
  987. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  988. {
  989. /* Set the Initialization mode */
  990. WRITE_REG(RTCx->ISR, RTC_LL_INIT_MASK);
  991. }
  992. /**
  993. * @brief Disable initialization mode (Free running mode)
  994. * @rmtoll ISR INIT LL_RTC_DisableInitMode
  995. * @param RTCx RTC Instance
  996. * @retval None
  997. */
  998. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  999. {
  1000. /* Exit Initialization mode */
  1001. WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
  1002. }
  1003. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1004. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1005. /**
  1006. * @brief Set Binary mode (Sub Second Register)
  1007. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1008. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
  1009. * @rmtoll RTC_ICSR BIN LL_RTC_SetBinaryMode
  1010. * @param RTCx RTC Instance
  1011. * @param BinaryMode can be one of the following values:
  1012. * @arg @ref LL_RTC_BINARY_NONE
  1013. * @arg @ref LL_RTC_BINARY_ONLY
  1014. * @arg @ref LL_RTC_BINARY_BINARY_MIX
  1015. * @retval None
  1016. */
  1017. __STATIC_INLINE void LL_RTC_SetBinaryMode(RTC_TypeDef *RTCx, uint32_t BinaryMode)
  1018. {
  1019. MODIFY_REG(RTCx->ICSR, RTC_ICSR_BIN, BinaryMode);
  1020. }
  1021. /**
  1022. * @brief Get Binary mode (Sub Second Register)
  1023. * @rmtoll RTC_ICSR BIN LL_RTC_GetBinaryMode
  1024. * @param RTCx RTC Instance
  1025. * @retval This parameter can be one of the following values:
  1026. * @arg @ref LL_RTC_BINARY_NONE
  1027. * @arg @ref LL_RTC_BINARY_ONLY
  1028. * @arg @ref LL_RTC_BINARY_BINARY_MIX
  1029. * @retval None
  1030. */
  1031. __STATIC_INLINE uint32_t LL_RTC_GetBinaryMode(RTC_TypeDef *RTCx)
  1032. {
  1033. return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BIN));
  1034. }
  1035. /**
  1036. * @brief Set Binary Mix mode BCDU
  1037. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1038. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
  1039. * @rmtoll RTC_ICSR BCDU LL_RTC_SetBinMixBCDU
  1040. * @param RTCx RTC Instance
  1041. * @param BinMixBcdU can be one of the following values:
  1042. * @arg @ref LL_RTC_BINARY_MIX_BCDU_0
  1043. * @arg @ref LL_RTC_BINARY_MIX_BCDU_1
  1044. * @arg @ref LL_RTC_BINARY_MIX_BCDU_2
  1045. * @arg @ref LL_RTC_BINARY_MIX_BCDU_3
  1046. * @arg @ref LL_RTC_BINARY_MIX_BCDU_4
  1047. * @arg @ref LL_RTC_BINARY_MIX_BCDU_5
  1048. * @arg @ref LL_RTC_BINARY_MIX_BCDU_6
  1049. * @arg @ref LL_RTC_BINARY_MIX_BCDU_7
  1050. * @retval None
  1051. */
  1052. __STATIC_INLINE void LL_RTC_SetBinMixBCDU(RTC_TypeDef *RTCx, uint32_t BinMixBcdU)
  1053. {
  1054. MODIFY_REG(RTCx->ICSR, RTC_ICSR_BCDU, BinMixBcdU);
  1055. }
  1056. /**
  1057. * @brief Get Binary Mix mode BCDU
  1058. * @rmtoll RTC_ICSR BCDU LL_RTC_GetBinMixBCDU
  1059. * @param RTCx RTC Instance
  1060. * @retval This parameter can be one of the following values:
  1061. * @arg @ref LL_RTC_BINARY_MIX_BCDU_0
  1062. * @arg @ref LL_RTC_BINARY_MIX_BCDU_1
  1063. * @arg @ref LL_RTC_BINARY_MIX_BCDU_2
  1064. * @arg @ref LL_RTC_BINARY_MIX_BCDU_3
  1065. * @arg @ref LL_RTC_BINARY_MIX_BCDU_4
  1066. * @arg @ref LL_RTC_BINARY_MIX_BCDU_5
  1067. * @arg @ref LL_RTC_BINARY_MIX_BCDU_6
  1068. * @arg @ref LL_RTC_BINARY_MIX_BCDU_7
  1069. * @retval None
  1070. */
  1071. __STATIC_INLINE uint32_t LL_RTC_GetBinMixBCDU(RTC_TypeDef *RTCx)
  1072. {
  1073. return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BCDU));
  1074. }
  1075. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1076. /**
  1077. * @brief Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
  1078. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1079. * @rmtoll RTC_CR POL LL_RTC_SetOutputPolarity
  1080. * @param RTCx RTC Instance
  1081. * @param Polarity This parameter can be one of the following values:
  1082. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  1083. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  1084. * @retval None
  1085. */
  1086. __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
  1087. {
  1088. MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
  1089. }
  1090. /**
  1091. * @brief Get Output polarity
  1092. * @rmtoll RTC_CR POL LL_RTC_GetOutputPolarity
  1093. * @param RTCx RTC Instance
  1094. * @retval Returned value can be one of the following values:
  1095. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  1096. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  1097. */
  1098. __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
  1099. {
  1100. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
  1101. }
  1102. /**
  1103. * @brief Enable Bypass the shadow registers
  1104. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1105. * @rmtoll RTC_CR BYPSHAD LL_RTC_EnableShadowRegBypass
  1106. * @param RTCx RTC Instance
  1107. * @retval None
  1108. */
  1109. __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
  1110. {
  1111. SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  1112. }
  1113. /**
  1114. * @brief Disable Bypass the shadow registers
  1115. * @rmtoll RTC_CR BYPSHAD LL_RTC_DisableShadowRegBypass
  1116. * @param RTCx RTC Instance
  1117. * @retval None
  1118. */
  1119. __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
  1120. {
  1121. CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  1122. }
  1123. /**
  1124. * @brief Check if Shadow registers bypass is enabled or not.
  1125. * @rmtoll RTC_CR BYPSHAD LL_RTC_IsShadowRegBypassEnabled
  1126. * @param RTCx RTC Instance
  1127. * @retval State of bit (1 or 0).
  1128. */
  1129. __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
  1130. {
  1131. return (READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD));
  1132. }
  1133. /**
  1134. * @brief Enable RTC_REFIN reference clock detection (50 or 60 Hz)
  1135. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1136. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1137. * @rmtoll RTC_CR REFCKON LL_RTC_EnableRefClock
  1138. * @param RTCx RTC Instance
  1139. * @retval None
  1140. */
  1141. __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
  1142. {
  1143. SET_BIT(RTCx->CR, RTC_CR_REFCKON);
  1144. }
  1145. /**
  1146. * @brief Disable RTC_REFIN reference clock detection (50 or 60 Hz)
  1147. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1148. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1149. * @rmtoll RTC_CR REFCKON LL_RTC_DisableRefClock
  1150. * @param RTCx RTC Instance
  1151. * @retval None
  1152. */
  1153. __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
  1154. {
  1155. CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
  1156. }
  1157. /**
  1158. * @brief Set Asynchronous prescaler factor
  1159. * @rmtoll RTC_PRER PREDIV_A LL_RTC_SetAsynchPrescaler
  1160. * @param RTCx RTC Instance
  1161. * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
  1162. * @retval None
  1163. */
  1164. __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
  1165. {
  1166. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
  1167. }
  1168. /**
  1169. * @brief Set Synchronous prescaler factor
  1170. * @rmtoll RTC_PRER PREDIV_S LL_RTC_SetSynchPrescaler
  1171. * @param RTCx RTC Instance
  1172. * @param SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
  1173. * @retval None
  1174. */
  1175. __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
  1176. {
  1177. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
  1178. }
  1179. /**
  1180. * @brief Get Asynchronous prescaler factor
  1181. * @rmtoll RTC_PRER PREDIV_A LL_RTC_GetAsynchPrescaler
  1182. * @param RTCx RTC Instance
  1183. * @retval Value between Min_Data = 0 and Max_Data = 0x7F
  1184. */
  1185. __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
  1186. {
  1187. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
  1188. }
  1189. /**
  1190. * @brief Get Synchronous prescaler factor
  1191. * @rmtoll RTC_PRER PREDIV_S LL_RTC_GetSynchPrescaler
  1192. * @param RTCx RTC Instance
  1193. * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
  1194. */
  1195. __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
  1196. {
  1197. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
  1198. }
  1199. /**
  1200. * @brief Enable the write protection for RTC registers.
  1201. * @rmtoll RTC_WPR KEY LL_RTC_EnableWriteProtection
  1202. * @param RTCx RTC Instance
  1203. * @retval None
  1204. */
  1205. __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
  1206. {
  1207. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
  1208. }
  1209. /**
  1210. * @brief Disable the write protection for RTC registers.
  1211. * @rmtoll RTC_WPR KEY LL_RTC_DisableWriteProtection
  1212. * @param RTCx RTC Instance
  1213. * @retval None
  1214. */
  1215. __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
  1216. {
  1217. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
  1218. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
  1219. }
  1220. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  1221. /**
  1222. * @brief Enable tamper output.
  1223. * @note When the tamper output is enabled, all external and internal tamper flags
  1224. * are ORed and routed to the TAMPALRM output.
  1225. * @rmtoll RTC_CR TAMPOE LL_RTC_EnableTamperOutput
  1226. * @param RTCx RTC Instance
  1227. * @retval None
  1228. */
  1229. __STATIC_INLINE void LL_RTC_EnableTamperOutput(RTC_TypeDef *RTCx)
  1230. {
  1231. SET_BIT(RTCx->CR, RTC_CR_TAMPOE);
  1232. }
  1233. /**
  1234. * @brief Disable tamper output.
  1235. * @rmtoll RTC_CR TAMPOE LL_RTC_DisableTamperOutput
  1236. * @param RTCx RTC Instance
  1237. * @retval None
  1238. */
  1239. __STATIC_INLINE void LL_RTC_DisableTamperOutput(RTC_TypeDef *RTCx)
  1240. {
  1241. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPOE);
  1242. }
  1243. /**
  1244. * @brief Check if tamper output is enabled or not.
  1245. * @rmtoll RTC_CR TAMPOE LL_RTC_IsTamperOutputEnabled
  1246. * @param RTCx RTC Instance
  1247. * @retval State of bit (1 or 0).
  1248. */
  1249. __STATIC_INLINE uint32_t LL_RTC_IsTamperOutputEnabled(RTC_TypeDef *RTCx)
  1250. {
  1251. return (READ_BIT(RTCx->CR, RTC_CR_TAMPOE) == (RTC_CR_TAMPOE));
  1252. }
  1253. /**
  1254. * @brief Enable internal pull-up in output mode.
  1255. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_EnableAlarmPullUp
  1256. * @param RTCx RTC Instance
  1257. * @retval None
  1258. */
  1259. __STATIC_INLINE void LL_RTC_EnableAlarmPullUp(RTC_TypeDef *RTCx)
  1260. {
  1261. SET_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
  1262. }
  1263. /**
  1264. * @brief Disable internal pull-up in output mode.
  1265. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_EnableAlarmPullUp
  1266. * @param RTCx RTC Instance
  1267. * @retval None
  1268. */
  1269. __STATIC_INLINE void LL_RTC_DisableAlarmPullUp(RTC_TypeDef *RTCx)
  1270. {
  1271. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
  1272. }
  1273. /**
  1274. * @brief Check if internal pull-up in output mode is enabled or not.
  1275. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_IsAlarmPullUpEnabled
  1276. * @param RTCx RTC Instance
  1277. * @retval State of bit (1 or 0).
  1278. */
  1279. __STATIC_INLINE uint32_t LL_RTC_IsAlarmPullUpEnabled(RTC_TypeDef *RTCx)
  1280. {
  1281. return (READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU) == (RTC_CR_TAMPALRM_PU));
  1282. }
  1283. /**
  1284. * @brief Enable RTC_OUT2 output
  1285. * @note RTC_OUT2 mapping depends on both OSEL (@ref LL_RTC_SetAlarmOutEvent)
  1286. * and COE (@ref LL_RTC_CAL_SetOutputFreq) settings.
  1287. * @note RTC_OUT2 isn't available ins VBAT mode.
  1288. * @rmtoll RTC_CR OUT2EN LL_RTC_EnableOutput2
  1289. * @param RTCx RTC Instance
  1290. * @retval None
  1291. */
  1292. __STATIC_INLINE void LL_RTC_EnableOutput2(RTC_TypeDef *RTCx)
  1293. {
  1294. SET_BIT(RTCx->CR, RTC_CR_OUT2EN);
  1295. }
  1296. /**
  1297. * @brief Disable RTC_OUT2 output
  1298. * @rmtoll RTC_CR OUT2EN LL_RTC_DisableOutput2
  1299. * @param RTCx RTC Instance
  1300. * @retval None
  1301. */
  1302. __STATIC_INLINE void LL_RTC_DisableOutput2(RTC_TypeDef *RTCx)
  1303. {
  1304. CLEAR_BIT(RTCx->CR, RTC_CR_OUT2EN);
  1305. }
  1306. /**
  1307. * @brief Check if RTC_OUT2 output is enabled or not.
  1308. * @rmtoll RTC_CR OUT2EN LL_RTC_IsOutput2Enabled
  1309. * @param RTCx RTC Instance
  1310. * @retval State of bit (1 or 0).
  1311. */
  1312. __STATIC_INLINE uint32_t LL_RTC_IsOutput2Enabled(RTC_TypeDef *RTCx)
  1313. {
  1314. return (READ_BIT(RTCx->CR, RTC_CR_OUT2EN) == (RTC_CR_OUT2EN));
  1315. }
  1316. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1317. /**
  1318. * @brief Enable RTC_OUT remap
  1319. * @rmtoll OR OUT_RMP LL_RTC_EnableOutRemap
  1320. * @param RTCx RTC Instance
  1321. * @retval None
  1322. */
  1323. __STATIC_INLINE void LL_RTC_EnableOutRemap(RTC_TypeDef *RTCx)
  1324. {
  1325. SET_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  1326. }
  1327. /**
  1328. * @brief Disable RTC_OUT remap
  1329. * @rmtoll OR OUT_RMP LL_RTC_DisableOutRemap
  1330. * @param RTCx RTC Instance
  1331. * @retval None
  1332. */
  1333. __STATIC_INLINE void LL_RTC_DisableOutRemap(RTC_TypeDef *RTCx)
  1334. {
  1335. CLEAR_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  1336. }
  1337. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  1338. /**
  1339. * @}
  1340. */
  1341. /** @defgroup RTC_LL_EF_Time Time
  1342. * @{
  1343. */
  1344. /**
  1345. * @brief Set time format (AM/24-hour or PM notation)
  1346. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1347. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1348. * @rmtoll RTC_TR PM LL_RTC_TIME_SetFormat
  1349. * @param RTCx RTC Instance
  1350. * @param TimeFormat This parameter can be one of the following values:
  1351. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1352. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1353. * @retval None
  1354. */
  1355. __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1356. {
  1357. MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
  1358. }
  1359. /**
  1360. * @brief Get time format (AM or PM notation)
  1361. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1362. * before reading this bit
  1363. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1364. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1365. * @rmtoll RTC_TR PM LL_RTC_TIME_GetFormat
  1366. * @param RTCx RTC Instance
  1367. * @retval Returned value can be one of the following values:
  1368. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1369. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1370. */
  1371. __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
  1372. {
  1373. return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
  1374. }
  1375. /**
  1376. * @brief Set Hours in BCD format
  1377. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1378. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1379. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
  1380. * @rmtoll RTC_TR HT LL_RTC_TIME_SetHour\n
  1381. * RTC_TR HU LL_RTC_TIME_SetHour
  1382. * @param RTCx RTC Instance
  1383. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1384. * @retval None
  1385. */
  1386. __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1387. {
  1388. MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
  1389. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
  1390. }
  1391. /**
  1392. * @brief Get Hours in BCD format
  1393. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1394. * before reading this bit
  1395. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1396. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1397. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
  1398. * Binary format
  1399. * @rmtoll RTC_TR HT LL_RTC_TIME_GetHour\n
  1400. * RTC_TR HU LL_RTC_TIME_GetHour
  1401. * @param RTCx RTC Instance
  1402. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1403. */
  1404. __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
  1405. {
  1406. return ((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
  1407. }
  1408. /**
  1409. * @brief Set Minutes in BCD format
  1410. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1411. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1412. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1413. * @rmtoll RTC_TR MNT LL_RTC_TIME_SetMinute\n
  1414. * RTC_TR MNU LL_RTC_TIME_SetMinute
  1415. * @param RTCx RTC Instance
  1416. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1417. * @retval None
  1418. */
  1419. __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1420. {
  1421. MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
  1422. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
  1423. }
  1424. /**
  1425. * @brief Get Minutes in BCD format
  1426. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1427. * before reading this bit
  1428. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1429. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1430. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
  1431. * to Binary format
  1432. * @rmtoll RTC_TR MNT LL_RTC_TIME_GetMinute\n
  1433. * RTC_TR MNU LL_RTC_TIME_GetMinute
  1434. * @param RTCx RTC Instance
  1435. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1436. */
  1437. __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
  1438. {
  1439. return ((READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU))) >> RTC_TR_MNU_Pos);
  1440. }
  1441. /**
  1442. * @brief Set Seconds in BCD format
  1443. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1444. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1445. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1446. * @rmtoll RTC_TR ST LL_RTC_TIME_SetSecond\n
  1447. * RTC_TR SU LL_RTC_TIME_SetSecond
  1448. * @param RTCx RTC Instance
  1449. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1450. * @retval None
  1451. */
  1452. __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1453. {
  1454. MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
  1455. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
  1456. }
  1457. /**
  1458. * @brief Get Seconds in BCD format
  1459. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1460. * before reading this bit
  1461. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1462. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1463. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
  1464. * to Binary format
  1465. * @rmtoll RTC_TR ST LL_RTC_TIME_GetSecond\n
  1466. * RTC_TR SU LL_RTC_TIME_GetSecond
  1467. * @param RTCx RTC Instance
  1468. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1469. */
  1470. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
  1471. {
  1472. return ((READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU))) >> RTC_TR_SU_Pos);
  1473. }
  1474. /**
  1475. * @brief Set time (hour, minute and second) in BCD format
  1476. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1477. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1478. * @note TimeFormat and Hours should follow the same format
  1479. * @rmtoll RTC_TR PM LL_RTC_TIME_Config\n
  1480. * RTC_TR HT LL_RTC_TIME_Config\n
  1481. * RTC_TR HU LL_RTC_TIME_Config\n
  1482. * RTC_TR MNT LL_RTC_TIME_Config\n
  1483. * RTC_TR MNU LL_RTC_TIME_Config\n
  1484. * RTC_TR ST LL_RTC_TIME_Config\n
  1485. * RTC_TR SU LL_RTC_TIME_Config
  1486. * @param RTCx RTC Instance
  1487. * @param Format12_24 This parameter can be one of the following values:
  1488. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1489. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1490. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1491. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1492. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1493. * @retval None
  1494. */
  1495. __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1496. {
  1497. uint32_t temp = 0U;
  1498. temp = Format12_24 | \
  1499. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
  1500. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
  1501. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
  1502. 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);
  1503. }
  1504. /**
  1505. * @brief Get time (hour, minute and second) in BCD format
  1506. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1507. * before reading this bit
  1508. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1509. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1510. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1511. * are available to get independently each parameter.
  1512. * @rmtoll RTC_TR HT LL_RTC_TIME_Get\n
  1513. * RTC_TR HU LL_RTC_TIME_Get\n
  1514. * RTC_TR MNT LL_RTC_TIME_Get\n
  1515. * RTC_TR MNU LL_RTC_TIME_Get\n
  1516. * RTC_TR ST LL_RTC_TIME_Get\n
  1517. * RTC_TR SU LL_RTC_TIME_Get
  1518. * @param RTCx RTC Instance
  1519. * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
  1520. */
  1521. __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
  1522. {
  1523. uint32_t temp = 0U;
  1524. temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
  1525. return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR) | \
  1526. (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
  1527. ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
  1528. }
  1529. /**
  1530. * @brief Memorize whether the daylight saving time change has been performed
  1531. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1532. * @rmtoll RTC_CR BKP LL_RTC_TIME_EnableDayLightStore
  1533. * @param RTCx RTC Instance
  1534. * @retval None
  1535. */
  1536. __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
  1537. {
  1538. SET_BIT(RTCx->CR, RTC_CR_BKP);
  1539. }
  1540. /**
  1541. * @brief Disable memorization whether the daylight saving time change has been performed.
  1542. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1543. * @rmtoll RTC_CR BKP LL_RTC_TIME_DisableDayLightStore
  1544. * @param RTCx RTC Instance
  1545. * @retval None
  1546. */
  1547. __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
  1548. {
  1549. CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
  1550. }
  1551. /**
  1552. * @brief Check if RTC Day Light Saving stored operation has been enabled or not
  1553. * @rmtoll RTC_CR BKP LL_RTC_TIME_IsDayLightStoreEnabled
  1554. * @param RTCx RTC Instance
  1555. * @retval State of bit (1 or 0).
  1556. */
  1557. __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
  1558. {
  1559. return (READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP));
  1560. }
  1561. /**
  1562. * @brief Subtract 1 hour (winter time change)
  1563. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1564. * @rmtoll RTC_CR SUB1H LL_RTC_TIME_DecHour
  1565. * @param RTCx RTC Instance
  1566. * @retval None
  1567. */
  1568. __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
  1569. {
  1570. SET_BIT(RTCx->CR, RTC_CR_SUB1H);
  1571. }
  1572. /**
  1573. * @brief Add 1 hour (summer time change)
  1574. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1575. * @rmtoll RTC_CR ADD1H LL_RTC_TIME_IncHour
  1576. * @param RTCx RTC Instance
  1577. * @retval None
  1578. */
  1579. __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
  1580. {
  1581. SET_BIT(RTCx->CR, RTC_CR_ADD1H);
  1582. }
  1583. /**
  1584. * @brief Get Sub second value in the synchronous prescaler counter.
  1585. * @note You can use both SubSeconds value and SecondFraction (PREDIV_S through
  1586. * LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
  1587. * SubSeconds value in second fraction ratio with time unit following
  1588. * generic formula:
  1589. * ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
  1590. * This conversion can be performed only if no shift operation is pending
  1591. * (ie. SHFP=0) when PREDIV_S >= SS.
  1592. * @rmtoll RTC_SSR SS LL_RTC_TIME_GetSubSecond
  1593. * @param RTCx RTC Instance
  1594. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  1595. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  1596. */
  1597. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
  1598. {
  1599. return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
  1600. }
  1601. /**
  1602. * @brief Synchronize to a remote clock with a high degree of precision.
  1603. * @note This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
  1604. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1605. * @note When REFCKON is set, firmware must not write to Shift control register.
  1606. * @rmtoll RTC_SHIFTR ADD1S LL_RTC_TIME_Synchronize\n
  1607. * RTC_SHIFTR SUBFS LL_RTC_TIME_Synchronize
  1608. * @param RTCx RTC Instance
  1609. * @param ShiftSecond This parameter can be one of the following values:
  1610. * @arg @ref LL_RTC_SHIFT_SECOND_DELAY
  1611. * @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
  1612. * @param Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
  1613. * @retval None
  1614. */
  1615. __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
  1616. {
  1617. WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
  1618. }
  1619. /**
  1620. * @}
  1621. */
  1622. /** @defgroup RTC_LL_EF_Date Date
  1623. * @{
  1624. */
  1625. /**
  1626. * @brief Set Year in BCD format
  1627. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
  1628. * @rmtoll RTC_DR YT LL_RTC_DATE_SetYear\n
  1629. * RTC_DR YU LL_RTC_DATE_SetYear
  1630. * @param RTCx RTC Instance
  1631. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1632. * @retval None
  1633. */
  1634. __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
  1635. {
  1636. MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
  1637. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
  1638. }
  1639. /**
  1640. * @brief Get Year in BCD format
  1641. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1642. * before reading this bit
  1643. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
  1644. * @rmtoll RTC_DR YT LL_RTC_DATE_GetYear\n
  1645. * RTC_DR YU LL_RTC_DATE_GetYear
  1646. * @param RTCx RTC Instance
  1647. * @retval Value between Min_Data=0x00 and Max_Data=0x99
  1648. */
  1649. __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
  1650. {
  1651. return ((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
  1652. }
  1653. /**
  1654. * @brief Set Week day
  1655. * @rmtoll RTC_DR WDU LL_RTC_DATE_SetWeekDay
  1656. * @param RTCx RTC Instance
  1657. * @param WeekDay This parameter can be one of the following values:
  1658. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1659. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1660. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1661. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1662. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1663. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1664. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1665. * @retval None
  1666. */
  1667. __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1668. {
  1669. MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
  1670. }
  1671. /**
  1672. * @brief Get Week day
  1673. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1674. * before reading this bit
  1675. * @rmtoll RTC_DR WDU LL_RTC_DATE_GetWeekDay
  1676. * @param RTCx RTC Instance
  1677. * @retval Returned value can be one of the following values:
  1678. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1679. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1680. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1681. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1682. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1683. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1684. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1685. */
  1686. __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
  1687. {
  1688. return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
  1689. }
  1690. /**
  1691. * @brief Set Month in BCD format
  1692. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
  1693. * @rmtoll RTC_DR MT LL_RTC_DATE_SetMonth\n
  1694. * RTC_DR MU LL_RTC_DATE_SetMonth
  1695. * @param RTCx RTC Instance
  1696. * @param Month This parameter can be one of the following values:
  1697. * @arg @ref LL_RTC_MONTH_JANUARY
  1698. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1699. * @arg @ref LL_RTC_MONTH_MARCH
  1700. * @arg @ref LL_RTC_MONTH_APRIL
  1701. * @arg @ref LL_RTC_MONTH_MAY
  1702. * @arg @ref LL_RTC_MONTH_JUNE
  1703. * @arg @ref LL_RTC_MONTH_JULY
  1704. * @arg @ref LL_RTC_MONTH_AUGUST
  1705. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1706. * @arg @ref LL_RTC_MONTH_OCTOBER
  1707. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1708. * @arg @ref LL_RTC_MONTH_DECEMBER
  1709. * @retval None
  1710. */
  1711. __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
  1712. {
  1713. MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
  1714. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
  1715. }
  1716. /**
  1717. * @brief Get Month in BCD format
  1718. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1719. * before reading this bit
  1720. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  1721. * @rmtoll RTC_DR MT LL_RTC_DATE_GetMonth\n
  1722. * RTC_DR MU LL_RTC_DATE_GetMonth
  1723. * @param RTCx RTC Instance
  1724. * @retval Returned value can be one of the following values:
  1725. * @arg @ref LL_RTC_MONTH_JANUARY
  1726. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1727. * @arg @ref LL_RTC_MONTH_MARCH
  1728. * @arg @ref LL_RTC_MONTH_APRIL
  1729. * @arg @ref LL_RTC_MONTH_MAY
  1730. * @arg @ref LL_RTC_MONTH_JUNE
  1731. * @arg @ref LL_RTC_MONTH_JULY
  1732. * @arg @ref LL_RTC_MONTH_AUGUST
  1733. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1734. * @arg @ref LL_RTC_MONTH_OCTOBER
  1735. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1736. * @arg @ref LL_RTC_MONTH_DECEMBER
  1737. */
  1738. __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
  1739. {
  1740. return ((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
  1741. }
  1742. /**
  1743. * @brief Set Day in BCD format
  1744. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1745. * @rmtoll RTC_DR DT LL_RTC_DATE_SetDay\n
  1746. * RTC_DR DU LL_RTC_DATE_SetDay
  1747. * @param RTCx RTC Instance
  1748. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1749. * @retval None
  1750. */
  1751. __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1752. {
  1753. MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
  1754. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
  1755. }
  1756. /**
  1757. * @brief Get Day in BCD format
  1758. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1759. * before reading this bit
  1760. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1761. * @rmtoll RTC_DR DT LL_RTC_DATE_GetDay\n
  1762. * RTC_DR DU LL_RTC_DATE_GetDay
  1763. * @param RTCx RTC Instance
  1764. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1765. */
  1766. __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
  1767. {
  1768. return ((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
  1769. }
  1770. /**
  1771. * @brief Set date (WeekDay, Day, Month and Year) in BCD format
  1772. * @rmtoll RTC_DR WDU LL_RTC_DATE_Config\n
  1773. * RTC_DR MT LL_RTC_DATE_Config\n
  1774. * RTC_DR MU LL_RTC_DATE_Config\n
  1775. * RTC_DR DT LL_RTC_DATE_Config\n
  1776. * RTC_DR DU LL_RTC_DATE_Config\n
  1777. * RTC_DR YT LL_RTC_DATE_Config\n
  1778. * RTC_DR YU LL_RTC_DATE_Config
  1779. * @param RTCx RTC Instance
  1780. * @param WeekDay This parameter can be one of the following values:
  1781. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1782. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1783. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1784. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1785. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1786. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1787. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1788. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1789. * @param Month This parameter can be one of the following values:
  1790. * @arg @ref LL_RTC_MONTH_JANUARY
  1791. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1792. * @arg @ref LL_RTC_MONTH_MARCH
  1793. * @arg @ref LL_RTC_MONTH_APRIL
  1794. * @arg @ref LL_RTC_MONTH_MAY
  1795. * @arg @ref LL_RTC_MONTH_JUNE
  1796. * @arg @ref LL_RTC_MONTH_JULY
  1797. * @arg @ref LL_RTC_MONTH_AUGUST
  1798. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1799. * @arg @ref LL_RTC_MONTH_OCTOBER
  1800. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1801. * @arg @ref LL_RTC_MONTH_DECEMBER
  1802. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1803. * @retval None
  1804. */
  1805. __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
  1806. {
  1807. uint32_t temp = 0U;
  1808. temp = (WeekDay << RTC_DR_WDU_Pos) | \
  1809. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)) | \
  1810. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
  1811. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
  1812. 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);
  1813. }
  1814. /**
  1815. * @brief Get date (WeekDay, Day, Month and Year) in BCD format
  1816. * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
  1817. * before reading this bit
  1818. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
  1819. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  1820. * @rmtoll RTC_DR WDU LL_RTC_DATE_Get\n
  1821. * RTC_DR MT LL_RTC_DATE_Get\n
  1822. * RTC_DR MU LL_RTC_DATE_Get\n
  1823. * RTC_DR DT LL_RTC_DATE_Get\n
  1824. * RTC_DR DU LL_RTC_DATE_Get\n
  1825. * RTC_DR YT LL_RTC_DATE_Get\n
  1826. * RTC_DR YU LL_RTC_DATE_Get
  1827. * @param RTCx RTC Instance
  1828. * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
  1829. */
  1830. __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
  1831. {
  1832. uint32_t temp = 0U;
  1833. 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));
  1834. return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
  1835. (((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U) | ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos)) << RTC_OFFSET_DAY) | \
  1836. (((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U) | ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos)) << RTC_OFFSET_MONTH) | \
  1837. ((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos)));
  1838. }
  1839. /**
  1840. * @}
  1841. */
  1842. /** @defgroup RTC_LL_EF_ALARMA ALARMA
  1843. * @{
  1844. */
  1845. /**
  1846. * @brief Enable Alarm A
  1847. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1848. * @rmtoll RTC_CR ALRAE LL_RTC_ALMA_Enable
  1849. * @param RTCx RTC Instance
  1850. * @retval None
  1851. */
  1852. __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
  1853. {
  1854. SET_BIT(RTCx->CR, RTC_CR_ALRAE);
  1855. }
  1856. /**
  1857. * @brief Disable Alarm A
  1858. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1859. * @rmtoll RTC_CR ALRAE LL_RTC_ALMA_Disable
  1860. * @param RTCx RTC Instance
  1861. * @retval None
  1862. */
  1863. __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
  1864. {
  1865. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
  1866. }
  1867. /**
  1868. * @brief Specify the Alarm A masks.
  1869. * @rmtoll RTC_ALRMAR MSK4 LL_RTC_ALMA_SetMask\n
  1870. * RTC_ALRMAR MSK3 LL_RTC_ALMA_SetMask\n
  1871. * RTC_ALRMAR MSK2 LL_RTC_ALMA_SetMask\n
  1872. * RTC_ALRMAR MSK1 LL_RTC_ALMA_SetMask
  1873. * @param RTCx RTC Instance
  1874. * @param Mask This parameter can be a combination of the following values:
  1875. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1876. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1877. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1878. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1879. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1880. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1881. * @retval None
  1882. */
  1883. __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1884. {
  1885. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
  1886. }
  1887. /**
  1888. * @brief Get the Alarm A masks.
  1889. * @rmtoll RTC_ALRMAR MSK4 LL_RTC_ALMA_GetMask\n
  1890. * RTC_ALRMAR MSK3 LL_RTC_ALMA_GetMask\n
  1891. * RTC_ALRMAR MSK2 LL_RTC_ALMA_GetMask\n
  1892. * RTC_ALRMAR MSK1 LL_RTC_ALMA_GetMask
  1893. * @param RTCx RTC Instance
  1894. * @retval Returned value can be can be a combination of the following values:
  1895. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1896. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1897. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1898. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1899. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1900. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1901. */
  1902. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
  1903. {
  1904. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
  1905. }
  1906. /**
  1907. * @brief Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  1908. * @rmtoll RTC_ALRMAR WDSEL LL_RTC_ALMA_EnableWeekday
  1909. * @param RTCx RTC Instance
  1910. * @retval None
  1911. */
  1912. __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
  1913. {
  1914. SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1915. }
  1916. /**
  1917. * @brief Disable AlarmA Week day selection (DU[3:0] represents the date )
  1918. * @rmtoll RTC_ALRMAR WDSEL LL_RTC_ALMA_DisableWeekday
  1919. * @param RTCx RTC Instance
  1920. * @retval None
  1921. */
  1922. __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
  1923. {
  1924. CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1925. }
  1926. /**
  1927. * @brief Set ALARM A Day in BCD format
  1928. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1929. * @rmtoll RTC_ALRMAR DT LL_RTC_ALMA_SetDay\n
  1930. * RTC_ALRMAR DU LL_RTC_ALMA_SetDay
  1931. * @param RTCx RTC Instance
  1932. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1933. * @retval None
  1934. */
  1935. __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1936. {
  1937. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
  1938. (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
  1939. }
  1940. /**
  1941. * @brief Get ALARM A Day in BCD format
  1942. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1943. * @rmtoll RTC_ALRMAR DT LL_RTC_ALMA_GetDay\n
  1944. * RTC_ALRMAR DU LL_RTC_ALMA_GetDay
  1945. * @param RTCx RTC Instance
  1946. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1947. */
  1948. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
  1949. {
  1950. return ((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
  1951. }
  1952. /**
  1953. * @brief Set ALARM A Weekday
  1954. * @rmtoll RTC_ALRMAR DU LL_RTC_ALMA_SetWeekDay
  1955. * @param RTCx RTC Instance
  1956. * @param WeekDay This parameter can be one of the following values:
  1957. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1958. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1959. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1960. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1961. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1962. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1963. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1964. * @retval None
  1965. */
  1966. __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1967. {
  1968. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
  1969. }
  1970. /**
  1971. * @brief Get ALARM A Weekday
  1972. * @rmtoll RTC_ALRMAR DU LL_RTC_ALMA_GetWeekDay
  1973. * @param RTCx RTC Instance
  1974. * @retval Returned value can be one of the following values:
  1975. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1976. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1977. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1978. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1979. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1980. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1981. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1982. */
  1983. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
  1984. {
  1985. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
  1986. }
  1987. /**
  1988. * @brief Set Alarm A time format (AM/24-hour or PM notation)
  1989. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_SetTimeFormat
  1990. * @param RTCx RTC Instance
  1991. * @param TimeFormat This parameter can be one of the following values:
  1992. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1993. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1994. * @retval None
  1995. */
  1996. __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1997. {
  1998. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
  1999. }
  2000. /**
  2001. * @brief Get Alarm A time format (AM or PM notation)
  2002. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_GetTimeFormat
  2003. * @param RTCx RTC Instance
  2004. * @retval Returned value can be one of the following values:
  2005. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  2006. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  2007. */
  2008. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
  2009. {
  2010. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
  2011. }
  2012. /**
  2013. * @brief Set ALARM A Hours in BCD format
  2014. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  2015. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_SetHour\n
  2016. * RTC_ALRMAR HU LL_RTC_ALMA_SetHour
  2017. * @param RTCx RTC Instance
  2018. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2019. * @retval None
  2020. */
  2021. __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  2022. {
  2023. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
  2024. (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
  2025. }
  2026. /**
  2027. * @brief Get ALARM A Hours in BCD format
  2028. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2029. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_GetHour\n
  2030. * RTC_ALRMAR HU LL_RTC_ALMA_GetHour
  2031. * @param RTCx RTC Instance
  2032. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2033. */
  2034. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
  2035. {
  2036. return ((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
  2037. }
  2038. /**
  2039. * @brief Set ALARM A Minutes in BCD format
  2040. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  2041. * @rmtoll RTC_ALRMAR MNT LL_RTC_ALMA_SetMinute\n
  2042. * RTC_ALRMAR MNU LL_RTC_ALMA_SetMinute
  2043. * @param RTCx RTC Instance
  2044. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2045. * @retval None
  2046. */
  2047. __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  2048. {
  2049. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
  2050. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
  2051. }
  2052. /**
  2053. * @brief Get ALARM A Minutes in BCD format
  2054. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2055. * @rmtoll RTC_ALRMAR MNT LL_RTC_ALMA_GetMinute\n
  2056. * RTC_ALRMAR MNU LL_RTC_ALMA_GetMinute
  2057. * @param RTCx RTC Instance
  2058. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2059. */
  2060. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
  2061. {
  2062. return ((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
  2063. }
  2064. /**
  2065. * @brief Set ALARM A Seconds in BCD format
  2066. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  2067. * @rmtoll RTC_ALRMAR ST LL_RTC_ALMA_SetSecond\n
  2068. * RTC_ALRMAR SU LL_RTC_ALMA_SetSecond
  2069. * @param RTCx RTC Instance
  2070. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2071. * @retval None
  2072. */
  2073. __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  2074. {
  2075. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
  2076. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
  2077. }
  2078. /**
  2079. * @brief Get ALARM A Seconds in BCD format
  2080. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2081. * @rmtoll RTC_ALRMAR ST LL_RTC_ALMA_GetSecond\n
  2082. * RTC_ALRMAR SU LL_RTC_ALMA_GetSecond
  2083. * @param RTCx RTC Instance
  2084. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2085. */
  2086. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
  2087. {
  2088. return ((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
  2089. }
  2090. /**
  2091. * @brief Set Alarm A Time (hour, minute and second) in BCD format
  2092. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_ConfigTime\n
  2093. * RTC_ALRMAR HT LL_RTC_ALMA_ConfigTime\n
  2094. * RTC_ALRMAR HU LL_RTC_ALMA_ConfigTime\n
  2095. * RTC_ALRMAR MNT LL_RTC_ALMA_ConfigTime\n
  2096. * RTC_ALRMAR MNU LL_RTC_ALMA_ConfigTime\n
  2097. * RTC_ALRMAR ST LL_RTC_ALMA_ConfigTime\n
  2098. * RTC_ALRMAR SU LL_RTC_ALMA_ConfigTime
  2099. * @param RTCx RTC Instance
  2100. * @param Format12_24 This parameter can be one of the following values:
  2101. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  2102. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  2103. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2104. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2105. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2106. * @retval None
  2107. */
  2108. __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2109. {
  2110. uint32_t temp = 0U;
  2111. temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)) | \
  2112. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
  2113. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
  2114. 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);
  2115. }
  2116. /**
  2117. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  2118. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2119. * are available to get independently each parameter.
  2120. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_GetTime\n
  2121. * RTC_ALRMAR HU LL_RTC_ALMA_GetTime\n
  2122. * RTC_ALRMAR MNT LL_RTC_ALMA_GetTime\n
  2123. * RTC_ALRMAR MNU LL_RTC_ALMA_GetTime\n
  2124. * RTC_ALRMAR ST LL_RTC_ALMA_GetTime\n
  2125. * RTC_ALRMAR SU LL_RTC_ALMA_GetTime
  2126. * @param RTCx RTC Instance
  2127. * @retval Combination of hours, minutes and seconds.
  2128. */
  2129. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
  2130. {
  2131. return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
  2132. }
  2133. /**
  2134. * @brief Set Alarm A Mask the most-significant bits starting at this bit
  2135. * @note This register can be written only when ALRAE is reset in RTC_CR register,
  2136. * or in initialization mode.
  2137. * @rmtoll RTC_ALRMASSR MASKSS LL_RTC_ALMA_SetSubSecondMask
  2138. * @param RTCx RTC Instance
  2139. * @param Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
  2140. * else Value between Min_Data=0x0 and Max_Data=0x3F
  2141. * @retval None
  2142. */
  2143. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2144. {
  2145. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
  2146. }
  2147. /**
  2148. * @brief Get Alarm A Mask the most-significant bits starting at this bit
  2149. * @rmtoll RTC_ALRMASSR MASKSS LL_RTC_ALMA_GetSubSecondMask
  2150. * @param RTCx RTC Instance
  2151. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
  2152. * else Value between Min_Data=0x0 and Max_Data=0x3F
  2153. */
  2154. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
  2155. {
  2156. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
  2157. }
  2158. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  2159. /**
  2160. * @brief Set Alarm A Binary mode auto clear
  2161. * @note This register can be written only when ALRAE is reset in RTC_CR register,
  2162. * or in initialization mode.
  2163. * @rmtoll RTC_ALRABINR SSCLR LL_RTC_ALMA_SetBinAutoClr
  2164. * @param RTCx RTC Instance
  2165. * @param BinaryAutoClr This parameter can be one of the following values:
  2166. * @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
  2167. * @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
  2168. * @retval None
  2169. */
  2170. __STATIC_INLINE void LL_RTC_ALMA_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
  2171. {
  2172. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR, BinaryAutoClr);
  2173. }
  2174. /**
  2175. * @brief Get Alarm A Binary mode auto clear
  2176. * @rmtoll RTC_ALRABINR SSCLR LL_RTC_ALMA_GetBinAutoClr
  2177. * @param RTCx RTC Instance
  2178. * @retval It can be one of the following values:
  2179. * @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
  2180. * @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
  2181. */
  2182. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetBinAutoClr(RTC_TypeDef *RTCx)
  2183. {
  2184. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR));
  2185. }
  2186. /**
  2187. * @brief Set Alarm A Sub seconds value
  2188. * @rmtoll RTC_ALRMABINR SS LL_RTC_ALMA_SetSubSecond
  2189. * @param RTCx RTC Instance
  2190. * @param Subsecond If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  2191. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  2192. * @retval None
  2193. */
  2194. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2195. {
  2196. MODIFY_REG(RTCx->ALRABINR, RTC_ALRABINR_SS, Subsecond);
  2197. }
  2198. /**
  2199. * @brief Get Alarm A Sub seconds value
  2200. * @rmtoll RTC_ALRMABINR SS LL_RTC_ALMA_GetSubSecond
  2201. * @param RTCx RTC Instance
  2202. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  2203. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  2204. */
  2205. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
  2206. {
  2207. return (uint32_t)(READ_BIT(RTCx->ALRABINR, RTC_ALRABINR_SS));
  2208. }
  2209. #else /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  2210. /**
  2211. * @brief Set Alarm A Sub seconds value
  2212. * @rmtoll RCT_ALRMASSR SS LL_RTC_ALMA_SetSubSecond
  2213. * @param RTCx RTC Instance
  2214. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2215. * @retval None
  2216. */
  2217. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2218. {
  2219. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
  2220. }
  2221. /**
  2222. * @brief Get Alarm A Sub seconds value
  2223. * @rmtoll RCT_ALRMASSR SS LL_RTC_ALMA_GetSubSecond
  2224. * @param RTCx RTC Instance
  2225. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2226. */
  2227. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
  2228. {
  2229. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
  2230. }
  2231. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  2232. /**
  2233. * @}
  2234. */
  2235. /** @defgroup RTC_LL_EF_ALARMB ALARMB
  2236. * @{
  2237. */
  2238. /**
  2239. * @brief Enable Alarm B
  2240. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2241. * @rmtoll RTC_CR ALRBE LL_RTC_ALMB_Enable
  2242. * @param RTCx RTC Instance
  2243. * @retval None
  2244. */
  2245. __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
  2246. {
  2247. SET_BIT(RTCx->CR, RTC_CR_ALRBE);
  2248. }
  2249. /**
  2250. * @brief Disable Alarm B
  2251. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2252. * @rmtoll RTC_CR ALRBE LL_RTC_ALMB_Disable
  2253. * @param RTCx RTC Instance
  2254. * @retval None
  2255. */
  2256. __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
  2257. {
  2258. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
  2259. }
  2260. /**
  2261. * @brief Specify the Alarm B masks.
  2262. * @rmtoll RTC_ALRMBR MSK4 LL_RTC_ALMB_SetMask\n
  2263. * RTC_ALRMBR MSK3 LL_RTC_ALMB_SetMask\n
  2264. * RTC_ALRMBR MSK2 LL_RTC_ALMB_SetMask\n
  2265. * RTC_ALRMBR MSK1 LL_RTC_ALMB_SetMask
  2266. * @param RTCx RTC Instance
  2267. * @param Mask This parameter can be a combination of the following values:
  2268. * @arg @ref LL_RTC_ALMB_MASK_NONE
  2269. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  2270. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  2271. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  2272. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  2273. * @arg @ref LL_RTC_ALMB_MASK_ALL
  2274. * @retval None
  2275. */
  2276. __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2277. {
  2278. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
  2279. }
  2280. /**
  2281. * @brief Get the Alarm B masks.
  2282. * @rmtoll RTC_ALRMBR MSK4 LL_RTC_ALMB_GetMask\n
  2283. * RTC_ALRMBR MSK3 LL_RTC_ALMB_GetMask\n
  2284. * RTC_ALRMBR MSK2 LL_RTC_ALMB_GetMask\n
  2285. * RTC_ALRMBR MSK1 LL_RTC_ALMB_GetMask
  2286. * @param RTCx RTC Instance
  2287. * @retval Returned value can be can be a combination of the following values:
  2288. * @arg @ref LL_RTC_ALMB_MASK_NONE
  2289. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  2290. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  2291. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  2292. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  2293. * @arg @ref LL_RTC_ALMB_MASK_ALL
  2294. */
  2295. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
  2296. {
  2297. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
  2298. }
  2299. /**
  2300. * @brief Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  2301. * @rmtoll RTC_ALRMBR WDSEL LL_RTC_ALMB_EnableWeekday
  2302. * @param RTCx RTC Instance
  2303. * @retval None
  2304. */
  2305. __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
  2306. {
  2307. SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2308. }
  2309. /**
  2310. * @brief Disable AlarmB Week day selection (DU[3:0] represents the date )
  2311. * @rmtoll RTC_ALRMBR WDSEL LL_RTC_ALMB_DisableWeekday
  2312. * @param RTCx RTC Instance
  2313. * @retval None
  2314. */
  2315. __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
  2316. {
  2317. CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2318. }
  2319. /**
  2320. * @brief Set ALARM B Day in BCD format
  2321. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  2322. * @rmtoll RTC_ALRMBR DT LL_RTC_ALMB_SetDay\n
  2323. * RTC_ALRMBR DU LL_RTC_ALMB_SetDay
  2324. * @param RTCx RTC Instance
  2325. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  2326. * @retval None
  2327. */
  2328. __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  2329. {
  2330. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
  2331. (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
  2332. }
  2333. /**
  2334. * @brief Get ALARM B Day in BCD format
  2335. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2336. * @rmtoll RTC_ALRMBR DT LL_RTC_ALMB_GetDay\n
  2337. * RTC_ALRMBR DU LL_RTC_ALMB_GetDay
  2338. * @param RTCx RTC Instance
  2339. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2340. */
  2341. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
  2342. {
  2343. return ((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
  2344. }
  2345. /**
  2346. * @brief Set ALARM B Weekday
  2347. * @rmtoll RTC_ALRMBR DU LL_RTC_ALMB_SetWeekDay
  2348. * @param RTCx RTC Instance
  2349. * @param WeekDay This parameter can be one of the following values:
  2350. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2351. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2352. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2353. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2354. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2355. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2356. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2357. * @retval None
  2358. */
  2359. __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  2360. {
  2361. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
  2362. }
  2363. /**
  2364. * @brief Get ALARM B Weekday
  2365. * @rmtoll RTC_ALRMBR DU LL_RTC_ALMB_GetWeekDay
  2366. * @param RTCx RTC Instance
  2367. * @retval Returned value can be one of the following values:
  2368. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2369. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2370. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2371. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2372. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2373. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2374. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2375. */
  2376. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
  2377. {
  2378. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
  2379. }
  2380. /**
  2381. * @brief Set ALARM B time format (AM/24-hour or PM notation)
  2382. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_SetTimeFormat
  2383. * @param RTCx RTC Instance
  2384. * @param TimeFormat This parameter can be one of the following values:
  2385. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2386. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2387. * @retval None
  2388. */
  2389. __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  2390. {
  2391. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
  2392. }
  2393. /**
  2394. * @brief Get ALARM B time format (AM or PM notation)
  2395. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_GetTimeFormat
  2396. * @param RTCx RTC Instance
  2397. * @retval Returned value can be one of the following values:
  2398. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2399. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2400. */
  2401. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
  2402. {
  2403. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
  2404. }
  2405. /**
  2406. * @brief Set ALARM B Hours in BCD format
  2407. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  2408. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_SetHour\n
  2409. * RTC_ALRMBR HU LL_RTC_ALMB_SetHour
  2410. * @param RTCx RTC Instance
  2411. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2412. * @retval None
  2413. */
  2414. __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  2415. {
  2416. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
  2417. (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
  2418. }
  2419. /**
  2420. * @brief Get ALARM B Hours in BCD format
  2421. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2422. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_GetHour\n
  2423. * RTC_ALRMBR HU LL_RTC_ALMB_GetHour
  2424. * @param RTCx RTC Instance
  2425. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2426. */
  2427. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
  2428. {
  2429. return ((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
  2430. }
  2431. /**
  2432. * @brief Set ALARM B Minutes in BCD format
  2433. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  2434. * @rmtoll RTC_ALRMBR MNT LL_RTC_ALMB_SetMinute\n
  2435. * RTC_ALRMBR MNU LL_RTC_ALMB_SetMinute
  2436. * @param RTCx RTC Instance
  2437. * @param Minutes between Min_Data=0x00 and Max_Data=0x59
  2438. * @retval None
  2439. */
  2440. __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  2441. {
  2442. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
  2443. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
  2444. }
  2445. /**
  2446. * @brief Get ALARM B Minutes in BCD format
  2447. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2448. * @rmtoll RTC_ALRMBR MNT LL_RTC_ALMB_GetMinute\n
  2449. * RTC_ALRMBR MNU LL_RTC_ALMB_GetMinute
  2450. * @param RTCx RTC Instance
  2451. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2452. */
  2453. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
  2454. {
  2455. return ((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
  2456. }
  2457. /**
  2458. * @brief Set ALARM B Seconds in BCD format
  2459. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  2460. * @rmtoll RTC_ALRMBR ST LL_RTC_ALMB_SetSecond\n
  2461. * RTC_ALRMBR SU LL_RTC_ALMB_SetSecond
  2462. * @param RTCx RTC Instance
  2463. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2464. * @retval None
  2465. */
  2466. __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  2467. {
  2468. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
  2469. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
  2470. }
  2471. /**
  2472. * @brief Get ALARM B Seconds in BCD format
  2473. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2474. * @rmtoll RTC_ALRMBR ST LL_RTC_ALMB_GetSecond\n
  2475. * RTC_ALRMBR SU LL_RTC_ALMB_GetSecond
  2476. * @param RTCx RTC Instance
  2477. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2478. */
  2479. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
  2480. {
  2481. return ((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
  2482. }
  2483. /**
  2484. * @brief Set Alarm B Time (hour, minute and second) in BCD format
  2485. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_ConfigTime\n
  2486. * RTC_ALRMBR HT LL_RTC_ALMB_ConfigTime\n
  2487. * RTC_ALRMBR HU LL_RTC_ALMB_ConfigTime\n
  2488. * RTC_ALRMBR MNT LL_RTC_ALMB_ConfigTime\n
  2489. * RTC_ALRMBR MNU LL_RTC_ALMB_ConfigTime\n
  2490. * RTC_ALRMBR ST LL_RTC_ALMB_ConfigTime\n
  2491. * RTC_ALRMBR SU LL_RTC_ALMB_ConfigTime
  2492. * @param RTCx RTC Instance
  2493. * @param Format12_24 This parameter can be one of the following values:
  2494. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2495. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2496. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2497. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2498. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2499. * @retval None
  2500. */
  2501. __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2502. {
  2503. uint32_t temp = 0U;
  2504. temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)) | \
  2505. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
  2506. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
  2507. 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);
  2508. }
  2509. /**
  2510. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  2511. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2512. * are available to get independently each parameter.
  2513. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_GetTime\n
  2514. * RTC_ALRMBR HU LL_RTC_ALMB_GetTime\n
  2515. * RTC_ALRMBR MNT LL_RTC_ALMB_GetTime\n
  2516. * RTC_ALRMBR MNU LL_RTC_ALMB_GetTime\n
  2517. * RTC_ALRMBR ST LL_RTC_ALMB_GetTime\n
  2518. * RTC_ALRMBR SU LL_RTC_ALMB_GetTime
  2519. * @param RTCx RTC Instance
  2520. * @retval Combination of hours, minutes and seconds.
  2521. */
  2522. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
  2523. {
  2524. return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
  2525. }
  2526. /**
  2527. * @brief Set Alarm B Mask the most-significant bits starting at this bit
  2528. * @note This register can be written only when ALRBE is reset in RTC_CR register,
  2529. * or in initialization mode.
  2530. * @rmtoll RTC_ALRMBSSR MASKSS LL_RTC_ALMB_SetSubSecondMask
  2531. * @param RTCx RTC Instance
  2532. * @param Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
  2533. * else Value between Min_Data=0x0 and Max_Data=0x3F
  2534. * @retval None
  2535. */
  2536. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2537. {
  2538. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
  2539. }
  2540. /**
  2541. * @brief Get Alarm B Mask the most-significant bits starting at this bit
  2542. * @rmtoll RTC_ALRMBSSR MASKSS LL_RTC_ALMB_GetSubSecondMask
  2543. * @param RTCx RTC Instance
  2544. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
  2545. * else Value between Min_Data=0x0 and Max_Data=0x3F
  2546. */
  2547. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
  2548. {
  2549. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS) >> RTC_ALRMBSSR_MASKSS_Pos);
  2550. }
  2551. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  2552. /**
  2553. * @brief Set Alarm B Binary mode auto clear
  2554. * @note This register can be written only when ALRBE is reset in RTC_CR register,
  2555. * or in initialization mode.
  2556. * @rmtoll RTC_ALRBBINR SSCLR LL_RTC_ALMB_SetBinAutoClr
  2557. * @param RTCx RTC Instance
  2558. * @param BinaryAutoClr This parameter can be one of the following values:
  2559. * @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
  2560. * @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
  2561. * @retval None
  2562. */
  2563. __STATIC_INLINE void LL_RTC_ALMB_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
  2564. {
  2565. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR, BinaryAutoClr);
  2566. }
  2567. /**
  2568. * @brief Get Alarm B Binary mode auto clear
  2569. * @rmtoll RTC_ALRBBINR SSCLR LL_RTC_ALMB_GetBinAutoClr
  2570. * @param RTCx RTC Instance
  2571. * @retval It can be one of the following values:
  2572. * @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
  2573. * @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
  2574. */
  2575. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetBinAutoClr(RTC_TypeDef *RTCx)
  2576. {
  2577. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR));
  2578. }
  2579. /**
  2580. * @brief Set Alarm B Sub seconds value
  2581. * @rmtoll RTC_ALRMBBINR SS LL_RTC_ALMB_SetSubSecond
  2582. * @param RTCx RTC Instance
  2583. * @param Subsecond If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  2584. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  2585. * @retval None
  2586. */
  2587. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2588. {
  2589. MODIFY_REG(RTCx->ALRBBINR, RTC_ALRBBINR_SS, Subsecond);
  2590. }
  2591. /**
  2592. * @brief Get Alarm B Sub seconds value
  2593. * @rmtoll RTC_ALRMBBINR SS LL_RTC_ALMB_GetSubSecond
  2594. * @param RTCx RTC Instance
  2595. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  2596. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  2597. */
  2598. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
  2599. {
  2600. return (uint32_t)(READ_BIT(RTCx->ALRBBINR, RTC_ALRBBINR_SS));
  2601. }
  2602. #else /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  2603. /**
  2604. * @brief Set Alarm B Sub seconds value
  2605. * @rmtoll RTC_ALRMBSSR SS LL_RTC_ALMB_SetSubSecond
  2606. * @param RTCx RTC Instance
  2607. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2608. * @retval None
  2609. */
  2610. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2611. {
  2612. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
  2613. }
  2614. /**
  2615. * @brief Get Alarm B Sub seconds value
  2616. * @rmtoll RTC_ALRMBSSR SS LL_RTC_ALMB_GetSubSecond
  2617. * @param RTCx RTC Instance
  2618. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2619. */
  2620. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
  2621. {
  2622. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
  2623. }
  2624. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  2625. /**
  2626. * @}
  2627. */
  2628. /** @defgroup RTC_LL_EF_Timestamp Timestamp
  2629. * @{
  2630. */
  2631. /**
  2632. * @brief Enable internal event timestamp
  2633. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2634. * @rmtoll RTC_CR ITSE LL_RTC_TS_EnableInternalEvent
  2635. * @param RTCx RTC Instance
  2636. * @retval None
  2637. */
  2638. __STATIC_INLINE void LL_RTC_TS_EnableInternalEvent(RTC_TypeDef *RTCx)
  2639. {
  2640. SET_BIT(RTCx->CR, RTC_CR_ITSE);
  2641. }
  2642. /**
  2643. * @brief Disable internal event timestamp
  2644. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2645. * @rmtoll RTC_CR ITSE LL_RTC_TS_DisableInternalEvent
  2646. * @param RTCx RTC Instance
  2647. * @retval None
  2648. */
  2649. __STATIC_INLINE void LL_RTC_TS_DisableInternalEvent(RTC_TypeDef *RTCx)
  2650. {
  2651. CLEAR_BIT(RTCx->CR, RTC_CR_ITSE);
  2652. }
  2653. /**
  2654. * @brief Enable Timestamp
  2655. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2656. * @rmtoll RTC_CR ITSE LL_RTC_TS_Enable
  2657. * @param RTCx RTC Instance
  2658. * @retval None
  2659. */
  2660. __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
  2661. {
  2662. SET_BIT(RTCx->CR, RTC_CR_TSE);
  2663. }
  2664. /**
  2665. * @brief Disable Timestamp
  2666. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2667. * @rmtoll RTC_CR ITSE LL_RTC_TS_Disable
  2668. * @param RTCx RTC Instance
  2669. * @retval None
  2670. */
  2671. __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
  2672. {
  2673. CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
  2674. }
  2675. /**
  2676. * @brief Set Time-stamp event active edge
  2677. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2678. * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
  2679. * @rmtoll RTC_CR ITSEDGE LL_RTC_TS_SetActiveEdge
  2680. * @param RTCx RTC Instance
  2681. * @param Edge This parameter can be one of the following values:
  2682. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2683. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2684. * @retval None
  2685. */
  2686. __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
  2687. {
  2688. MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
  2689. }
  2690. /**
  2691. * @brief Get Time-stamp event active edge
  2692. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2693. * @rmtoll RTC_CR ITSEDGE LL_RTC_TS_GetActiveEdge
  2694. * @param RTCx RTC Instance
  2695. * @retval Returned value can be one of the following values:
  2696. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2697. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2698. */
  2699. __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
  2700. {
  2701. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
  2702. }
  2703. /**
  2704. * @brief Get Timestamp AM/PM notation (AM or 24-hour format)
  2705. * @rmtoll RTC_TSTR PM LL_RTC_TS_GetTimeFormat
  2706. * @param RTCx RTC Instance
  2707. * @retval Returned value can be one of the following values:
  2708. * @arg @ref LL_RTC_TS_TIME_FORMAT_AM
  2709. * @arg @ref LL_RTC_TS_TIME_FORMAT_PM
  2710. */
  2711. __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
  2712. {
  2713. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
  2714. }
  2715. /**
  2716. * @brief Get Timestamp Hours in BCD format
  2717. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2718. * @rmtoll RTC_TSTR HT LL_RTC_TS_GetHour\n
  2719. * RTC_TSTR HU LL_RTC_TS_GetHour
  2720. * @param RTCx RTC Instance
  2721. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2722. */
  2723. __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
  2724. {
  2725. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
  2726. }
  2727. /**
  2728. * @brief Get Timestamp Minutes in BCD format
  2729. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2730. * @rmtoll RTC_TSTR MNT LL_RTC_TS_GetMinute\n
  2731. * RTC_TSTR HU LL_RTC_TS_GetMinute
  2732. * @param RTCx RTC Instance
  2733. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2734. */
  2735. __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
  2736. {
  2737. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
  2738. }
  2739. /**
  2740. * @brief Get Timestamp Seconds in BCD format
  2741. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2742. * @rmtoll RTC_TSTR ST LL_RTC_TS_GetSecond\n
  2743. * RTC_TSTR HU LL_RTC_TS_GetSecond
  2744. * @param RTCx RTC Instance
  2745. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2746. */
  2747. __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
  2748. {
  2749. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
  2750. }
  2751. /**
  2752. * @brief Get Timestamp time (hour, minute and second) in BCD format
  2753. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2754. * are available to get independently each parameter.
  2755. * @rmtoll RTC_TSTR HT LL_RTC_TS_GetTime\n
  2756. * RTC_TSTR HU LL_RTC_TS_GetTime\n
  2757. * RTC_TSTR MNT LL_RTC_TS_GetTime\n
  2758. * RTC_TSTR MNU LL_RTC_TS_GetTime\n
  2759. * RTC_TSTR ST LL_RTC_TS_GetTime\n
  2760. * RTC_TSTR SU LL_RTC_TS_GetTime
  2761. * @param RTCx RTC Instance
  2762. * @retval Combination of hours, minutes and seconds.
  2763. */
  2764. __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
  2765. {
  2766. return (uint32_t)(READ_BIT(RTCx->TSTR,
  2767. RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
  2768. }
  2769. /**
  2770. * @brief Get Timestamp Week day
  2771. * @rmtoll RTC_TSDR WDU LL_RTC_TS_GetWeekDay
  2772. * @param RTCx RTC Instance
  2773. * @retval Returned value can be one of the following values:
  2774. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2775. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2776. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2777. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2778. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2779. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2780. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2781. */
  2782. __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
  2783. {
  2784. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
  2785. }
  2786. /**
  2787. * @brief Get Timestamp Month in BCD format
  2788. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  2789. * @rmtoll RTC_TSDR MT LL_RTC_TS_GetMonth\n
  2790. * RTC_TSDR MU LL_RTC_TS_GetMonth
  2791. * @param RTCx RTC Instance
  2792. * @retval Returned value can be one of the following values:
  2793. * @arg @ref LL_RTC_MONTH_JANUARY
  2794. * @arg @ref LL_RTC_MONTH_FEBRUARY
  2795. * @arg @ref LL_RTC_MONTH_MARCH
  2796. * @arg @ref LL_RTC_MONTH_APRIL
  2797. * @arg @ref LL_RTC_MONTH_MAY
  2798. * @arg @ref LL_RTC_MONTH_JUNE
  2799. * @arg @ref LL_RTC_MONTH_JULY
  2800. * @arg @ref LL_RTC_MONTH_AUGUST
  2801. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  2802. * @arg @ref LL_RTC_MONTH_OCTOBER
  2803. * @arg @ref LL_RTC_MONTH_NOVEMBER
  2804. * @arg @ref LL_RTC_MONTH_DECEMBER
  2805. */
  2806. __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
  2807. {
  2808. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
  2809. }
  2810. /**
  2811. * @brief Get Timestamp Day in BCD format
  2812. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2813. * @rmtoll RTC_TSDR DT LL_RTC_TS_GetDay\n
  2814. * RTC_TSDR DU LL_RTC_TS_GetDay
  2815. * @param RTCx RTC Instance
  2816. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2817. */
  2818. __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
  2819. {
  2820. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
  2821. }
  2822. /**
  2823. * @brief Get Timestamp date (WeekDay, Day and Month) in BCD format
  2824. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
  2825. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  2826. * @rmtoll RTC_TSDR WDU LL_RTC_TS_GetDate\n
  2827. * RTC_TSDR MT LL_RTC_TS_GetDate\n
  2828. * RTC_TSDR MU LL_RTC_TS_GetDate\n
  2829. * RTC_TSDR DT LL_RTC_TS_GetDate\n
  2830. * RTC_TSDR DU LL_RTC_TS_GetDate
  2831. * @param RTCx RTC Instance
  2832. * @retval Combination of Weekday, Day and Month
  2833. */
  2834. __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
  2835. {
  2836. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
  2837. }
  2838. /**
  2839. * @brief Get time-stamp sub second value
  2840. * @rmtoll RTC_TSSSR SS LL_RTC_TS_GetSubSecond
  2841. * @param RTCx RTC Instance
  2842. * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
  2843. * else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
  2844. */
  2845. __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
  2846. {
  2847. return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
  2848. }
  2849. /**
  2850. * @}
  2851. */
  2852. #if defined(RTC_WAKEUP_SUPPORT)
  2853. /** @defgroup RTC_LL_EF_Wakeup Wakeup
  2854. * @{
  2855. */
  2856. /**
  2857. * @brief Enable Wakeup timer
  2858. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2859. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_Enable
  2860. * @param RTCx RTC Instance
  2861. * @retval None
  2862. */
  2863. __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
  2864. {
  2865. SET_BIT(RTCx->CR, RTC_CR_WUTE);
  2866. }
  2867. /**
  2868. * @brief Disable Wakeup timer
  2869. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2870. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_Disable
  2871. * @param RTCx RTC Instance
  2872. * @retval None
  2873. */
  2874. __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
  2875. {
  2876. CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
  2877. }
  2878. /**
  2879. * @brief Check if Wakeup timer is enabled or not
  2880. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_IsEnabled
  2881. * @param RTCx RTC Instance
  2882. * @retval State of bit (1 or 0).
  2883. */
  2884. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
  2885. {
  2886. return (READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE));
  2887. }
  2888. /**
  2889. * @brief Select Wakeup clock
  2890. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2891. * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
  2892. * @rmtoll RTC_CR WUCKSEL LL_RTC_WAKEUP_SetClock
  2893. * @param RTCx RTC Instance
  2894. * @param WakeupClock This parameter can be one of the following values:
  2895. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2896. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2897. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2898. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2899. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2900. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2901. * @retval None
  2902. */
  2903. __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
  2904. {
  2905. MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
  2906. }
  2907. /**
  2908. * @brief Get Wakeup clock
  2909. * @rmtoll RTC_CR WUCKSEL LL_RTC_WAKEUP_GetClock
  2910. * @param RTCx RTC Instance
  2911. * @retval Returned value can be one of the following values:
  2912. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2913. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2914. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2915. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2916. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2917. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2918. */
  2919. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
  2920. {
  2921. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
  2922. }
  2923. /**
  2924. * @brief Set Wakeup auto-reload value
  2925. * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
  2926. * @rmtoll RTC_WUTR WUT LL_RTC_WAKEUP_SetAutoReload
  2927. * @param RTCx RTC Instance
  2928. * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
  2929. * @retval None
  2930. */
  2931. __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
  2932. {
  2933. MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
  2934. }
  2935. /**
  2936. * @brief Get Wakeup auto-reload value
  2937. * @rmtoll RTC_WUTR WUT LL_RTC_WAKEUP_GetAutoReload
  2938. * @param RTCx RTC Instance
  2939. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2940. */
  2941. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
  2942. {
  2943. return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
  2944. }
  2945. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  2946. /**
  2947. * @brief Set Wakeup auto-clear value
  2948. * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
  2949. * @rmtoll RTC_WUTR WUTOCLR LL_RTC_WAKEUP_SetAutoClr
  2950. * @param RTCx RTC Instance
  2951. * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
  2952. * @retval None
  2953. */
  2954. __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoClr(RTC_TypeDef *RTCx, uint32_t Value)
  2955. {
  2956. MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUTOCLR, (Value << RTC_WUTR_WUTOCLR_Pos));
  2957. }
  2958. /**
  2959. * @brief Get Wakeup auto-clear value
  2960. * @rmtoll RTC_WUTR WUTOCLR LL_RTC_WAKEUP_GetAutoClr
  2961. * @param RTCx RTC Instance
  2962. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2963. */
  2964. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoClr(RTC_TypeDef *RTCx)
  2965. {
  2966. return (uint32_t)((READ_BIT(RTCx->WUTR, RTC_WUTR_WUTOCLR)) >> RTC_WUTR_WUTOCLR_Pos);
  2967. }
  2968. #endif /* defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  2969. /**
  2970. * @}
  2971. */
  2972. #endif /* RTC_WAKEUP_SUPPORT */
  2973. /** @defgroup RTC_LL_EF_Calibration Calibration
  2974. * @{
  2975. */
  2976. /**
  2977. * @brief Set Calibration output frequency (1 Hz or 512 Hz)
  2978. * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2979. * @rmtoll RTC_CR COE LL_RTC_CAL_SetOutputFreq\n
  2980. * RTC_CR COSEL LL_RTC_CAL_SetOutputFreq
  2981. * @param RTCx RTC Instance
  2982. * @param Frequency This parameter can be one of the following values:
  2983. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  2984. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  2985. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  2986. * @retval None
  2987. */
  2988. __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
  2989. {
  2990. MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
  2991. }
  2992. /**
  2993. * @brief Get Calibration output frequency (1 Hz or 512 Hz)
  2994. * @rmtoll RTC_CR COE LL_RTC_CAL_GetOutputFreq\n
  2995. * RTC_CR COSEL LL_RTC_CAL_GetOutputFreq
  2996. * @param RTCx RTC Instance
  2997. * @retval Returned value can be one of the following values:
  2998. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  2999. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  3000. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  3001. */
  3002. __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
  3003. {
  3004. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
  3005. }
  3006. /**
  3007. * @brief Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
  3008. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3009. * @note Bit can be written only when RECALPF is set to 0
  3010. * @rmtoll RTC_CALR CALP LL_RTC_CAL_SetPulse
  3011. * @param RTCx RTC Instance
  3012. * @param Pulse This parameter can be one of the following values:
  3013. * @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
  3014. * @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
  3015. * @retval None
  3016. */
  3017. __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
  3018. {
  3019. MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
  3020. }
  3021. /**
  3022. * @brief Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
  3023. * @rmtoll RTC_CALR CALP LL_RTC_CAL_IsPulseInserted
  3024. * @param RTCx RTC Instance
  3025. * @retval State of bit (1 or 0).
  3026. */
  3027. __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
  3028. {
  3029. return (READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP));
  3030. }
  3031. /**
  3032. * @brief Set the calibration cycle period
  3033. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3034. * @note Bit can be written only when RECALPF is set to 0
  3035. * @rmtoll RTC_CALR CALW8 LL_RTC_CAL_SetPeriod\n
  3036. * RTC_CALR CALW16 LL_RTC_CAL_SetPeriod
  3037. * @param RTCx RTC Instance
  3038. * @param Period This parameter can be one of the following values:
  3039. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3040. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3041. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3042. * @retval None
  3043. */
  3044. __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
  3045. {
  3046. MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
  3047. }
  3048. /**
  3049. * @brief Get the calibration cycle period
  3050. * @rmtoll RTC_CALR CALW8 LL_RTC_CAL_GetPeriod\n
  3051. * RTC_CALR CALW16 LL_RTC_CAL_GetPeriod
  3052. * @param RTCx RTC Instance
  3053. * @retval Returned value can be one of the following values:
  3054. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3055. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3056. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3057. */
  3058. __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
  3059. {
  3060. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
  3061. }
  3062. /**
  3063. * @brief Set Calibration minus
  3064. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3065. * @note Bit can be written only when RECALPF is set to 0
  3066. * @rmtoll RTC_CALR CALM LL_RTC_CAL_SetMinus
  3067. * @param RTCx RTC Instance
  3068. * @param CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
  3069. * @retval None
  3070. */
  3071. __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
  3072. {
  3073. MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
  3074. }
  3075. /**
  3076. * @brief Get Calibration minus
  3077. * @rmtoll RTC_CALR CALM LL_RTC_CAL_GetMinus
  3078. * @param RTCx RTC Instance
  3079. * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
  3080. */
  3081. __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
  3082. {
  3083. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
  3084. }
  3085. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3086. /**
  3087. * @brief Enable Calibration Low Power
  3088. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3089. * @note Bit can be written only when RECALPF is set to 0
  3090. * @rmtoll RTC_CALR LPCAL LL_RTC_CAL_LowPower_Enable
  3091. * @param RTCx RTC Instance
  3092. * @retval None
  3093. */
  3094. __STATIC_INLINE void LL_RTC_CAL_LowPower_Enable(RTC_TypeDef *RTCx)
  3095. {
  3096. SET_BIT(RTCx->CALR, RTC_CALR_LPCAL);
  3097. }
  3098. /**
  3099. * @brief Disable Calibration Low Power
  3100. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3101. * @note Bit can be written only when RECALPF is set to 0
  3102. * @rmtoll RTC_CALR LPCAL LL_RTC_CAL_LowPower_Disable
  3103. * @param RTCx RTC Instance
  3104. * @retval None
  3105. */
  3106. __STATIC_INLINE void LL_RTC_CAL_LowPower_Disable(RTC_TypeDef *RTCx)
  3107. {
  3108. CLEAR_BIT(RTCx->CALR, RTC_CALR_LPCAL);
  3109. }
  3110. /**
  3111. * @brief Check if Calibration Low Power is enabled or not
  3112. * @rmtoll RTC_CALR LPCAL LL_RTC_CAL_LowPower_IsEnabled
  3113. * @param RTCx RTC Instance
  3114. * @retval State of bit (1 or 0).
  3115. */
  3116. __STATIC_INLINE uint32_t LL_RTC_CAL_LowPower_IsEnabled(RTC_TypeDef *RTCx)
  3117. {
  3118. return (READ_BIT(RTCx->CALR, RTC_CALR_LPCAL) == (RTC_CALR_LPCAL));
  3119. }
  3120. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  3121. /**
  3122. * @}
  3123. */
  3124. #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3125. /**
  3126. * @brief Activate timestamp on tamper detection event
  3127. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_EnableOnTamper
  3128. * @param RTCx RTC Instance
  3129. * @retval None
  3130. */
  3131. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  3132. {
  3133. SET_BIT(RTCx->CR, RTC_CR_TAMPTS);
  3134. }
  3135. /**
  3136. * @brief Disable timestamp on tamper detection event
  3137. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_DisableOnTamper
  3138. * @param RTCx RTC Instance
  3139. * @retval None
  3140. */
  3141. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  3142. {
  3143. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPTS);
  3144. }
  3145. /** @defgroup RTC_LL_EF_Tamper Tamper
  3146. * @{
  3147. */
  3148. /**
  3149. * @brief Enable TAMPx input detection
  3150. * @rmtoll TAMP_CR1 TAMP1E LL_RTC_TAMPER_Enable\n
  3151. * TAMP_CR1 TAMP2E LL_RTC_TAMPER_Enable
  3152. * @param TAMPx TAMP Instance
  3153. * @param Tamper This parameter can be a combination of the following values:
  3154. * @arg @ref LL_RTC_TAMPER_1
  3155. * @arg @ref LL_RTC_TAMPER_2
  3156. *
  3157. * @retval None
  3158. */
  3159. __STATIC_INLINE void LL_RTC_TAMPER_Enable(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3160. {
  3161. SET_BIT(TAMPx->CR1, Tamper);
  3162. }
  3163. /**
  3164. * @brief Clear TAMPx input detection
  3165. * @rmtoll TAMP_CR1 TAMP1E LL_RTC_TAMPER_Disable\n
  3166. * TAMP_CR1 TAMP2E LL_RTC_TAMPER_Disable
  3167. * @param TAMPx TAMP Instance
  3168. * @param Tamper This parameter can be a combination of the following values:
  3169. * @arg @ref LL_RTC_TAMPER_1
  3170. * @arg @ref LL_RTC_TAMPER_2
  3171. *
  3172. * @retval None
  3173. */
  3174. __STATIC_INLINE void LL_RTC_TAMPER_Disable(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3175. {
  3176. CLEAR_BIT(TAMPx->CR1, Tamper);
  3177. }
  3178. /**
  3179. * @brief Enable Tamper mask flag
  3180. * @note Associated Tamper IT must not enabled when tamper mask is set.
  3181. * @rmtoll TAMP_CR2 TAMP1MF LL_RTC_TAMPER_EnableMask\n
  3182. * TAMP_CR2 TAMP2MF LL_RTC_TAMPER_EnableMask
  3183. * @param TAMPx TAMP Instance
  3184. * @param Mask This parameter can be a combination of the following values:
  3185. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  3186. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  3187. *
  3188. * @retval None
  3189. */
  3190. __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(TAMP_TypeDef *TAMPx, uint32_t Mask)
  3191. {
  3192. SET_BIT(TAMPx->CR2, Mask);
  3193. }
  3194. /**
  3195. * @brief Disable Tamper mask flag
  3196. * @rmtoll TAMP_CR2 TAMP1MF LL_RTC_TAMPER_DisableMask\n
  3197. * TAMP_CR2 TAMP2MF LL_RTC_TAMPER_DisableMask
  3198. * @param TAMPx TAMP Instance
  3199. * @param Mask This parameter can be a combination of the following values:
  3200. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  3201. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  3202. *
  3203. * @retval None
  3204. */
  3205. __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(TAMP_TypeDef *TAMPx, uint32_t Mask)
  3206. {
  3207. CLEAR_BIT(TAMPx->CR2, Mask);
  3208. }
  3209. /**
  3210. * @brief Enable backup register erase after Tamper event detection
  3211. * @rmtoll TAMP_CR2 TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
  3212. * TAMP_CR2 TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP
  3213. * @param TAMPx TAMP Instance
  3214. * @param Tamper This parameter can be a combination of the following values:
  3215. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  3216. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  3217. *
  3218. * @retval None
  3219. */
  3220. __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3221. {
  3222. CLEAR_BIT(TAMPx->CR2, Tamper);
  3223. }
  3224. /**
  3225. * @brief Disable backup register erase after Tamper event detection
  3226. * @rmtoll TAMP_CR2 TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
  3227. * TAMP_CR2 TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP
  3228. * @param TAMPx TAMP Instance
  3229. * @param Tamper This parameter can be a combination of the following values:
  3230. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  3231. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  3232. *
  3233. * @retval None
  3234. */
  3235. __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3236. {
  3237. SET_BIT(TAMPx->CR2, Tamper);
  3238. }
  3239. /**
  3240. * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  3241. * @rmtoll TAMP_FLTCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
  3242. * @param TAMPx TAMP Instance
  3243. * @retval None
  3244. */
  3245. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(TAMP_TypeDef *TAMPx)
  3246. {
  3247. SET_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPUDIS);
  3248. }
  3249. /**
  3250. * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
  3251. * @rmtoll TAMP_FLTCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
  3252. * @param TAMPx TAMP Instance
  3253. * @retval None
  3254. */
  3255. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(TAMP_TypeDef *TAMPx)
  3256. {
  3257. CLEAR_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPUDIS);
  3258. }
  3259. /**
  3260. * @brief Set RTC_TAMPx precharge duration
  3261. * @rmtoll TAMP_FLTCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
  3262. * @param TAMPx TAMP Instance
  3263. * @param Duration This parameter can be one of the following values:
  3264. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  3265. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  3266. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  3267. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  3268. * @retval None
  3269. */
  3270. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(TAMP_TypeDef *TAMPx, uint32_t Duration)
  3271. {
  3272. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPPRCH, Duration);
  3273. }
  3274. /**
  3275. * @brief Get RTC_TAMPx precharge duration
  3276. * @rmtoll TAMP_FLTCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
  3277. * @param TAMPx TAMP Instance
  3278. * @retval Returned value can be one of the following values:
  3279. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  3280. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  3281. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  3282. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  3283. */
  3284. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(TAMP_TypeDef *TAMPx)
  3285. {
  3286. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPRCH));
  3287. }
  3288. /**
  3289. * @brief Set RTC_TAMPx filter count
  3290. * @rmtoll TAMP_FLTCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
  3291. * @param TAMPx TAMP Instance
  3292. * @param FilterCount This parameter can be one of the following values:
  3293. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  3294. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  3295. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  3296. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  3297. * @retval None
  3298. */
  3299. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(TAMP_TypeDef *TAMPx, uint32_t FilterCount)
  3300. {
  3301. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPFLT, FilterCount);
  3302. }
  3303. /**
  3304. * @brief Get RTC_TAMPx filter count
  3305. * @rmtoll TAMP_FLTCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
  3306. * @param TAMPx TAMP Instance
  3307. * @retval Returned value can be one of the following values:
  3308. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  3309. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  3310. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  3311. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  3312. */
  3313. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(TAMP_TypeDef *TAMPx)
  3314. {
  3315. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPFLT));
  3316. }
  3317. /**
  3318. * @brief Set Tamper sampling frequency
  3319. * @rmtoll TAMP_FLTCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
  3320. * @param TAMPx TAMP Instance
  3321. * @param SamplingFreq This parameter can be one of the following values:
  3322. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  3323. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  3324. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  3325. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  3326. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  3327. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  3328. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  3329. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  3330. * @retval None
  3331. */
  3332. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(TAMP_TypeDef *TAMPx, uint32_t SamplingFreq)
  3333. {
  3334. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPFREQ, SamplingFreq);
  3335. }
  3336. /**
  3337. * @brief Get Tamper sampling frequency
  3338. * @rmtoll TAMP_FLTCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
  3339. * @param TAMPx TAMP Instance
  3340. * @retval Returned value can be one of the following values:
  3341. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  3342. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  3343. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  3344. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  3345. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  3346. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  3347. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  3348. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  3349. */
  3350. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(TAMP_TypeDef *TAMPx)
  3351. {
  3352. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPFREQ));
  3353. }
  3354. /**
  3355. * @brief Enable Active level for Tamper input
  3356. * @rmtoll TAMP_CR2 TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel\n
  3357. * TAMP_CR2 TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel
  3358. * @param TAMPx TAMP Instance
  3359. * @param Tamper This parameter can be a combination of the following values:
  3360. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  3361. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  3362. *
  3363. * @retval None
  3364. */
  3365. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3366. {
  3367. SET_BIT(TAMPx->CR2, Tamper);
  3368. }
  3369. /**
  3370. * @brief Disable Active level for Tamper input
  3371. * @rmtoll TAMP_CR2 TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel\n
  3372. * TAMP_CR2 TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel
  3373. * @param TAMPx TAMP Instance
  3374. * @param Tamper This parameter can be a combination of the following values:
  3375. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  3376. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  3377. *
  3378. * @retval None
  3379. */
  3380. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3381. {
  3382. CLEAR_BIT(TAMPx->CR2, Tamper);
  3383. }
  3384. /**
  3385. * @}
  3386. */
  3387. /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
  3388. * @{
  3389. */
  3390. /**
  3391. * @brief Writes a data in a specified Backup data register.
  3392. * @rmtoll TAMP_BKPxR BKP LL_RTC_BKP_SetRegister
  3393. * @param TAMPx RTC Instance
  3394. * @param BackupRegister This parameter can be one of the following values:
  3395. * @arg @ref LL_RTC_BKP_DR0
  3396. * @arg @ref LL_RTC_BKP_DR1
  3397. * @arg @ref LL_RTC_BKP_DR2
  3398. * @arg @ref LL_RTC_BKP_DR3
  3399. * @arg @ref LL_RTC_BKP_DR4
  3400. * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3401. * @retval None
  3402. */
  3403. __STATIC_INLINE void LL_RTC_BKP_SetRegister(TAMP_TypeDef *TAMPx, uint32_t BackupRegister, uint32_t Data)
  3404. {
  3405. uint32_t tmp = 0U;
  3406. tmp = (uint32_t)(&(TAMPx->BKP0R));
  3407. tmp += (BackupRegister * 4U);
  3408. /* Write the specified register */
  3409. *(__IO uint32_t *)tmp = (uint32_t)Data;
  3410. }
  3411. /**
  3412. * @brief Reads data from the specified RTC Backup data Register.
  3413. * @rmtoll TAMP_BKPxR BKP LL_RTC_BKP_GetRegister
  3414. * @param TAMPx RTC Instance
  3415. * @param BackupRegister This parameter can be one of the following values:
  3416. * @arg @ref LL_RTC_BKP_DR0
  3417. * @arg @ref LL_RTC_BKP_DR1
  3418. * @arg @ref LL_RTC_BKP_DR2
  3419. * @arg @ref LL_RTC_BKP_DR3
  3420. * @arg @ref LL_RTC_BKP_DR4
  3421. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3422. */
  3423. __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(TAMP_TypeDef *TAMPx, uint32_t BackupRegister)
  3424. {
  3425. uint32_t tmp = 0U;
  3426. tmp = (uint32_t)(&(TAMPx->BKP0R));
  3427. tmp += (BackupRegister * 4U);
  3428. /* Read the specified register */
  3429. return (*(__IO uint32_t *)tmp);
  3430. }
  3431. /**
  3432. * @}
  3433. */
  3434. /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
  3435. * @{
  3436. */
  3437. /**
  3438. * @brief Get Internal Time-stamp flag
  3439. * @rmtoll RTC_SR ITSF LL_RTC_IsActiveFlag_ITS
  3440. * @param RTCx RTC Instance
  3441. * @retval State of bit (1 or 0).
  3442. */
  3443. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
  3444. {
  3445. return (READ_BIT(RTCx->SR, RTC_SR_ITSF) == (RTC_SR_ITSF));
  3446. }
  3447. /**
  3448. * @brief Get Recalibration pending Flag
  3449. * @rmtoll RTC_ICSR RECALPF LL_RTC_IsActiveFlag_RECALP
  3450. * @param RTCx RTC Instance
  3451. * @retval State of bit (1 or 0).
  3452. */
  3453. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  3454. {
  3455. return (READ_BIT(RTCx->ICSR, RTC_ICSR_RECALPF) == (RTC_ICSR_RECALPF));
  3456. }
  3457. /**
  3458. * @brief Get Time-stamp overflow flag
  3459. * @rmtoll RTC_SR TSOVF LL_RTC_IsActiveFlag_TSOV
  3460. * @param RTCx RTC Instance
  3461. * @retval State of bit (1 or 0).
  3462. */
  3463. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  3464. {
  3465. return (READ_BIT(RTCx->SR, RTC_SR_TSOVF) == (RTC_SR_TSOVF));
  3466. }
  3467. /**
  3468. * @brief Get Time-stamp flag
  3469. * @rmtoll RTC_SR TSF LL_RTC_IsActiveFlag_TS
  3470. * @param RTCx RTC Instance
  3471. * @retval State of bit (1 or 0).
  3472. */
  3473. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  3474. {
  3475. return (READ_BIT(RTCx->SR, RTC_SR_TSF) == (RTC_SR_TSF));
  3476. }
  3477. /**
  3478. * @brief Get Wakeup timer flag
  3479. * @rmtoll RTC_SR WUTF LL_RTC_IsActiveFlag_WUT
  3480. * @param RTCx RTC Instance
  3481. * @retval State of bit (1 or 0).
  3482. */
  3483. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  3484. {
  3485. return (READ_BIT(RTCx->SR, RTC_SR_WUTF) == (RTC_SR_WUTF));
  3486. }
  3487. /**
  3488. * @brief Get Alarm B flag
  3489. * @rmtoll RTC_SR ALRBF LL_RTC_IsActiveFlag_ALRB
  3490. * @param RTCx RTC Instance
  3491. * @retval State of bit (1 or 0).
  3492. */
  3493. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  3494. {
  3495. return (READ_BIT(RTCx->SR, RTC_SR_ALRBF) == (RTC_SR_ALRBF));
  3496. }
  3497. /**
  3498. * @brief Get Alarm A flag
  3499. * @rmtoll RTC_SR ALRAF LL_RTC_IsActiveFlag_ALRA
  3500. * @param RTCx RTC Instance
  3501. * @retval State of bit (1 or 0).
  3502. */
  3503. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  3504. {
  3505. return (READ_BIT(RTCx->SR, RTC_SR_ALRAF) == (RTC_SR_ALRAF));
  3506. }
  3507. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3508. /**
  3509. * @brief Get SSR Underflow flag
  3510. * @rmtoll RTC_SR SSRUF LL_RTC_IsActiveFlag_SSRU
  3511. * @param RTCx RTC Instance
  3512. * @retval State of bit (1 or 0).
  3513. */
  3514. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRU(RTC_TypeDef *RTCx)
  3515. {
  3516. return ((READ_BIT(RTCx->SR, RTC_SR_SSRUF) == (RTC_SR_SSRUF)) ? 1U : 0U);
  3517. }
  3518. #endif
  3519. /**
  3520. * @brief Clear Internal Time-stamp flag
  3521. * @rmtoll RTC_SCR CITSF LL_RTC_ClearFlag_ITS
  3522. * @param RTCx RTC Instance
  3523. * @retval None
  3524. */
  3525. __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
  3526. {
  3527. SET_BIT(RTCx->SCR, RTC_SCR_CITSF);
  3528. }
  3529. /**
  3530. * @brief Clear Time-stamp overflow flag
  3531. * @rmtoll RTC_SCR CTSOVF LL_RTC_ClearFlag_TSOV
  3532. * @param RTCx RTC Instance
  3533. * @retval None
  3534. */
  3535. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  3536. {
  3537. SET_BIT(RTCx->SCR, RTC_SCR_CTSOVF);
  3538. }
  3539. /**
  3540. * @brief Clear Time-stamp flag
  3541. * @rmtoll RTC_SCR CTSF LL_RTC_ClearFlag_TS
  3542. * @param RTCx RTC Instance
  3543. * @retval None
  3544. */
  3545. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  3546. {
  3547. SET_BIT(RTCx->SCR, RTC_SCR_CTSF);
  3548. }
  3549. /**
  3550. * @brief Clear Wakeup timer flag
  3551. * @rmtoll RTC_SCR CWUTF LL_RTC_ClearFlag_WUT
  3552. * @param RTCx RTC Instance
  3553. * @retval None
  3554. */
  3555. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  3556. {
  3557. SET_BIT(RTCx->SCR, RTC_SCR_CWUTF);
  3558. }
  3559. /**
  3560. * @brief Clear Alarm B flag
  3561. * @rmtoll RTC_SCR CALRBF LL_RTC_ClearFlag_ALRB
  3562. * @param RTCx RTC Instance
  3563. * @retval None
  3564. */
  3565. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  3566. {
  3567. SET_BIT(RTCx->SCR, RTC_SCR_CALRBF);
  3568. }
  3569. /**
  3570. * @brief Clear Alarm A flag
  3571. * @rmtoll RTC_SCR CALRAF LL_RTC_ClearFlag_ALRA
  3572. * @param RTCx RTC Instance
  3573. * @retval None
  3574. */
  3575. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  3576. {
  3577. SET_BIT(RTCx->SCR, RTC_SCR_CALRAF);
  3578. }
  3579. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3580. /**
  3581. * @brief Clear SSR Underflow flag
  3582. * @rmtoll RTC_SCR CSSRUF LL_RTC_ClearFlag_SSRU
  3583. * @param RTCx RTC Instance
  3584. * @retval None
  3585. */
  3586. __STATIC_INLINE void LL_RTC_ClearFlag_SSRU(RTC_TypeDef *RTCx)
  3587. {
  3588. WRITE_REG(RTCx->SCR, RTC_SCR_CSSRUF);
  3589. }
  3590. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  3591. /**
  3592. * @brief Get Initialization flag
  3593. * @rmtoll RTC_ICSR INITF LL_RTC_IsActiveFlag_INIT
  3594. * @param RTCx RTC Instance
  3595. * @retval State of bit (1 or 0).
  3596. */
  3597. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  3598. {
  3599. return (READ_BIT(RTCx->ICSR, RTC_ICSR_INITF) == (RTC_ICSR_INITF));
  3600. }
  3601. /**
  3602. * @brief Get Registers synchronization flag
  3603. * @rmtoll RTC_ICSR RSF LL_RTC_IsActiveFlag_RS
  3604. * @param RTCx RTC Instance
  3605. * @retval State of bit (1 or 0).
  3606. */
  3607. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  3608. {
  3609. return (READ_BIT(RTCx->ICSR, RTC_ICSR_RSF) == (RTC_ICSR_RSF));
  3610. }
  3611. /**
  3612. * @brief Clear Registers synchronization flag
  3613. * @rmtoll RTC_ICSR RSF LL_RTC_ClearFlag_RS
  3614. * @param RTCx RTC Instance
  3615. * @retval None
  3616. */
  3617. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  3618. {
  3619. WRITE_REG(RTCx->ICSR, (~((RTC_ICSR_RSF | RTC_ICSR_INIT) & 0x000000FFU) | (RTCx->ICSR & RTC_ICSR_INIT)));
  3620. }
  3621. /**
  3622. * @brief Get Initialization status flag
  3623. * @rmtoll RTC_ICSR INITS LL_RTC_IsActiveFlag_INITS
  3624. * @param RTCx RTC Instance
  3625. * @retval State of bit (1 or 0).
  3626. */
  3627. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  3628. {
  3629. return (READ_BIT(RTCx->ICSR, RTC_ICSR_INITS) == (RTC_ICSR_INITS));
  3630. }
  3631. /**
  3632. * @brief Get Shift operation pending flag
  3633. * @rmtoll RTC_ICSR SHPF LL_RTC_IsActiveFlag_SHP
  3634. * @param RTCx RTC Instance
  3635. * @retval State of bit (1 or 0).
  3636. */
  3637. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  3638. {
  3639. return (READ_BIT(RTCx->ICSR, RTC_ICSR_SHPF) == (RTC_ICSR_SHPF));
  3640. }
  3641. /**
  3642. * @brief Get Wakeup timer write flag
  3643. * @rmtoll RTC_ICSR WUTWF LL_RTC_IsActiveFlag_WUTW
  3644. * @param RTCx RTC Instance
  3645. * @retval State of bit (1 or 0).
  3646. */
  3647. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  3648. {
  3649. return (READ_BIT(RTCx->ICSR, RTC_ICSR_WUTWF) == (RTC_ICSR_WUTWF));
  3650. }
  3651. /**
  3652. * @brief Get Alarm A masked flag.
  3653. * @rmtoll RTC_MISR ALRAMF LL_RTC_IsActiveFlag_ALRAM
  3654. * @param RTCx RTC Instance
  3655. * @retval State of bit (1 or 0).
  3656. */
  3657. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAM(RTC_TypeDef *RTCx)
  3658. {
  3659. return (READ_BIT(RTCx->MISR, RTC_MISR_ALRAMF) == (RTC_MISR_ALRAMF));
  3660. }
  3661. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3662. /**
  3663. * @brief Get SSR Underflow masked flag.
  3664. * @rmtoll RTC_MISR SSRUMF LL_RTC_IsActiveFlag_SSRUM
  3665. * @param RTCx RTC Instance
  3666. * @retval State of bit (1 or 0).
  3667. */
  3668. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRUM(RTC_TypeDef *RTCx)
  3669. {
  3670. return ((READ_BIT(RTCx->MISR, RTC_MISR_SSRUMF) == (RTC_MISR_SSRUMF)) ? 1U : 0U);
  3671. }
  3672. #endif
  3673. /**
  3674. * @brief Get Alarm B masked flag.
  3675. * @rmtoll RTC_MISR ALRBMF LL_RTC_IsActiveFlag_ALRBM
  3676. * @param RTCx RTC Instance
  3677. * @retval State of bit (1 or 0).
  3678. */
  3679. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBM(RTC_TypeDef *RTCx)
  3680. {
  3681. return (READ_BIT(RTCx->MISR, RTC_MISR_ALRBMF) == (RTC_MISR_ALRBMF));
  3682. }
  3683. /**
  3684. * @brief Get Wakeup timer masked flag.
  3685. * @rmtoll RTC_MISR WUTMF LL_RTC_IsActiveFlag_WUTM
  3686. * @param RTCx RTC Instance
  3687. * @retval State of bit (1 or 0).
  3688. */
  3689. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTM(RTC_TypeDef *RTCx)
  3690. {
  3691. return (READ_BIT(RTCx->MISR, RTC_MISR_WUTMF) == (RTC_MISR_WUTMF));
  3692. }
  3693. /**
  3694. * @brief Get Time-stamp masked flag.
  3695. * @rmtoll RTC_MISR TSMF LL_RTC_IsActiveFlag_TSM
  3696. * @param RTCx RTC Instance
  3697. * @retval State of bit (1 or 0).
  3698. */
  3699. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSM(RTC_TypeDef *RTCx)
  3700. {
  3701. return (READ_BIT(RTCx->MISR, RTC_MISR_TSMF) == (RTC_MISR_TSMF));
  3702. }
  3703. /**
  3704. * @brief Get Time-stamp overflow masked flag.
  3705. * @rmtoll RTC_MISR TSOVMF LL_RTC_IsActiveFlag_TSOVM
  3706. * @param RTCx RTC Instance
  3707. * @retval State of bit (1 or 0).
  3708. */
  3709. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOVM(RTC_TypeDef *RTCx)
  3710. {
  3711. return (READ_BIT(RTCx->MISR, RTC_MISR_TSOVMF) == (RTC_MISR_TSOVMF));
  3712. }
  3713. /**
  3714. * @brief Get Internal Time-stamp masked flag.
  3715. * @rmtoll RTC_MISR ITSMF LL_RTC_IsActiveFlag_ITSM
  3716. * @param RTCx RTC Instance
  3717. * @retval State of bit (1 or 0).
  3718. */
  3719. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITSM(RTC_TypeDef *RTCx)
  3720. {
  3721. return (READ_BIT(RTCx->MISR, RTC_MISR_ITSMF) == (RTC_MISR_ITSMF));
  3722. }
  3723. /**
  3724. * @brief Get tamper 1 detection flag.
  3725. * @rmtoll TAMP_SR TAMP1F LL_RTC_IsActiveFlag_TAMP1
  3726. * @param TAMPx TAMP Instance
  3727. * @retval State of bit (1 or 0).
  3728. */
  3729. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(TAMP_TypeDef *TAMPx)
  3730. {
  3731. return (READ_BIT(TAMPx->SR, TAMP_SR_TAMP1F) == (TAMP_SR_TAMP1F));
  3732. }
  3733. /**
  3734. * @brief Get tamper 2 detection flag.
  3735. * @rmtoll TAMP_SR TAMP2F LL_RTC_IsActiveFlag_TAMP2
  3736. * @param TAMPx TAMP Instance
  3737. * @retval State of bit (1 or 0).
  3738. */
  3739. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(TAMP_TypeDef *TAMPx)
  3740. {
  3741. return (READ_BIT(TAMPx->SR, TAMP_SR_TAMP2F) == (TAMP_SR_TAMP2F));
  3742. }
  3743. #if defined(RTC_TAMPER3_SUPPORT)
  3744. /**
  3745. * @brief Get tamper 3 detection flag.
  3746. * @rmtoll TAMP_SR TAMP3F LL_RTC_IsActiveFlag_TAMP3
  3747. * @param TAMPx TAMP Instance
  3748. * @retval State of bit (1 or 0).
  3749. */
  3750. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(TAMP_TypeDef *TAMPx)
  3751. {
  3752. return (READ_BIT(TAMPx->SR, TAMP_SR_TAMP3F) == (TAMP_SR_TAMP3F));
  3753. }
  3754. #endif
  3755. /**
  3756. * @brief Get tamper 1 interrupt masked flag.
  3757. * @rmtoll TAMP_MISR TAMP1MF LL_RTC_IsActiveFlag_TAMP1M
  3758. * @param TAMPx TAMP Instance
  3759. * @retval State of bit (1 or 0).
  3760. */
  3761. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1M(TAMP_TypeDef *TAMPx)
  3762. {
  3763. return (READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP1MF) == (TAMP_MISR_TAMP1MF));
  3764. }
  3765. /**
  3766. * @brief Get tamper 2 interrupt masked flag.
  3767. * @rmtoll TAMP_MISR TAMP2MF LL_RTC_IsActiveFlag_TAMP2M
  3768. * @param TAMPx TAMP Instance
  3769. * @retval State of bit (1 or 0).
  3770. */
  3771. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2M(TAMP_TypeDef *TAMPx)
  3772. {
  3773. return (READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP2MF) == (TAMP_MISR_TAMP2MF));
  3774. }
  3775. #if defined(RTC_TAMPER3_SUPPORT)
  3776. /**
  3777. * @brief Get tamper 3 interrupt masked flag.
  3778. * @rmtoll TAMP_MISR TAMP3MF LL_RTC_IsActiveFlag_TAMP3M
  3779. * @param TAMPx TAMP Instance
  3780. * @retval State of bit (1 or 0).
  3781. */
  3782. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3M(TAMP_TypeDef *TAMPx)
  3783. {
  3784. return (READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP3MF) == (TAMP_MISR_TAMP3MF));
  3785. }
  3786. #endif
  3787. /**
  3788. * @brief Clear tamper 1 detection flag.
  3789. * @rmtoll TAMP_SCR CTAMP1F LL_RTC_ClearFlag_TAMP1
  3790. * @param TAMPx TAMP Instance
  3791. * @retval None
  3792. */
  3793. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(TAMP_TypeDef *TAMPx)
  3794. {
  3795. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP1F);
  3796. }
  3797. /**
  3798. * @brief Clear tamper 2 detection flag.
  3799. * @rmtoll TAMP_SCR CTAMP2F LL_RTC_ClearFlag_TAMP2
  3800. * @param TAMPx TAMP Instance
  3801. * @retval None
  3802. */
  3803. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(TAMP_TypeDef *TAMPx)
  3804. {
  3805. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP2F);
  3806. }
  3807. #if defined(RTC_TAMPER3_SUPPORT)
  3808. /**
  3809. * @brief Clear tamper 3 detection flag.
  3810. * @rmtoll TAMP_SCR CTAMP3F LL_RTC_ClearFlag_TAMP3
  3811. * @param TAMPx TAMP Instance
  3812. * @retval None
  3813. */
  3814. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(TAMP_TypeDef *TAMPx)
  3815. {
  3816. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP3F);
  3817. }
  3818. #endif
  3819. /**
  3820. * @}
  3821. */
  3822. /** @defgroup RTC_LL_EF_IT_Management IT_Management
  3823. * @{
  3824. */
  3825. /**
  3826. * @brief Enable Time-stamp interrupt
  3827. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3828. * @rmtoll RTC_CR TSIE LL_RTC_EnableIT_TS
  3829. * @param RTCx RTC Instance
  3830. * @retval None
  3831. */
  3832. __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
  3833. {
  3834. SET_BIT(RTCx->CR, RTC_CR_TSIE);
  3835. }
  3836. /**
  3837. * @brief Disable Time-stamp interrupt
  3838. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3839. * @rmtoll RTC_CR TSIE LL_RTC_DisableIT_TS
  3840. * @param RTCx RTC Instance
  3841. * @retval None
  3842. */
  3843. __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
  3844. {
  3845. CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
  3846. }
  3847. /**
  3848. * @brief Enable Wakeup timer interrupt
  3849. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3850. * @rmtoll RTC_CR WUTIE LL_RTC_EnableIT_WUT
  3851. * @param RTCx RTC Instance
  3852. * @retval None
  3853. */
  3854. __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
  3855. {
  3856. SET_BIT(RTCx->CR, RTC_CR_WUTIE);
  3857. }
  3858. /**
  3859. * @brief Disable Wakeup timer interrupt
  3860. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3861. * @rmtoll RTC_CR WUTIE LL_RTC_DisableIT_WUT
  3862. * @param RTCx RTC Instance
  3863. * @retval None
  3864. */
  3865. __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
  3866. {
  3867. CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
  3868. }
  3869. /**
  3870. * @brief Enable Alarm B interrupt
  3871. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3872. * @rmtoll RTC_CR ALRBIE LL_RTC_EnableIT_ALRB
  3873. * @param RTCx RTC Instance
  3874. * @retval None
  3875. */
  3876. __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
  3877. {
  3878. SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3879. }
  3880. /**
  3881. * @brief Disable Alarm B interrupt
  3882. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3883. * @rmtoll RTC_CR ALRBIE LL_RTC_DisableIT_ALRB
  3884. * @param RTCx RTC Instance
  3885. * @retval None
  3886. */
  3887. __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
  3888. {
  3889. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3890. }
  3891. /**
  3892. * @brief Enable Alarm A interrupt
  3893. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3894. * @rmtoll RTC_CR ALRAIE LL_RTC_EnableIT_ALRA
  3895. * @param RTCx RTC Instance
  3896. * @retval None
  3897. */
  3898. __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
  3899. {
  3900. SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3901. }
  3902. /**
  3903. * @brief Disable Alarm A interrupt
  3904. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3905. * @rmtoll RTC_CR ALRAIE LL_RTC_DisableIT_ALRA
  3906. * @param RTCx RTC Instance
  3907. * @retval None
  3908. */
  3909. __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
  3910. {
  3911. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3912. }
  3913. #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
  3914. /**
  3915. * @brief Enable SSR Underflow interrupt
  3916. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3917. * @rmtoll RTC_CR SSRUIE LL_RTC_EnableIT_SSRU
  3918. * @param RTCx RTC Instance
  3919. * @retval None
  3920. */
  3921. __STATIC_INLINE void LL_RTC_EnableIT_SSRU(RTC_TypeDef *RTCx)
  3922. {
  3923. SET_BIT(RTCx->CR, RTC_CR_SSRUIE);
  3924. }
  3925. /**
  3926. * @brief Disable SSR Underflow interrupt
  3927. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3928. * @rmtoll RTC_CR SSRUIE LL_RTC_DisableIT_SSRU
  3929. * @param RTCx RTC Instance
  3930. * @retval None
  3931. */
  3932. __STATIC_INLINE void LL_RTC_DisableIT_SSRU(RTC_TypeDef *RTCx)
  3933. {
  3934. CLEAR_BIT(RTCx->CR, RTC_CR_SSRUIE);
  3935. }
  3936. /**
  3937. * @brief Check if SSR Underflow interrupt is enabled or not
  3938. * @rmtoll RTC_CR SSRUIE LL_RTC_IsEnabledIT_SSRU
  3939. * @param RTCx RTC Instance
  3940. * @retval State of bit (1 or 0).
  3941. */
  3942. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SSRU(RTC_TypeDef *RTCx)
  3943. {
  3944. return ((READ_BIT(RTCx->CR, RTC_CR_SSRUIE) == (RTC_CR_SSRUIE)) ? 1U : 0U);
  3945. }
  3946. #endif /* #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  3947. /**
  3948. * @brief Check if Time-stamp interrupt is enabled or not
  3949. * @rmtoll RTC_CR TSIE LL_RTC_IsEnabledIT_TS
  3950. * @param RTCx RTC Instance
  3951. * @retval State of bit (1 or 0).
  3952. */
  3953. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
  3954. {
  3955. return (READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE));
  3956. }
  3957. /**
  3958. * @brief Check if Wakeup timer interrupt is enabled or not
  3959. * @rmtoll RTC_CR WUTIE LL_RTC_IsEnabledIT_WUT
  3960. * @param RTCx RTC Instance
  3961. * @retval State of bit (1 or 0).
  3962. */
  3963. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
  3964. {
  3965. return (READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE));
  3966. }
  3967. /**
  3968. * @brief Check if Alarm B interrupt is enabled or not
  3969. * @rmtoll RTC_CR ALRBIE LL_RTC_IsEnabledIT_ALRB
  3970. * @param RTCx RTC Instance
  3971. * @retval State of bit (1 or 0).
  3972. */
  3973. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
  3974. {
  3975. return (READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE));
  3976. }
  3977. /**
  3978. * @brief Check if Alarm A interrupt is enabled or not
  3979. * @rmtoll RTC_CR ALRAIE LL_RTC_IsEnabledIT_ALRA
  3980. * @param RTCx RTC Instance
  3981. * @retval State of bit (1 or 0).
  3982. */
  3983. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
  3984. {
  3985. return (READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE));
  3986. }
  3987. /**
  3988. * @brief Enable tamper 1 interrupt.
  3989. * @rmtoll TAMP_IER TAMP1IE LL_RTC_EnableIT_TAMP1
  3990. * @param TAMPx TAMP Instance
  3991. * @retval None
  3992. */
  3993. __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(TAMP_TypeDef *TAMPx)
  3994. {
  3995. SET_BIT(TAMPx->IER, TAMP_IER_TAMP1IE);
  3996. }
  3997. /**
  3998. * @brief Disable tamper 1 interrupt.
  3999. * @rmtoll TAMP_IER TAMP1IE LL_RTC_DisableIT_TAMP1
  4000. * @param TAMPx TAMP Instance
  4001. * @retval None
  4002. */
  4003. __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(TAMP_TypeDef *TAMPx)
  4004. {
  4005. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP1IE);
  4006. }
  4007. /**
  4008. * @brief Enable tamper 2 interrupt.
  4009. * @rmtoll TAMP_IER TAMP2IE LL_RTC_EnableIT_TAMP2
  4010. * @param TAMPx TAMP Instance
  4011. * @retval None
  4012. */
  4013. __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(TAMP_TypeDef *TAMPx)
  4014. {
  4015. SET_BIT(TAMPx->IER, TAMP_IER_TAMP2IE);
  4016. }
  4017. /**
  4018. * @brief Disable tamper 2 interrupt.
  4019. * @rmtoll TAMP_IER TAMP2IE LL_RTC_DisableIT_TAMP2
  4020. * @param TAMPx TAMP Instance
  4021. * @retval None
  4022. */
  4023. __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(TAMP_TypeDef *TAMPx)
  4024. {
  4025. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP2IE);
  4026. }
  4027. /**
  4028. * @brief Check if tamper 1 interrupt is enabled or not.
  4029. * @rmtoll TAMP_IER TAMP1IE LL_RTC_IsEnabledIT_TAMP1
  4030. * @param TAMPx TAMP Instance
  4031. * @retval State of bit (1 or 0).
  4032. */
  4033. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(TAMP_TypeDef *TAMPx)
  4034. {
  4035. return (READ_BIT(TAMPx->IER, TAMP_IER_TAMP1IE) == (TAMP_IER_TAMP1IE));
  4036. }
  4037. /**
  4038. * @brief Check if tamper 2 interrupt is enabled or not.
  4039. * @rmtoll TAMP_IER TAMP2IE LL_RTC_IsEnabledIT_TAMP2
  4040. * @param TAMPx TAMP Instance
  4041. * @retval State of bit (1 or 0).
  4042. */
  4043. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(TAMP_TypeDef *TAMPx)
  4044. {
  4045. return (READ_BIT(TAMPx->IER, TAMP_IER_TAMP2IE) == (TAMP_IER_TAMP2IE));
  4046. }
  4047. #if defined(RTC_TAMPER3_SUPPORT)
  4048. /**
  4049. * @brief Enable tamper 3 interrupt.
  4050. * @rmtoll TAMP_IER TAMP3IE LL_RTC_EnableIT_TAMP3
  4051. * @param TAMPx TAMP Instance
  4052. * @retval None
  4053. */
  4054. __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(TAMP_TypeDef *TAMPx)
  4055. {
  4056. SET_BIT(TAMPx->IER, TAMP_IER_TAMP3IE);
  4057. }
  4058. /**
  4059. * @brief Disable tamper 3 interrupt.
  4060. * @rmtoll TAMP_IER TAMP3IE LL_RTC_DisableIT_TAMP3
  4061. * @param TAMPx TAMP Instance
  4062. * @retval None
  4063. */
  4064. __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(TAMP_TypeDef *TAMPx)
  4065. {
  4066. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP3IE);
  4067. }
  4068. /**
  4069. * @brief Check if tamper 3 interrupt is enabled or not.
  4070. * @rmtoll TAMP_IER TAMP3IE LL_RTC_IsEnabledIT_TAMP3
  4071. * @param TAMPx TAMP Instance
  4072. * @retval State of bit (1 or 0).
  4073. */
  4074. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(TAMP_TypeDef *TAMPx)
  4075. {
  4076. return (READ_BIT(TAMPx->IER, TAMP_IER_TAMP3IE) == (TAMP_IER_TAMP3IE));
  4077. }
  4078. #endif
  4079. /**
  4080. * @}
  4081. */
  4082. #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  4083. #if defined(RTC_TAMPCR_TAMPTS)
  4084. /**
  4085. * @brief Activate timestamp on tamper detection event
  4086. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_EnableOnTamper
  4087. * @param RTCx RTC Instance
  4088. * @retval None
  4089. */
  4090. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  4091. {
  4092. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  4093. }
  4094. /**
  4095. * @brief Disable timestamp on tamper detection event
  4096. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_DisableOnTamper
  4097. * @param RTCx RTC Instance
  4098. * @retval None
  4099. */
  4100. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  4101. {
  4102. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  4103. }
  4104. #endif /* RTC_TAMPCR_TAMPTS */
  4105. /** @defgroup RTC_LL_EF_Tamper Tamper
  4106. * @{
  4107. */
  4108. /**
  4109. * @brief Enable RTC_TAMPx input detection
  4110. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Enable\n
  4111. * TAMPCR TAMP2E LL_RTC_TAMPER_Enable\n
  4112. * TAMPCR TAMP3E LL_RTC_TAMPER_Enable
  4113. * @param RTCx RTC Instance
  4114. * @param Tamper This parameter can be a combination of the following values:
  4115. * @arg @ref LL_RTC_TAMPER_1
  4116. * @arg @ref LL_RTC_TAMPER_2
  4117. * @arg @ref LL_RTC_TAMPER_3
  4118. *
  4119. * @retval None
  4120. */
  4121. __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
  4122. {
  4123. SET_BIT(RTCx->TAMPCR, Tamper);
  4124. }
  4125. /**
  4126. * @brief Clear RTC_TAMPx input detection
  4127. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Disable\n
  4128. * TAMPCR TAMP2E LL_RTC_TAMPER_Disable\n
  4129. * TAMPCR TAMP3E LL_RTC_TAMPER_Disable
  4130. * @param RTCx RTC Instance
  4131. * @param Tamper This parameter can be a combination of the following values:
  4132. * @arg @ref LL_RTC_TAMPER_1
  4133. * @arg @ref LL_RTC_TAMPER_2
  4134. * @arg @ref LL_RTC_TAMPER_3
  4135. *
  4136. * @retval None
  4137. */
  4138. __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
  4139. {
  4140. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  4141. }
  4142. /**
  4143. * @brief Enable Tamper mask flag
  4144. * @note Associated Tamper IT must not enabled when tamper mask is set.
  4145. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_EnableMask\n
  4146. * TAMPCR TAMP2MF LL_RTC_TAMPER_EnableMask\n
  4147. * TAMPCR TAMP3MF LL_RTC_TAMPER_EnableMask
  4148. * @param RTCx RTC Instance
  4149. * @param Mask This parameter can be a combination of the following values:
  4150. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  4151. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  4152. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  4153. *
  4154. * @retval None
  4155. */
  4156. __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  4157. {
  4158. SET_BIT(RTCx->TAMPCR, Mask);
  4159. }
  4160. /**
  4161. * @brief Disable Tamper mask flag
  4162. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_DisableMask\n
  4163. * TAMPCR TAMP2MF LL_RTC_TAMPER_DisableMask\n
  4164. * TAMPCR TAMP3MF LL_RTC_TAMPER_DisableMask
  4165. * @param RTCx RTC Instance
  4166. * @param Mask This parameter can be a combination of the following values:
  4167. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  4168. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  4169. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  4170. *
  4171. * @retval None
  4172. */
  4173. __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  4174. {
  4175. CLEAR_BIT(RTCx->TAMPCR, Mask);
  4176. }
  4177. /**
  4178. * @brief Enable backup register erase after Tamper event detection
  4179. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
  4180. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
  4181. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_EnableEraseBKP
  4182. * @param RTCx RTC Instance
  4183. * @param Tamper This parameter can be a combination of the following values:
  4184. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  4185. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  4186. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  4187. *
  4188. * @retval None
  4189. */
  4190. __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  4191. {
  4192. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  4193. }
  4194. /**
  4195. * @brief Disable backup register erase after Tamper event detection
  4196. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
  4197. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
  4198. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_DisableEraseBKP
  4199. * @param RTCx RTC Instance
  4200. * @param Tamper This parameter can be a combination of the following values:
  4201. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  4202. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  4203. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  4204. *
  4205. * @retval None
  4206. */
  4207. __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  4208. {
  4209. SET_BIT(RTCx->TAMPCR, Tamper);
  4210. }
  4211. #if defined(RTC_TAMPCR_TAMPPUDIS)
  4212. /**
  4213. * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  4214. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
  4215. * @param RTCx RTC Instance
  4216. * @retval None
  4217. */
  4218. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
  4219. {
  4220. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  4221. }
  4222. /**
  4223. * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
  4224. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
  4225. * @param RTCx RTC Instance
  4226. * @retval None
  4227. */
  4228. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
  4229. {
  4230. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  4231. }
  4232. #endif /* RTC_TAMPCR_TAMPPUDIS */
  4233. #if defined(RTC_TAMPCR_TAMPPRCH)
  4234. /**
  4235. * @brief Set RTC_TAMPx precharge duration
  4236. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
  4237. * @param RTCx RTC Instance
  4238. * @param Duration This parameter can be one of the following values:
  4239. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  4240. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  4241. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  4242. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  4243. * @retval None
  4244. */
  4245. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
  4246. {
  4247. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH, Duration);
  4248. }
  4249. /**
  4250. * @brief Get RTC_TAMPx precharge duration
  4251. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
  4252. * @param RTCx RTC Instance
  4253. * @retval Returned value can be one of the following values:
  4254. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  4255. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  4256. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  4257. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  4258. */
  4259. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
  4260. {
  4261. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH));
  4262. }
  4263. #endif /* RTC_TAMPCR_TAMPPRCH */
  4264. #if defined(RTC_TAMPCR_TAMPFLT)
  4265. /**
  4266. * @brief Set RTC_TAMPx filter count
  4267. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
  4268. * @param RTCx RTC Instance
  4269. * @param FilterCount This parameter can be one of the following values:
  4270. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  4271. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  4272. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  4273. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  4274. * @retval None
  4275. */
  4276. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
  4277. {
  4278. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT, FilterCount);
  4279. }
  4280. /**
  4281. * @brief Get RTC_TAMPx filter count
  4282. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
  4283. * @param RTCx RTC Instance
  4284. * @retval Returned value can be one of the following values:
  4285. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  4286. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  4287. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  4288. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  4289. */
  4290. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
  4291. {
  4292. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT));
  4293. }
  4294. #endif /* RTC_TAMPCR_TAMPFLT */
  4295. #if defined(RTC_TAMPCR_TAMPFREQ)
  4296. /**
  4297. * @brief Set Tamper sampling frequency
  4298. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
  4299. * @param RTCx RTC Instance
  4300. * @param SamplingFreq This parameter can be one of the following values:
  4301. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  4302. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  4303. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  4304. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  4305. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  4306. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  4307. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  4308. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  4309. * @retval None
  4310. */
  4311. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
  4312. {
  4313. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ, SamplingFreq);
  4314. }
  4315. /**
  4316. * @brief Get Tamper sampling frequency
  4317. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
  4318. * @param RTCx RTC Instance
  4319. * @retval Returned value can be one of the following values:
  4320. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  4321. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  4322. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  4323. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  4324. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  4325. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  4326. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  4327. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  4328. */
  4329. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
  4330. {
  4331. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ));
  4332. }
  4333. #endif /* RTC_TAMPCR_TAMPFREQ */
  4334. /**
  4335. * @brief Enable Active level for Tamper input
  4336. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel\n
  4337. * TAMPCR TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel\n
  4338. * TAMPCR TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
  4339. * @param RTCx RTC Instance
  4340. * @param Tamper This parameter can be a combination of the following values:
  4341. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  4342. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  4343. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  4344. *
  4345. * @retval None
  4346. */
  4347. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  4348. {
  4349. SET_BIT(RTCx->TAMPCR, Tamper);
  4350. }
  4351. /**
  4352. * @brief Disable Active level for Tamper input
  4353. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel\n
  4354. * TAMPCR TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel\n
  4355. * TAMPCR TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
  4356. * @param RTCx RTC Instance
  4357. * @param Tamper This parameter can be a combination of the following values:
  4358. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  4359. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  4360. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  4361. *
  4362. * @retval None
  4363. */
  4364. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  4365. {
  4366. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  4367. }
  4368. /**
  4369. * @}
  4370. */
  4371. #if defined(RTC_BACKUP_SUPPORT)
  4372. /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
  4373. * @{
  4374. */
  4375. /**
  4376. * @brief Writes a data in a specified RTC Backup data register.
  4377. * @rmtoll BKPxR BKP LL_RTC_BAK_SetRegister
  4378. * @param RTCx RTC Instance
  4379. * @param BackupRegister This parameter can be one of the following values:
  4380. * @arg @ref LL_RTC_BKP_DR0
  4381. * @arg @ref LL_RTC_BKP_DR1
  4382. * @arg @ref LL_RTC_BKP_DR2
  4383. * @arg @ref LL_RTC_BKP_DR3
  4384. * @arg @ref LL_RTC_BKP_DR4
  4385. * @arg @ref LL_RTC_BKP_DR5
  4386. * @arg @ref LL_RTC_BKP_DR6
  4387. * @arg @ref LL_RTC_BKP_DR7
  4388. * @arg @ref LL_RTC_BKP_DR8
  4389. * @arg @ref LL_RTC_BKP_DR9
  4390. * @arg @ref LL_RTC_BKP_DR10
  4391. * @arg @ref LL_RTC_BKP_DR11
  4392. * @arg @ref LL_RTC_BKP_DR12
  4393. * @arg @ref LL_RTC_BKP_DR13
  4394. * @arg @ref LL_RTC_BKP_DR14
  4395. * @arg @ref LL_RTC_BKP_DR15
  4396. * @arg @ref LL_RTC_BKP_DR16
  4397. * @arg @ref LL_RTC_BKP_DR17
  4398. * @arg @ref LL_RTC_BKP_DR18
  4399. * @arg @ref LL_RTC_BKP_DR19
  4400. * @arg @ref LL_RTC_BKP_DR20
  4401. * @arg @ref LL_RTC_BKP_DR21
  4402. * @arg @ref LL_RTC_BKP_DR22
  4403. * @arg @ref LL_RTC_BKP_DR23
  4404. * @arg @ref LL_RTC_BKP_DR24
  4405. * @arg @ref LL_RTC_BKP_DR25
  4406. * @arg @ref LL_RTC_BKP_DR26
  4407. * @arg @ref LL_RTC_BKP_DR27
  4408. * @arg @ref LL_RTC_BKP_DR28
  4409. * @arg @ref LL_RTC_BKP_DR29
  4410. * @arg @ref LL_RTC_BKP_DR30
  4411. * @arg @ref LL_RTC_BKP_DR31
  4412. * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  4413. * @retval None
  4414. */
  4415. __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
  4416. {
  4417. uint32_t tmp = 0U;
  4418. tmp = (uint32_t)(&(RTCx->BKP0R));
  4419. tmp += (BackupRegister * 4U);
  4420. /* Write the specified register */
  4421. *(__IO uint32_t *)tmp = (uint32_t)Data;
  4422. }
  4423. /**
  4424. * @brief Reads data from the specified RTC Backup data Register.
  4425. * @rmtoll BKPxR BKP LL_RTC_BAK_GetRegister
  4426. * @param RTCx RTC Instance
  4427. * @param BackupRegister This parameter can be one of the following values:
  4428. * @arg @ref LL_RTC_BKP_DR0
  4429. * @arg @ref LL_RTC_BKP_DR1
  4430. * @arg @ref LL_RTC_BKP_DR2
  4431. * @arg @ref LL_RTC_BKP_DR3
  4432. * @arg @ref LL_RTC_BKP_DR4
  4433. * @arg @ref LL_RTC_BKP_DR5
  4434. * @arg @ref LL_RTC_BKP_DR6
  4435. * @arg @ref LL_RTC_BKP_DR7
  4436. * @arg @ref LL_RTC_BKP_DR8
  4437. * @arg @ref LL_RTC_BKP_DR9
  4438. * @arg @ref LL_RTC_BKP_DR10
  4439. * @arg @ref LL_RTC_BKP_DR11
  4440. * @arg @ref LL_RTC_BKP_DR12
  4441. * @arg @ref LL_RTC_BKP_DR13
  4442. * @arg @ref LL_RTC_BKP_DR14
  4443. * @arg @ref LL_RTC_BKP_DR15
  4444. * @arg @ref LL_RTC_BKP_DR16
  4445. * @arg @ref LL_RTC_BKP_DR17
  4446. * @arg @ref LL_RTC_BKP_DR18
  4447. * @arg @ref LL_RTC_BKP_DR19
  4448. * @arg @ref LL_RTC_BKP_DR20
  4449. * @arg @ref LL_RTC_BKP_DR21
  4450. * @arg @ref LL_RTC_BKP_DR22
  4451. * @arg @ref LL_RTC_BKP_DR23
  4452. * @arg @ref LL_RTC_BKP_DR24
  4453. * @arg @ref LL_RTC_BKP_DR25
  4454. * @arg @ref LL_RTC_BKP_DR26
  4455. * @arg @ref LL_RTC_BKP_DR27
  4456. * @arg @ref LL_RTC_BKP_DR28
  4457. * @arg @ref LL_RTC_BKP_DR29
  4458. * @arg @ref LL_RTC_BKP_DR30
  4459. * @arg @ref LL_RTC_BKP_DR31
  4460. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  4461. */
  4462. __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
  4463. {
  4464. uint32_t tmp = 0U;
  4465. tmp = (uint32_t)(&(RTCx->BKP0R));
  4466. tmp += (BackupRegister * 4U);
  4467. /* Read the specified register */
  4468. return (*(__IO uint32_t *)tmp);
  4469. }
  4470. /**
  4471. * @}
  4472. */
  4473. #endif /* RTC_BACKUP_SUPPORT */
  4474. /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
  4475. * @{
  4476. */
  4477. /**
  4478. * @brief Get Internal Time-stamp flag
  4479. * @rmtoll RTC_SR ITSF LL_RTC_IsActiveFlag_ITS
  4480. * @param RTCx RTC Instance
  4481. * @retval State of bit (1 or 0).
  4482. */
  4483. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
  4484. {
  4485. return (READ_BIT(RTCx->ISR, RTC_ISR_ITSF) == (RTC_ISR_ITSF));
  4486. }
  4487. /**
  4488. * @brief Get Recalibration pending Flag
  4489. * @rmtoll ISR RECALPF LL_RTC_IsActiveFlag_RECALP
  4490. * @param RTCx RTC Instance
  4491. * @retval State of bit (1 or 0).
  4492. */
  4493. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  4494. {
  4495. return (READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF));
  4496. }
  4497. #if defined(RTC_TAMPER3_SUPPORT)
  4498. /**
  4499. * @brief Get RTC_TAMP3 detection flag
  4500. * @rmtoll ISR TAMP3F LL_RTC_IsActiveFlag_TAMP3
  4501. * @param RTCx RTC Instance
  4502. * @retval State of bit (1 or 0).
  4503. */
  4504. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
  4505. {
  4506. return (READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F));
  4507. }
  4508. #endif /* RTC_TAMPER3_SUPPORT */
  4509. #if defined(RTC_TAMPER2_SUPPORT)
  4510. /**
  4511. * @brief Get RTC_TAMP2 detection flag
  4512. * @rmtoll ISR TAMP2F LL_RTC_IsActiveFlag_TAMP2
  4513. * @param RTCx RTC Instance
  4514. * @retval State of bit (1 or 0).
  4515. */
  4516. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
  4517. {
  4518. return (READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F));
  4519. }
  4520. #endif /* RTC_TAMPER2_SUPPORT */
  4521. #if defined(RTC_TAMPER1_SUPPORT)
  4522. /**
  4523. * @brief Get RTC_TAMP1 detection flag
  4524. * @rmtoll ISR TAMP1F LL_RTC_IsActiveFlag_TAMP1
  4525. * @param RTCx RTC Instance
  4526. * @retval State of bit (1 or 0).
  4527. */
  4528. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
  4529. {
  4530. return (READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F));
  4531. }
  4532. #endif /* RTC_TAMPER1_SUPPORT */
  4533. /**
  4534. * @brief Get Time-stamp overflow flag
  4535. * @rmtoll ISR TSOVF LL_RTC_IsActiveFlag_TSOV
  4536. * @param RTCx RTC Instance
  4537. * @retval State of bit (1 or 0).
  4538. */
  4539. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  4540. {
  4541. return (READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF));
  4542. }
  4543. /**
  4544. * @brief Get Time-stamp flag
  4545. * @rmtoll ISR TSF LL_RTC_IsActiveFlag_TS
  4546. * @param RTCx RTC Instance
  4547. * @retval State of bit (1 or 0).
  4548. */
  4549. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  4550. {
  4551. return (READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF));
  4552. }
  4553. #if defined(RTC_WAKEUP_SUPPORT)
  4554. /**
  4555. * @brief Get Wakeup timer flag
  4556. * @rmtoll ISR WUTF LL_RTC_IsActiveFlag_WUT
  4557. * @param RTCx RTC Instance
  4558. * @retval State of bit (1 or 0).
  4559. */
  4560. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  4561. {
  4562. return (READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF));
  4563. }
  4564. #endif /* RTC_WAKEUP_SUPPORT */
  4565. /**
  4566. * @brief Get Alarm B flag
  4567. * @rmtoll ISR ALRBF LL_RTC_IsActiveFlag_ALRB
  4568. * @param RTCx RTC Instance
  4569. * @retval State of bit (1 or 0).
  4570. */
  4571. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  4572. {
  4573. return (READ_BIT(RTCx->ISR, RTC_ISR_ALRBF) == (RTC_ISR_ALRBF));
  4574. }
  4575. /**
  4576. * @brief Get Alarm A flag
  4577. * @rmtoll ISR ALRAF LL_RTC_IsActiveFlag_ALRA
  4578. * @param RTCx RTC Instance
  4579. * @retval State of bit (1 or 0).
  4580. */
  4581. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  4582. {
  4583. return (READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF));
  4584. }
  4585. /**
  4586. * @brief Clear Internal Time-stamp flag
  4587. * @rmtoll ISR ITSF LL_RTC_ClearFlag_ITS
  4588. * @param RTCx RTC Instance
  4589. * @retval None
  4590. */
  4591. __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
  4592. {
  4593. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ITSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4594. }
  4595. #if defined(RTC_TAMPER3_SUPPORT)
  4596. /**
  4597. * @brief Clear RTC_TAMP3 detection flag
  4598. * @rmtoll ISR TAMP3F LL_RTC_ClearFlag_TAMP3
  4599. * @param RTCx RTC Instance
  4600. * @retval None
  4601. */
  4602. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
  4603. {
  4604. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4605. }
  4606. #endif /* RTC_TAMPER3_SUPPORT */
  4607. #if defined(RTC_TAMPER2_SUPPORT)
  4608. /**
  4609. * @brief Clear RTC_TAMP2 detection flag
  4610. * @rmtoll ISR TAMP2F LL_RTC_ClearFlag_TAMP2
  4611. * @param RTCx RTC Instance
  4612. * @retval None
  4613. */
  4614. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
  4615. {
  4616. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4617. }
  4618. #endif /* RTC_TAMPER2_SUPPORT */
  4619. #if defined(RTC_TAMPER1_SUPPORT)
  4620. /**
  4621. * @brief Clear RTC_TAMP1 detection flag
  4622. * @rmtoll ISR TAMP1F LL_RTC_ClearFlag_TAMP1
  4623. * @param RTCx RTC Instance
  4624. * @retval None
  4625. */
  4626. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
  4627. {
  4628. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4629. }
  4630. #endif /* RTC_TAMPER1_SUPPORT */
  4631. /**
  4632. * @brief Clear Time-stamp overflow flag
  4633. * @rmtoll ISR TSOVF LL_RTC_ClearFlag_TSOV
  4634. * @param RTCx RTC Instance
  4635. * @retval None
  4636. */
  4637. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  4638. {
  4639. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4640. }
  4641. /**
  4642. * @brief Clear Time-stamp flag
  4643. * @rmtoll ISR TSF LL_RTC_ClearFlag_TS
  4644. * @param RTCx RTC Instance
  4645. * @retval None
  4646. */
  4647. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  4648. {
  4649. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4650. }
  4651. #if defined(RTC_WAKEUP_SUPPORT)
  4652. /**
  4653. * @brief Clear Wakeup timer flag
  4654. * @rmtoll ISR WUTF LL_RTC_ClearFlag_WUT
  4655. * @param RTCx RTC Instance
  4656. * @retval None
  4657. */
  4658. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  4659. {
  4660. WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4661. }
  4662. #endif /* RTC_WAKEUP_SUPPORT */
  4663. /**
  4664. * @brief Clear Alarm B flag
  4665. * @rmtoll ISR ALRBF LL_RTC_ClearFlag_ALRB
  4666. * @param RTCx RTC Instance
  4667. * @retval None
  4668. */
  4669. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  4670. {
  4671. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRBF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4672. }
  4673. /**
  4674. * @brief Clear Alarm A flag
  4675. * @rmtoll ISR ALRAF LL_RTC_ClearFlag_ALRA
  4676. * @param RTCx RTC Instance
  4677. * @retval None
  4678. */
  4679. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  4680. {
  4681. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4682. }
  4683. /**
  4684. * @brief Get Initialization flag
  4685. * @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT
  4686. * @param RTCx RTC Instance
  4687. * @retval State of bit (1 or 0).
  4688. */
  4689. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  4690. {
  4691. return (READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF));
  4692. }
  4693. /**
  4694. * @brief Get Registers synchronization flag
  4695. * @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS
  4696. * @param RTCx RTC Instance
  4697. * @retval State of bit (1 or 0).
  4698. */
  4699. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  4700. {
  4701. return (READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF));
  4702. }
  4703. /**
  4704. * @brief Clear Registers synchronization flag
  4705. * @rmtoll ISR RSF LL_RTC_ClearFlag_RS
  4706. * @param RTCx RTC Instance
  4707. * @retval None
  4708. */
  4709. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  4710. {
  4711. WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  4712. }
  4713. /**
  4714. * @brief Get Initialization status flag
  4715. * @rmtoll ISR INITS LL_RTC_IsActiveFlag_INITS
  4716. * @param RTCx RTC Instance
  4717. * @retval State of bit (1 or 0).
  4718. */
  4719. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  4720. {
  4721. return (READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS));
  4722. }
  4723. /**
  4724. * @brief Get Shift operation pending flag
  4725. * @rmtoll ISR SHPF LL_RTC_IsActiveFlag_SHP
  4726. * @param RTCx RTC Instance
  4727. * @retval State of bit (1 or 0).
  4728. */
  4729. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  4730. {
  4731. return (READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF));
  4732. }
  4733. #if defined(RTC_WAKEUP_SUPPORT)
  4734. /**
  4735. * @brief Get Wakeup timer write flag
  4736. * @rmtoll ISR WUTWF LL_RTC_IsActiveFlag_WUTW
  4737. * @param RTCx RTC Instance
  4738. * @retval State of bit (1 or 0).
  4739. */
  4740. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  4741. {
  4742. return (READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF));
  4743. }
  4744. #endif /* RTC_WAKEUP_SUPPORT */
  4745. /**
  4746. * @brief Get Alarm B write flag
  4747. * @rmtoll ISR ALRBWF LL_RTC_IsActiveFlag_ALRBW
  4748. * @param RTCx RTC Instance
  4749. * @retval State of bit (1 or 0).
  4750. */
  4751. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
  4752. {
  4753. return (READ_BIT(RTCx->ISR, RTC_ISR_ALRBWF) == (RTC_ISR_ALRBWF));
  4754. }
  4755. /**
  4756. * @brief Get Alarm A write flag
  4757. * @rmtoll ISR ALRAWF LL_RTC_IsActiveFlag_ALRAW
  4758. * @param RTCx RTC Instance
  4759. * @retval State of bit (1 or 0).
  4760. */
  4761. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
  4762. {
  4763. return (READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF));
  4764. }
  4765. /**
  4766. * @}
  4767. */
  4768. /** @defgroup RTC_LL_EF_IT_Management IT_Management
  4769. * @{
  4770. */
  4771. /**
  4772. * @brief Enable Time-stamp interrupt
  4773. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4774. * @rmtoll RTC_CR TSIE LL_RTC_EnableIT_TS
  4775. * @param RTCx RTC Instance
  4776. * @retval None
  4777. */
  4778. __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
  4779. {
  4780. SET_BIT(RTCx->CR, RTC_CR_TSIE);
  4781. }
  4782. /**
  4783. * @brief Disable Time-stamp interrupt
  4784. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4785. * @rmtoll RTC_CR TSIE LL_RTC_DisableIT_TS
  4786. * @param RTCx RTC Instance
  4787. * @retval None
  4788. */
  4789. __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
  4790. {
  4791. CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
  4792. }
  4793. #if defined(RTC_WAKEUP_SUPPORT)
  4794. /**
  4795. * @brief Enable Wakeup timer interrupt
  4796. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4797. * @rmtoll RTC_CR WUTIE LL_RTC_EnableIT_WUT
  4798. * @param RTCx RTC Instance
  4799. * @retval None
  4800. */
  4801. __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
  4802. {
  4803. SET_BIT(RTCx->CR, RTC_CR_WUTIE);
  4804. }
  4805. /**
  4806. * @brief Disable Wakeup timer interrupt
  4807. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4808. * @rmtoll RTC_CR WUTIE LL_RTC_DisableIT_WUT
  4809. * @param RTCx RTC Instance
  4810. * @retval None
  4811. */
  4812. __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
  4813. {
  4814. CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
  4815. }
  4816. #endif /* RTC_WAKEUP_SUPPORT */
  4817. /**
  4818. * @brief Enable Alarm B interrupt
  4819. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4820. * @rmtoll RTC_CR ALRBIE LL_RTC_EnableIT_ALRB
  4821. * @param RTCx RTC Instance
  4822. * @retval None
  4823. */
  4824. __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
  4825. {
  4826. SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
  4827. }
  4828. /**
  4829. * @brief Disable Alarm B interrupt
  4830. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4831. * @rmtoll RTC_CR ALRBIE LL_RTC_DisableIT_ALRB
  4832. * @param RTCx RTC Instance
  4833. * @retval None
  4834. */
  4835. __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
  4836. {
  4837. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
  4838. }
  4839. /**
  4840. * @brief Enable Alarm A interrupt
  4841. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4842. * @rmtoll RTC_CR ALRAIE LL_RTC_EnableIT_ALRA
  4843. * @param RTCx RTC Instance
  4844. * @retval None
  4845. */
  4846. __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
  4847. {
  4848. SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
  4849. }
  4850. /**
  4851. * @brief Disable Alarm A interrupt
  4852. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4853. * @rmtoll RTC_CR ALRAIE LL_RTC_DisableIT_ALRA
  4854. * @param RTCx RTC Instance
  4855. * @retval None
  4856. */
  4857. __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
  4858. {
  4859. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
  4860. }
  4861. #if defined(RTC_TAMPER3_SUPPORT)
  4862. /**
  4863. * @brief Enable Tamper 3 interrupt
  4864. * @rmtoll TAMPCR TAMP3IE LL_RTC_EnableIT_TAMP3
  4865. * @param RTCx RTC Instance
  4866. * @retval None
  4867. */
  4868. __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(RTC_TypeDef *RTCx)
  4869. {
  4870. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  4871. }
  4872. /**
  4873. * @brief Disable Tamper 3 interrupt
  4874. * @rmtoll TAMPCR TAMP3IE LL_RTC_DisableIT_TAMP3
  4875. * @param RTCx RTC Instance
  4876. * @retval None
  4877. */
  4878. __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(RTC_TypeDef *RTCx)
  4879. {
  4880. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  4881. }
  4882. #endif /* RTC_TAMPER3_SUPPORT */
  4883. #if defined(RTC_TAMPER2_SUPPORT)
  4884. /**
  4885. * @brief Enable Tamper 2 interrupt
  4886. * @rmtoll TAMPCR TAMP2IE LL_RTC_EnableIT_TAMP2
  4887. * @param RTCx RTC Instance
  4888. * @retval None
  4889. */
  4890. __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(RTC_TypeDef *RTCx)
  4891. {
  4892. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  4893. }
  4894. /**
  4895. * @brief Disable Tamper 2 interrupt
  4896. * @rmtoll TAMPCR TAMP2IE LL_RTC_DisableIT_TAMP2
  4897. * @param RTCx RTC Instance
  4898. * @retval None
  4899. */
  4900. __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(RTC_TypeDef *RTCx)
  4901. {
  4902. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  4903. }
  4904. #endif /* RTC_TAMPER2_SUPPORT */
  4905. #if defined(RTC_TAMPER1_SUPPORT)
  4906. /**
  4907. * @brief Enable Tamper 1 interrupt
  4908. * @rmtoll TAMPCR TAMP1IE LL_RTC_EnableIT_TAMP1
  4909. * @param RTCx RTC Instance
  4910. * @retval None
  4911. */
  4912. __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(RTC_TypeDef *RTCx)
  4913. {
  4914. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  4915. }
  4916. /**
  4917. * @brief Disable Tamper 1 interrupt
  4918. * @rmtoll TAMPCR TAMP1IE LL_RTC_DisableIT_TAMP1
  4919. * @param RTCx RTC Instance
  4920. * @retval None
  4921. */
  4922. __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(RTC_TypeDef *RTCx)
  4923. {
  4924. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  4925. }
  4926. #endif /* RTC_TAMPER1_SUPPORT */
  4927. /**
  4928. * @brief Enable all Tamper Interrupt
  4929. * @rmtoll TAMPCR TAMPIE LL_RTC_EnableIT_TAMP
  4930. * @param RTCx RTC Instance
  4931. * @retval None
  4932. */
  4933. __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
  4934. {
  4935. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  4936. }
  4937. /**
  4938. * @brief Disable all Tamper Interrupt
  4939. * @rmtoll TAMPCR TAMPIE LL_RTC_DisableIT_TAMP
  4940. * @param RTCx RTC Instance
  4941. * @retval None
  4942. */
  4943. __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
  4944. {
  4945. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  4946. }
  4947. /**
  4948. * @brief Check if Time-stamp interrupt is enabled or not
  4949. * @rmtoll CR TSIE LL_RTC_IsEnabledIT_TS
  4950. * @param RTCx RTC Instance
  4951. * @retval State of bit (1 or 0).
  4952. */
  4953. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
  4954. {
  4955. return (READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE));
  4956. }
  4957. #if defined(RTC_WAKEUP_SUPPORT)
  4958. /**
  4959. * @brief Check if Wakeup timer interrupt is enabled or not
  4960. * @rmtoll CR WUTIE LL_RTC_IsEnabledIT_WUT
  4961. * @param RTCx RTC Instance
  4962. * @retval State of bit (1 or 0).
  4963. */
  4964. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
  4965. {
  4966. return (READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE));
  4967. }
  4968. #endif /* RTC_WAKEUP_SUPPORT */
  4969. /**
  4970. * @brief Check if Alarm B interrupt is enabled or not
  4971. * @rmtoll CR ALRBIE LL_RTC_IsEnabledIT_ALRB
  4972. * @param RTCx RTC Instance
  4973. * @retval State of bit (1 or 0).
  4974. */
  4975. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
  4976. {
  4977. return (READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE));
  4978. }
  4979. /**
  4980. * @brief Check if Alarm A interrupt is enabled or not
  4981. * @rmtoll CR ALRAIE LL_RTC_IsEnabledIT_ALRA
  4982. * @param RTCx RTC Instance
  4983. * @retval State of bit (1 or 0).
  4984. */
  4985. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
  4986. {
  4987. return (READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE));
  4988. }
  4989. #if defined(RTC_TAMPER3_SUPPORT)
  4990. /**
  4991. * @brief Check if Tamper 3 interrupt is enabled or not
  4992. * @rmtoll TAMPCR TAMP3IE LL_RTC_IsEnabledIT_TAMP3
  4993. * @param RTCx RTC Instance
  4994. * @retval State of bit (1 or 0).
  4995. */
  4996. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef *RTCx)
  4997. {
  4998. return (READ_BIT(RTCx->TAMPCR,
  4999. RTC_TAMPCR_TAMP3IE) == (RTC_TAMPCR_TAMP3IE));
  5000. }
  5001. #endif /* RTC_TAMPER3_SUPPORT */
  5002. #if defined(RTC_TAMPER2_SUPPORT)
  5003. /**
  5004. * @brief Check if Tamper 2 interrupt is enabled or not
  5005. * @rmtoll TAMPCR TAMP2IE LL_RTC_IsEnabledIT_TAMP2
  5006. * @param RTCx RTC Instance
  5007. * @retval State of bit (1 or 0).
  5008. */
  5009. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef *RTCx)
  5010. {
  5011. return (READ_BIT(RTCx->TAMPCR,
  5012. RTC_TAMPCR_TAMP2IE) == (RTC_TAMPCR_TAMP2IE));
  5013. }
  5014. #endif /* RTC_TAMPER2_SUPPORT */
  5015. #if defined(RTC_TAMPER1_SUPPORT)
  5016. /**
  5017. * @brief Check if Tamper 1 interrupt is enabled or not
  5018. * @rmtoll TAMPCR TAMP1IE LL_RTC_IsEnabledIT_TAMP1
  5019. * @param RTCx RTC Instance
  5020. * @retval State of bit (1 or 0).
  5021. */
  5022. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef *RTCx)
  5023. {
  5024. return (READ_BIT(RTCx->TAMPCR,
  5025. RTC_TAMPCR_TAMP1IE) == (RTC_TAMPCR_TAMP1IE));
  5026. }
  5027. #endif /* RTC_TAMPER1_SUPPORT */
  5028. /**
  5029. * @brief Check if all the TAMPER interrupts are enabled or not
  5030. * @rmtoll TAMPCR TAMPIE LL_RTC_IsEnabledIT_TAMP
  5031. * @param RTCx RTC Instance
  5032. * @retval State of bit (1 or 0).
  5033. */
  5034. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
  5035. {
  5036. return (READ_BIT(RTCx->TAMPCR,
  5037. RTC_TAMPCR_TAMPIE) == (RTC_TAMPCR_TAMPIE));
  5038. }
  5039. /**
  5040. * @}
  5041. */
  5042. #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
  5043. #if defined(USE_FULL_LL_DRIVER)
  5044. /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
  5045. * @{
  5046. */
  5047. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
  5048. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
  5049. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
  5050. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
  5051. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
  5052. ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
  5053. void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
  5054. ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  5055. ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  5056. void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  5057. void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  5058. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
  5059. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
  5060. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
  5061. /**
  5062. * @}
  5063. */
  5064. #endif /* USE_FULL_LL_DRIVER */
  5065. /**
  5066. * @}
  5067. */
  5068. /**
  5069. * @}
  5070. */
  5071. #endif /* defined(RTC) */
  5072. /**
  5073. * @}
  5074. */
  5075. #ifdef __cplusplus
  5076. }
  5077. #endif
  5078. #endif /* STM32L4xx_LL_RTC_H */