stm32l4xx_ll_rtc.h 149 KB

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