stm32g0xx_ll_usart.h 170 KB

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