stm32f3xx_ll_rtc.h 145 KB

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