stm32h7xx_ll_lpuart.h 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_lpuart.h
  4. * @author MCD Application Team
  5. * @brief Header file of LPUART LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 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 STM32H7xx_LL_LPUART_H
  20. #define STM32H7xx_LL_LPUART_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h7xx.h"
  26. /** @addtogroup STM32H7xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (LPUART1)
  30. /** @defgroup LPUART_LL LPUART
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables
  36. * @{
  37. */
  38. /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */
  39. static const uint16_t LPUART_PRESCALER_TAB[] =
  40. {
  41. (uint16_t)1,
  42. (uint16_t)2,
  43. (uint16_t)4,
  44. (uint16_t)6,
  45. (uint16_t)8,
  46. (uint16_t)10,
  47. (uint16_t)12,
  48. (uint16_t)16,
  49. (uint16_t)32,
  50. (uint16_t)64,
  51. (uint16_t)128,
  52. (uint16_t)256
  53. };
  54. /**
  55. * @}
  56. */
  57. /* Private constants ---------------------------------------------------------*/
  58. /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants
  59. * @{
  60. */
  61. /* Defines used in Baud Rate related macros and corresponding register setting computation */
  62. #define LPUART_LPUARTDIV_FREQ_MUL 256U
  63. #define LPUART_BRR_MASK 0x000FFFFFU
  64. #define LPUART_BRR_MIN_VALUE 0x00000300U
  65. /**
  66. * @}
  67. */
  68. /* Private macros ------------------------------------------------------------*/
  69. #if defined(USE_FULL_LL_DRIVER)
  70. /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros
  71. * @{
  72. */
  73. /**
  74. * @}
  75. */
  76. #endif /*USE_FULL_LL_DRIVER*/
  77. /* Exported types ------------------------------------------------------------*/
  78. #if defined(USE_FULL_LL_DRIVER)
  79. /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures
  80. * @{
  81. */
  82. /**
  83. * @brief LL LPUART Init Structure definition
  84. */
  85. typedef struct
  86. {
  87. uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate.
  88. This parameter can be a value of @ref LPUART_LL_EC_PRESCALER.
  89. This feature can be modified afterwards using unitary
  90. function @ref LL_LPUART_SetPrescaler().*/
  91. uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate.
  92. This feature can be modified afterwards using unitary
  93. function @ref LL_LPUART_SetBaudRate().*/
  94. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  95. This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH.
  96. This feature can be modified afterwards using unitary
  97. function @ref LL_LPUART_SetDataWidth().*/
  98. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  99. This parameter can be a value of @ref LPUART_LL_EC_STOPBITS.
  100. This feature can be modified afterwards using unitary
  101. function @ref LL_LPUART_SetStopBitsLength().*/
  102. uint32_t Parity; /*!< Specifies the parity mode.
  103. This parameter can be a value of @ref LPUART_LL_EC_PARITY.
  104. This feature can be modified afterwards using unitary
  105. function @ref LL_LPUART_SetParity().*/
  106. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  107. This parameter can be a value of @ref LPUART_LL_EC_DIRECTION.
  108. This feature can be modified afterwards using unitary
  109. function @ref LL_LPUART_SetTransferDirection().*/
  110. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  111. This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL.
  112. This feature can be modified afterwards using unitary
  113. function @ref LL_LPUART_SetHWFlowCtrl().*/
  114. } LL_LPUART_InitTypeDef;
  115. /**
  116. * @}
  117. */
  118. #endif /* USE_FULL_LL_DRIVER */
  119. /* Exported constants --------------------------------------------------------*/
  120. /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants
  121. * @{
  122. */
  123. /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines
  124. * @brief Flags defines which can be used with LL_LPUART_WriteReg function
  125. * @{
  126. */
  127. #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error clear flag */
  128. #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error clear flag */
  129. #define LL_LPUART_ICR_NCF USART_ICR_NECF /*!< Noise error detected clear flag */
  130. #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error clear flag */
  131. #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected clear flag */
  132. #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete clear flag */
  133. #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS clear flag */
  134. #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match clear flag */
  135. #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode clear flag */
  136. /**
  137. * @}
  138. */
  139. /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines
  140. * @brief Flags defines which can be used with LL_LPUART_ReadReg function
  141. * @{
  142. */
  143. #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  144. #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  145. #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  146. #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  147. #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  148. #define LL_LPUART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */
  149. #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  150. #define LL_LPUART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/
  151. #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  152. #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  153. #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  154. #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  155. #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  156. #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  157. #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  158. #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  159. #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  160. #define LL_LPUART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */
  161. #define LL_LPUART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */
  162. #define LL_LPUART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */
  163. #define LL_LPUART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */
  164. /**
  165. * @}
  166. */
  167. /** @defgroup LPUART_LL_EC_IT IT Defines
  168. * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions
  169. * @{
  170. */
  171. #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  172. #define LL_LPUART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty
  173. interrupt enable */
  174. #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  175. #define LL_LPUART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO
  176. not full interrupt enable */
  177. #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  178. #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  179. #define LL_LPUART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */
  180. #define LL_LPUART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */
  181. #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  182. #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  183. #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  184. #define LL_LPUART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */
  185. #define LL_LPUART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */
  186. /**
  187. * @}
  188. */
  189. /** @defgroup LPUART_LL_EC_FIFOTHRESHOLD FIFO Threshold
  190. * @{
  191. */
  192. #define LL_LPUART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */
  193. #define LL_LPUART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */
  194. #define LL_LPUART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */
  195. #define LL_LPUART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */
  196. #define LL_LPUART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */
  197. #define LL_LPUART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */
  198. /**
  199. * @}
  200. */
  201. /** @defgroup LPUART_LL_EC_DIRECTION Direction
  202. * @{
  203. */
  204. #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  205. #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  206. #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  207. #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  208. /**
  209. * @}
  210. */
  211. /** @defgroup LPUART_LL_EC_PARITY Parity Control
  212. * @{
  213. */
  214. #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  215. #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  216. #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  217. /**
  218. * @}
  219. */
  220. /** @defgroup LPUART_LL_EC_WAKEUP Wakeup
  221. * @{
  222. */
  223. #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */
  224. #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */
  225. /**
  226. * @}
  227. */
  228. /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth
  229. * @{
  230. */
  231. #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  232. #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  233. #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  234. /**
  235. * @}
  236. */
  237. /** @defgroup LPUART_LL_EC_PRESCALER Clock Source Prescaler
  238. * @{
  239. */
  240. #define LL_LPUART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */
  241. #define LL_LPUART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */
  242. #define LL_LPUART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */
  243. #define LL_LPUART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 |\
  244. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */
  245. #define LL_LPUART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */
  246. #define LL_LPUART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 |\
  247. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */
  248. #define LL_LPUART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 |\
  249. USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */
  250. #define LL_LPUART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 |\
  251. USART_PRESC_PRESCALER_1 |\
  252. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */
  253. #define LL_LPUART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */
  254. #define LL_LPUART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 |\
  255. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */
  256. #define LL_LPUART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 |\
  257. USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */
  258. #define LL_LPUART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 |\
  259. USART_PRESC_PRESCALER_1 |\
  260. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */
  261. /**
  262. * @}
  263. */
  264. /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits
  265. * @{
  266. */
  267. #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  268. #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  269. /**
  270. * @}
  271. */
  272. /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap
  273. * @{
  274. */
  275. #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  276. #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  277. /**
  278. * @}
  279. */
  280. /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  281. * @{
  282. */
  283. #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  284. #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  285. /**
  286. * @}
  287. */
  288. /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  289. * @{
  290. */
  291. #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  292. #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  293. /**
  294. * @}
  295. */
  296. /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion
  297. * @{
  298. */
  299. #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received
  300. in positive/direct logic. (1=H, 0=L) */
  301. #define LL_LPUART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received
  302. in negative/inverse logic. (1=L, 0=H).
  303. The parity bit is also inverted. */
  304. /**
  305. * @}
  306. */
  307. /** @defgroup LPUART_LL_EC_BITORDER Bit Order
  308. * @{
  309. */
  310. #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first,
  311. following the start bit */
  312. #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first,
  313. following the start bit */
  314. /**
  315. * @}
  316. */
  317. /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection
  318. * @{
  319. */
  320. #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  321. #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  322. /**
  323. * @}
  324. */
  325. /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control
  326. * @{
  327. */
  328. #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  329. #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested
  330. when there is space in the receive buffer */
  331. #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted
  332. when the nCTS input is asserted (tied to 0)*/
  333. #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  334. /**
  335. * @}
  336. */
  337. /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation
  338. * @{
  339. */
  340. #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  341. #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  342. #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  343. /**
  344. * @}
  345. */
  346. /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity
  347. * @{
  348. */
  349. #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  350. #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  351. /**
  352. * @}
  353. */
  354. /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data
  355. * @{
  356. */
  357. #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  358. #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  359. /**
  360. * @}
  361. */
  362. /**
  363. * @}
  364. */
  365. /* Exported macro ------------------------------------------------------------*/
  366. /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros
  367. * @{
  368. */
  369. /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros
  370. * @{
  371. */
  372. /**
  373. * @brief Write a value in LPUART register
  374. * @param __INSTANCE__ LPUART Instance
  375. * @param __REG__ Register to be written
  376. * @param __VALUE__ Value to be written in the register
  377. * @retval None
  378. */
  379. #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  380. /**
  381. * @brief Read a value in LPUART register
  382. * @param __INSTANCE__ LPUART Instance
  383. * @param __REG__ Register to be read
  384. * @retval Register value
  385. */
  386. #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  387. /**
  388. * @}
  389. */
  390. /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros
  391. * @{
  392. */
  393. /**
  394. * @brief Compute LPUARTDIV value according to Peripheral Clock and
  395. * expected Baud Rate (20-bit value of LPUARTDIV is returned)
  396. * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance
  397. * @param __PRESCALER__ This parameter can be one of the following values:
  398. * @arg @ref LL_LPUART_PRESCALER_DIV1
  399. * @arg @ref LL_LPUART_PRESCALER_DIV2
  400. * @arg @ref LL_LPUART_PRESCALER_DIV4
  401. * @arg @ref LL_LPUART_PRESCALER_DIV6
  402. * @arg @ref LL_LPUART_PRESCALER_DIV8
  403. * @arg @ref LL_LPUART_PRESCALER_DIV10
  404. * @arg @ref LL_LPUART_PRESCALER_DIV12
  405. * @arg @ref LL_LPUART_PRESCALER_DIV16
  406. * @arg @ref LL_LPUART_PRESCALER_DIV32
  407. * @arg @ref LL_LPUART_PRESCALER_DIV64
  408. * @arg @ref LL_LPUART_PRESCALER_DIV128
  409. * @arg @ref LL_LPUART_PRESCALER_DIV256
  410. * @param __BAUDRATE__ Baud Rate value to achieve
  411. * @retval LPUARTDIV value to be used for BRR register filling
  412. */
  413. #define __LL_LPUART_DIV(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (uint32_t)\
  414. ((((((uint64_t)(__PERIPHCLK__)/(uint64_t)(LPUART_PRESCALER_TAB[(uint16_t)(__PRESCALER__)]))\
  415. * LPUART_LPUARTDIV_FREQ_MUL) + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__)) & LPUART_BRR_MASK)
  416. /**
  417. * @}
  418. */
  419. /**
  420. * @}
  421. */
  422. /* Exported functions --------------------------------------------------------*/
  423. /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions
  424. * @{
  425. */
  426. /** @defgroup LPUART_LL_EF_Configuration Configuration functions
  427. * @{
  428. */
  429. /**
  430. * @brief LPUART Enable
  431. * @rmtoll CR1 UE LL_LPUART_Enable
  432. * @param LPUARTx LPUART Instance
  433. * @retval None
  434. */
  435. __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx)
  436. {
  437. SET_BIT(LPUARTx->CR1, USART_CR1_UE);
  438. }
  439. /**
  440. * @brief LPUART Disable
  441. * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately,
  442. * and current operations are discarded. The configuration of the LPUART is kept, but all the status
  443. * flags, in the LPUARTx_ISR are set to their default values.
  444. * @note In order to go into low-power mode without generating errors on the line,
  445. * the TE bit must be reset before and the software must wait
  446. * for the TC bit in the LPUART_ISR to be set before resetting the UE bit.
  447. * The DMA requests are also reset when UE = 0 so the DMA channel must
  448. * be disabled before resetting the UE bit.
  449. * @rmtoll CR1 UE LL_LPUART_Disable
  450. * @param LPUARTx LPUART Instance
  451. * @retval None
  452. */
  453. __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx)
  454. {
  455. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE);
  456. }
  457. /**
  458. * @brief Indicate if LPUART is enabled
  459. * @rmtoll CR1 UE LL_LPUART_IsEnabled
  460. * @param LPUARTx LPUART Instance
  461. * @retval State of bit (1 or 0).
  462. */
  463. __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(const USART_TypeDef *LPUARTx)
  464. {
  465. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL);
  466. }
  467. /**
  468. * @brief FIFO Mode Enable
  469. * @rmtoll CR1 FIFOEN LL_LPUART_EnableFIFO
  470. * @param LPUARTx LPUART Instance
  471. * @retval None
  472. */
  473. __STATIC_INLINE void LL_LPUART_EnableFIFO(USART_TypeDef *LPUARTx)
  474. {
  475. SET_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  476. }
  477. /**
  478. * @brief FIFO Mode Disable
  479. * @rmtoll CR1 FIFOEN LL_LPUART_DisableFIFO
  480. * @param LPUARTx LPUART Instance
  481. * @retval None
  482. */
  483. __STATIC_INLINE void LL_LPUART_DisableFIFO(USART_TypeDef *LPUARTx)
  484. {
  485. CLEAR_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  486. }
  487. /**
  488. * @brief Indicate if FIFO Mode is enabled
  489. * @rmtoll CR1 FIFOEN LL_LPUART_IsEnabledFIFO
  490. * @param LPUARTx LPUART Instance
  491. * @retval State of bit (1 or 0).
  492. */
  493. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledFIFO(const USART_TypeDef *LPUARTx)
  494. {
  495. return ((READ_BIT(LPUARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL);
  496. }
  497. /**
  498. * @brief Configure TX FIFO Threshold
  499. * @rmtoll CR3 TXFTCFG LL_LPUART_SetTXFIFOThreshold
  500. * @param LPUARTx LPUART Instance
  501. * @param Threshold This parameter can be one of the following values:
  502. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  503. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  504. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  505. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  506. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  507. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  508. * @retval None
  509. */
  510. __STATIC_INLINE void LL_LPUART_SetTXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  511. {
  512. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos);
  513. }
  514. /**
  515. * @brief Return TX FIFO Threshold Configuration
  516. * @rmtoll CR3 TXFTCFG LL_LPUART_GetTXFIFOThreshold
  517. * @param LPUARTx LPUART Instance
  518. * @retval Returned value can be one of the following values:
  519. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  520. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  521. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  522. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  523. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  524. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  525. */
  526. __STATIC_INLINE uint32_t LL_LPUART_GetTXFIFOThreshold(const USART_TypeDef *LPUARTx)
  527. {
  528. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
  529. }
  530. /**
  531. * @brief Configure RX FIFO Threshold
  532. * @rmtoll CR3 RXFTCFG LL_LPUART_SetRXFIFOThreshold
  533. * @param LPUARTx LPUART Instance
  534. * @param Threshold This parameter can be one of the following values:
  535. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  536. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  537. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  538. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  539. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  540. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  541. * @retval None
  542. */
  543. __STATIC_INLINE void LL_LPUART_SetRXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  544. {
  545. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos);
  546. }
  547. /**
  548. * @brief Return RX FIFO Threshold Configuration
  549. * @rmtoll CR3 RXFTCFG LL_LPUART_GetRXFIFOThreshold
  550. * @param LPUARTx LPUART Instance
  551. * @retval Returned value can be one of the following values:
  552. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  553. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  554. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  555. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  556. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  557. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  558. */
  559. __STATIC_INLINE uint32_t LL_LPUART_GetRXFIFOThreshold(const USART_TypeDef *LPUARTx)
  560. {
  561. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
  562. }
  563. /**
  564. * @brief Configure TX and RX FIFOs Threshold
  565. * @rmtoll CR3 TXFTCFG LL_LPUART_ConfigFIFOsThreshold\n
  566. * CR3 RXFTCFG LL_LPUART_ConfigFIFOsThreshold
  567. * @param LPUARTx LPUART Instance
  568. * @param TXThreshold This parameter can be one of the following values:
  569. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  570. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  571. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  572. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  573. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  574. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  575. * @param RXThreshold This parameter can be one of the following values:
  576. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  577. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  578. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  579. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  580. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  581. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  582. * @retval None
  583. */
  584. __STATIC_INLINE void LL_LPUART_ConfigFIFOsThreshold(USART_TypeDef *LPUARTx, uint32_t TXThreshold, uint32_t RXThreshold)
  585. {
  586. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | \
  587. (RXThreshold << USART_CR3_RXFTCFG_Pos));
  588. }
  589. /**
  590. * @brief LPUART enabled in STOP Mode
  591. * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that
  592. * LPUART clock selection is HSI or LSE in RCC.
  593. * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode
  594. * @param LPUARTx LPUART Instance
  595. * @retval None
  596. */
  597. __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx)
  598. {
  599. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_UESM);
  600. }
  601. /**
  602. * @brief LPUART disabled in STOP Mode
  603. * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode
  604. * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode
  605. * @param LPUARTx LPUART Instance
  606. * @retval None
  607. */
  608. __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx)
  609. {
  610. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM);
  611. }
  612. /**
  613. * @brief Indicate if LPUART is enabled in STOP Mode
  614. * (able to wake up MCU from Stop mode or not)
  615. * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode
  616. * @param LPUARTx LPUART Instance
  617. * @retval State of bit (1 or 0).
  618. */
  619. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(const USART_TypeDef *LPUARTx)
  620. {
  621. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL);
  622. }
  623. /**
  624. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  625. * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx
  626. * @param LPUARTx LPUART Instance
  627. * @retval None
  628. */
  629. __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx)
  630. {
  631. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RE);
  632. }
  633. /**
  634. * @brief Receiver Disable
  635. * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx
  636. * @param LPUARTx LPUART Instance
  637. * @retval None
  638. */
  639. __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx)
  640. {
  641. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE);
  642. }
  643. /**
  644. * @brief Transmitter Enable
  645. * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx
  646. * @param LPUARTx LPUART Instance
  647. * @retval None
  648. */
  649. __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx)
  650. {
  651. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TE);
  652. }
  653. /**
  654. * @brief Transmitter Disable
  655. * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx
  656. * @param LPUARTx LPUART Instance
  657. * @retval None
  658. */
  659. __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx)
  660. {
  661. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE);
  662. }
  663. /**
  664. * @brief Configure simultaneously enabled/disabled states
  665. * of Transmitter and Receiver
  666. * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n
  667. * CR1 TE LL_LPUART_SetTransferDirection
  668. * @param LPUARTx LPUART Instance
  669. * @param TransferDirection This parameter can be one of the following values:
  670. * @arg @ref LL_LPUART_DIRECTION_NONE
  671. * @arg @ref LL_LPUART_DIRECTION_RX
  672. * @arg @ref LL_LPUART_DIRECTION_TX
  673. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  674. * @retval None
  675. */
  676. __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection)
  677. {
  678. ATOMIC_MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  679. }
  680. /**
  681. * @brief Return enabled/disabled states of Transmitter and Receiver
  682. * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n
  683. * CR1 TE LL_LPUART_GetTransferDirection
  684. * @param LPUARTx LPUART Instance
  685. * @retval Returned value can be one of the following values:
  686. * @arg @ref LL_LPUART_DIRECTION_NONE
  687. * @arg @ref LL_LPUART_DIRECTION_RX
  688. * @arg @ref LL_LPUART_DIRECTION_TX
  689. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  690. */
  691. __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(const USART_TypeDef *LPUARTx)
  692. {
  693. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  694. }
  695. /**
  696. * @brief Configure Parity (enabled/disabled and parity mode if enabled)
  697. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  698. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  699. * (depending on data width) and parity is checked on the received data.
  700. * @rmtoll CR1 PS LL_LPUART_SetParity\n
  701. * CR1 PCE LL_LPUART_SetParity
  702. * @param LPUARTx LPUART Instance
  703. * @param Parity This parameter can be one of the following values:
  704. * @arg @ref LL_LPUART_PARITY_NONE
  705. * @arg @ref LL_LPUART_PARITY_EVEN
  706. * @arg @ref LL_LPUART_PARITY_ODD
  707. * @retval None
  708. */
  709. __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity)
  710. {
  711. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  712. }
  713. /**
  714. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  715. * @rmtoll CR1 PS LL_LPUART_GetParity\n
  716. * CR1 PCE LL_LPUART_GetParity
  717. * @param LPUARTx LPUART Instance
  718. * @retval Returned value can be one of the following values:
  719. * @arg @ref LL_LPUART_PARITY_NONE
  720. * @arg @ref LL_LPUART_PARITY_EVEN
  721. * @arg @ref LL_LPUART_PARITY_ODD
  722. */
  723. __STATIC_INLINE uint32_t LL_LPUART_GetParity(const USART_TypeDef *LPUARTx)
  724. {
  725. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  726. }
  727. /**
  728. * @brief Set Receiver Wake Up method from Mute mode.
  729. * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod
  730. * @param LPUARTx LPUART Instance
  731. * @param Method This parameter can be one of the following values:
  732. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  733. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  734. * @retval None
  735. */
  736. __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method)
  737. {
  738. MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method);
  739. }
  740. /**
  741. * @brief Return Receiver Wake Up method from Mute mode
  742. * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod
  743. * @param LPUARTx LPUART Instance
  744. * @retval Returned value can be one of the following values:
  745. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  746. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  747. */
  748. __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(const USART_TypeDef *LPUARTx)
  749. {
  750. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE));
  751. }
  752. /**
  753. * @brief Set Word length (nb of data bits, excluding start and stop bits)
  754. * @rmtoll CR1 M LL_LPUART_SetDataWidth
  755. * @param LPUARTx LPUART Instance
  756. * @param DataWidth This parameter can be one of the following values:
  757. * @arg @ref LL_LPUART_DATAWIDTH_7B
  758. * @arg @ref LL_LPUART_DATAWIDTH_8B
  759. * @arg @ref LL_LPUART_DATAWIDTH_9B
  760. * @retval None
  761. */
  762. __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth)
  763. {
  764. MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth);
  765. }
  766. /**
  767. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  768. * @rmtoll CR1 M LL_LPUART_GetDataWidth
  769. * @param LPUARTx LPUART Instance
  770. * @retval Returned value can be one of the following values:
  771. * @arg @ref LL_LPUART_DATAWIDTH_7B
  772. * @arg @ref LL_LPUART_DATAWIDTH_8B
  773. * @arg @ref LL_LPUART_DATAWIDTH_9B
  774. */
  775. __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(const USART_TypeDef *LPUARTx)
  776. {
  777. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M));
  778. }
  779. /**
  780. * @brief Allow switch between Mute Mode and Active mode
  781. * @rmtoll CR1 MME LL_LPUART_EnableMuteMode
  782. * @param LPUARTx LPUART Instance
  783. * @retval None
  784. */
  785. __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx)
  786. {
  787. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_MME);
  788. }
  789. /**
  790. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  791. * @rmtoll CR1 MME LL_LPUART_DisableMuteMode
  792. * @param LPUARTx LPUART Instance
  793. * @retval None
  794. */
  795. __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx)
  796. {
  797. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME);
  798. }
  799. /**
  800. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  801. * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode
  802. * @param LPUARTx LPUART Instance
  803. * @retval State of bit (1 or 0).
  804. */
  805. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(const USART_TypeDef *LPUARTx)
  806. {
  807. return ((READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL);
  808. }
  809. /**
  810. * @brief Configure Clock source prescaler for baudrate generator and oversampling
  811. * @rmtoll PRESC PRESCALER LL_LPUART_SetPrescaler
  812. * @param LPUARTx LPUART Instance
  813. * @param PrescalerValue This parameter can be one of the following values:
  814. * @arg @ref LL_LPUART_PRESCALER_DIV1
  815. * @arg @ref LL_LPUART_PRESCALER_DIV2
  816. * @arg @ref LL_LPUART_PRESCALER_DIV4
  817. * @arg @ref LL_LPUART_PRESCALER_DIV6
  818. * @arg @ref LL_LPUART_PRESCALER_DIV8
  819. * @arg @ref LL_LPUART_PRESCALER_DIV10
  820. * @arg @ref LL_LPUART_PRESCALER_DIV12
  821. * @arg @ref LL_LPUART_PRESCALER_DIV16
  822. * @arg @ref LL_LPUART_PRESCALER_DIV32
  823. * @arg @ref LL_LPUART_PRESCALER_DIV64
  824. * @arg @ref LL_LPUART_PRESCALER_DIV128
  825. * @arg @ref LL_LPUART_PRESCALER_DIV256
  826. * @retval None
  827. */
  828. __STATIC_INLINE void LL_LPUART_SetPrescaler(USART_TypeDef *LPUARTx, uint32_t PrescalerValue)
  829. {
  830. MODIFY_REG(LPUARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue);
  831. }
  832. /**
  833. * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling
  834. * @rmtoll PRESC PRESCALER LL_LPUART_GetPrescaler
  835. * @param LPUARTx LPUART Instance
  836. * @retval Returned value can be one of the following values:
  837. * @arg @ref LL_LPUART_PRESCALER_DIV1
  838. * @arg @ref LL_LPUART_PRESCALER_DIV2
  839. * @arg @ref LL_LPUART_PRESCALER_DIV4
  840. * @arg @ref LL_LPUART_PRESCALER_DIV6
  841. * @arg @ref LL_LPUART_PRESCALER_DIV8
  842. * @arg @ref LL_LPUART_PRESCALER_DIV10
  843. * @arg @ref LL_LPUART_PRESCALER_DIV12
  844. * @arg @ref LL_LPUART_PRESCALER_DIV16
  845. * @arg @ref LL_LPUART_PRESCALER_DIV32
  846. * @arg @ref LL_LPUART_PRESCALER_DIV64
  847. * @arg @ref LL_LPUART_PRESCALER_DIV128
  848. * @arg @ref LL_LPUART_PRESCALER_DIV256
  849. */
  850. __STATIC_INLINE uint32_t LL_LPUART_GetPrescaler(const USART_TypeDef *LPUARTx)
  851. {
  852. return (uint32_t)(READ_BIT(LPUARTx->PRESC, USART_PRESC_PRESCALER));
  853. }
  854. /**
  855. * @brief Set the length of the stop bits
  856. * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength
  857. * @param LPUARTx LPUART Instance
  858. * @param StopBits This parameter can be one of the following values:
  859. * @arg @ref LL_LPUART_STOPBITS_1
  860. * @arg @ref LL_LPUART_STOPBITS_2
  861. * @retval None
  862. */
  863. __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits)
  864. {
  865. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  866. }
  867. /**
  868. * @brief Retrieve the length of the stop bits
  869. * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength
  870. * @param LPUARTx LPUART Instance
  871. * @retval Returned value can be one of the following values:
  872. * @arg @ref LL_LPUART_STOPBITS_1
  873. * @arg @ref LL_LPUART_STOPBITS_2
  874. */
  875. __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(const USART_TypeDef *LPUARTx)
  876. {
  877. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP));
  878. }
  879. /**
  880. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  881. * @note Call of this function is equivalent to following function call sequence :
  882. * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function
  883. * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function
  884. * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function
  885. * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n
  886. * CR1 PCE LL_LPUART_ConfigCharacter\n
  887. * CR1 M LL_LPUART_ConfigCharacter\n
  888. * CR2 STOP LL_LPUART_ConfigCharacter
  889. * @param LPUARTx LPUART Instance
  890. * @param DataWidth This parameter can be one of the following values:
  891. * @arg @ref LL_LPUART_DATAWIDTH_7B
  892. * @arg @ref LL_LPUART_DATAWIDTH_8B
  893. * @arg @ref LL_LPUART_DATAWIDTH_9B
  894. * @param Parity This parameter can be one of the following values:
  895. * @arg @ref LL_LPUART_PARITY_NONE
  896. * @arg @ref LL_LPUART_PARITY_EVEN
  897. * @arg @ref LL_LPUART_PARITY_ODD
  898. * @param StopBits This parameter can be one of the following values:
  899. * @arg @ref LL_LPUART_STOPBITS_1
  900. * @arg @ref LL_LPUART_STOPBITS_2
  901. * @retval None
  902. */
  903. __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity,
  904. uint32_t StopBits)
  905. {
  906. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  907. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  908. }
  909. /**
  910. * @brief Configure TX/RX pins swapping setting.
  911. * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap
  912. * @param LPUARTx LPUART Instance
  913. * @param SwapConfig This parameter can be one of the following values:
  914. * @arg @ref LL_LPUART_TXRX_STANDARD
  915. * @arg @ref LL_LPUART_TXRX_SWAPPED
  916. * @retval None
  917. */
  918. __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig)
  919. {
  920. MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig);
  921. }
  922. /**
  923. * @brief Retrieve TX/RX pins swapping configuration.
  924. * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap
  925. * @param LPUARTx LPUART Instance
  926. * @retval Returned value can be one of the following values:
  927. * @arg @ref LL_LPUART_TXRX_STANDARD
  928. * @arg @ref LL_LPUART_TXRX_SWAPPED
  929. */
  930. __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(const USART_TypeDef *LPUARTx)
  931. {
  932. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP));
  933. }
  934. /**
  935. * @brief Configure RX pin active level logic
  936. * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel
  937. * @param LPUARTx LPUART Instance
  938. * @param PinInvMethod This parameter can be one of the following values:
  939. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  940. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  941. * @retval None
  942. */
  943. __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  944. {
  945. MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  946. }
  947. /**
  948. * @brief Retrieve RX pin active level logic configuration
  949. * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel
  950. * @param LPUARTx LPUART Instance
  951. * @retval Returned value can be one of the following values:
  952. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  953. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  954. */
  955. __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(const USART_TypeDef *LPUARTx)
  956. {
  957. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV));
  958. }
  959. /**
  960. * @brief Configure TX pin active level logic
  961. * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel
  962. * @param LPUARTx LPUART Instance
  963. * @param PinInvMethod This parameter can be one of the following values:
  964. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  965. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  966. * @retval None
  967. */
  968. __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  969. {
  970. MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  971. }
  972. /**
  973. * @brief Retrieve TX pin active level logic configuration
  974. * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel
  975. * @param LPUARTx LPUART Instance
  976. * @retval Returned value can be one of the following values:
  977. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  978. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  979. */
  980. __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(const USART_TypeDef *LPUARTx)
  981. {
  982. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV));
  983. }
  984. /**
  985. * @brief Configure Binary data logic.
  986. *
  987. * @note Allow to define how Logical data from the data register are send/received :
  988. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  989. * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic
  990. * @param LPUARTx LPUART Instance
  991. * @param DataLogic This parameter can be one of the following values:
  992. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  993. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  994. * @retval None
  995. */
  996. __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic)
  997. {
  998. MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic);
  999. }
  1000. /**
  1001. * @brief Retrieve Binary data configuration
  1002. * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic
  1003. * @param LPUARTx LPUART Instance
  1004. * @retval Returned value can be one of the following values:
  1005. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  1006. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  1007. */
  1008. __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(const USART_TypeDef *LPUARTx)
  1009. {
  1010. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV));
  1011. }
  1012. /**
  1013. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  1014. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1015. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1016. * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder
  1017. * @param LPUARTx LPUART Instance
  1018. * @param BitOrder This parameter can be one of the following values:
  1019. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  1020. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  1021. * @retval None
  1022. */
  1023. __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder)
  1024. {
  1025. MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  1026. }
  1027. /**
  1028. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  1029. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1030. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1031. * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder
  1032. * @param LPUARTx LPUART Instance
  1033. * @retval Returned value can be one of the following values:
  1034. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  1035. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  1036. */
  1037. __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(const USART_TypeDef *LPUARTx)
  1038. {
  1039. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST));
  1040. }
  1041. /**
  1042. * @brief Set Address of the LPUART node.
  1043. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  1044. * for wake up with address mark detection.
  1045. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  1046. * (b7-b4 should be set to 0)
  1047. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  1048. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  1049. * for wake up with 7-bit address mark detection.
  1050. * The MSB of the character sent by the transmitter should be equal to 1.
  1051. * It may also be used for character detection during normal reception,
  1052. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  1053. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  1054. * value and CMF flag is set on match)
  1055. * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n
  1056. * CR2 ADDM7 LL_LPUART_ConfigNodeAddress
  1057. * @param LPUARTx LPUART Instance
  1058. * @param AddressLen This parameter can be one of the following values:
  1059. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1060. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1061. * @param NodeAddress 4 or 7 bit Address of the LPUART node.
  1062. * @retval None
  1063. */
  1064. __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress)
  1065. {
  1066. MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  1067. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  1068. }
  1069. /**
  1070. * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2.
  1071. * @note If 4-bit Address Detection is selected in ADDM7,
  1072. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  1073. * If 7-bit Address Detection is selected in ADDM7,
  1074. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  1075. * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress
  1076. * @param LPUARTx LPUART Instance
  1077. * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255)
  1078. */
  1079. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(const USART_TypeDef *LPUARTx)
  1080. {
  1081. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  1082. }
  1083. /**
  1084. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  1085. * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen
  1086. * @param LPUARTx LPUART Instance
  1087. * @retval Returned value can be one of the following values:
  1088. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1089. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1090. */
  1091. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(const USART_TypeDef *LPUARTx)
  1092. {
  1093. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7));
  1094. }
  1095. /**
  1096. * @brief Enable RTS HW Flow Control
  1097. * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl
  1098. * @param LPUARTx LPUART Instance
  1099. * @retval None
  1100. */
  1101. __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1102. {
  1103. SET_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1104. }
  1105. /**
  1106. * @brief Disable RTS HW Flow Control
  1107. * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl
  1108. * @param LPUARTx LPUART Instance
  1109. * @retval None
  1110. */
  1111. __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1112. {
  1113. CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1114. }
  1115. /**
  1116. * @brief Enable CTS HW Flow Control
  1117. * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl
  1118. * @param LPUARTx LPUART Instance
  1119. * @retval None
  1120. */
  1121. __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1122. {
  1123. SET_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1124. }
  1125. /**
  1126. * @brief Disable CTS HW Flow Control
  1127. * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl
  1128. * @param LPUARTx LPUART Instance
  1129. * @retval None
  1130. */
  1131. __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1132. {
  1133. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1134. }
  1135. /**
  1136. * @brief Configure HW Flow Control mode (both CTS and RTS)
  1137. * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n
  1138. * CR3 CTSE LL_LPUART_SetHWFlowCtrl
  1139. * @param LPUARTx LPUART Instance
  1140. * @param HardwareFlowControl This parameter can be one of the following values:
  1141. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1142. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1143. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1144. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1145. * @retval None
  1146. */
  1147. __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl)
  1148. {
  1149. MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  1150. }
  1151. /**
  1152. * @brief Return HW Flow Control configuration (both CTS and RTS)
  1153. * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n
  1154. * CR3 CTSE LL_LPUART_GetHWFlowCtrl
  1155. * @param LPUARTx LPUART Instance
  1156. * @retval Returned value can be one of the following values:
  1157. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1158. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1159. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1160. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1161. */
  1162. __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(const USART_TypeDef *LPUARTx)
  1163. {
  1164. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  1165. }
  1166. /**
  1167. * @brief Enable Overrun detection
  1168. * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect
  1169. * @param LPUARTx LPUART Instance
  1170. * @retval None
  1171. */
  1172. __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx)
  1173. {
  1174. CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1175. }
  1176. /**
  1177. * @brief Disable Overrun detection
  1178. * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect
  1179. * @param LPUARTx LPUART Instance
  1180. * @retval None
  1181. */
  1182. __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx)
  1183. {
  1184. SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1185. }
  1186. /**
  1187. * @brief Indicate if Overrun detection is enabled
  1188. * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect
  1189. * @param LPUARTx LPUART Instance
  1190. * @retval State of bit (1 or 0).
  1191. */
  1192. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(const USART_TypeDef *LPUARTx)
  1193. {
  1194. return ((READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL);
  1195. }
  1196. /**
  1197. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1198. * @rmtoll CR3 WUS LL_LPUART_SetWKUPType
  1199. * @param LPUARTx LPUART Instance
  1200. * @param Type This parameter can be one of the following values:
  1201. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1202. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1203. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1204. * @retval None
  1205. */
  1206. __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type)
  1207. {
  1208. MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type);
  1209. }
  1210. /**
  1211. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1212. * @rmtoll CR3 WUS LL_LPUART_GetWKUPType
  1213. * @param LPUARTx LPUART Instance
  1214. * @retval Returned value can be one of the following values:
  1215. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1216. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1217. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1218. */
  1219. __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(const USART_TypeDef *LPUARTx)
  1220. {
  1221. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS));
  1222. }
  1223. /**
  1224. * @brief Configure LPUART BRR register for achieving expected Baud Rate value.
  1225. *
  1226. * @note Compute and set LPUARTDIV value in BRR Register (full BRR content)
  1227. * according to used Peripheral Clock and expected Baud Rate values
  1228. * @note Peripheral clock and Baud Rate values provided as function parameters should be valid
  1229. * (Baud rate value != 0).
  1230. * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit,
  1231. * a care should be taken when generating high baud rates using high PeriphClk
  1232. * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate].
  1233. * @rmtoll BRR BRR LL_LPUART_SetBaudRate
  1234. * @param LPUARTx LPUART Instance
  1235. * @param PeriphClk Peripheral Clock
  1236. * @param PrescalerValue This parameter can be one of the following values:
  1237. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1238. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1239. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1240. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1241. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1242. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1243. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1244. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1245. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1246. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1247. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1248. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1249. * @param BaudRate Baud Rate
  1250. * @retval None
  1251. */
  1252. __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
  1253. uint32_t BaudRate)
  1254. {
  1255. if (BaudRate != 0U)
  1256. {
  1257. LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, PrescalerValue, BaudRate);
  1258. }
  1259. }
  1260. /**
  1261. * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register
  1262. * (full BRR content), and to used Peripheral Clock values
  1263. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  1264. * @rmtoll BRR BRR LL_LPUART_GetBaudRate
  1265. * @param LPUARTx LPUART Instance
  1266. * @param PeriphClk Peripheral Clock
  1267. * @param PrescalerValue This parameter can be one of the following values:
  1268. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1269. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1270. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1271. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1272. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1273. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1274. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1275. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1276. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1277. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1278. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1279. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1280. * @retval Baud Rate
  1281. */
  1282. __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(const USART_TypeDef *LPUARTx, uint32_t PeriphClk,
  1283. uint32_t PrescalerValue)
  1284. {
  1285. uint32_t lpuartdiv;
  1286. uint32_t brrresult;
  1287. uint32_t periphclkpresc = (uint32_t)(PeriphClk / (LPUART_PRESCALER_TAB[(uint16_t)PrescalerValue]));
  1288. lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK;
  1289. if (lpuartdiv >= LPUART_BRR_MIN_VALUE)
  1290. {
  1291. brrresult = (uint32_t)(((uint64_t)(periphclkpresc) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv);
  1292. }
  1293. else
  1294. {
  1295. brrresult = 0x0UL;
  1296. }
  1297. return (brrresult);
  1298. }
  1299. /**
  1300. * @}
  1301. */
  1302. /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1303. * @{
  1304. */
  1305. /**
  1306. * @brief Enable Single Wire Half-Duplex mode
  1307. * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex
  1308. * @param LPUARTx LPUART Instance
  1309. * @retval None
  1310. */
  1311. __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx)
  1312. {
  1313. SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1314. }
  1315. /**
  1316. * @brief Disable Single Wire Half-Duplex mode
  1317. * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex
  1318. * @param LPUARTx LPUART Instance
  1319. * @retval None
  1320. */
  1321. __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx)
  1322. {
  1323. CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1324. }
  1325. /**
  1326. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1327. * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex
  1328. * @param LPUARTx LPUART Instance
  1329. * @retval State of bit (1 or 0).
  1330. */
  1331. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(const USART_TypeDef *LPUARTx)
  1332. {
  1333. return ((READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL);
  1334. }
  1335. /**
  1336. * @}
  1337. */
  1338. /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1339. * @{
  1340. */
  1341. /**
  1342. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1343. * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime
  1344. * @param LPUARTx LPUART Instance
  1345. * @param Time Value between Min_Data=0 and Max_Data=31
  1346. * @retval None
  1347. */
  1348. __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1349. {
  1350. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1351. }
  1352. /**
  1353. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1354. * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime
  1355. * @param LPUARTx LPUART Instance
  1356. * @retval Time value expressed on 5 bits ([4:0] bits) : c
  1357. */
  1358. __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(const USART_TypeDef *LPUARTx)
  1359. {
  1360. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1361. }
  1362. /**
  1363. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1364. * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime
  1365. * @param LPUARTx LPUART Instance
  1366. * @param Time Value between Min_Data=0 and Max_Data=31
  1367. * @retval None
  1368. */
  1369. __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1370. {
  1371. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1372. }
  1373. /**
  1374. * @brief Return DEAT (Driver Enable Assertion Time)
  1375. * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime
  1376. * @param LPUARTx LPUART Instance
  1377. * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31
  1378. */
  1379. __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(const USART_TypeDef *LPUARTx)
  1380. {
  1381. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  1382. }
  1383. /**
  1384. * @brief Enable Driver Enable (DE) Mode
  1385. * @rmtoll CR3 DEM LL_LPUART_EnableDEMode
  1386. * @param LPUARTx LPUART Instance
  1387. * @retval None
  1388. */
  1389. __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx)
  1390. {
  1391. SET_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1392. }
  1393. /**
  1394. * @brief Disable Driver Enable (DE) Mode
  1395. * @rmtoll CR3 DEM LL_LPUART_DisableDEMode
  1396. * @param LPUARTx LPUART Instance
  1397. * @retval None
  1398. */
  1399. __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx)
  1400. {
  1401. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1402. }
  1403. /**
  1404. * @brief Indicate if Driver Enable (DE) Mode is enabled
  1405. * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode
  1406. * @param LPUARTx LPUART Instance
  1407. * @retval State of bit (1 or 0).
  1408. */
  1409. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(const USART_TypeDef *LPUARTx)
  1410. {
  1411. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL);
  1412. }
  1413. /**
  1414. * @brief Select Driver Enable Polarity
  1415. * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity
  1416. * @param LPUARTx LPUART Instance
  1417. * @param Polarity This parameter can be one of the following values:
  1418. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1419. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1420. * @retval None
  1421. */
  1422. __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity)
  1423. {
  1424. MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity);
  1425. }
  1426. /**
  1427. * @brief Return Driver Enable Polarity
  1428. * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity
  1429. * @param LPUARTx LPUART Instance
  1430. * @retval Returned value can be one of the following values:
  1431. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1432. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1433. */
  1434. __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(const USART_TypeDef *LPUARTx)
  1435. {
  1436. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP));
  1437. }
  1438. /**
  1439. * @}
  1440. */
  1441. /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management
  1442. * @{
  1443. */
  1444. /**
  1445. * @brief Check if the LPUART Parity Error Flag is set or not
  1446. * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE
  1447. * @param LPUARTx LPUART Instance
  1448. * @retval State of bit (1 or 0).
  1449. */
  1450. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(const USART_TypeDef *LPUARTx)
  1451. {
  1452. return ((READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL);
  1453. }
  1454. /**
  1455. * @brief Check if the LPUART Framing Error Flag is set or not
  1456. * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE
  1457. * @param LPUARTx LPUART Instance
  1458. * @retval State of bit (1 or 0).
  1459. */
  1460. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(const USART_TypeDef *LPUARTx)
  1461. {
  1462. return ((READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL);
  1463. }
  1464. /**
  1465. * @brief Check if the LPUART Noise error detected Flag is set or not
  1466. * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE
  1467. * @param LPUARTx LPUART Instance
  1468. * @retval State of bit (1 or 0).
  1469. */
  1470. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(const USART_TypeDef *LPUARTx)
  1471. {
  1472. return ((READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL);
  1473. }
  1474. /**
  1475. * @brief Check if the LPUART OverRun Error Flag is set or not
  1476. * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE
  1477. * @param LPUARTx LPUART Instance
  1478. * @retval State of bit (1 or 0).
  1479. */
  1480. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(const USART_TypeDef *LPUARTx)
  1481. {
  1482. return ((READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL);
  1483. }
  1484. /**
  1485. * @brief Check if the LPUART IDLE line detected Flag is set or not
  1486. * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE
  1487. * @param LPUARTx LPUART Instance
  1488. * @retval State of bit (1 or 0).
  1489. */
  1490. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(const USART_TypeDef *LPUARTx)
  1491. {
  1492. return ((READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL);
  1493. }
  1494. #define LL_LPUART_IsActiveFlag_RXNE LL_LPUART_IsActiveFlag_RXNE_RXFNE /* Redefinition for legacy purpose */
  1495. /**
  1496. * @brief Check if the LPUART Read Data Register or LPUART RX FIFO Not Empty Flag is set or not
  1497. * @rmtoll ISR RXNE_RXFNE LL_LPUART_IsActiveFlag_RXNE_RXFNE
  1498. * @param LPUARTx LPUART Instance
  1499. * @retval State of bit (1 or 0).
  1500. */
  1501. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE_RXFNE(const USART_TypeDef *LPUARTx)
  1502. {
  1503. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL);
  1504. }
  1505. /**
  1506. * @brief Check if the LPUART Transmission Complete Flag is set or not
  1507. * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC
  1508. * @param LPUARTx LPUART Instance
  1509. * @retval State of bit (1 or 0).
  1510. */
  1511. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(const USART_TypeDef *LPUARTx)
  1512. {
  1513. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL);
  1514. }
  1515. #define LL_LPUART_IsActiveFlag_TXE LL_LPUART_IsActiveFlag_TXE_TXFNF /* Redefinition for legacy purpose */
  1516. /**
  1517. * @brief Check if the LPUART Transmit Data Register Empty or LPUART TX FIFO Not Full Flag is set or not
  1518. * @rmtoll ISR TXE_TXFNF LL_LPUART_IsActiveFlag_TXE_TXFNF
  1519. * @param LPUARTx LPUART Instance
  1520. * @retval State of bit (1 or 0).
  1521. */
  1522. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE_TXFNF(const USART_TypeDef *LPUARTx)
  1523. {
  1524. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL);
  1525. }
  1526. /**
  1527. * @brief Check if the LPUART CTS interrupt Flag is set or not
  1528. * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS
  1529. * @param LPUARTx LPUART Instance
  1530. * @retval State of bit (1 or 0).
  1531. */
  1532. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(const USART_TypeDef *LPUARTx)
  1533. {
  1534. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL);
  1535. }
  1536. /**
  1537. * @brief Check if the LPUART CTS Flag is set or not
  1538. * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS
  1539. * @param LPUARTx LPUART Instance
  1540. * @retval State of bit (1 or 0).
  1541. */
  1542. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(const USART_TypeDef *LPUARTx)
  1543. {
  1544. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL);
  1545. }
  1546. /**
  1547. * @brief Check if the LPUART Busy Flag is set or not
  1548. * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY
  1549. * @param LPUARTx LPUART Instance
  1550. * @retval State of bit (1 or 0).
  1551. */
  1552. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(const USART_TypeDef *LPUARTx)
  1553. {
  1554. return ((READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL);
  1555. }
  1556. /**
  1557. * @brief Check if the LPUART Character Match Flag is set or not
  1558. * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM
  1559. * @param LPUARTx LPUART Instance
  1560. * @retval State of bit (1 or 0).
  1561. */
  1562. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(const USART_TypeDef *LPUARTx)
  1563. {
  1564. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL);
  1565. }
  1566. /**
  1567. * @brief Check if the LPUART Send Break Flag is set or not
  1568. * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK
  1569. * @param LPUARTx LPUART Instance
  1570. * @retval State of bit (1 or 0).
  1571. */
  1572. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(const USART_TypeDef *LPUARTx)
  1573. {
  1574. return ((READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL);
  1575. }
  1576. /**
  1577. * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not
  1578. * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU
  1579. * @param LPUARTx LPUART Instance
  1580. * @retval State of bit (1 or 0).
  1581. */
  1582. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(const USART_TypeDef *LPUARTx)
  1583. {
  1584. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL);
  1585. }
  1586. /**
  1587. * @brief Check if the LPUART Wake Up from stop mode Flag is set or not
  1588. * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP
  1589. * @param LPUARTx LPUART Instance
  1590. * @retval State of bit (1 or 0).
  1591. */
  1592. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(const USART_TypeDef *LPUARTx)
  1593. {
  1594. return ((READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL);
  1595. }
  1596. /**
  1597. * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not
  1598. * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK
  1599. * @param LPUARTx LPUART Instance
  1600. * @retval State of bit (1 or 0).
  1601. */
  1602. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(const USART_TypeDef *LPUARTx)
  1603. {
  1604. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL);
  1605. }
  1606. /**
  1607. * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not
  1608. * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK
  1609. * @param LPUARTx LPUART Instance
  1610. * @retval State of bit (1 or 0).
  1611. */
  1612. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(const USART_TypeDef *LPUARTx)
  1613. {
  1614. return ((READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL);
  1615. }
  1616. /**
  1617. * @brief Check if the LPUART TX FIFO Empty Flag is set or not
  1618. * @rmtoll ISR TXFE LL_LPUART_IsActiveFlag_TXFE
  1619. * @param LPUARTx LPUART Instance
  1620. * @retval State of bit (1 or 0).
  1621. */
  1622. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFE(const USART_TypeDef *LPUARTx)
  1623. {
  1624. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL);
  1625. }
  1626. /**
  1627. * @brief Check if the LPUART RX FIFO Full Flag is set or not
  1628. * @rmtoll ISR RXFF LL_LPUART_IsActiveFlag_RXFF
  1629. * @param LPUARTx LPUART Instance
  1630. * @retval State of bit (1 or 0).
  1631. */
  1632. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFF(const USART_TypeDef *LPUARTx)
  1633. {
  1634. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL);
  1635. }
  1636. /**
  1637. * @brief Check if the LPUART TX FIFO Threshold Flag is set or not
  1638. * @rmtoll ISR TXFT LL_LPUART_IsActiveFlag_TXFT
  1639. * @param LPUARTx LPUART Instance
  1640. * @retval State of bit (1 or 0).
  1641. */
  1642. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFT(const USART_TypeDef *LPUARTx)
  1643. {
  1644. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL);
  1645. }
  1646. /**
  1647. * @brief Check if the LPUART RX FIFO Threshold Flag is set or not
  1648. * @rmtoll ISR RXFT LL_LPUART_IsActiveFlag_RXFT
  1649. * @param LPUARTx LPUART Instance
  1650. * @retval State of bit (1 or 0).
  1651. */
  1652. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFT(const USART_TypeDef *LPUARTx)
  1653. {
  1654. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL);
  1655. }
  1656. /**
  1657. * @brief Clear Parity Error Flag
  1658. * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE
  1659. * @param LPUARTx LPUART Instance
  1660. * @retval None
  1661. */
  1662. __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx)
  1663. {
  1664. WRITE_REG(LPUARTx->ICR, USART_ICR_PECF);
  1665. }
  1666. /**
  1667. * @brief Clear Framing Error Flag
  1668. * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE
  1669. * @param LPUARTx LPUART Instance
  1670. * @retval None
  1671. */
  1672. __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx)
  1673. {
  1674. WRITE_REG(LPUARTx->ICR, USART_ICR_FECF);
  1675. }
  1676. /**
  1677. * @brief Clear Noise detected Flag
  1678. * @rmtoll ICR NECF LL_LPUART_ClearFlag_NE
  1679. * @param LPUARTx LPUART Instance
  1680. * @retval None
  1681. */
  1682. __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx)
  1683. {
  1684. WRITE_REG(LPUARTx->ICR, USART_ICR_NECF);
  1685. }
  1686. /**
  1687. * @brief Clear OverRun Error Flag
  1688. * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE
  1689. * @param LPUARTx LPUART Instance
  1690. * @retval None
  1691. */
  1692. __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx)
  1693. {
  1694. WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF);
  1695. }
  1696. /**
  1697. * @brief Clear IDLE line detected Flag
  1698. * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE
  1699. * @param LPUARTx LPUART Instance
  1700. * @retval None
  1701. */
  1702. __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx)
  1703. {
  1704. WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF);
  1705. }
  1706. /**
  1707. * @brief Clear Transmission Complete Flag
  1708. * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC
  1709. * @param LPUARTx LPUART Instance
  1710. * @retval None
  1711. */
  1712. __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx)
  1713. {
  1714. WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF);
  1715. }
  1716. /**
  1717. * @brief Clear CTS Interrupt Flag
  1718. * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS
  1719. * @param LPUARTx LPUART Instance
  1720. * @retval None
  1721. */
  1722. __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx)
  1723. {
  1724. WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF);
  1725. }
  1726. /**
  1727. * @brief Clear Character Match Flag
  1728. * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM
  1729. * @param LPUARTx LPUART Instance
  1730. * @retval None
  1731. */
  1732. __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx)
  1733. {
  1734. WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF);
  1735. }
  1736. /**
  1737. * @brief Clear Wake Up from stop mode Flag
  1738. * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP
  1739. * @param LPUARTx LPUART Instance
  1740. * @retval None
  1741. */
  1742. __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx)
  1743. {
  1744. WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF);
  1745. }
  1746. /**
  1747. * @}
  1748. */
  1749. /** @defgroup LPUART_LL_EF_IT_Management IT_Management
  1750. * @{
  1751. */
  1752. /**
  1753. * @brief Enable IDLE Interrupt
  1754. * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE
  1755. * @param LPUARTx LPUART Instance
  1756. * @retval None
  1757. */
  1758. __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx)
  1759. {
  1760. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1761. }
  1762. #define LL_LPUART_EnableIT_RXNE LL_LPUART_EnableIT_RXNE_RXFNE /* Redefinition for legacy purpose */
  1763. /**
  1764. * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt
  1765. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_EnableIT_RXNE_RXFNE
  1766. * @param LPUARTx LPUART Instance
  1767. * @retval None
  1768. */
  1769. __STATIC_INLINE void LL_LPUART_EnableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1770. {
  1771. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  1772. }
  1773. /**
  1774. * @brief Enable Transmission Complete Interrupt
  1775. * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC
  1776. * @param LPUARTx LPUART Instance
  1777. * @retval None
  1778. */
  1779. __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx)
  1780. {
  1781. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1782. }
  1783. #define LL_LPUART_EnableIT_TXE LL_LPUART_EnableIT_TXE_TXFNF /* Redefinition for legacy purpose */
  1784. /**
  1785. * @brief Enable TX Empty and TX FIFO Not Full Interrupt
  1786. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_EnableIT_TXE_TXFNF
  1787. * @param LPUARTx LPUART Instance
  1788. * @retval None
  1789. */
  1790. __STATIC_INLINE void LL_LPUART_EnableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1791. {
  1792. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  1793. }
  1794. /**
  1795. * @brief Enable Parity Error Interrupt
  1796. * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE
  1797. * @param LPUARTx LPUART Instance
  1798. * @retval None
  1799. */
  1800. __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx)
  1801. {
  1802. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1803. }
  1804. /**
  1805. * @brief Enable Character Match Interrupt
  1806. * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM
  1807. * @param LPUARTx LPUART Instance
  1808. * @retval None
  1809. */
  1810. __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx)
  1811. {
  1812. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1813. }
  1814. /**
  1815. * @brief Enable TX FIFO Empty Interrupt
  1816. * @rmtoll CR1 TXFEIE LL_LPUART_EnableIT_TXFE
  1817. * @param LPUARTx LPUART Instance
  1818. * @retval None
  1819. */
  1820. __STATIC_INLINE void LL_LPUART_EnableIT_TXFE(USART_TypeDef *LPUARTx)
  1821. {
  1822. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  1823. }
  1824. /**
  1825. * @brief Enable RX FIFO Full Interrupt
  1826. * @rmtoll CR1 RXFFIE LL_LPUART_EnableIT_RXFF
  1827. * @param LPUARTx LPUART Instance
  1828. * @retval None
  1829. */
  1830. __STATIC_INLINE void LL_LPUART_EnableIT_RXFF(USART_TypeDef *LPUARTx)
  1831. {
  1832. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  1833. }
  1834. /**
  1835. * @brief Enable Error Interrupt
  1836. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1837. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1838. * - 0: Interrupt is inhibited
  1839. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1840. * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR
  1841. * @param LPUARTx LPUART Instance
  1842. * @retval None
  1843. */
  1844. __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx)
  1845. {
  1846. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1847. }
  1848. /**
  1849. * @brief Enable CTS Interrupt
  1850. * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS
  1851. * @param LPUARTx LPUART Instance
  1852. * @retval None
  1853. */
  1854. __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx)
  1855. {
  1856. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1857. }
  1858. /**
  1859. * @brief Enable Wake Up from Stop Mode Interrupt
  1860. * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP
  1861. * @param LPUARTx LPUART Instance
  1862. * @retval None
  1863. */
  1864. __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx)
  1865. {
  1866. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  1867. }
  1868. /**
  1869. * @brief Enable TX FIFO Threshold Interrupt
  1870. * @rmtoll CR3 TXFTIE LL_LPUART_EnableIT_TXFT
  1871. * @param LPUARTx LPUART Instance
  1872. * @retval None
  1873. */
  1874. __STATIC_INLINE void LL_LPUART_EnableIT_TXFT(USART_TypeDef *LPUARTx)
  1875. {
  1876. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  1877. }
  1878. /**
  1879. * @brief Enable RX FIFO Threshold Interrupt
  1880. * @rmtoll CR3 RXFTIE LL_LPUART_EnableIT_RXFT
  1881. * @param LPUARTx LPUART Instance
  1882. * @retval None
  1883. */
  1884. __STATIC_INLINE void LL_LPUART_EnableIT_RXFT(USART_TypeDef *LPUARTx)
  1885. {
  1886. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  1887. }
  1888. /**
  1889. * @brief Disable IDLE Interrupt
  1890. * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE
  1891. * @param LPUARTx LPUART Instance
  1892. * @retval None
  1893. */
  1894. __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx)
  1895. {
  1896. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1897. }
  1898. #define LL_LPUART_DisableIT_RXNE LL_LPUART_DisableIT_RXNE_RXFNE /* Redefinition for legacy purpose */
  1899. /**
  1900. * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt
  1901. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_DisableIT_RXNE_RXFNE
  1902. * @param LPUARTx LPUART Instance
  1903. * @retval None
  1904. */
  1905. __STATIC_INLINE void LL_LPUART_DisableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1906. {
  1907. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  1908. }
  1909. /**
  1910. * @brief Disable Transmission Complete Interrupt
  1911. * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC
  1912. * @param LPUARTx LPUART Instance
  1913. * @retval None
  1914. */
  1915. __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx)
  1916. {
  1917. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1918. }
  1919. #define LL_LPUART_DisableIT_TXE LL_LPUART_DisableIT_TXE_TXFNF /* Redefinition for legacy purpose */
  1920. /**
  1921. * @brief Disable TX Empty and TX FIFO Not Full Interrupt
  1922. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_DisableIT_TXE_TXFNF
  1923. * @param LPUARTx LPUART Instance
  1924. * @retval None
  1925. */
  1926. __STATIC_INLINE void LL_LPUART_DisableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1927. {
  1928. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  1929. }
  1930. /**
  1931. * @brief Disable Parity Error Interrupt
  1932. * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE
  1933. * @param LPUARTx LPUART Instance
  1934. * @retval None
  1935. */
  1936. __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx)
  1937. {
  1938. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1939. }
  1940. /**
  1941. * @brief Disable Character Match Interrupt
  1942. * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM
  1943. * @param LPUARTx LPUART Instance
  1944. * @retval None
  1945. */
  1946. __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx)
  1947. {
  1948. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1949. }
  1950. /**
  1951. * @brief Disable TX FIFO Empty Interrupt
  1952. * @rmtoll CR1 TXFEIE LL_LPUART_DisableIT_TXFE
  1953. * @param LPUARTx LPUART Instance
  1954. * @retval None
  1955. */
  1956. __STATIC_INLINE void LL_LPUART_DisableIT_TXFE(USART_TypeDef *LPUARTx)
  1957. {
  1958. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  1959. }
  1960. /**
  1961. * @brief Disable RX FIFO Full Interrupt
  1962. * @rmtoll CR1 RXFFIE LL_LPUART_DisableIT_RXFF
  1963. * @param LPUARTx LPUART Instance
  1964. * @retval None
  1965. */
  1966. __STATIC_INLINE void LL_LPUART_DisableIT_RXFF(USART_TypeDef *LPUARTx)
  1967. {
  1968. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  1969. }
  1970. /**
  1971. * @brief Disable Error Interrupt
  1972. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1973. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1974. * - 0: Interrupt is inhibited
  1975. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1976. * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR
  1977. * @param LPUARTx LPUART Instance
  1978. * @retval None
  1979. */
  1980. __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx)
  1981. {
  1982. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1983. }
  1984. /**
  1985. * @brief Disable CTS Interrupt
  1986. * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS
  1987. * @param LPUARTx LPUART Instance
  1988. * @retval None
  1989. */
  1990. __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx)
  1991. {
  1992. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1993. }
  1994. /**
  1995. * @brief Disable Wake Up from Stop Mode Interrupt
  1996. * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP
  1997. * @param LPUARTx LPUART Instance
  1998. * @retval None
  1999. */
  2000. __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx)
  2001. {
  2002. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  2003. }
  2004. /**
  2005. * @brief Disable TX FIFO Threshold Interrupt
  2006. * @rmtoll CR3 TXFTIE LL_LPUART_DisableIT_TXFT
  2007. * @param LPUARTx LPUART Instance
  2008. * @retval None
  2009. */
  2010. __STATIC_INLINE void LL_LPUART_DisableIT_TXFT(USART_TypeDef *LPUARTx)
  2011. {
  2012. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  2013. }
  2014. /**
  2015. * @brief Disable RX FIFO Threshold Interrupt
  2016. * @rmtoll CR3 RXFTIE LL_LPUART_DisableIT_RXFT
  2017. * @param LPUARTx LPUART Instance
  2018. * @retval None
  2019. */
  2020. __STATIC_INLINE void LL_LPUART_DisableIT_RXFT(USART_TypeDef *LPUARTx)
  2021. {
  2022. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  2023. }
  2024. /**
  2025. * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled.
  2026. * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE
  2027. * @param LPUARTx LPUART Instance
  2028. * @retval State of bit (1 or 0).
  2029. */
  2030. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(const USART_TypeDef *LPUARTx)
  2031. {
  2032. return ((READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL);
  2033. }
  2034. #define LL_LPUART_IsEnabledIT_RXNE LL_LPUART_IsEnabledIT_RXNE_RXFNE /* Redefinition for legacy purpose */
  2035. /**
  2036. * @brief Check if the LPUART RX Not Empty and LPUART RX FIFO Not Empty Interrupt is enabled or disabled.
  2037. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_IsEnabledIT_RXNE_RXFNE
  2038. * @param LPUARTx LPUART Instance
  2039. * @retval State of bit (1 or 0).
  2040. */
  2041. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE_RXFNE(const USART_TypeDef *LPUARTx)
  2042. {
  2043. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL);
  2044. }
  2045. /**
  2046. * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled.
  2047. * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC
  2048. * @param LPUARTx LPUART Instance
  2049. * @retval State of bit (1 or 0).
  2050. */
  2051. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(const USART_TypeDef *LPUARTx)
  2052. {
  2053. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL);
  2054. }
  2055. #define LL_LPUART_IsEnabledIT_TXE LL_LPUART_IsEnabledIT_TXE_TXFNF /* Redefinition for legacy purpose */
  2056. /**
  2057. * @brief Check if the LPUART TX Empty and LPUART TX FIFO Not Full Interrupt is enabled or disabled
  2058. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_IsEnabledIT_TXE_TXFNF
  2059. * @param LPUARTx LPUART Instance
  2060. * @retval State of bit (1 or 0).
  2061. */
  2062. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE_TXFNF(const USART_TypeDef *LPUARTx)
  2063. {
  2064. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL);
  2065. }
  2066. /**
  2067. * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled.
  2068. * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE
  2069. * @param LPUARTx LPUART Instance
  2070. * @retval State of bit (1 or 0).
  2071. */
  2072. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(const USART_TypeDef *LPUARTx)
  2073. {
  2074. return ((READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL);
  2075. }
  2076. /**
  2077. * @brief Check if the LPUART Character Match Interrupt is enabled or disabled.
  2078. * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM
  2079. * @param LPUARTx LPUART Instance
  2080. * @retval State of bit (1 or 0).
  2081. */
  2082. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(const USART_TypeDef *LPUARTx)
  2083. {
  2084. return ((READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL);
  2085. }
  2086. /**
  2087. * @brief Check if the LPUART TX FIFO Empty Interrupt is enabled or disabled
  2088. * @rmtoll CR1 TXFEIE LL_LPUART_IsEnabledIT_TXFE
  2089. * @param LPUARTx LPUART Instance
  2090. * @retval State of bit (1 or 0).
  2091. */
  2092. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFE(const USART_TypeDef *LPUARTx)
  2093. {
  2094. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL);
  2095. }
  2096. /**
  2097. * @brief Check if the LPUART RX FIFO Full Interrupt is enabled or disabled
  2098. * @rmtoll CR1 RXFFIE LL_LPUART_IsEnabledIT_RXFF
  2099. * @param LPUARTx LPUART Instance
  2100. * @retval State of bit (1 or 0).
  2101. */
  2102. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFF(const USART_TypeDef *LPUARTx)
  2103. {
  2104. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL);
  2105. }
  2106. /**
  2107. * @brief Check if the LPUART Error Interrupt is enabled or disabled.
  2108. * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR
  2109. * @param LPUARTx LPUART Instance
  2110. * @retval State of bit (1 or 0).
  2111. */
  2112. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(const USART_TypeDef *LPUARTx)
  2113. {
  2114. return ((READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL);
  2115. }
  2116. /**
  2117. * @brief Check if the LPUART CTS Interrupt is enabled or disabled.
  2118. * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS
  2119. * @param LPUARTx LPUART Instance
  2120. * @retval State of bit (1 or 0).
  2121. */
  2122. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(const USART_TypeDef *LPUARTx)
  2123. {
  2124. return ((READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL);
  2125. }
  2126. /**
  2127. * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled.
  2128. * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP
  2129. * @param LPUARTx LPUART Instance
  2130. * @retval State of bit (1 or 0).
  2131. */
  2132. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(const USART_TypeDef *LPUARTx)
  2133. {
  2134. return ((READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL);
  2135. }
  2136. /**
  2137. * @brief Check if LPUART TX FIFO Threshold Interrupt is enabled or disabled
  2138. * @rmtoll CR3 TXFTIE LL_LPUART_IsEnabledIT_TXFT
  2139. * @param LPUARTx LPUART Instance
  2140. * @retval State of bit (1 or 0).
  2141. */
  2142. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFT(const USART_TypeDef *LPUARTx)
  2143. {
  2144. return ((READ_BIT(LPUARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL);
  2145. }
  2146. /**
  2147. * @brief Check if LPUART RX FIFO Threshold Interrupt is enabled or disabled
  2148. * @rmtoll CR3 RXFTIE LL_LPUART_IsEnabledIT_RXFT
  2149. * @param LPUARTx LPUART Instance
  2150. * @retval State of bit (1 or 0).
  2151. */
  2152. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFT(const USART_TypeDef *LPUARTx)
  2153. {
  2154. return ((READ_BIT(LPUARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL);
  2155. }
  2156. /**
  2157. * @}
  2158. */
  2159. /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management
  2160. * @{
  2161. */
  2162. /**
  2163. * @brief Enable DMA Mode for reception
  2164. * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX
  2165. * @param LPUARTx LPUART Instance
  2166. * @retval None
  2167. */
  2168. __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx)
  2169. {
  2170. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2171. }
  2172. /**
  2173. * @brief Disable DMA Mode for reception
  2174. * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX
  2175. * @param LPUARTx LPUART Instance
  2176. * @retval None
  2177. */
  2178. __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx)
  2179. {
  2180. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2181. }
  2182. /**
  2183. * @brief Check if DMA Mode is enabled for reception
  2184. * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX
  2185. * @param LPUARTx LPUART Instance
  2186. * @retval State of bit (1 or 0).
  2187. */
  2188. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(const USART_TypeDef *LPUARTx)
  2189. {
  2190. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL);
  2191. }
  2192. /**
  2193. * @brief Enable DMA Mode for transmission
  2194. * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX
  2195. * @param LPUARTx LPUART Instance
  2196. * @retval None
  2197. */
  2198. __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx)
  2199. {
  2200. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2201. }
  2202. /**
  2203. * @brief Disable DMA Mode for transmission
  2204. * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX
  2205. * @param LPUARTx LPUART Instance
  2206. * @retval None
  2207. */
  2208. __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx)
  2209. {
  2210. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2211. }
  2212. /**
  2213. * @brief Check if DMA Mode is enabled for transmission
  2214. * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX
  2215. * @param LPUARTx LPUART Instance
  2216. * @retval State of bit (1 or 0).
  2217. */
  2218. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(const USART_TypeDef *LPUARTx)
  2219. {
  2220. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL);
  2221. }
  2222. /**
  2223. * @brief Enable DMA Disabling on Reception Error
  2224. * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr
  2225. * @param LPUARTx LPUART Instance
  2226. * @retval None
  2227. */
  2228. __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2229. {
  2230. SET_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2231. }
  2232. /**
  2233. * @brief Disable DMA Disabling on Reception Error
  2234. * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr
  2235. * @param LPUARTx LPUART Instance
  2236. * @retval None
  2237. */
  2238. __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2239. {
  2240. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2241. }
  2242. /**
  2243. * @brief Indicate if DMA Disabling on Reception Error is disabled
  2244. * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr
  2245. * @param LPUARTx LPUART Instance
  2246. * @retval State of bit (1 or 0).
  2247. */
  2248. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(const USART_TypeDef *LPUARTx)
  2249. {
  2250. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL);
  2251. }
  2252. /**
  2253. * @brief Get the LPUART data register address used for DMA transfer
  2254. * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n
  2255. * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr
  2256. * @param LPUARTx LPUART Instance
  2257. * @param Direction This parameter can be one of the following values:
  2258. * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT
  2259. * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE
  2260. * @retval Address of data register
  2261. */
  2262. __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(const USART_TypeDef *LPUARTx, uint32_t Direction)
  2263. {
  2264. uint32_t data_reg_addr;
  2265. if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT)
  2266. {
  2267. /* return address of TDR register */
  2268. data_reg_addr = (uint32_t) &(LPUARTx->TDR);
  2269. }
  2270. else
  2271. {
  2272. /* return address of RDR register */
  2273. data_reg_addr = (uint32_t) &(LPUARTx->RDR);
  2274. }
  2275. return data_reg_addr;
  2276. }
  2277. /**
  2278. * @}
  2279. */
  2280. /** @defgroup LPUART_LL_EF_Data_Management Data_Management
  2281. * @{
  2282. */
  2283. /**
  2284. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  2285. * @rmtoll RDR RDR LL_LPUART_ReceiveData8
  2286. * @param LPUARTx LPUART Instance
  2287. * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF
  2288. */
  2289. __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(const USART_TypeDef *LPUARTx)
  2290. {
  2291. return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR) & 0xFFU);
  2292. }
  2293. /**
  2294. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  2295. * @rmtoll RDR RDR LL_LPUART_ReceiveData9
  2296. * @param LPUARTx LPUART Instance
  2297. * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF
  2298. */
  2299. __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(const USART_TypeDef *LPUARTx)
  2300. {
  2301. return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR));
  2302. }
  2303. /**
  2304. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  2305. * @rmtoll TDR TDR LL_LPUART_TransmitData8
  2306. * @param LPUARTx LPUART Instance
  2307. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  2308. * @retval None
  2309. */
  2310. __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value)
  2311. {
  2312. LPUARTx->TDR = Value;
  2313. }
  2314. /**
  2315. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  2316. * @rmtoll TDR TDR LL_LPUART_TransmitData9
  2317. * @param LPUARTx LPUART Instance
  2318. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  2319. * @retval None
  2320. */
  2321. __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value)
  2322. {
  2323. LPUARTx->TDR = Value & 0x1FFUL;
  2324. }
  2325. /**
  2326. * @}
  2327. */
  2328. /** @defgroup LPUART_LL_EF_Execution Execution
  2329. * @{
  2330. */
  2331. /**
  2332. * @brief Request Break sending
  2333. * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending
  2334. * @param LPUARTx LPUART Instance
  2335. * @retval None
  2336. */
  2337. __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx)
  2338. {
  2339. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_SBKRQ);
  2340. }
  2341. /**
  2342. * @brief Put LPUART in mute mode and set the RWU flag
  2343. * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode
  2344. * @param LPUARTx LPUART Instance
  2345. * @retval None
  2346. */
  2347. __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx)
  2348. {
  2349. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_MMRQ);
  2350. }
  2351. /**
  2352. * @brief Request a Receive Data and FIFO flush
  2353. * @note Allows to discard the received data without reading them, and avoid an overrun
  2354. * condition.
  2355. * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush
  2356. * @param LPUARTx LPUART Instance
  2357. * @retval None
  2358. */
  2359. __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx)
  2360. {
  2361. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_RXFRQ);
  2362. }
  2363. /**
  2364. * @}
  2365. */
  2366. #if defined(USE_FULL_LL_DRIVER)
  2367. /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions
  2368. * @{
  2369. */
  2370. ErrorStatus LL_LPUART_DeInit(const USART_TypeDef *LPUARTx);
  2371. ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, const LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2372. void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2373. /**
  2374. * @}
  2375. */
  2376. #endif /* USE_FULL_LL_DRIVER */
  2377. /**
  2378. * @}
  2379. */
  2380. /**
  2381. * @}
  2382. */
  2383. #endif /* LPUART1 */
  2384. /**
  2385. * @}
  2386. */
  2387. #ifdef __cplusplus
  2388. }
  2389. #endif
  2390. #endif /* STM32H7xx_LL_LPUART_H */