stm32g0xx_ll_usart.h 175 KB

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