stm32l1xx_ll_rtc.h 141 KB

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