stm32f3xx_ll_rtc.h 136 KB

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