stm32g0xx_ll_usart.h 170 KB

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