stm32f4xx_ll_rtc.h 147 KB

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