stm32l4xx_ll_rtc.h 145 KB

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