stm32l4xx_ll_lpuart.h 101 KB

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