stm32f3xx_ll_usart.h 141 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_ll_usart.h
  4. * @author MCD Application Team
  5. * @brief Header file of USART LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 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 __STM32F3xx_LL_USART_H
  37. #define __STM32F3xx_LL_USART_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f3xx.h"
  43. /** @addtogroup STM32F3xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5)
  47. /** @defgroup USART_LL USART
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /** @defgroup USART_LL_Private_Constants USART Private Constants
  54. * @{
  55. */
  56. /**
  57. * @}
  58. */
  59. /* Private macros ------------------------------------------------------------*/
  60. #if defined(USE_FULL_LL_DRIVER)
  61. /** @defgroup USART_LL_Private_Macros USART Private Macros
  62. * @{
  63. */
  64. /**
  65. * @}
  66. */
  67. #endif /*USE_FULL_LL_DRIVER*/
  68. /* Exported types ------------------------------------------------------------*/
  69. #if defined(USE_FULL_LL_DRIVER)
  70. /** @defgroup USART_LL_ES_INIT USART Exported Init structures
  71. * @{
  72. */
  73. /**
  74. * @brief LL USART Init Structure definition
  75. */
  76. typedef struct
  77. {
  78. uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate.
  79. This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
  80. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  81. This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
  82. This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
  83. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  84. This parameter can be a value of @ref USART_LL_EC_STOPBITS.
  85. This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
  86. uint32_t Parity; /*!< Specifies the parity mode.
  87. This parameter can be a value of @ref USART_LL_EC_PARITY.
  88. This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
  89. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  90. This parameter can be a value of @ref USART_LL_EC_DIRECTION.
  91. This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
  92. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  93. This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
  94. This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
  95. uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8.
  96. This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
  97. This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
  98. } LL_USART_InitTypeDef;
  99. /**
  100. * @brief LL USART Clock Init Structure definition
  101. */
  102. typedef struct
  103. {
  104. uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled.
  105. This parameter can be a value of @ref USART_LL_EC_CLOCK.
  106. USART HW configuration can be modified afterwards using unitary functions
  107. @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
  108. For more details, refer to description of this function. */
  109. uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock.
  110. This parameter can be a value of @ref USART_LL_EC_POLARITY.
  111. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
  112. For more details, refer to description of this function. */
  113. uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made.
  114. This parameter can be a value of @ref USART_LL_EC_PHASE.
  115. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
  116. For more details, refer to description of this function. */
  117. uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted
  118. data bit (MSB) has to be output on the SCLK pin in synchronous mode.
  119. This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
  120. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
  121. For more details, refer to description of this function. */
  122. } LL_USART_ClockInitTypeDef;
  123. /**
  124. * @}
  125. */
  126. #endif /* USE_FULL_LL_DRIVER */
  127. /* Exported constants --------------------------------------------------------*/
  128. /** @defgroup USART_LL_Exported_Constants USART Exported Constants
  129. * @{
  130. */
  131. /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
  132. * @brief Flags defines which can be used with LL_USART_WriteReg function
  133. * @{
  134. */
  135. #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
  136. #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
  137. #define LL_USART_ICR_NCF USART_ICR_NCF /*!< Noise detected flag */
  138. #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
  139. #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
  140. #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
  141. #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection flag */
  142. #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
  143. #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout flag */
  144. #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block flag */
  145. #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
  146. #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
  151. * @brief Flags defines which can be used with LL_USART_ReadReg function
  152. * @{
  153. */
  154. #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  155. #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  156. #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  157. #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  158. #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  159. #define LL_USART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */
  160. #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  161. #define LL_USART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */
  162. #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */
  163. #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  164. #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  165. #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */
  166. #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */
  167. #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */
  168. #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */
  169. #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  170. #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  171. #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  172. #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  173. #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  174. #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  175. #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  176. /**
  177. * @}
  178. */
  179. /** @defgroup USART_LL_EC_IT IT Defines
  180. * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
  181. * @{
  182. */
  183. #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  184. #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
  185. #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  186. #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
  187. #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  188. #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  189. #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */
  190. #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */
  191. #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */
  192. #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  193. #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  194. #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  195. /**
  196. * @}
  197. */
  198. /** @defgroup USART_LL_EC_DIRECTION Communication Direction
  199. * @{
  200. */
  201. #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  202. #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  203. #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  204. #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  205. /**
  206. * @}
  207. */
  208. /** @defgroup USART_LL_EC_PARITY Parity Control
  209. * @{
  210. */
  211. #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  212. #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  213. #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup USART_LL_EC_WAKEUP Wakeup
  218. * @{
  219. */
  220. #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */
  221. #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */
  222. /**
  223. * @}
  224. */
  225. /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
  226. * @{
  227. */
  228. #if defined(USART_7BITS_SUPPORT)
  229. #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  230. #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  231. #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  232. #else
  233. #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  234. #define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  235. #endif
  236. /**
  237. * @}
  238. */
  239. /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
  240. * @{
  241. */
  242. #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
  243. #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
  244. /**
  245. * @}
  246. */
  247. #if defined(USE_FULL_LL_DRIVER)
  248. /** @defgroup USART_LL_EC_CLOCK Clock Signal
  249. * @{
  250. */
  251. #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */
  252. #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */
  253. /**
  254. * @}
  255. */
  256. #endif /*USE_FULL_LL_DRIVER*/
  257. /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
  258. * @{
  259. */
  260. #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */
  261. #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
  262. /**
  263. * @}
  264. */
  265. /** @defgroup USART_LL_EC_PHASE Clock Phase
  266. * @{
  267. */
  268. #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */
  269. #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
  270. /**
  271. * @}
  272. */
  273. /** @defgroup USART_LL_EC_POLARITY Clock Polarity
  274. * @{
  275. */
  276. #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/
  277. #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
  278. /**
  279. * @}
  280. */
  281. /** @defgroup USART_LL_EC_STOPBITS Stop Bits
  282. * @{
  283. */
  284. #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */
  285. #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  286. #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
  287. #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  288. /**
  289. * @}
  290. */
  291. /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap
  292. * @{
  293. */
  294. #define LL_USART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  295. #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  300. * @{
  301. */
  302. #define LL_USART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  303. #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  304. /**
  305. * @}
  306. */
  307. /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  308. * @{
  309. */
  310. #define LL_USART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  311. #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  312. /**
  313. * @}
  314. */
  315. /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion
  316. * @{
  317. */
  318. #define LL_USART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
  319. #define LL_USART_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. */
  320. /**
  321. * @}
  322. */
  323. /** @defgroup USART_LL_EC_BITORDER Bit Order
  324. * @{
  325. */
  326. #define LL_USART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
  327. #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
  328. /**
  329. * @}
  330. */
  331. /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection
  332. * @{
  333. */
  334. #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */
  335. #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */
  336. #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */
  337. #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
  338. /**
  339. * @}
  340. */
  341. /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection
  342. * @{
  343. */
  344. #define LL_USART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  345. #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  346. /**
  347. * @}
  348. */
  349. /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
  350. * @{
  351. */
  352. #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  353. #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
  354. #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
  355. #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  356. /**
  357. * @}
  358. */
  359. /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation
  360. * @{
  361. */
  362. #define LL_USART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  363. #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  364. #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  365. /**
  366. * @}
  367. */
  368. /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
  369. * @{
  370. */
  371. #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */
  372. #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
  373. /**
  374. * @}
  375. */
  376. /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
  377. * @{
  378. */
  379. #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */
  380. #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
  381. /**
  382. * @}
  383. */
  384. /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity
  385. * @{
  386. */
  387. #define LL_USART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  388. #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  389. /**
  390. * @}
  391. */
  392. /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data
  393. * @{
  394. */
  395. #define LL_USART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  396. #define LL_USART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  397. /**
  398. * @}
  399. */
  400. /**
  401. * @}
  402. */
  403. /* Exported macro ------------------------------------------------------------*/
  404. /** @defgroup USART_LL_Exported_Macros USART Exported Macros
  405. * @{
  406. */
  407. /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
  408. * @{
  409. */
  410. /**
  411. * @brief Write a value in USART register
  412. * @param __INSTANCE__ USART Instance
  413. * @param __REG__ Register to be written
  414. * @param __VALUE__ Value to be written in the register
  415. * @retval None
  416. */
  417. #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  418. /**
  419. * @brief Read a value in USART register
  420. * @param __INSTANCE__ USART Instance
  421. * @param __REG__ Register to be read
  422. * @retval Register value
  423. */
  424. #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  425. /**
  426. * @}
  427. */
  428. /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
  429. * @{
  430. */
  431. /**
  432. * @brief Compute USARTDIV value according to Peripheral Clock and
  433. * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
  434. * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
  435. * @param __BAUDRATE__ Baud rate value to achieve
  436. * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
  437. */
  438. #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__PERIPHCLK__)*2) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
  439. /**
  440. * @brief Compute USARTDIV value according to Peripheral Clock and
  441. * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
  442. * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
  443. * @param __BAUDRATE__ Baud rate value to achieve
  444. * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
  445. */
  446. #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
  447. /**
  448. * @}
  449. */
  450. /**
  451. * @}
  452. */
  453. /* Exported functions --------------------------------------------------------*/
  454. /** @defgroup USART_LL_Exported_Functions USART Exported Functions
  455. * @{
  456. */
  457. /** @defgroup USART_LL_EF_Configuration Configuration functions
  458. * @{
  459. */
  460. /**
  461. * @brief USART Enable
  462. * @rmtoll CR1 UE LL_USART_Enable
  463. * @param USARTx USART Instance
  464. * @retval None
  465. */
  466. __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
  467. {
  468. SET_BIT(USARTx->CR1, USART_CR1_UE);
  469. }
  470. /**
  471. * @brief USART Disable (all USART prescalers and outputs are disabled)
  472. * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
  473. * and current operations are discarded. The configuration of the USART is kept, but all the status
  474. * flags, in the USARTx_ISR are set to their default values.
  475. * @rmtoll CR1 UE LL_USART_Disable
  476. * @param USARTx USART Instance
  477. * @retval None
  478. */
  479. __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
  480. {
  481. CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
  482. }
  483. /**
  484. * @brief Indicate if USART is enabled
  485. * @rmtoll CR1 UE LL_USART_IsEnabled
  486. * @param USARTx USART Instance
  487. * @retval State of bit (1 or 0).
  488. */
  489. __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
  490. {
  491. return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
  492. }
  493. /**
  494. * @brief USART enabled in STOP Mode.
  495. * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
  496. * USART clock selection is HSI or LSE in RCC.
  497. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  498. * Wake-up from Stop mode feature is supported by the USARTx instance.
  499. * @rmtoll CR1 UESM LL_USART_EnableInStopMode
  500. * @param USARTx USART Instance
  501. * @retval None
  502. */
  503. __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
  504. {
  505. SET_BIT(USARTx->CR1, USART_CR1_UESM);
  506. }
  507. /**
  508. * @brief USART disabled in STOP Mode.
  509. * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode
  510. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  511. * Wake-up from Stop mode feature is supported by the USARTx instance.
  512. * @rmtoll CR1 UESM LL_USART_DisableInStopMode
  513. * @param USARTx USART Instance
  514. * @retval None
  515. */
  516. __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
  517. {
  518. CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
  519. }
  520. /**
  521. * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
  522. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  523. * Wake-up from Stop mode feature is supported by the USARTx instance.
  524. * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode
  525. * @param USARTx USART Instance
  526. * @retval State of bit (1 or 0).
  527. */
  528. __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
  529. {
  530. return (READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM));
  531. }
  532. /**
  533. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  534. * @rmtoll CR1 RE LL_USART_EnableDirectionRx
  535. * @param USARTx USART Instance
  536. * @retval None
  537. */
  538. __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
  539. {
  540. SET_BIT(USARTx->CR1, USART_CR1_RE);
  541. }
  542. /**
  543. * @brief Receiver Disable
  544. * @rmtoll CR1 RE LL_USART_DisableDirectionRx
  545. * @param USARTx USART Instance
  546. * @retval None
  547. */
  548. __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
  549. {
  550. CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
  551. }
  552. /**
  553. * @brief Transmitter Enable
  554. * @rmtoll CR1 TE LL_USART_EnableDirectionTx
  555. * @param USARTx USART Instance
  556. * @retval None
  557. */
  558. __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
  559. {
  560. SET_BIT(USARTx->CR1, USART_CR1_TE);
  561. }
  562. /**
  563. * @brief Transmitter Disable
  564. * @rmtoll CR1 TE LL_USART_DisableDirectionTx
  565. * @param USARTx USART Instance
  566. * @retval None
  567. */
  568. __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
  569. {
  570. CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
  571. }
  572. /**
  573. * @brief Configure simultaneously enabled/disabled states
  574. * of Transmitter and Receiver
  575. * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
  576. * CR1 TE LL_USART_SetTransferDirection
  577. * @param USARTx USART Instance
  578. * @param TransferDirection This parameter can be one of the following values:
  579. * @arg @ref LL_USART_DIRECTION_NONE
  580. * @arg @ref LL_USART_DIRECTION_RX
  581. * @arg @ref LL_USART_DIRECTION_TX
  582. * @arg @ref LL_USART_DIRECTION_TX_RX
  583. * @retval None
  584. */
  585. __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
  586. {
  587. MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  588. }
  589. /**
  590. * @brief Return enabled/disabled states of Transmitter and Receiver
  591. * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
  592. * CR1 TE LL_USART_GetTransferDirection
  593. * @param USARTx USART Instance
  594. * @retval Returned value can be one of the following values:
  595. * @arg @ref LL_USART_DIRECTION_NONE
  596. * @arg @ref LL_USART_DIRECTION_RX
  597. * @arg @ref LL_USART_DIRECTION_TX
  598. * @arg @ref LL_USART_DIRECTION_TX_RX
  599. */
  600. __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
  601. {
  602. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  603. }
  604. /**
  605. * @brief Configure Parity (enabled/disabled and parity mode if enabled).
  606. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  607. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  608. * (9th or 8th bit depending on data width) and parity is checked on the received data.
  609. * @rmtoll CR1 PS LL_USART_SetParity\n
  610. * CR1 PCE LL_USART_SetParity
  611. * @param USARTx USART Instance
  612. * @param Parity This parameter can be one of the following values:
  613. * @arg @ref LL_USART_PARITY_NONE
  614. * @arg @ref LL_USART_PARITY_EVEN
  615. * @arg @ref LL_USART_PARITY_ODD
  616. * @retval None
  617. */
  618. __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
  619. {
  620. MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  621. }
  622. /**
  623. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  624. * @rmtoll CR1 PS LL_USART_GetParity\n
  625. * CR1 PCE LL_USART_GetParity
  626. * @param USARTx USART Instance
  627. * @retval Returned value can be one of the following values:
  628. * @arg @ref LL_USART_PARITY_NONE
  629. * @arg @ref LL_USART_PARITY_EVEN
  630. * @arg @ref LL_USART_PARITY_ODD
  631. */
  632. __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
  633. {
  634. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  635. }
  636. /**
  637. * @brief Set Receiver Wake Up method from Mute mode.
  638. * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
  639. * @param USARTx USART Instance
  640. * @param Method This parameter can be one of the following values:
  641. * @arg @ref LL_USART_WAKEUP_IDLELINE
  642. * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
  643. * @retval None
  644. */
  645. __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
  646. {
  647. MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
  648. }
  649. /**
  650. * @brief Return Receiver Wake Up method from Mute mode
  651. * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
  652. * @param USARTx USART Instance
  653. * @retval Returned value can be one of the following values:
  654. * @arg @ref LL_USART_WAKEUP_IDLELINE
  655. * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
  656. */
  657. __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
  658. {
  659. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
  660. }
  661. /**
  662. * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
  663. * @rmtoll CR1 M0 LL_USART_SetDataWidth\n
  664. * CR1 M1 LL_USART_SetDataWidth
  665. * @param USARTx USART Instance
  666. * @param DataWidth This parameter can be one of the following values:
  667. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  668. * @arg @ref LL_USART_DATAWIDTH_8B
  669. * @arg @ref LL_USART_DATAWIDTH_9B
  670. *
  671. * (*) Values not available on all devices
  672. * @retval None
  673. */
  674. __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
  675. {
  676. MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
  677. }
  678. /**
  679. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  680. * @rmtoll CR1 M0 LL_USART_GetDataWidth\n
  681. * CR1 M1 LL_USART_GetDataWidth
  682. * @param USARTx USART Instance
  683. * @retval Returned value can be one of the following values:
  684. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  685. * @arg @ref LL_USART_DATAWIDTH_8B
  686. * @arg @ref LL_USART_DATAWIDTH_9B
  687. *
  688. * (*) Values not available on all devices
  689. */
  690. __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
  691. {
  692. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
  693. }
  694. /**
  695. * @brief Allow switch between Mute Mode and Active mode
  696. * @rmtoll CR1 MME LL_USART_EnableMuteMode
  697. * @param USARTx USART Instance
  698. * @retval None
  699. */
  700. __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
  701. {
  702. SET_BIT(USARTx->CR1, USART_CR1_MME);
  703. }
  704. /**
  705. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  706. * @rmtoll CR1 MME LL_USART_DisableMuteMode
  707. * @param USARTx USART Instance
  708. * @retval None
  709. */
  710. __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
  711. {
  712. CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
  713. }
  714. /**
  715. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  716. * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode
  717. * @param USARTx USART Instance
  718. * @retval State of bit (1 or 0).
  719. */
  720. __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
  721. {
  722. return (READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME));
  723. }
  724. /**
  725. * @brief Set Oversampling to 8-bit or 16-bit mode
  726. * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
  727. * @param USARTx USART Instance
  728. * @param OverSampling This parameter can be one of the following values:
  729. * @arg @ref LL_USART_OVERSAMPLING_16
  730. * @arg @ref LL_USART_OVERSAMPLING_8
  731. * @retval None
  732. */
  733. __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
  734. {
  735. MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
  736. }
  737. /**
  738. * @brief Return Oversampling mode
  739. * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
  740. * @param USARTx USART Instance
  741. * @retval Returned value can be one of the following values:
  742. * @arg @ref LL_USART_OVERSAMPLING_16
  743. * @arg @ref LL_USART_OVERSAMPLING_8
  744. */
  745. __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
  746. {
  747. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
  748. }
  749. /**
  750. * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
  751. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  752. * Synchronous mode is supported by the USARTx instance.
  753. * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
  754. * @param USARTx USART Instance
  755. * @param LastBitClockPulse This parameter can be one of the following values:
  756. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  757. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  758. * @retval None
  759. */
  760. __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
  761. {
  762. MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
  763. }
  764. /**
  765. * @brief Retrieve Clock pulse of the last data bit output configuration
  766. * (Last bit Clock pulse output to the SCLK pin or not)
  767. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  768. * Synchronous mode is supported by the USARTx instance.
  769. * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
  770. * @param USARTx USART Instance
  771. * @retval Returned value can be one of the following values:
  772. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  773. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  774. */
  775. __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
  776. {
  777. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
  778. }
  779. /**
  780. * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
  781. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  782. * Synchronous mode is supported by the USARTx instance.
  783. * @rmtoll CR2 CPHA LL_USART_SetClockPhase
  784. * @param USARTx USART Instance
  785. * @param ClockPhase This parameter can be one of the following values:
  786. * @arg @ref LL_USART_PHASE_1EDGE
  787. * @arg @ref LL_USART_PHASE_2EDGE
  788. * @retval None
  789. */
  790. __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
  791. {
  792. MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
  793. }
  794. /**
  795. * @brief Return phase of the clock output on the SCLK pin in synchronous mode
  796. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  797. * Synchronous mode is supported by the USARTx instance.
  798. * @rmtoll CR2 CPHA LL_USART_GetClockPhase
  799. * @param USARTx USART Instance
  800. * @retval Returned value can be one of the following values:
  801. * @arg @ref LL_USART_PHASE_1EDGE
  802. * @arg @ref LL_USART_PHASE_2EDGE
  803. */
  804. __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
  805. {
  806. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
  807. }
  808. /**
  809. * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
  810. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  811. * Synchronous mode is supported by the USARTx instance.
  812. * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
  813. * @param USARTx USART Instance
  814. * @param ClockPolarity This parameter can be one of the following values:
  815. * @arg @ref LL_USART_POLARITY_LOW
  816. * @arg @ref LL_USART_POLARITY_HIGH
  817. * @retval None
  818. */
  819. __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
  820. {
  821. MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
  822. }
  823. /**
  824. * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
  825. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  826. * Synchronous mode is supported by the USARTx instance.
  827. * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
  828. * @param USARTx USART Instance
  829. * @retval Returned value can be one of the following values:
  830. * @arg @ref LL_USART_POLARITY_LOW
  831. * @arg @ref LL_USART_POLARITY_HIGH
  832. */
  833. __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
  834. {
  835. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
  836. }
  837. /**
  838. * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
  839. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  840. * Synchronous mode is supported by the USARTx instance.
  841. * @note Call of this function is equivalent to following function call sequence :
  842. * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
  843. * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
  844. * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
  845. * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
  846. * CR2 CPOL LL_USART_ConfigClock\n
  847. * CR2 LBCL LL_USART_ConfigClock
  848. * @param USARTx USART Instance
  849. * @param Phase This parameter can be one of the following values:
  850. * @arg @ref LL_USART_PHASE_1EDGE
  851. * @arg @ref LL_USART_PHASE_2EDGE
  852. * @param Polarity This parameter can be one of the following values:
  853. * @arg @ref LL_USART_POLARITY_LOW
  854. * @arg @ref LL_USART_POLARITY_HIGH
  855. * @param LBCPOutput This parameter can be one of the following values:
  856. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  857. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  858. * @retval None
  859. */
  860. __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
  861. {
  862. MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
  863. }
  864. /**
  865. * @brief Enable Clock output on SCLK pin
  866. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  867. * Synchronous mode is supported by the USARTx instance.
  868. * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
  869. * @param USARTx USART Instance
  870. * @retval None
  871. */
  872. __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
  873. {
  874. SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
  875. }
  876. /**
  877. * @brief Disable Clock output on SCLK pin
  878. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  879. * Synchronous mode is supported by the USARTx instance.
  880. * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
  881. * @param USARTx USART Instance
  882. * @retval None
  883. */
  884. __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
  885. {
  886. CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
  887. }
  888. /**
  889. * @brief Indicate if Clock output on SCLK pin is enabled
  890. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  891. * Synchronous mode is supported by the USARTx instance.
  892. * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
  893. * @param USARTx USART Instance
  894. * @retval State of bit (1 or 0).
  895. */
  896. __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
  897. {
  898. return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
  899. }
  900. /**
  901. * @brief Set the length of the stop bits
  902. * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
  903. * @param USARTx USART Instance
  904. * @param StopBits This parameter can be one of the following values:
  905. * @arg @ref LL_USART_STOPBITS_0_5
  906. * @arg @ref LL_USART_STOPBITS_1
  907. * @arg @ref LL_USART_STOPBITS_1_5
  908. * @arg @ref LL_USART_STOPBITS_2
  909. * @retval None
  910. */
  911. __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
  912. {
  913. MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
  914. }
  915. /**
  916. * @brief Retrieve the length of the stop bits
  917. * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
  918. * @param USARTx USART Instance
  919. * @retval Returned value can be one of the following values:
  920. * @arg @ref LL_USART_STOPBITS_0_5
  921. * @arg @ref LL_USART_STOPBITS_1
  922. * @arg @ref LL_USART_STOPBITS_1_5
  923. * @arg @ref LL_USART_STOPBITS_2
  924. */
  925. __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
  926. {
  927. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
  928. }
  929. /**
  930. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  931. * @note Call of this function is equivalent to following function call sequence :
  932. * - Data Width configuration using @ref LL_USART_SetDataWidth() function
  933. * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
  934. * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
  935. * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
  936. * CR1 PCE LL_USART_ConfigCharacter\n
  937. * CR1 M0 LL_USART_ConfigCharacter\n
  938. * CR1 M1 LL_USART_ConfigCharacter\n
  939. * CR2 STOP LL_USART_ConfigCharacter
  940. * @param USARTx USART Instance
  941. * @param DataWidth This parameter can be one of the following values:
  942. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  943. * @arg @ref LL_USART_DATAWIDTH_8B
  944. * @arg @ref LL_USART_DATAWIDTH_9B
  945. * @param Parity This parameter can be one of the following values:
  946. * @arg @ref LL_USART_PARITY_NONE
  947. * @arg @ref LL_USART_PARITY_EVEN
  948. * @arg @ref LL_USART_PARITY_ODD
  949. * @param StopBits This parameter can be one of the following values:
  950. * @arg @ref LL_USART_STOPBITS_0_5
  951. * @arg @ref LL_USART_STOPBITS_1
  952. * @arg @ref LL_USART_STOPBITS_1_5
  953. * @arg @ref LL_USART_STOPBITS_2
  954. *
  955. * (*) Values not available on all devices
  956. * @retval None
  957. */
  958. __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
  959. uint32_t StopBits)
  960. {
  961. MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  962. MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
  963. }
  964. /**
  965. * @brief Configure TX/RX pins swapping setting.
  966. * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap
  967. * @param USARTx USART Instance
  968. * @param SwapConfig This parameter can be one of the following values:
  969. * @arg @ref LL_USART_TXRX_STANDARD
  970. * @arg @ref LL_USART_TXRX_SWAPPED
  971. * @retval None
  972. */
  973. __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
  974. {
  975. MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
  976. }
  977. /**
  978. * @brief Retrieve TX/RX pins swapping configuration.
  979. * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap
  980. * @param USARTx USART Instance
  981. * @retval Returned value can be one of the following values:
  982. * @arg @ref LL_USART_TXRX_STANDARD
  983. * @arg @ref LL_USART_TXRX_SWAPPED
  984. */
  985. __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
  986. {
  987. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
  988. }
  989. /**
  990. * @brief Configure RX pin active level logic
  991. * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel
  992. * @param USARTx USART Instance
  993. * @param PinInvMethod This parameter can be one of the following values:
  994. * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
  995. * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
  996. * @retval None
  997. */
  998. __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
  999. {
  1000. MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  1001. }
  1002. /**
  1003. * @brief Retrieve RX pin active level logic configuration
  1004. * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel
  1005. * @param USARTx USART Instance
  1006. * @retval Returned value can be one of the following values:
  1007. * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
  1008. * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
  1009. */
  1010. __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
  1011. {
  1012. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
  1013. }
  1014. /**
  1015. * @brief Configure TX pin active level logic
  1016. * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel
  1017. * @param USARTx USART Instance
  1018. * @param PinInvMethod This parameter can be one of the following values:
  1019. * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
  1020. * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
  1021. * @retval None
  1022. */
  1023. __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
  1024. {
  1025. MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  1026. }
  1027. /**
  1028. * @brief Retrieve TX pin active level logic configuration
  1029. * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel
  1030. * @param USARTx USART Instance
  1031. * @retval Returned value can be one of the following values:
  1032. * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
  1033. * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
  1034. */
  1035. __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
  1036. {
  1037. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
  1038. }
  1039. /**
  1040. * @brief Configure Binary data logic.
  1041. * @note Allow to define how Logical data from the data register are send/received :
  1042. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  1043. * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic
  1044. * @param USARTx USART Instance
  1045. * @param DataLogic This parameter can be one of the following values:
  1046. * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
  1047. * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
  1048. * @retval None
  1049. */
  1050. __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
  1051. {
  1052. MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
  1053. }
  1054. /**
  1055. * @brief Retrieve Binary data configuration
  1056. * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic
  1057. * @param USARTx USART Instance
  1058. * @retval Returned value can be one of the following values:
  1059. * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
  1060. * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
  1061. */
  1062. __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
  1063. {
  1064. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
  1065. }
  1066. /**
  1067. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  1068. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1069. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1070. * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder
  1071. * @param USARTx USART Instance
  1072. * @param BitOrder This parameter can be one of the following values:
  1073. * @arg @ref LL_USART_BITORDER_LSBFIRST
  1074. * @arg @ref LL_USART_BITORDER_MSBFIRST
  1075. * @retval None
  1076. */
  1077. __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
  1078. {
  1079. MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  1080. }
  1081. /**
  1082. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  1083. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1084. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1085. * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder
  1086. * @param USARTx USART Instance
  1087. * @retval Returned value can be one of the following values:
  1088. * @arg @ref LL_USART_BITORDER_LSBFIRST
  1089. * @arg @ref LL_USART_BITORDER_MSBFIRST
  1090. */
  1091. __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
  1092. {
  1093. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
  1094. }
  1095. /**
  1096. * @brief Enable Auto Baud-Rate Detection
  1097. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1098. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1099. * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate
  1100. * @param USARTx USART Instance
  1101. * @retval None
  1102. */
  1103. __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
  1104. {
  1105. SET_BIT(USARTx->CR2, USART_CR2_ABREN);
  1106. }
  1107. /**
  1108. * @brief Disable Auto Baud-Rate Detection
  1109. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1110. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1111. * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate
  1112. * @param USARTx USART Instance
  1113. * @retval None
  1114. */
  1115. __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
  1116. {
  1117. CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
  1118. }
  1119. /**
  1120. * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled
  1121. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1122. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1123. * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud
  1124. * @param USARTx USART Instance
  1125. * @retval State of bit (1 or 0).
  1126. */
  1127. __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
  1128. {
  1129. return (READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN));
  1130. }
  1131. /**
  1132. * @brief Set Auto Baud-Rate mode bits
  1133. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1134. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1135. * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode
  1136. * @param USARTx USART Instance
  1137. * @param AutoBaudRateMode This parameter can be one of the following values:
  1138. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
  1139. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
  1140. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
  1141. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
  1142. * @retval None
  1143. */
  1144. __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
  1145. {
  1146. MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
  1147. }
  1148. /**
  1149. * @brief Return Auto Baud-Rate mode
  1150. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1151. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1152. * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode
  1153. * @param USARTx USART Instance
  1154. * @retval Returned value can be one of the following values:
  1155. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
  1156. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
  1157. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
  1158. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
  1159. */
  1160. __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
  1161. {
  1162. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
  1163. }
  1164. /**
  1165. * @brief Enable Receiver Timeout
  1166. * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout
  1167. * @param USARTx USART Instance
  1168. * @retval None
  1169. */
  1170. __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
  1171. {
  1172. SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
  1173. }
  1174. /**
  1175. * @brief Disable Receiver Timeout
  1176. * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout
  1177. * @param USARTx USART Instance
  1178. * @retval None
  1179. */
  1180. __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
  1181. {
  1182. CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
  1183. }
  1184. /**
  1185. * @brief Indicate if Receiver Timeout feature is enabled
  1186. * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout
  1187. * @param USARTx USART Instance
  1188. * @retval State of bit (1 or 0).
  1189. */
  1190. __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
  1191. {
  1192. return (READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN));
  1193. }
  1194. /**
  1195. * @brief Set Address of the USART node.
  1196. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  1197. * for wake up with address mark detection.
  1198. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  1199. * (b7-b4 should be set to 0)
  1200. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  1201. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  1202. * for wake up with 7-bit address mark detection.
  1203. * The MSB of the character sent by the transmitter should be equal to 1.
  1204. * It may also be used for character detection during normal reception,
  1205. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  1206. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  1207. * value and CMF flag is set on match)
  1208. * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n
  1209. * CR2 ADDM7 LL_USART_ConfigNodeAddress
  1210. * @param USARTx USART Instance
  1211. * @param AddressLen This parameter can be one of the following values:
  1212. * @arg @ref LL_USART_ADDRESS_DETECT_4B
  1213. * @arg @ref LL_USART_ADDRESS_DETECT_7B
  1214. * @param NodeAddress 4 or 7 bit Address of the USART node.
  1215. * @retval None
  1216. */
  1217. __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
  1218. {
  1219. MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  1220. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  1221. }
  1222. /**
  1223. * @brief Return 8 bit Address of the USART node as set in ADD field of CR2.
  1224. * @note If 4-bit Address Detection is selected in ADDM7,
  1225. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  1226. * If 7-bit Address Detection is selected in ADDM7,
  1227. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  1228. * @rmtoll CR2 ADD LL_USART_GetNodeAddress
  1229. * @param USARTx USART Instance
  1230. * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
  1231. */
  1232. __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
  1233. {
  1234. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  1235. }
  1236. /**
  1237. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  1238. * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen
  1239. * @param USARTx USART Instance
  1240. * @retval Returned value can be one of the following values:
  1241. * @arg @ref LL_USART_ADDRESS_DETECT_4B
  1242. * @arg @ref LL_USART_ADDRESS_DETECT_7B
  1243. */
  1244. __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
  1245. {
  1246. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
  1247. }
  1248. /**
  1249. * @brief Enable RTS HW Flow Control
  1250. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1251. * Hardware Flow control feature is supported by the USARTx instance.
  1252. * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
  1253. * @param USARTx USART Instance
  1254. * @retval None
  1255. */
  1256. __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
  1257. {
  1258. SET_BIT(USARTx->CR3, USART_CR3_RTSE);
  1259. }
  1260. /**
  1261. * @brief Disable RTS HW Flow Control
  1262. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1263. * Hardware Flow control feature is supported by the USARTx instance.
  1264. * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
  1265. * @param USARTx USART Instance
  1266. * @retval None
  1267. */
  1268. __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
  1269. {
  1270. CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
  1271. }
  1272. /**
  1273. * @brief Enable CTS HW Flow Control
  1274. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1275. * Hardware Flow control feature is supported by the USARTx instance.
  1276. * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
  1277. * @param USARTx USART Instance
  1278. * @retval None
  1279. */
  1280. __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
  1281. {
  1282. SET_BIT(USARTx->CR3, USART_CR3_CTSE);
  1283. }
  1284. /**
  1285. * @brief Disable CTS HW Flow Control
  1286. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1287. * Hardware Flow control feature is supported by the USARTx instance.
  1288. * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
  1289. * @param USARTx USART Instance
  1290. * @retval None
  1291. */
  1292. __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
  1293. {
  1294. CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
  1295. }
  1296. /**
  1297. * @brief Configure HW Flow Control mode (both CTS and RTS)
  1298. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1299. * Hardware Flow control feature is supported by the USARTx instance.
  1300. * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
  1301. * CR3 CTSE LL_USART_SetHWFlowCtrl
  1302. * @param USARTx USART Instance
  1303. * @param HardwareFlowControl This parameter can be one of the following values:
  1304. * @arg @ref LL_USART_HWCONTROL_NONE
  1305. * @arg @ref LL_USART_HWCONTROL_RTS
  1306. * @arg @ref LL_USART_HWCONTROL_CTS
  1307. * @arg @ref LL_USART_HWCONTROL_RTS_CTS
  1308. * @retval None
  1309. */
  1310. __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
  1311. {
  1312. MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  1313. }
  1314. /**
  1315. * @brief Return HW Flow Control configuration (both CTS and RTS)
  1316. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1317. * Hardware Flow control feature is supported by the USARTx instance.
  1318. * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
  1319. * CR3 CTSE LL_USART_GetHWFlowCtrl
  1320. * @param USARTx USART Instance
  1321. * @retval Returned value can be one of the following values:
  1322. * @arg @ref LL_USART_HWCONTROL_NONE
  1323. * @arg @ref LL_USART_HWCONTROL_RTS
  1324. * @arg @ref LL_USART_HWCONTROL_CTS
  1325. * @arg @ref LL_USART_HWCONTROL_RTS_CTS
  1326. */
  1327. __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
  1328. {
  1329. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  1330. }
  1331. /**
  1332. * @brief Enable One bit sampling method
  1333. * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
  1334. * @param USARTx USART Instance
  1335. * @retval None
  1336. */
  1337. __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
  1338. {
  1339. SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
  1340. }
  1341. /**
  1342. * @brief Disable One bit sampling method
  1343. * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
  1344. * @param USARTx USART Instance
  1345. * @retval None
  1346. */
  1347. __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
  1348. {
  1349. CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
  1350. }
  1351. /**
  1352. * @brief Indicate if One bit sampling method is enabled
  1353. * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
  1354. * @param USARTx USART Instance
  1355. * @retval State of bit (1 or 0).
  1356. */
  1357. __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
  1358. {
  1359. return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
  1360. }
  1361. /**
  1362. * @brief Enable Overrun detection
  1363. * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect
  1364. * @param USARTx USART Instance
  1365. * @retval None
  1366. */
  1367. __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
  1368. {
  1369. CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
  1370. }
  1371. /**
  1372. * @brief Disable Overrun detection
  1373. * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect
  1374. * @param USARTx USART Instance
  1375. * @retval None
  1376. */
  1377. __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
  1378. {
  1379. SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
  1380. }
  1381. /**
  1382. * @brief Indicate if Overrun detection is enabled
  1383. * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect
  1384. * @param USARTx USART Instance
  1385. * @retval State of bit (1 or 0).
  1386. */
  1387. __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
  1388. {
  1389. return (READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS);
  1390. }
  1391. /**
  1392. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1393. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  1394. * Wake-up from Stop mode feature is supported by the USARTx instance.
  1395. * @rmtoll CR3 WUS LL_USART_SetWKUPType
  1396. * @param USARTx USART Instance
  1397. * @param Type This parameter can be one of the following values:
  1398. * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
  1399. * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
  1400. * @arg @ref LL_USART_WAKEUP_ON_RXNE
  1401. * @retval None
  1402. */
  1403. __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
  1404. {
  1405. MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
  1406. }
  1407. /**
  1408. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1409. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  1410. * Wake-up from Stop mode feature is supported by the USARTx instance.
  1411. * @rmtoll CR3 WUS LL_USART_GetWKUPType
  1412. * @param USARTx USART Instance
  1413. * @retval Returned value can be one of the following values:
  1414. * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
  1415. * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
  1416. * @arg @ref LL_USART_WAKEUP_ON_RXNE
  1417. */
  1418. __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
  1419. {
  1420. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
  1421. }
  1422. /**
  1423. * @brief Configure USART BRR register for achieving expected Baud Rate value.
  1424. * @note Compute and set USARTDIV value in BRR Register (full BRR content)
  1425. * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
  1426. * @note Peripheral clock and Baud rate values provided as function parameters should be valid
  1427. * (Baud rate value != 0)
  1428. * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
  1429. * @rmtoll BRR BRR LL_USART_SetBaudRate
  1430. * @param USARTx USART Instance
  1431. * @param PeriphClk Peripheral Clock
  1432. * @param OverSampling This parameter can be one of the following values:
  1433. * @arg @ref LL_USART_OVERSAMPLING_16
  1434. * @arg @ref LL_USART_OVERSAMPLING_8
  1435. * @param BaudRate Baud Rate
  1436. * @retval None
  1437. */
  1438. __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
  1439. uint32_t BaudRate)
  1440. {
  1441. register uint32_t usartdiv = 0x0U;
  1442. register uint32_t brrtemp = 0x0U;
  1443. if (OverSampling == LL_USART_OVERSAMPLING_8)
  1444. {
  1445. usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
  1446. brrtemp = usartdiv & 0xFFF0U;
  1447. brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
  1448. USARTx->BRR = brrtemp;
  1449. }
  1450. else
  1451. {
  1452. USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
  1453. }
  1454. }
  1455. /**
  1456. * @brief Return current Baud Rate value, according to USARTDIV present in BRR register
  1457. * (full BRR content), and to used Peripheral Clock and Oversampling mode values
  1458. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  1459. * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
  1460. * @rmtoll BRR BRR LL_USART_GetBaudRate
  1461. * @param USARTx USART Instance
  1462. * @param PeriphClk Peripheral Clock
  1463. * @param OverSampling This parameter can be one of the following values:
  1464. * @arg @ref LL_USART_OVERSAMPLING_16
  1465. * @arg @ref LL_USART_OVERSAMPLING_8
  1466. * @retval Baud Rate
  1467. */
  1468. __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
  1469. {
  1470. register uint32_t usartdiv = 0x0U;
  1471. register uint32_t brrresult = 0x0U;
  1472. usartdiv = USARTx->BRR;
  1473. if (OverSampling == LL_USART_OVERSAMPLING_8)
  1474. {
  1475. if ((usartdiv & 0xFFF7U) != 0U)
  1476. {
  1477. usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
  1478. brrresult = (PeriphClk * 2U) / usartdiv;
  1479. }
  1480. }
  1481. else
  1482. {
  1483. if ((usartdiv & 0xFFFFU) != 0U)
  1484. {
  1485. brrresult = PeriphClk / usartdiv;
  1486. }
  1487. }
  1488. return (brrresult);
  1489. }
  1490. /**
  1491. * @brief Set Receiver Time Out Value (expressed in nb of bits duration)
  1492. * @rmtoll RTOR RTO LL_USART_SetRxTimeout
  1493. * @param USARTx USART Instance
  1494. * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
  1495. * @retval None
  1496. */
  1497. __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
  1498. {
  1499. MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
  1500. }
  1501. /**
  1502. * @brief Get Receiver Time Out Value (expressed in nb of bits duration)
  1503. * @rmtoll RTOR RTO LL_USART_GetRxTimeout
  1504. * @param USARTx USART Instance
  1505. * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
  1506. */
  1507. __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
  1508. {
  1509. return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
  1510. }
  1511. /**
  1512. * @brief Set Block Length value in reception
  1513. * @rmtoll RTOR BLEN LL_USART_SetBlockLength
  1514. * @param USARTx USART Instance
  1515. * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF
  1516. * @retval None
  1517. */
  1518. __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
  1519. {
  1520. MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos);
  1521. }
  1522. /**
  1523. * @brief Get Block Length value in reception
  1524. * @rmtoll RTOR BLEN LL_USART_GetBlockLength
  1525. * @param USARTx USART Instance
  1526. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1527. */
  1528. __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
  1529. {
  1530. return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos);
  1531. }
  1532. /**
  1533. * @}
  1534. */
  1535. /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
  1536. * @{
  1537. */
  1538. /**
  1539. * @brief Enable IrDA mode
  1540. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1541. * IrDA feature is supported by the USARTx instance.
  1542. * @rmtoll CR3 IREN LL_USART_EnableIrda
  1543. * @param USARTx USART Instance
  1544. * @retval None
  1545. */
  1546. __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
  1547. {
  1548. SET_BIT(USARTx->CR3, USART_CR3_IREN);
  1549. }
  1550. /**
  1551. * @brief Disable IrDA mode
  1552. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1553. * IrDA feature is supported by the USARTx instance.
  1554. * @rmtoll CR3 IREN LL_USART_DisableIrda
  1555. * @param USARTx USART Instance
  1556. * @retval None
  1557. */
  1558. __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
  1559. {
  1560. CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
  1561. }
  1562. /**
  1563. * @brief Indicate if IrDA mode is enabled
  1564. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1565. * IrDA feature is supported by the USARTx instance.
  1566. * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
  1567. * @param USARTx USART Instance
  1568. * @retval State of bit (1 or 0).
  1569. */
  1570. __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
  1571. {
  1572. return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
  1573. }
  1574. /**
  1575. * @brief Configure IrDA Power Mode (Normal or Low Power)
  1576. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1577. * IrDA feature is supported by the USARTx instance.
  1578. * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
  1579. * @param USARTx USART Instance
  1580. * @param PowerMode This parameter can be one of the following values:
  1581. * @arg @ref LL_USART_IRDA_POWER_NORMAL
  1582. * @arg @ref LL_USART_IRDA_POWER_LOW
  1583. * @retval None
  1584. */
  1585. __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
  1586. {
  1587. MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
  1588. }
  1589. /**
  1590. * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
  1591. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1592. * IrDA feature is supported by the USARTx instance.
  1593. * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
  1594. * @param USARTx USART Instance
  1595. * @retval Returned value can be one of the following values:
  1596. * @arg @ref LL_USART_IRDA_POWER_NORMAL
  1597. * @arg @ref LL_USART_PHASE_2EDGE
  1598. */
  1599. __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
  1600. {
  1601. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
  1602. }
  1603. /**
  1604. * @brief Set Irda prescaler value, used for dividing the USART clock source
  1605. * to achieve the Irda Low Power frequency (8 bits value)
  1606. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1607. * IrDA feature is supported by the USARTx instance.
  1608. * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
  1609. * @param USARTx USART Instance
  1610. * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
  1611. * @retval None
  1612. */
  1613. __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
  1614. {
  1615. MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
  1616. }
  1617. /**
  1618. * @brief Return Irda prescaler value, used for dividing the USART clock source
  1619. * to achieve the Irda Low Power frequency (8 bits value)
  1620. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1621. * IrDA feature is supported by the USARTx instance.
  1622. * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
  1623. * @param USARTx USART Instance
  1624. * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
  1625. */
  1626. __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
  1627. {
  1628. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
  1629. }
  1630. /**
  1631. * @}
  1632. */
  1633. /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
  1634. * @{
  1635. */
  1636. /**
  1637. * @brief Enable Smartcard NACK transmission
  1638. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1639. * Smartcard feature is supported by the USARTx instance.
  1640. * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
  1641. * @param USARTx USART Instance
  1642. * @retval None
  1643. */
  1644. __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
  1645. {
  1646. SET_BIT(USARTx->CR3, USART_CR3_NACK);
  1647. }
  1648. /**
  1649. * @brief Disable Smartcard NACK transmission
  1650. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1651. * Smartcard feature is supported by the USARTx instance.
  1652. * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
  1653. * @param USARTx USART Instance
  1654. * @retval None
  1655. */
  1656. __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
  1657. {
  1658. CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
  1659. }
  1660. /**
  1661. * @brief Indicate if Smartcard NACK transmission is enabled
  1662. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1663. * Smartcard feature is supported by the USARTx instance.
  1664. * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
  1665. * @param USARTx USART Instance
  1666. * @retval State of bit (1 or 0).
  1667. */
  1668. __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
  1669. {
  1670. return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
  1671. }
  1672. /**
  1673. * @brief Enable Smartcard mode
  1674. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1675. * Smartcard feature is supported by the USARTx instance.
  1676. * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
  1677. * @param USARTx USART Instance
  1678. * @retval None
  1679. */
  1680. __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
  1681. {
  1682. SET_BIT(USARTx->CR3, USART_CR3_SCEN);
  1683. }
  1684. /**
  1685. * @brief Disable Smartcard mode
  1686. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1687. * Smartcard feature is supported by the USARTx instance.
  1688. * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
  1689. * @param USARTx USART Instance
  1690. * @retval None
  1691. */
  1692. __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
  1693. {
  1694. CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
  1695. }
  1696. /**
  1697. * @brief Indicate if Smartcard mode is enabled
  1698. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1699. * Smartcard feature is supported by the USARTx instance.
  1700. * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
  1701. * @param USARTx USART Instance
  1702. * @retval State of bit (1 or 0).
  1703. */
  1704. __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
  1705. {
  1706. return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
  1707. }
  1708. /**
  1709. * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
  1710. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1711. * Smartcard feature is supported by the USARTx instance.
  1712. * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
  1713. * In transmission mode, it specifies the number of automatic retransmission retries, before
  1714. * generating a transmission error (FE bit set).
  1715. * In reception mode, it specifies the number or erroneous reception trials, before generating a
  1716. * reception error (RXNE and PE bits set)
  1717. * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount
  1718. * @param USARTx USART Instance
  1719. * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7
  1720. * @retval None
  1721. */
  1722. __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
  1723. {
  1724. MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos);
  1725. }
  1726. /**
  1727. * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
  1728. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1729. * Smartcard feature is supported by the USARTx instance.
  1730. * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount
  1731. * @param USARTx USART Instance
  1732. * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7)
  1733. */
  1734. __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
  1735. {
  1736. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos);
  1737. }
  1738. /**
  1739. * @brief Set Smartcard prescaler value, used for dividing the USART clock
  1740. * source to provide the SMARTCARD Clock (5 bits value)
  1741. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1742. * Smartcard feature is supported by the USARTx instance.
  1743. * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
  1744. * @param USARTx USART Instance
  1745. * @param PrescalerValue Value between Min_Data=0 and Max_Data=31
  1746. * @retval None
  1747. */
  1748. __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
  1749. {
  1750. MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
  1751. }
  1752. /**
  1753. * @brief Return Smartcard prescaler value, used for dividing the USART clock
  1754. * source to provide the SMARTCARD Clock (5 bits value)
  1755. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1756. * Smartcard feature is supported by the USARTx instance.
  1757. * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
  1758. * @param USARTx USART Instance
  1759. * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
  1760. */
  1761. __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
  1762. {
  1763. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
  1764. }
  1765. /**
  1766. * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
  1767. * (GT[7:0] bits : Guard time value)
  1768. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1769. * Smartcard feature is supported by the USARTx instance.
  1770. * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
  1771. * @param USARTx USART Instance
  1772. * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
  1773. * @retval None
  1774. */
  1775. __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
  1776. {
  1777. MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_GTPR_GT_Pos);
  1778. }
  1779. /**
  1780. * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
  1781. * (GT[7:0] bits : Guard time value)
  1782. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1783. * Smartcard feature is supported by the USARTx instance.
  1784. * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
  1785. * @param USARTx USART Instance
  1786. * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
  1787. */
  1788. __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
  1789. {
  1790. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos);
  1791. }
  1792. /**
  1793. * @}
  1794. */
  1795. /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1796. * @{
  1797. */
  1798. /**
  1799. * @brief Enable Single Wire Half-Duplex mode
  1800. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1801. * Half-Duplex mode is supported by the USARTx instance.
  1802. * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
  1803. * @param USARTx USART Instance
  1804. * @retval None
  1805. */
  1806. __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
  1807. {
  1808. SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
  1809. }
  1810. /**
  1811. * @brief Disable Single Wire Half-Duplex mode
  1812. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1813. * Half-Duplex mode is supported by the USARTx instance.
  1814. * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
  1815. * @param USARTx USART Instance
  1816. * @retval None
  1817. */
  1818. __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
  1819. {
  1820. CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
  1821. }
  1822. /**
  1823. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1824. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1825. * Half-Duplex mode is supported by the USARTx instance.
  1826. * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
  1827. * @param USARTx USART Instance
  1828. * @retval State of bit (1 or 0).
  1829. */
  1830. __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
  1831. {
  1832. return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
  1833. }
  1834. /**
  1835. * @}
  1836. */
  1837. /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
  1838. * @{
  1839. */
  1840. /**
  1841. * @brief Set LIN Break Detection Length
  1842. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1843. * LIN feature is supported by the USARTx instance.
  1844. * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
  1845. * @param USARTx USART Instance
  1846. * @param LINBDLength This parameter can be one of the following values:
  1847. * @arg @ref LL_USART_LINBREAK_DETECT_10B
  1848. * @arg @ref LL_USART_LINBREAK_DETECT_11B
  1849. * @retval None
  1850. */
  1851. __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
  1852. {
  1853. MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
  1854. }
  1855. /**
  1856. * @brief Return LIN Break Detection Length
  1857. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1858. * LIN feature is supported by the USARTx instance.
  1859. * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
  1860. * @param USARTx USART Instance
  1861. * @retval Returned value can be one of the following values:
  1862. * @arg @ref LL_USART_LINBREAK_DETECT_10B
  1863. * @arg @ref LL_USART_LINBREAK_DETECT_11B
  1864. */
  1865. __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
  1866. {
  1867. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
  1868. }
  1869. /**
  1870. * @brief Enable LIN mode
  1871. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1872. * LIN feature is supported by the USARTx instance.
  1873. * @rmtoll CR2 LINEN LL_USART_EnableLIN
  1874. * @param USARTx USART Instance
  1875. * @retval None
  1876. */
  1877. __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
  1878. {
  1879. SET_BIT(USARTx->CR2, USART_CR2_LINEN);
  1880. }
  1881. /**
  1882. * @brief Disable LIN mode
  1883. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1884. * LIN feature is supported by the USARTx instance.
  1885. * @rmtoll CR2 LINEN LL_USART_DisableLIN
  1886. * @param USARTx USART Instance
  1887. * @retval None
  1888. */
  1889. __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
  1890. {
  1891. CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
  1892. }
  1893. /**
  1894. * @brief Indicate if LIN mode is enabled
  1895. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1896. * LIN feature is supported by the USARTx instance.
  1897. * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
  1898. * @param USARTx USART Instance
  1899. * @retval State of bit (1 or 0).
  1900. */
  1901. __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
  1902. {
  1903. return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
  1904. }
  1905. /**
  1906. * @}
  1907. */
  1908. /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1909. * @{
  1910. */
  1911. /**
  1912. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1913. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1914. * Driver Enable feature is supported by the USARTx instance.
  1915. * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime
  1916. * @param USARTx USART Instance
  1917. * @param Time Value between Min_Data=0 and Max_Data=31
  1918. * @retval None
  1919. */
  1920. __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
  1921. {
  1922. MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1923. }
  1924. /**
  1925. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1926. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1927. * Driver Enable feature is supported by the USARTx instance.
  1928. * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime
  1929. * @param USARTx USART Instance
  1930. * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
  1931. */
  1932. __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
  1933. {
  1934. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1935. }
  1936. /**
  1937. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1938. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1939. * Driver Enable feature is supported by the USARTx instance.
  1940. * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime
  1941. * @param USARTx USART Instance
  1942. * @param Time Value between Min_Data=0 and Max_Data=31
  1943. * @retval None
  1944. */
  1945. __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
  1946. {
  1947. MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1948. }
  1949. /**
  1950. * @brief Return DEAT (Driver Enable Assertion Time)
  1951. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1952. * Driver Enable feature is supported by the USARTx instance.
  1953. * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime
  1954. * @param USARTx USART Instance
  1955. * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
  1956. */
  1957. __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
  1958. {
  1959. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  1960. }
  1961. /**
  1962. * @brief Enable Driver Enable (DE) Mode
  1963. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1964. * Driver Enable feature is supported by the USARTx instance.
  1965. * @rmtoll CR3 DEM LL_USART_EnableDEMode
  1966. * @param USARTx USART Instance
  1967. * @retval None
  1968. */
  1969. __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
  1970. {
  1971. SET_BIT(USARTx->CR3, USART_CR3_DEM);
  1972. }
  1973. /**
  1974. * @brief Disable Driver Enable (DE) Mode
  1975. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1976. * Driver Enable feature is supported by the USARTx instance.
  1977. * @rmtoll CR3 DEM LL_USART_DisableDEMode
  1978. * @param USARTx USART Instance
  1979. * @retval None
  1980. */
  1981. __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
  1982. {
  1983. CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
  1984. }
  1985. /**
  1986. * @brief Indicate if Driver Enable (DE) Mode is enabled
  1987. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1988. * Driver Enable feature is supported by the USARTx instance.
  1989. * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode
  1990. * @param USARTx USART Instance
  1991. * @retval State of bit (1 or 0).
  1992. */
  1993. __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
  1994. {
  1995. return (READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM));
  1996. }
  1997. /**
  1998. * @brief Select Driver Enable Polarity
  1999. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2000. * Driver Enable feature is supported by the USARTx instance.
  2001. * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity
  2002. * @param USARTx USART Instance
  2003. * @param Polarity This parameter can be one of the following values:
  2004. * @arg @ref LL_USART_DE_POLARITY_HIGH
  2005. * @arg @ref LL_USART_DE_POLARITY_LOW
  2006. * @retval None
  2007. */
  2008. __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
  2009. {
  2010. MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
  2011. }
  2012. /**
  2013. * @brief Return Driver Enable Polarity
  2014. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2015. * Driver Enable feature is supported by the USARTx instance.
  2016. * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity
  2017. * @param USARTx USART Instance
  2018. * @retval Returned value can be one of the following values:
  2019. * @arg @ref LL_USART_DE_POLARITY_HIGH
  2020. * @arg @ref LL_USART_DE_POLARITY_LOW
  2021. */
  2022. __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
  2023. {
  2024. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
  2025. }
  2026. /**
  2027. * @}
  2028. */
  2029. /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
  2030. * @{
  2031. */
  2032. /**
  2033. * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
  2034. * @note In UART mode, the following bits must be kept cleared:
  2035. * - LINEN bit in the USART_CR2 register,
  2036. * - CLKEN bit in the USART_CR2 register,
  2037. * - SCEN bit in the USART_CR3 register,
  2038. * - IREN bit in the USART_CR3 register,
  2039. * - HDSEL bit in the USART_CR3 register.
  2040. * @note Call of this function is equivalent to following function call sequence :
  2041. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2042. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2043. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2044. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2045. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2046. * @note Other remaining configurations items related to Asynchronous Mode
  2047. * (as Baud Rate, Word length, Parity, ...) should be set using
  2048. * dedicated functions
  2049. * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
  2050. * CR2 CLKEN LL_USART_ConfigAsyncMode\n
  2051. * CR3 SCEN LL_USART_ConfigAsyncMode\n
  2052. * CR3 IREN LL_USART_ConfigAsyncMode\n
  2053. * CR3 HDSEL LL_USART_ConfigAsyncMode
  2054. * @param USARTx USART Instance
  2055. * @retval None
  2056. */
  2057. __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
  2058. {
  2059. /* In Asynchronous mode, the following bits must be kept cleared:
  2060. - LINEN, CLKEN bits in the USART_CR2 register,
  2061. - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
  2062. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2063. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
  2064. }
  2065. /**
  2066. * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
  2067. * @note In Synchronous mode, the following bits must be kept cleared:
  2068. * - LINEN bit in the USART_CR2 register,
  2069. * - SCEN bit in the USART_CR3 register,
  2070. * - IREN bit in the USART_CR3 register,
  2071. * - HDSEL bit in the USART_CR3 register.
  2072. * This function also sets the USART in Synchronous mode.
  2073. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  2074. * Synchronous mode is supported by the USARTx instance.
  2075. * @note Call of this function is equivalent to following function call sequence :
  2076. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2077. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2078. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2079. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2080. * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
  2081. * @note Other remaining configurations items related to Synchronous Mode
  2082. * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
  2083. * dedicated functions
  2084. * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
  2085. * CR2 CLKEN LL_USART_ConfigSyncMode\n
  2086. * CR3 SCEN LL_USART_ConfigSyncMode\n
  2087. * CR3 IREN LL_USART_ConfigSyncMode\n
  2088. * CR3 HDSEL LL_USART_ConfigSyncMode
  2089. * @param USARTx USART Instance
  2090. * @retval None
  2091. */
  2092. __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
  2093. {
  2094. /* In Synchronous mode, the following bits must be kept cleared:
  2095. - LINEN bit in the USART_CR2 register,
  2096. - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
  2097. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
  2098. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
  2099. /* set the UART/USART in Synchronous mode */
  2100. SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
  2101. }
  2102. /**
  2103. * @brief Perform basic configuration of USART for enabling use in LIN Mode
  2104. * @note In LIN mode, the following bits must be kept cleared:
  2105. * - STOP and CLKEN bits in the USART_CR2 register,
  2106. * - SCEN bit in the USART_CR3 register,
  2107. * - IREN bit in the USART_CR3 register,
  2108. * - HDSEL bit in the USART_CR3 register.
  2109. * This function also set the UART/USART in LIN mode.
  2110. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2111. * LIN feature is supported by the USARTx instance.
  2112. * @note Call of this function is equivalent to following function call sequence :
  2113. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2114. * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2115. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2116. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2117. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2118. * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
  2119. * @note Other remaining configurations items related to LIN Mode
  2120. * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
  2121. * dedicated functions
  2122. * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
  2123. * CR2 STOP LL_USART_ConfigLINMode\n
  2124. * CR2 LINEN LL_USART_ConfigLINMode\n
  2125. * CR3 IREN LL_USART_ConfigLINMode\n
  2126. * CR3 SCEN LL_USART_ConfigLINMode\n
  2127. * CR3 HDSEL LL_USART_ConfigLINMode
  2128. * @param USARTx USART Instance
  2129. * @retval None
  2130. */
  2131. __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
  2132. {
  2133. /* In LIN mode, the following bits must be kept cleared:
  2134. - STOP and CLKEN bits in the USART_CR2 register,
  2135. - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
  2136. CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
  2137. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
  2138. /* Set the UART/USART in LIN mode */
  2139. SET_BIT(USARTx->CR2, USART_CR2_LINEN);
  2140. }
  2141. /**
  2142. * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
  2143. * @note In Half Duplex mode, the following bits must be kept cleared:
  2144. * - LINEN bit in the USART_CR2 register,
  2145. * - CLKEN bit in the USART_CR2 register,
  2146. * - SCEN bit in the USART_CR3 register,
  2147. * - IREN bit in the USART_CR3 register,
  2148. * This function also sets the UART/USART in Half Duplex mode.
  2149. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  2150. * Half-Duplex mode is supported by the USARTx instance.
  2151. * @note Call of this function is equivalent to following function call sequence :
  2152. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2153. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2154. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2155. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2156. * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
  2157. * @note Other remaining configurations items related to Half Duplex Mode
  2158. * (as Baud Rate, Word length, Parity, ...) should be set using
  2159. * dedicated functions
  2160. * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
  2161. * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
  2162. * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
  2163. * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
  2164. * CR3 IREN LL_USART_ConfigHalfDuplexMode
  2165. * @param USARTx USART Instance
  2166. * @retval None
  2167. */
  2168. __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
  2169. {
  2170. /* In Half Duplex mode, the following bits must be kept cleared:
  2171. - LINEN and CLKEN bits in the USART_CR2 register,
  2172. - SCEN and IREN bits in the USART_CR3 register.*/
  2173. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2174. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
  2175. /* set the UART/USART in Half Duplex mode */
  2176. SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
  2177. }
  2178. /**
  2179. * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
  2180. * @note In Smartcard mode, the following bits must be kept cleared:
  2181. * - LINEN bit in the USART_CR2 register,
  2182. * - IREN bit in the USART_CR3 register,
  2183. * - HDSEL bit in the USART_CR3 register.
  2184. * This function also configures Stop bits to 1.5 bits and
  2185. * sets the USART in Smartcard mode (SCEN bit).
  2186. * Clock Output is also enabled (CLKEN).
  2187. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2188. * Smartcard feature is supported by the USARTx instance.
  2189. * @note Call of this function is equivalent to following function call sequence :
  2190. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2191. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2192. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2193. * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2194. * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
  2195. * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
  2196. * @note Other remaining configurations items related to Smartcard Mode
  2197. * (as Baud Rate, Word length, Parity, ...) should be set using
  2198. * dedicated functions
  2199. * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
  2200. * CR2 STOP LL_USART_ConfigSmartcardMode\n
  2201. * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
  2202. * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
  2203. * CR3 SCEN LL_USART_ConfigSmartcardMode
  2204. * @param USARTx USART Instance
  2205. * @retval None
  2206. */
  2207. __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
  2208. {
  2209. /* In Smartcard mode, the following bits must be kept cleared:
  2210. - LINEN bit in the USART_CR2 register,
  2211. - IREN and HDSEL bits in the USART_CR3 register.*/
  2212. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
  2213. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
  2214. /* Configure Stop bits to 1.5 bits */
  2215. /* Synchronous mode is activated by default */
  2216. SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
  2217. /* set the UART/USART in Smartcard mode */
  2218. SET_BIT(USARTx->CR3, USART_CR3_SCEN);
  2219. }
  2220. /**
  2221. * @brief Perform basic configuration of USART for enabling use in Irda Mode
  2222. * @note In IRDA mode, the following bits must be kept cleared:
  2223. * - LINEN bit in the USART_CR2 register,
  2224. * - STOP and CLKEN bits in the USART_CR2 register,
  2225. * - SCEN bit in the USART_CR3 register,
  2226. * - HDSEL bit in the USART_CR3 register.
  2227. * This function also sets the UART/USART in IRDA mode (IREN bit).
  2228. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  2229. * IrDA feature is supported by the USARTx instance.
  2230. * @note Call of this function is equivalent to following function call sequence :
  2231. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2232. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2233. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2234. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2235. * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2236. * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
  2237. * @note Other remaining configurations items related to Irda Mode
  2238. * (as Baud Rate, Word length, Power mode, ...) should be set using
  2239. * dedicated functions
  2240. * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
  2241. * CR2 CLKEN LL_USART_ConfigIrdaMode\n
  2242. * CR2 STOP LL_USART_ConfigIrdaMode\n
  2243. * CR3 SCEN LL_USART_ConfigIrdaMode\n
  2244. * CR3 HDSEL LL_USART_ConfigIrdaMode\n
  2245. * CR3 IREN LL_USART_ConfigIrdaMode
  2246. * @param USARTx USART Instance
  2247. * @retval None
  2248. */
  2249. __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
  2250. {
  2251. /* In IRDA mode, the following bits must be kept cleared:
  2252. - LINEN, STOP and CLKEN bits in the USART_CR2 register,
  2253. - SCEN and HDSEL bits in the USART_CR3 register.*/
  2254. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
  2255. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2256. /* set the UART/USART in IRDA mode */
  2257. SET_BIT(USARTx->CR3, USART_CR3_IREN);
  2258. }
  2259. /**
  2260. * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
  2261. * (several USARTs connected in a network, one of the USARTs can be the master,
  2262. * its TX output connected to the RX inputs of the other slaves USARTs).
  2263. * @note In MultiProcessor mode, the following bits must be kept cleared:
  2264. * - LINEN bit in the USART_CR2 register,
  2265. * - CLKEN bit in the USART_CR2 register,
  2266. * - SCEN bit in the USART_CR3 register,
  2267. * - IREN bit in the USART_CR3 register,
  2268. * - HDSEL bit in the USART_CR3 register.
  2269. * @note Call of this function is equivalent to following function call sequence :
  2270. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
  2271. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2272. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
  2273. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
  2274. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2275. * @note Other remaining configurations items related to Multi processor Mode
  2276. * (as Baud Rate, Wake Up Method, Node address, ...) should be set using
  2277. * dedicated functions
  2278. * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
  2279. * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
  2280. * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
  2281. * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
  2282. * CR3 IREN LL_USART_ConfigMultiProcessMode
  2283. * @param USARTx USART Instance
  2284. * @retval None
  2285. */
  2286. __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
  2287. {
  2288. /* In Multi Processor mode, the following bits must be kept cleared:
  2289. - LINEN and CLKEN bits in the USART_CR2 register,
  2290. - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
  2291. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2292. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
  2293. }
  2294. /**
  2295. * @}
  2296. */
  2297. /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
  2298. * @{
  2299. */
  2300. /**
  2301. * @brief Check if the USART Parity Error Flag is set or not
  2302. * @rmtoll ISR PE LL_USART_IsActiveFlag_PE
  2303. * @param USARTx USART Instance
  2304. * @retval State of bit (1 or 0).
  2305. */
  2306. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
  2307. {
  2308. return (READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE));
  2309. }
  2310. /**
  2311. * @brief Check if the USART Framing Error Flag is set or not
  2312. * @rmtoll ISR FE LL_USART_IsActiveFlag_FE
  2313. * @param USARTx USART Instance
  2314. * @retval State of bit (1 or 0).
  2315. */
  2316. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
  2317. {
  2318. return (READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE));
  2319. }
  2320. /**
  2321. * @brief Check if the USART Noise error detected Flag is set or not
  2322. * @rmtoll ISR NF LL_USART_IsActiveFlag_NE
  2323. * @param USARTx USART Instance
  2324. * @retval State of bit (1 or 0).
  2325. */
  2326. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
  2327. {
  2328. return (READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE));
  2329. }
  2330. /**
  2331. * @brief Check if the USART OverRun Error Flag is set or not
  2332. * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE
  2333. * @param USARTx USART Instance
  2334. * @retval State of bit (1 or 0).
  2335. */
  2336. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
  2337. {
  2338. return (READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE));
  2339. }
  2340. /**
  2341. * @brief Check if the USART IDLE line detected Flag is set or not
  2342. * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE
  2343. * @param USARTx USART Instance
  2344. * @retval State of bit (1 or 0).
  2345. */
  2346. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
  2347. {
  2348. return (READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE));
  2349. }
  2350. /**
  2351. * @brief Check if the USART Read Data Register Not Empty Flag is set or not
  2352. * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE
  2353. * @param USARTx USART Instance
  2354. * @retval State of bit (1 or 0).
  2355. */
  2356. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
  2357. {
  2358. return (READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE));
  2359. }
  2360. /**
  2361. * @brief Check if the USART Transmission Complete Flag is set or not
  2362. * @rmtoll ISR TC LL_USART_IsActiveFlag_TC
  2363. * @param USARTx USART Instance
  2364. * @retval State of bit (1 or 0).
  2365. */
  2366. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
  2367. {
  2368. return (READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC));
  2369. }
  2370. /**
  2371. * @brief Check if the USART Transmit Data Register Empty Flag is set or not
  2372. * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE
  2373. * @param USARTx USART Instance
  2374. * @retval State of bit (1 or 0).
  2375. */
  2376. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
  2377. {
  2378. return (READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE));
  2379. }
  2380. /**
  2381. * @brief Check if the USART LIN Break Detection Flag is set or not
  2382. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2383. * LIN feature is supported by the USARTx instance.
  2384. * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD
  2385. * @param USARTx USART Instance
  2386. * @retval State of bit (1 or 0).
  2387. */
  2388. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
  2389. {
  2390. return (READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF));
  2391. }
  2392. /**
  2393. * @brief Check if the USART CTS interrupt Flag is set or not
  2394. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2395. * Hardware Flow control feature is supported by the USARTx instance.
  2396. * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS
  2397. * @param USARTx USART Instance
  2398. * @retval State of bit (1 or 0).
  2399. */
  2400. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
  2401. {
  2402. return (READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF));
  2403. }
  2404. /**
  2405. * @brief Check if the USART CTS Flag is set or not
  2406. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2407. * Hardware Flow control feature is supported by the USARTx instance.
  2408. * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS
  2409. * @param USARTx USART Instance
  2410. * @retval State of bit (1 or 0).
  2411. */
  2412. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
  2413. {
  2414. return (READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS));
  2415. }
  2416. /**
  2417. * @brief Check if the USART Receiver Time Out Flag is set or not
  2418. * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO
  2419. * @param USARTx USART Instance
  2420. * @retval State of bit (1 or 0).
  2421. */
  2422. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
  2423. {
  2424. return (READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF));
  2425. }
  2426. /**
  2427. * @brief Check if the USART End Of Block Flag is set or not
  2428. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2429. * Smartcard feature is supported by the USARTx instance.
  2430. * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB
  2431. * @param USARTx USART Instance
  2432. * @retval State of bit (1 or 0).
  2433. */
  2434. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
  2435. {
  2436. return (READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF));
  2437. }
  2438. /**
  2439. * @brief Check if the USART Auto-Baud Rate Error Flag is set or not
  2440. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  2441. * Auto Baud Rate detection feature is supported by the USARTx instance.
  2442. * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE
  2443. * @param USARTx USART Instance
  2444. * @retval State of bit (1 or 0).
  2445. */
  2446. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
  2447. {
  2448. return (READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE));
  2449. }
  2450. /**
  2451. * @brief Check if the USART Auto-Baud Rate Flag is set or not
  2452. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  2453. * Auto Baud Rate detection feature is supported by the USARTx instance.
  2454. * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR
  2455. * @param USARTx USART Instance
  2456. * @retval State of bit (1 or 0).
  2457. */
  2458. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
  2459. {
  2460. return (READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF));
  2461. }
  2462. /**
  2463. * @brief Check if the USART Busy Flag is set or not
  2464. * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY
  2465. * @param USARTx USART Instance
  2466. * @retval State of bit (1 or 0).
  2467. */
  2468. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
  2469. {
  2470. return (READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY));
  2471. }
  2472. /**
  2473. * @brief Check if the USART Character Match Flag is set or not
  2474. * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM
  2475. * @param USARTx USART Instance
  2476. * @retval State of bit (1 or 0).
  2477. */
  2478. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
  2479. {
  2480. return (READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF));
  2481. }
  2482. /**
  2483. * @brief Check if the USART Send Break Flag is set or not
  2484. * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK
  2485. * @param USARTx USART Instance
  2486. * @retval State of bit (1 or 0).
  2487. */
  2488. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
  2489. {
  2490. return (READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF));
  2491. }
  2492. /**
  2493. * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
  2494. * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU
  2495. * @param USARTx USART Instance
  2496. * @retval State of bit (1 or 0).
  2497. */
  2498. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
  2499. {
  2500. return (READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU));
  2501. }
  2502. /**
  2503. * @brief Check if the USART Wake Up from stop mode Flag is set or not
  2504. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2505. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2506. * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP
  2507. * @param USARTx USART Instance
  2508. * @retval State of bit (1 or 0).
  2509. */
  2510. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
  2511. {
  2512. return (READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF));
  2513. }
  2514. /**
  2515. * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not
  2516. * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK
  2517. * @param USARTx USART Instance
  2518. * @retval State of bit (1 or 0).
  2519. */
  2520. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
  2521. {
  2522. return (READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK));
  2523. }
  2524. /**
  2525. * @brief Check if the USART Receive Enable Acknowledge Flag is set or not
  2526. * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK
  2527. * @param USARTx USART Instance
  2528. * @retval State of bit (1 or 0).
  2529. */
  2530. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
  2531. {
  2532. return (READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK));
  2533. }
  2534. /**
  2535. * @brief Clear Parity Error Flag
  2536. * @rmtoll ICR PECF LL_USART_ClearFlag_PE
  2537. * @param USARTx USART Instance
  2538. * @retval None
  2539. */
  2540. __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
  2541. {
  2542. WRITE_REG(USARTx->ICR, USART_ICR_PECF);
  2543. }
  2544. /**
  2545. * @brief Clear Framing Error Flag
  2546. * @rmtoll ICR FECF LL_USART_ClearFlag_FE
  2547. * @param USARTx USART Instance
  2548. * @retval None
  2549. */
  2550. __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
  2551. {
  2552. WRITE_REG(USARTx->ICR, USART_ICR_FECF);
  2553. }
  2554. /**
  2555. * @brief Clear Noise detected Flag
  2556. * @rmtoll ICR NCF LL_USART_ClearFlag_NE
  2557. * @param USARTx USART Instance
  2558. * @retval None
  2559. */
  2560. __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
  2561. {
  2562. WRITE_REG(USARTx->ICR, USART_ICR_NCF);
  2563. }
  2564. /**
  2565. * @brief Clear OverRun Error Flag
  2566. * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE
  2567. * @param USARTx USART Instance
  2568. * @retval None
  2569. */
  2570. __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
  2571. {
  2572. WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
  2573. }
  2574. /**
  2575. * @brief Clear IDLE line detected Flag
  2576. * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE
  2577. * @param USARTx USART Instance
  2578. * @retval None
  2579. */
  2580. __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
  2581. {
  2582. WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
  2583. }
  2584. /**
  2585. * @brief Clear Transmission Complete Flag
  2586. * @rmtoll ICR TCCF LL_USART_ClearFlag_TC
  2587. * @param USARTx USART Instance
  2588. * @retval None
  2589. */
  2590. __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
  2591. {
  2592. WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
  2593. }
  2594. /**
  2595. * @brief Clear LIN Break Detection Flag
  2596. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2597. * LIN feature is supported by the USARTx instance.
  2598. * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD
  2599. * @param USARTx USART Instance
  2600. * @retval None
  2601. */
  2602. __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
  2603. {
  2604. WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
  2605. }
  2606. /**
  2607. * @brief Clear CTS Interrupt Flag
  2608. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2609. * Hardware Flow control feature is supported by the USARTx instance.
  2610. * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS
  2611. * @param USARTx USART Instance
  2612. * @retval None
  2613. */
  2614. __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
  2615. {
  2616. WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
  2617. }
  2618. /**
  2619. * @brief Clear Receiver Time Out Flag
  2620. * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO
  2621. * @param USARTx USART Instance
  2622. * @retval None
  2623. */
  2624. __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
  2625. {
  2626. WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
  2627. }
  2628. /**
  2629. * @brief Clear End Of Block Flag
  2630. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2631. * Smartcard feature is supported by the USARTx instance.
  2632. * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB
  2633. * @param USARTx USART Instance
  2634. * @retval None
  2635. */
  2636. __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
  2637. {
  2638. WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
  2639. }
  2640. /**
  2641. * @brief Clear Character Match Flag
  2642. * @rmtoll ICR CMCF LL_USART_ClearFlag_CM
  2643. * @param USARTx USART Instance
  2644. * @retval None
  2645. */
  2646. __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
  2647. {
  2648. WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
  2649. }
  2650. /**
  2651. * @brief Clear Wake Up from stop mode Flag
  2652. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2653. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2654. * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP
  2655. * @param USARTx USART Instance
  2656. * @retval None
  2657. */
  2658. __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
  2659. {
  2660. WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
  2661. }
  2662. /**
  2663. * @}
  2664. */
  2665. /** @defgroup USART_LL_EF_IT_Management IT_Management
  2666. * @{
  2667. */
  2668. /**
  2669. * @brief Enable IDLE Interrupt
  2670. * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
  2671. * @param USARTx USART Instance
  2672. * @retval None
  2673. */
  2674. __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
  2675. {
  2676. SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
  2677. }
  2678. /**
  2679. * @brief Enable RX Not Empty Interrupt
  2680. * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE
  2681. * @param USARTx USART Instance
  2682. * @retval None
  2683. */
  2684. __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
  2685. {
  2686. SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
  2687. }
  2688. /**
  2689. * @brief Enable Transmission Complete Interrupt
  2690. * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
  2691. * @param USARTx USART Instance
  2692. * @retval None
  2693. */
  2694. __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
  2695. {
  2696. SET_BIT(USARTx->CR1, USART_CR1_TCIE);
  2697. }
  2698. /**
  2699. * @brief Enable TX Empty Interrupt
  2700. * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE
  2701. * @param USARTx USART Instance
  2702. * @retval None
  2703. */
  2704. __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
  2705. {
  2706. SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
  2707. }
  2708. /**
  2709. * @brief Enable Parity Error Interrupt
  2710. * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
  2711. * @param USARTx USART Instance
  2712. * @retval None
  2713. */
  2714. __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
  2715. {
  2716. SET_BIT(USARTx->CR1, USART_CR1_PEIE);
  2717. }
  2718. /**
  2719. * @brief Enable Character Match Interrupt
  2720. * @rmtoll CR1 CMIE LL_USART_EnableIT_CM
  2721. * @param USARTx USART Instance
  2722. * @retval None
  2723. */
  2724. __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
  2725. {
  2726. SET_BIT(USARTx->CR1, USART_CR1_CMIE);
  2727. }
  2728. /**
  2729. * @brief Enable Receiver Timeout Interrupt
  2730. * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO
  2731. * @param USARTx USART Instance
  2732. * @retval None
  2733. */
  2734. __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
  2735. {
  2736. SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
  2737. }
  2738. /**
  2739. * @brief Enable End Of Block Interrupt
  2740. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2741. * Smartcard feature is supported by the USARTx instance.
  2742. * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB
  2743. * @param USARTx USART Instance
  2744. * @retval None
  2745. */
  2746. __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
  2747. {
  2748. SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
  2749. }
  2750. /**
  2751. * @brief Enable LIN Break Detection Interrupt
  2752. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2753. * LIN feature is supported by the USARTx instance.
  2754. * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
  2755. * @param USARTx USART Instance
  2756. * @retval None
  2757. */
  2758. __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
  2759. {
  2760. SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
  2761. }
  2762. /**
  2763. * @brief Enable Error Interrupt
  2764. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  2765. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
  2766. * 0: Interrupt is inhibited
  2767. * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
  2768. * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
  2769. * @param USARTx USART Instance
  2770. * @retval None
  2771. */
  2772. __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
  2773. {
  2774. SET_BIT(USARTx->CR3, USART_CR3_EIE);
  2775. }
  2776. /**
  2777. * @brief Enable CTS Interrupt
  2778. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2779. * Hardware Flow control feature is supported by the USARTx instance.
  2780. * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
  2781. * @param USARTx USART Instance
  2782. * @retval None
  2783. */
  2784. __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
  2785. {
  2786. SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
  2787. }
  2788. /**
  2789. * @brief Enable Wake Up from Stop Mode Interrupt
  2790. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2791. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2792. * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP
  2793. * @param USARTx USART Instance
  2794. * @retval None
  2795. */
  2796. __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
  2797. {
  2798. SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
  2799. }
  2800. /**
  2801. * @brief Disable IDLE Interrupt
  2802. * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
  2803. * @param USARTx USART Instance
  2804. * @retval None
  2805. */
  2806. __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
  2807. {
  2808. CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
  2809. }
  2810. /**
  2811. * @brief Disable RX Not Empty Interrupt
  2812. * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE
  2813. * @param USARTx USART Instance
  2814. * @retval None
  2815. */
  2816. __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
  2817. {
  2818. CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
  2819. }
  2820. /**
  2821. * @brief Disable Transmission Complete Interrupt
  2822. * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
  2823. * @param USARTx USART Instance
  2824. * @retval None
  2825. */
  2826. __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
  2827. {
  2828. CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
  2829. }
  2830. /**
  2831. * @brief Disable TX Empty Interrupt
  2832. * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE
  2833. * @param USARTx USART Instance
  2834. * @retval None
  2835. */
  2836. __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
  2837. {
  2838. CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
  2839. }
  2840. /**
  2841. * @brief Disable Parity Error Interrupt
  2842. * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
  2843. * @param USARTx USART Instance
  2844. * @retval None
  2845. */
  2846. __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
  2847. {
  2848. CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
  2849. }
  2850. /**
  2851. * @brief Disable Character Match Interrupt
  2852. * @rmtoll CR1 CMIE LL_USART_DisableIT_CM
  2853. * @param USARTx USART Instance
  2854. * @retval None
  2855. */
  2856. __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
  2857. {
  2858. CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
  2859. }
  2860. /**
  2861. * @brief Disable Receiver Timeout Interrupt
  2862. * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO
  2863. * @param USARTx USART Instance
  2864. * @retval None
  2865. */
  2866. __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
  2867. {
  2868. CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
  2869. }
  2870. /**
  2871. * @brief Disable End Of Block Interrupt
  2872. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2873. * Smartcard feature is supported by the USARTx instance.
  2874. * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB
  2875. * @param USARTx USART Instance
  2876. * @retval None
  2877. */
  2878. __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
  2879. {
  2880. CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
  2881. }
  2882. /**
  2883. * @brief Disable LIN Break Detection Interrupt
  2884. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2885. * LIN feature is supported by the USARTx instance.
  2886. * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
  2887. * @param USARTx USART Instance
  2888. * @retval None
  2889. */
  2890. __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
  2891. {
  2892. CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
  2893. }
  2894. /**
  2895. * @brief Disable Error Interrupt
  2896. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  2897. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
  2898. * 0: Interrupt is inhibited
  2899. * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
  2900. * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
  2901. * @param USARTx USART Instance
  2902. * @retval None
  2903. */
  2904. __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
  2905. {
  2906. CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
  2907. }
  2908. /**
  2909. * @brief Disable CTS Interrupt
  2910. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2911. * Hardware Flow control feature is supported by the USARTx instance.
  2912. * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
  2913. * @param USARTx USART Instance
  2914. * @retval None
  2915. */
  2916. __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
  2917. {
  2918. CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
  2919. }
  2920. /**
  2921. * @brief Disable Wake Up from Stop Mode Interrupt
  2922. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2923. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2924. * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP
  2925. * @param USARTx USART Instance
  2926. * @retval None
  2927. */
  2928. __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
  2929. {
  2930. CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
  2931. }
  2932. /**
  2933. * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
  2934. * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
  2935. * @param USARTx USART Instance
  2936. * @retval State of bit (1 or 0).
  2937. */
  2938. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
  2939. {
  2940. return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
  2941. }
  2942. /**
  2943. * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled.
  2944. * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE
  2945. * @param USARTx USART Instance
  2946. * @retval State of bit (1 or 0).
  2947. */
  2948. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
  2949. {
  2950. return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
  2951. }
  2952. /**
  2953. * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
  2954. * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
  2955. * @param USARTx USART Instance
  2956. * @retval State of bit (1 or 0).
  2957. */
  2958. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
  2959. {
  2960. return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
  2961. }
  2962. /**
  2963. * @brief Check if the USART TX Empty Interrupt is enabled or disabled.
  2964. * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE
  2965. * @param USARTx USART Instance
  2966. * @retval State of bit (1 or 0).
  2967. */
  2968. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
  2969. {
  2970. return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
  2971. }
  2972. /**
  2973. * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
  2974. * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
  2975. * @param USARTx USART Instance
  2976. * @retval State of bit (1 or 0).
  2977. */
  2978. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
  2979. {
  2980. return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
  2981. }
  2982. /**
  2983. * @brief Check if the USART Character Match Interrupt is enabled or disabled.
  2984. * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM
  2985. * @param USARTx USART Instance
  2986. * @retval State of bit (1 or 0).
  2987. */
  2988. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
  2989. {
  2990. return (READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE));
  2991. }
  2992. /**
  2993. * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled.
  2994. * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO
  2995. * @param USARTx USART Instance
  2996. * @retval State of bit (1 or 0).
  2997. */
  2998. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
  2999. {
  3000. return (READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE));
  3001. }
  3002. /**
  3003. * @brief Check if the USART End Of Block Interrupt is enabled or disabled.
  3004. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  3005. * Smartcard feature is supported by the USARTx instance.
  3006. * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB
  3007. * @param USARTx USART Instance
  3008. * @retval State of bit (1 or 0).
  3009. */
  3010. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
  3011. {
  3012. return (READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE));
  3013. }
  3014. /**
  3015. * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
  3016. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  3017. * LIN feature is supported by the USARTx instance.
  3018. * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
  3019. * @param USARTx USART Instance
  3020. * @retval State of bit (1 or 0).
  3021. */
  3022. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
  3023. {
  3024. return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
  3025. }
  3026. /**
  3027. * @brief Check if the USART Error Interrupt is enabled or disabled.
  3028. * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
  3029. * @param USARTx USART Instance
  3030. * @retval State of bit (1 or 0).
  3031. */
  3032. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
  3033. {
  3034. return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
  3035. }
  3036. /**
  3037. * @brief Check if the USART CTS Interrupt is enabled or disabled.
  3038. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  3039. * Hardware Flow control feature is supported by the USARTx instance.
  3040. * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
  3041. * @param USARTx USART Instance
  3042. * @retval State of bit (1 or 0).
  3043. */
  3044. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
  3045. {
  3046. return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
  3047. }
  3048. /**
  3049. * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled.
  3050. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  3051. * Wake-up from Stop mode feature is supported by the USARTx instance.
  3052. * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP
  3053. * @param USARTx USART Instance
  3054. * @retval State of bit (1 or 0).
  3055. */
  3056. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
  3057. {
  3058. return (READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE));
  3059. }
  3060. /**
  3061. * @}
  3062. */
  3063. /** @defgroup USART_LL_EF_DMA_Management DMA_Management
  3064. * @{
  3065. */
  3066. /**
  3067. * @brief Enable DMA Mode for reception
  3068. * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
  3069. * @param USARTx USART Instance
  3070. * @retval None
  3071. */
  3072. __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
  3073. {
  3074. SET_BIT(USARTx->CR3, USART_CR3_DMAR);
  3075. }
  3076. /**
  3077. * @brief Disable DMA Mode for reception
  3078. * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
  3079. * @param USARTx USART Instance
  3080. * @retval None
  3081. */
  3082. __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
  3083. {
  3084. CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
  3085. }
  3086. /**
  3087. * @brief Check if DMA Mode is enabled for reception
  3088. * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
  3089. * @param USARTx USART Instance
  3090. * @retval State of bit (1 or 0).
  3091. */
  3092. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
  3093. {
  3094. return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
  3095. }
  3096. /**
  3097. * @brief Enable DMA Mode for transmission
  3098. * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
  3099. * @param USARTx USART Instance
  3100. * @retval None
  3101. */
  3102. __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
  3103. {
  3104. SET_BIT(USARTx->CR3, USART_CR3_DMAT);
  3105. }
  3106. /**
  3107. * @brief Disable DMA Mode for transmission
  3108. * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
  3109. * @param USARTx USART Instance
  3110. * @retval None
  3111. */
  3112. __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
  3113. {
  3114. CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
  3115. }
  3116. /**
  3117. * @brief Check if DMA Mode is enabled for transmission
  3118. * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
  3119. * @param USARTx USART Instance
  3120. * @retval State of bit (1 or 0).
  3121. */
  3122. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
  3123. {
  3124. return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
  3125. }
  3126. /**
  3127. * @brief Enable DMA Disabling on Reception Error
  3128. * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr
  3129. * @param USARTx USART Instance
  3130. * @retval None
  3131. */
  3132. __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
  3133. {
  3134. SET_BIT(USARTx->CR3, USART_CR3_DDRE);
  3135. }
  3136. /**
  3137. * @brief Disable DMA Disabling on Reception Error
  3138. * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr
  3139. * @param USARTx USART Instance
  3140. * @retval None
  3141. */
  3142. __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
  3143. {
  3144. CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
  3145. }
  3146. /**
  3147. * @brief Indicate if DMA Disabling on Reception Error is disabled
  3148. * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr
  3149. * @param USARTx USART Instance
  3150. * @retval State of bit (1 or 0).
  3151. */
  3152. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
  3153. {
  3154. return (READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE));
  3155. }
  3156. /**
  3157. * @brief Get the data register address used for DMA transfer
  3158. * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n
  3159. * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr
  3160. * @param USARTx USART Instance
  3161. * @param Direction This parameter can be one of the following values:
  3162. * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
  3163. * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
  3164. * @retval Address of data register
  3165. */
  3166. __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
  3167. {
  3168. register uint32_t data_reg_addr = 0U;
  3169. if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
  3170. {
  3171. /* return address of TDR register */
  3172. data_reg_addr = (uint32_t) &(USARTx->TDR);
  3173. }
  3174. else
  3175. {
  3176. /* return address of RDR register */
  3177. data_reg_addr = (uint32_t) &(USARTx->RDR);
  3178. }
  3179. return data_reg_addr;
  3180. }
  3181. /**
  3182. * @}
  3183. */
  3184. /** @defgroup USART_LL_EF_Data_Management Data_Management
  3185. * @{
  3186. */
  3187. /**
  3188. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  3189. * @rmtoll RDR RDR LL_USART_ReceiveData8
  3190. * @param USARTx USART Instance
  3191. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  3192. */
  3193. __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
  3194. {
  3195. return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
  3196. }
  3197. /**
  3198. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  3199. * @rmtoll RDR RDR LL_USART_ReceiveData9
  3200. * @param USARTx USART Instance
  3201. * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
  3202. */
  3203. __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
  3204. {
  3205. return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
  3206. }
  3207. /**
  3208. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  3209. * @rmtoll TDR TDR LL_USART_TransmitData8
  3210. * @param USARTx USART Instance
  3211. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  3212. * @retval None
  3213. */
  3214. __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
  3215. {
  3216. USARTx->TDR = Value;
  3217. }
  3218. /**
  3219. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  3220. * @rmtoll TDR TDR LL_USART_TransmitData9
  3221. * @param USARTx USART Instance
  3222. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  3223. * @retval None
  3224. */
  3225. __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
  3226. {
  3227. USARTx->TDR = Value & 0x1FFU;
  3228. }
  3229. /**
  3230. * @}
  3231. */
  3232. /** @defgroup USART_LL_EF_Execution Execution
  3233. * @{
  3234. */
  3235. /**
  3236. * @brief Request an Automatic Baud Rate measurement on next received data frame
  3237. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  3238. * Auto Baud Rate detection feature is supported by the USARTx instance.
  3239. * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate
  3240. * @param USARTx USART Instance
  3241. * @retval None
  3242. */
  3243. __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
  3244. {
  3245. SET_BIT(USARTx->RQR, USART_RQR_ABRRQ);
  3246. }
  3247. /**
  3248. * @brief Request Break sending
  3249. * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending
  3250. * @param USARTx USART Instance
  3251. * @retval None
  3252. */
  3253. __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
  3254. {
  3255. SET_BIT(USARTx->RQR, USART_RQR_SBKRQ);
  3256. }
  3257. /**
  3258. * @brief Put USART in mute mode and set the RWU flag
  3259. * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode
  3260. * @param USARTx USART Instance
  3261. * @retval None
  3262. */
  3263. __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
  3264. {
  3265. SET_BIT(USARTx->RQR, USART_RQR_MMRQ);
  3266. }
  3267. /**
  3268. * @brief Request a Receive Data flush
  3269. * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush
  3270. * @param USARTx USART Instance
  3271. * @retval None
  3272. */
  3273. __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
  3274. {
  3275. SET_BIT(USARTx->RQR, USART_RQR_RXFRQ);
  3276. }
  3277. /**
  3278. * @brief Request a Transmit data flush
  3279. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  3280. * Smartcard feature is supported by the USARTx instance.
  3281. * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush
  3282. * @param USARTx USART Instance
  3283. * @retval None
  3284. */
  3285. __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
  3286. {
  3287. SET_BIT(USARTx->RQR, USART_RQR_TXFRQ);
  3288. }
  3289. /**
  3290. * @}
  3291. */
  3292. #if defined(USE_FULL_LL_DRIVER)
  3293. /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
  3294. * @{
  3295. */
  3296. ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
  3297. ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
  3298. void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
  3299. ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
  3300. void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
  3301. /**
  3302. * @}
  3303. */
  3304. #endif /* USE_FULL_LL_DRIVER */
  3305. /**
  3306. * @}
  3307. */
  3308. /**
  3309. * @}
  3310. */
  3311. #endif /* USART1 || USART2|| USART3 || UART4 || UART5 */
  3312. /**
  3313. * @}
  3314. */
  3315. #ifdef __cplusplus
  3316. }
  3317. #endif
  3318. #endif /* __STM32F3xx_LL_USART_H */
  3319. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/