stm32h7xx_ll_usart.h 175 KB

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