stm32f4xx_ll_rtc.h 140 KB

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