stm32f0xx_ll_rtc.h 114 KB

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