You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32l1xx_ll_rtc.h 140KB

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