stm32l4xx_ll_lpuart.h 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_lpuart.h
  4. * @author MCD Application Team
  5. * @brief Header file of LPUART LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L4xx_LL_LPUART_H
  20. #define STM32L4xx_LL_LPUART_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l4xx.h"
  26. /** @addtogroup STM32L4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (LPUART1)
  30. /** @defgroup LPUART_LL LPUART
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. #if defined(USART_PRESC_PRESCALER)
  36. /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables
  37. * @{
  38. */
  39. /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */
  40. static const uint16_t LPUART_PRESCALER_TAB[] =
  41. {
  42. (uint16_t)1,
  43. (uint16_t)2,
  44. (uint16_t)4,
  45. (uint16_t)6,
  46. (uint16_t)8,
  47. (uint16_t)10,
  48. (uint16_t)12,
  49. (uint16_t)16,
  50. (uint16_t)32,
  51. (uint16_t)64,
  52. (uint16_t)128,
  53. (uint16_t)256
  54. };
  55. /**
  56. * @}
  57. */
  58. #endif /* USART_PRESC_PRESCALER */
  59. /* Private constants ---------------------------------------------------------*/
  60. /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants
  61. * @{
  62. */
  63. /* Defines used in Baud Rate related macros and corresponding register setting computation */
  64. #define LPUART_LPUARTDIV_FREQ_MUL 256U
  65. #define LPUART_BRR_MASK 0x000FFFFFU
  66. #define LPUART_BRR_MIN_VALUE 0x00000300U
  67. /**
  68. * @}
  69. */
  70. /* Private macros ------------------------------------------------------------*/
  71. #if defined(USE_FULL_LL_DRIVER)
  72. /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros
  73. * @{
  74. */
  75. /**
  76. * @}
  77. */
  78. #endif /*USE_FULL_LL_DRIVER*/
  79. /* Exported types ------------------------------------------------------------*/
  80. #if defined(USE_FULL_LL_DRIVER)
  81. /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures
  82. * @{
  83. */
  84. /**
  85. * @brief LL LPUART Init Structure definition
  86. */
  87. typedef struct
  88. {
  89. #if defined(USART_PRESC_PRESCALER)
  90. uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate.
  91. This parameter can be a value of @ref LPUART_LL_EC_PRESCALER.
  92. This feature can be modified afterwards using unitary
  93. function @ref LL_LPUART_SetPrescaler().*/
  94. #endif /* USART_PRESC_PRESCALER */
  95. uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate.
  96. This feature can be modified afterwards using unitary
  97. function @ref LL_LPUART_SetBaudRate().*/
  98. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  99. This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH.
  100. This feature can be modified afterwards using unitary
  101. function @ref LL_LPUART_SetDataWidth().*/
  102. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  103. This parameter can be a value of @ref LPUART_LL_EC_STOPBITS.
  104. This feature can be modified afterwards using unitary
  105. function @ref LL_LPUART_SetStopBitsLength().*/
  106. uint32_t Parity; /*!< Specifies the parity mode.
  107. This parameter can be a value of @ref LPUART_LL_EC_PARITY.
  108. This feature can be modified afterwards using unitary
  109. function @ref LL_LPUART_SetParity().*/
  110. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  111. This parameter can be a value of @ref LPUART_LL_EC_DIRECTION.
  112. This feature can be modified afterwards using unitary
  113. function @ref LL_LPUART_SetTransferDirection().*/
  114. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  115. This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL.
  116. This feature can be modified afterwards using unitary
  117. function @ref LL_LPUART_SetHWFlowCtrl().*/
  118. } LL_LPUART_InitTypeDef;
  119. /**
  120. * @}
  121. */
  122. #endif /* USE_FULL_LL_DRIVER */
  123. /* Exported constants --------------------------------------------------------*/
  124. /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants
  125. * @{
  126. */
  127. /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines
  128. * @brief Flags defines which can be used with LL_LPUART_WriteReg function
  129. * @{
  130. */
  131. #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error clear flag */
  132. #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error clear flag */
  133. #define LL_LPUART_ICR_NCF USART_ICR_NECF /*!< Noise error detected clear flag */
  134. #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error clear flag */
  135. #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected clear flag */
  136. #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete clear flag */
  137. #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS clear flag */
  138. #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match clear flag */
  139. #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode clear flag */
  140. /**
  141. * @}
  142. */
  143. /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines
  144. * @brief Flags defines which can be used with LL_LPUART_ReadReg function
  145. * @{
  146. */
  147. #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  148. #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  149. #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  150. #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  151. #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  152. #if defined(USART_CR1_FIFOEN)
  153. #define LL_LPUART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */
  154. #else
  155. #define LL_LPUART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */
  156. #endif /* USART_CR1_FIFOEN */
  157. #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  158. #if defined(USART_CR1_FIFOEN)
  159. #define LL_LPUART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/
  160. #else
  161. #define LL_LPUART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */
  162. #endif /* USART_CR1_FIFOEN */
  163. #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  164. #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  165. #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  166. #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  167. #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  168. #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  169. #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  170. #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  171. #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  172. #if defined(USART_CR1_FIFOEN)
  173. #define LL_LPUART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */
  174. #define LL_LPUART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */
  175. #define LL_LPUART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */
  176. #define LL_LPUART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */
  177. #endif /* USART_CR1_FIFOEN */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup LPUART_LL_EC_IT IT Defines
  182. * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions
  183. * @{
  184. */
  185. #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  186. #if defined(USART_CR1_FIFOEN)
  187. #define LL_LPUART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty
  188. interrupt enable */
  189. #else
  190. #define LL_LPUART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
  191. #endif /* USART_CR1_FIFOEN */
  192. #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  193. #if defined(USART_CR1_FIFOEN)
  194. #define LL_LPUART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO
  195. not full interrupt enable */
  196. #else
  197. #define LL_LPUART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
  198. #endif /* USART_CR1_FIFOEN */
  199. #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  200. #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  201. #if defined(USART_CR1_FIFOEN)
  202. #define LL_LPUART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */
  203. #define LL_LPUART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */
  204. #endif /* USART_CR1_FIFOEN */
  205. #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  206. #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  207. #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  208. #if defined(USART_CR1_FIFOEN)
  209. #define LL_LPUART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */
  210. #define LL_LPUART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */
  211. #endif /* USART_CR1_FIFOEN */
  212. /**
  213. * @}
  214. */
  215. #if defined(USART_CR1_FIFOEN)
  216. /** @defgroup LPUART_LL_EC_FIFOTHRESHOLD FIFO Threshold
  217. * @{
  218. */
  219. #define LL_LPUART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */
  220. #define LL_LPUART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */
  221. #define LL_LPUART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */
  222. #define LL_LPUART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */
  223. #define LL_LPUART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */
  224. #define LL_LPUART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */
  225. /**
  226. * @}
  227. */
  228. #endif /* USART_CR1_FIFOEN */
  229. /** @defgroup LPUART_LL_EC_DIRECTION Direction
  230. * @{
  231. */
  232. #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  233. #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  234. #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  235. #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  236. /**
  237. * @}
  238. */
  239. /** @defgroup LPUART_LL_EC_PARITY Parity Control
  240. * @{
  241. */
  242. #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  243. #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  244. #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  245. /**
  246. * @}
  247. */
  248. /** @defgroup LPUART_LL_EC_WAKEUP Wakeup
  249. * @{
  250. */
  251. #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */
  252. #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */
  253. /**
  254. * @}
  255. */
  256. /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth
  257. * @{
  258. */
  259. #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  260. #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  261. #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  262. /**
  263. * @}
  264. */
  265. #if defined(USART_PRESC_PRESCALER)
  266. /** @defgroup LPUART_LL_EC_PRESCALER Clock Source Prescaler
  267. * @{
  268. */
  269. #define LL_LPUART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */
  270. #define LL_LPUART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */
  271. #define LL_LPUART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */
  272. #define LL_LPUART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 |\
  273. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */
  274. #define LL_LPUART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */
  275. #define LL_LPUART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 |\
  276. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */
  277. #define LL_LPUART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 |\
  278. USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */
  279. #define LL_LPUART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 |\
  280. USART_PRESC_PRESCALER_1 |\
  281. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */
  282. #define LL_LPUART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */
  283. #define LL_LPUART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 |\
  284. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */
  285. #define LL_LPUART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 |\
  286. USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */
  287. #define LL_LPUART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 |\
  288. USART_PRESC_PRESCALER_1 |\
  289. USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */
  290. /**
  291. * @}
  292. */
  293. #endif /* USART_PRESC_PRESCALER */
  294. /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits
  295. * @{
  296. */
  297. #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  298. #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  299. /**
  300. * @}
  301. */
  302. /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap
  303. * @{
  304. */
  305. #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  306. #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  307. /**
  308. * @}
  309. */
  310. /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  311. * @{
  312. */
  313. #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  314. #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  315. /**
  316. * @}
  317. */
  318. /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  319. * @{
  320. */
  321. #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  322. #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  323. /**
  324. * @}
  325. */
  326. /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion
  327. * @{
  328. */
  329. #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received
  330. in positive/direct logic. (1=H, 0=L) */
  331. #define LL_LPUART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received
  332. in negative/inverse logic. (1=L, 0=H).
  333. The parity bit is also inverted. */
  334. /**
  335. * @}
  336. */
  337. /** @defgroup LPUART_LL_EC_BITORDER Bit Order
  338. * @{
  339. */
  340. #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first,
  341. following the start bit */
  342. #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first,
  343. following the start bit */
  344. /**
  345. * @}
  346. */
  347. /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection
  348. * @{
  349. */
  350. #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  351. #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  352. /**
  353. * @}
  354. */
  355. /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control
  356. * @{
  357. */
  358. #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  359. #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested
  360. when there is space in the receive buffer */
  361. #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted
  362. when the nCTS input is asserted (tied to 0)*/
  363. #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  364. /**
  365. * @}
  366. */
  367. /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation
  368. * @{
  369. */
  370. #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  371. #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  372. #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  373. /**
  374. * @}
  375. */
  376. /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity
  377. * @{
  378. */
  379. #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  380. #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  381. /**
  382. * @}
  383. */
  384. /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data
  385. * @{
  386. */
  387. #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  388. #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  389. /**
  390. * @}
  391. */
  392. /**
  393. * @}
  394. */
  395. /* Exported macro ------------------------------------------------------------*/
  396. /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros
  397. * @{
  398. */
  399. /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros
  400. * @{
  401. */
  402. /**
  403. * @brief Write a value in LPUART register
  404. * @param __INSTANCE__ LPUART Instance
  405. * @param __REG__ Register to be written
  406. * @param __VALUE__ Value to be written in the register
  407. * @retval None
  408. */
  409. #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  410. /**
  411. * @brief Read a value in LPUART register
  412. * @param __INSTANCE__ LPUART Instance
  413. * @param __REG__ Register to be read
  414. * @retval Register value
  415. */
  416. #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  417. /**
  418. * @}
  419. */
  420. /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros
  421. * @{
  422. */
  423. /**
  424. * @brief Compute LPUARTDIV value according to Peripheral Clock and
  425. * expected Baud Rate (20-bit value of LPUARTDIV is returned)
  426. * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance
  427. @if USART_PRESC_PRESCALER
  428. * @param __PRESCALER__ This parameter can be one of the following values:
  429. * @arg @ref LL_LPUART_PRESCALER_DIV1
  430. * @arg @ref LL_LPUART_PRESCALER_DIV2
  431. * @arg @ref LL_LPUART_PRESCALER_DIV4
  432. * @arg @ref LL_LPUART_PRESCALER_DIV6
  433. * @arg @ref LL_LPUART_PRESCALER_DIV8
  434. * @arg @ref LL_LPUART_PRESCALER_DIV10
  435. * @arg @ref LL_LPUART_PRESCALER_DIV12
  436. * @arg @ref LL_LPUART_PRESCALER_DIV16
  437. * @arg @ref LL_LPUART_PRESCALER_DIV32
  438. * @arg @ref LL_LPUART_PRESCALER_DIV64
  439. * @arg @ref LL_LPUART_PRESCALER_DIV128
  440. * @arg @ref LL_LPUART_PRESCALER_DIV256
  441. @endif
  442. * @param __BAUDRATE__ Baud Rate value to achieve
  443. * @retval LPUARTDIV value to be used for BRR register filling
  444. */
  445. #if defined(USART_PRESC_PRESCALER)
  446. #define __LL_LPUART_DIV(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (uint32_t)\
  447. ((((((uint64_t)(__PERIPHCLK__)/(uint64_t)(LPUART_PRESCALER_TAB[(uint16_t)(__PRESCALER__)]))\
  448. * LPUART_LPUARTDIV_FREQ_MUL) + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__)) & LPUART_BRR_MASK)
  449. #else
  450. #define __LL_LPUART_DIV(__PERIPHCLK__, __BAUDRATE__) (uint32_t)(((((uint64_t)(__PERIPHCLK__)*LPUART_LPUARTDIV_FREQ_MUL) + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__))\
  451. & LPUART_BRR_MASK)
  452. #endif /* USART_PRESC_PRESCALER */
  453. /**
  454. * @}
  455. */
  456. /**
  457. * @}
  458. */
  459. /* Exported functions --------------------------------------------------------*/
  460. /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions
  461. * @{
  462. */
  463. /** @defgroup LPUART_LL_EF_Configuration Configuration functions
  464. * @{
  465. */
  466. /**
  467. * @brief LPUART Enable
  468. * @rmtoll CR1 UE LL_LPUART_Enable
  469. * @param LPUARTx LPUART Instance
  470. * @retval None
  471. */
  472. __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx)
  473. {
  474. SET_BIT(LPUARTx->CR1, USART_CR1_UE);
  475. }
  476. /**
  477. * @brief LPUART Disable
  478. * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately,
  479. * and current operations are discarded. The configuration of the LPUART is kept, but all the status
  480. * flags, in the LPUARTx_ISR are set to their default values.
  481. * @note In order to go into low-power mode without generating errors on the line,
  482. * the TE bit must be reset before and the software must wait
  483. * for the TC bit in the LPUART_ISR to be set before resetting the UE bit.
  484. * The DMA requests are also reset when UE = 0 so the DMA channel must
  485. * be disabled before resetting the UE bit.
  486. * @rmtoll CR1 UE LL_LPUART_Disable
  487. * @param LPUARTx LPUART Instance
  488. * @retval None
  489. */
  490. __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx)
  491. {
  492. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE);
  493. }
  494. /**
  495. * @brief Indicate if LPUART is enabled
  496. * @rmtoll CR1 UE LL_LPUART_IsEnabled
  497. * @param LPUARTx LPUART Instance
  498. * @retval State of bit (1 or 0).
  499. */
  500. __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(const USART_TypeDef *LPUARTx)
  501. {
  502. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL);
  503. }
  504. #if defined(USART_CR1_FIFOEN)
  505. /**
  506. * @brief FIFO Mode Enable
  507. * @rmtoll CR1 FIFOEN LL_LPUART_EnableFIFO
  508. * @param LPUARTx LPUART Instance
  509. * @retval None
  510. */
  511. __STATIC_INLINE void LL_LPUART_EnableFIFO(USART_TypeDef *LPUARTx)
  512. {
  513. SET_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  514. }
  515. /**
  516. * @brief FIFO Mode Disable
  517. * @rmtoll CR1 FIFOEN LL_LPUART_DisableFIFO
  518. * @param LPUARTx LPUART Instance
  519. * @retval None
  520. */
  521. __STATIC_INLINE void LL_LPUART_DisableFIFO(USART_TypeDef *LPUARTx)
  522. {
  523. CLEAR_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  524. }
  525. /**
  526. * @brief Indicate if FIFO Mode is enabled
  527. * @rmtoll CR1 FIFOEN LL_LPUART_IsEnabledFIFO
  528. * @param LPUARTx LPUART Instance
  529. * @retval State of bit (1 or 0).
  530. */
  531. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledFIFO(const USART_TypeDef *LPUARTx)
  532. {
  533. return ((READ_BIT(LPUARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL);
  534. }
  535. /**
  536. * @brief Configure TX FIFO Threshold
  537. * @rmtoll CR3 TXFTCFG LL_LPUART_SetTXFIFOThreshold
  538. * @param LPUARTx LPUART Instance
  539. * @param Threshold This parameter can be one of the following values:
  540. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  541. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  542. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  543. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  544. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  545. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  546. * @retval None
  547. */
  548. __STATIC_INLINE void LL_LPUART_SetTXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  549. {
  550. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos);
  551. }
  552. /**
  553. * @brief Return TX FIFO Threshold Configuration
  554. * @rmtoll CR3 TXFTCFG LL_LPUART_GetTXFIFOThreshold
  555. * @param LPUARTx LPUART Instance
  556. * @retval Returned value can be one of the following values:
  557. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  558. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  559. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  560. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  561. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  562. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  563. */
  564. __STATIC_INLINE uint32_t LL_LPUART_GetTXFIFOThreshold(const USART_TypeDef *LPUARTx)
  565. {
  566. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
  567. }
  568. /**
  569. * @brief Configure RX FIFO Threshold
  570. * @rmtoll CR3 RXFTCFG LL_LPUART_SetRXFIFOThreshold
  571. * @param LPUARTx LPUART Instance
  572. * @param Threshold This parameter can be one of the following values:
  573. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  574. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  575. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  576. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  577. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  578. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  579. * @retval None
  580. */
  581. __STATIC_INLINE void LL_LPUART_SetRXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  582. {
  583. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos);
  584. }
  585. /**
  586. * @brief Return RX FIFO Threshold Configuration
  587. * @rmtoll CR3 RXFTCFG LL_LPUART_GetRXFIFOThreshold
  588. * @param LPUARTx LPUART Instance
  589. * @retval Returned value can be one of the following values:
  590. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  591. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  592. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  593. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  594. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  595. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  596. */
  597. __STATIC_INLINE uint32_t LL_LPUART_GetRXFIFOThreshold(const USART_TypeDef *LPUARTx)
  598. {
  599. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
  600. }
  601. /**
  602. * @brief Configure TX and RX FIFOs Threshold
  603. * @rmtoll CR3 TXFTCFG LL_LPUART_ConfigFIFOsThreshold\n
  604. * CR3 RXFTCFG LL_LPUART_ConfigFIFOsThreshold
  605. * @param LPUARTx LPUART Instance
  606. * @param TXThreshold This parameter can be one of the following values:
  607. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  608. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  609. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  610. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  611. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  612. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  613. * @param RXThreshold This parameter can be one of the following values:
  614. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  615. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  616. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  617. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  618. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  619. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  620. * @retval None
  621. */
  622. __STATIC_INLINE void LL_LPUART_ConfigFIFOsThreshold(USART_TypeDef *LPUARTx, uint32_t TXThreshold, uint32_t RXThreshold)
  623. {
  624. ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | \
  625. (RXThreshold << USART_CR3_RXFTCFG_Pos));
  626. }
  627. #endif /* USART_CR1_FIFOEN */
  628. /**
  629. * @brief LPUART enabled in STOP Mode
  630. * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that
  631. * LPUART clock selection is HSI or LSE in RCC.
  632. * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode
  633. * @param LPUARTx LPUART Instance
  634. * @retval None
  635. */
  636. __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx)
  637. {
  638. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_UESM);
  639. }
  640. /**
  641. * @brief LPUART disabled in STOP Mode
  642. * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode
  643. * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode
  644. * @param LPUARTx LPUART Instance
  645. * @retval None
  646. */
  647. __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx)
  648. {
  649. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM);
  650. }
  651. /**
  652. * @brief Indicate if LPUART is enabled in STOP Mode
  653. * (able to wake up MCU from Stop mode or not)
  654. * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode
  655. * @param LPUARTx LPUART Instance
  656. * @retval State of bit (1 or 0).
  657. */
  658. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(const USART_TypeDef *LPUARTx)
  659. {
  660. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL);
  661. }
  662. #if defined(USART_CR3_UCESM)
  663. /**
  664. * @brief LPUART Clock enabled in STOP Mode
  665. * @note When this function is called, LPUART Clock is enabled while in STOP mode
  666. * @rmtoll CR3 UCESM LL_LPUART_EnableClockInStopMode
  667. * @param LPUARTx LPUART Instance
  668. * @retval None
  669. */
  670. __STATIC_INLINE void LL_LPUART_EnableClockInStopMode(USART_TypeDef *LPUARTx)
  671. {
  672. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_UCESM);
  673. }
  674. /**
  675. * @brief LPUART clock disabled in STOP Mode
  676. * @note When this function is called, LPUART Clock is disabled while in STOP mode
  677. * @rmtoll CR3 UCESM LL_LPUART_DisableClockInStopMode
  678. * @param LPUARTx LPUART Instance
  679. * @retval None
  680. */
  681. __STATIC_INLINE void LL_LPUART_DisableClockInStopMode(USART_TypeDef *LPUARTx)
  682. {
  683. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_UCESM);
  684. }
  685. /**
  686. * @brief Indicate if LPUART clock is enabled in STOP Mode
  687. * @rmtoll CR3 UCESM LL_LPUART_IsClockEnabledInStopMode
  688. * @param LPUARTx LPUART Instance
  689. * @retval State of bit (1 or 0).
  690. */
  691. __STATIC_INLINE uint32_t LL_LPUART_IsClockEnabledInStopMode(const USART_TypeDef *LPUARTx)
  692. {
  693. return ((READ_BIT(LPUARTx->CR3, USART_CR3_UCESM) == (USART_CR3_UCESM)) ? 1UL : 0UL);
  694. }
  695. #endif /* USART_CR3_UCESM */
  696. /**
  697. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  698. * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx
  699. * @param LPUARTx LPUART Instance
  700. * @retval None
  701. */
  702. __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx)
  703. {
  704. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RE);
  705. }
  706. /**
  707. * @brief Receiver Disable
  708. * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx
  709. * @param LPUARTx LPUART Instance
  710. * @retval None
  711. */
  712. __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx)
  713. {
  714. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE);
  715. }
  716. /**
  717. * @brief Transmitter Enable
  718. * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx
  719. * @param LPUARTx LPUART Instance
  720. * @retval None
  721. */
  722. __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx)
  723. {
  724. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TE);
  725. }
  726. /**
  727. * @brief Transmitter Disable
  728. * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx
  729. * @param LPUARTx LPUART Instance
  730. * @retval None
  731. */
  732. __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx)
  733. {
  734. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE);
  735. }
  736. /**
  737. * @brief Configure simultaneously enabled/disabled states
  738. * of Transmitter and Receiver
  739. * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n
  740. * CR1 TE LL_LPUART_SetTransferDirection
  741. * @param LPUARTx LPUART Instance
  742. * @param TransferDirection This parameter can be one of the following values:
  743. * @arg @ref LL_LPUART_DIRECTION_NONE
  744. * @arg @ref LL_LPUART_DIRECTION_RX
  745. * @arg @ref LL_LPUART_DIRECTION_TX
  746. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  747. * @retval None
  748. */
  749. __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection)
  750. {
  751. ATOMIC_MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  752. }
  753. /**
  754. * @brief Return enabled/disabled states of Transmitter and Receiver
  755. * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n
  756. * CR1 TE LL_LPUART_GetTransferDirection
  757. * @param LPUARTx LPUART Instance
  758. * @retval Returned value can be one of the following values:
  759. * @arg @ref LL_LPUART_DIRECTION_NONE
  760. * @arg @ref LL_LPUART_DIRECTION_RX
  761. * @arg @ref LL_LPUART_DIRECTION_TX
  762. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  763. */
  764. __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(const USART_TypeDef *LPUARTx)
  765. {
  766. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  767. }
  768. /**
  769. * @brief Configure Parity (enabled/disabled and parity mode if enabled)
  770. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  771. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  772. * (depending on data width) and parity is checked on the received data.
  773. * @rmtoll CR1 PS LL_LPUART_SetParity\n
  774. * CR1 PCE LL_LPUART_SetParity
  775. * @param LPUARTx LPUART Instance
  776. * @param Parity This parameter can be one of the following values:
  777. * @arg @ref LL_LPUART_PARITY_NONE
  778. * @arg @ref LL_LPUART_PARITY_EVEN
  779. * @arg @ref LL_LPUART_PARITY_ODD
  780. * @retval None
  781. */
  782. __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity)
  783. {
  784. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  785. }
  786. /**
  787. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  788. * @rmtoll CR1 PS LL_LPUART_GetParity\n
  789. * CR1 PCE LL_LPUART_GetParity
  790. * @param LPUARTx LPUART Instance
  791. * @retval Returned value can be one of the following values:
  792. * @arg @ref LL_LPUART_PARITY_NONE
  793. * @arg @ref LL_LPUART_PARITY_EVEN
  794. * @arg @ref LL_LPUART_PARITY_ODD
  795. */
  796. __STATIC_INLINE uint32_t LL_LPUART_GetParity(const USART_TypeDef *LPUARTx)
  797. {
  798. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  799. }
  800. /**
  801. * @brief Set Receiver Wake Up method from Mute mode.
  802. * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod
  803. * @param LPUARTx LPUART Instance
  804. * @param Method This parameter can be one of the following values:
  805. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  806. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  807. * @retval None
  808. */
  809. __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method)
  810. {
  811. MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method);
  812. }
  813. /**
  814. * @brief Return Receiver Wake Up method from Mute mode
  815. * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod
  816. * @param LPUARTx LPUART Instance
  817. * @retval Returned value can be one of the following values:
  818. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  819. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  820. */
  821. __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(const USART_TypeDef *LPUARTx)
  822. {
  823. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE));
  824. }
  825. /**
  826. * @brief Set Word length (nb of data bits, excluding start and stop bits)
  827. * @rmtoll CR1 M LL_LPUART_SetDataWidth
  828. * @param LPUARTx LPUART Instance
  829. * @param DataWidth This parameter can be one of the following values:
  830. * @arg @ref LL_LPUART_DATAWIDTH_7B
  831. * @arg @ref LL_LPUART_DATAWIDTH_8B
  832. * @arg @ref LL_LPUART_DATAWIDTH_9B
  833. * @retval None
  834. */
  835. __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth)
  836. {
  837. MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth);
  838. }
  839. /**
  840. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  841. * @rmtoll CR1 M LL_LPUART_GetDataWidth
  842. * @param LPUARTx LPUART Instance
  843. * @retval Returned value can be one of the following values:
  844. * @arg @ref LL_LPUART_DATAWIDTH_7B
  845. * @arg @ref LL_LPUART_DATAWIDTH_8B
  846. * @arg @ref LL_LPUART_DATAWIDTH_9B
  847. */
  848. __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(const USART_TypeDef *LPUARTx)
  849. {
  850. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M));
  851. }
  852. /**
  853. * @brief Allow switch between Mute Mode and Active mode
  854. * @rmtoll CR1 MME LL_LPUART_EnableMuteMode
  855. * @param LPUARTx LPUART Instance
  856. * @retval None
  857. */
  858. __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx)
  859. {
  860. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_MME);
  861. }
  862. /**
  863. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  864. * @rmtoll CR1 MME LL_LPUART_DisableMuteMode
  865. * @param LPUARTx LPUART Instance
  866. * @retval None
  867. */
  868. __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx)
  869. {
  870. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME);
  871. }
  872. /**
  873. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  874. * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode
  875. * @param LPUARTx LPUART Instance
  876. * @retval State of bit (1 or 0).
  877. */
  878. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(const USART_TypeDef *LPUARTx)
  879. {
  880. return ((READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL);
  881. }
  882. #if defined(USART_PRESC_PRESCALER)
  883. /**
  884. * @brief Configure Clock source prescaler for baudrate generator and oversampling
  885. * @rmtoll PRESC PRESCALER LL_LPUART_SetPrescaler
  886. * @param LPUARTx LPUART Instance
  887. * @param PrescalerValue This parameter can be one of the following values:
  888. * @arg @ref LL_LPUART_PRESCALER_DIV1
  889. * @arg @ref LL_LPUART_PRESCALER_DIV2
  890. * @arg @ref LL_LPUART_PRESCALER_DIV4
  891. * @arg @ref LL_LPUART_PRESCALER_DIV6
  892. * @arg @ref LL_LPUART_PRESCALER_DIV8
  893. * @arg @ref LL_LPUART_PRESCALER_DIV10
  894. * @arg @ref LL_LPUART_PRESCALER_DIV12
  895. * @arg @ref LL_LPUART_PRESCALER_DIV16
  896. * @arg @ref LL_LPUART_PRESCALER_DIV32
  897. * @arg @ref LL_LPUART_PRESCALER_DIV64
  898. * @arg @ref LL_LPUART_PRESCALER_DIV128
  899. * @arg @ref LL_LPUART_PRESCALER_DIV256
  900. * @retval None
  901. */
  902. __STATIC_INLINE void LL_LPUART_SetPrescaler(USART_TypeDef *LPUARTx, uint32_t PrescalerValue)
  903. {
  904. MODIFY_REG(LPUARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue);
  905. }
  906. /**
  907. * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling
  908. * @rmtoll PRESC PRESCALER LL_LPUART_GetPrescaler
  909. * @param LPUARTx LPUART Instance
  910. * @retval Returned value can be one of the following values:
  911. * @arg @ref LL_LPUART_PRESCALER_DIV1
  912. * @arg @ref LL_LPUART_PRESCALER_DIV2
  913. * @arg @ref LL_LPUART_PRESCALER_DIV4
  914. * @arg @ref LL_LPUART_PRESCALER_DIV6
  915. * @arg @ref LL_LPUART_PRESCALER_DIV8
  916. * @arg @ref LL_LPUART_PRESCALER_DIV10
  917. * @arg @ref LL_LPUART_PRESCALER_DIV12
  918. * @arg @ref LL_LPUART_PRESCALER_DIV16
  919. * @arg @ref LL_LPUART_PRESCALER_DIV32
  920. * @arg @ref LL_LPUART_PRESCALER_DIV64
  921. * @arg @ref LL_LPUART_PRESCALER_DIV128
  922. * @arg @ref LL_LPUART_PRESCALER_DIV256
  923. */
  924. __STATIC_INLINE uint32_t LL_LPUART_GetPrescaler(const USART_TypeDef *LPUARTx)
  925. {
  926. return (uint32_t)(READ_BIT(LPUARTx->PRESC, USART_PRESC_PRESCALER));
  927. }
  928. #endif /* USART_PRESC_PRESCALER */
  929. /**
  930. * @brief Set the length of the stop bits
  931. * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength
  932. * @param LPUARTx LPUART Instance
  933. * @param StopBits This parameter can be one of the following values:
  934. * @arg @ref LL_LPUART_STOPBITS_1
  935. * @arg @ref LL_LPUART_STOPBITS_2
  936. * @retval None
  937. */
  938. __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits)
  939. {
  940. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  941. }
  942. /**
  943. * @brief Retrieve the length of the stop bits
  944. * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength
  945. * @param LPUARTx LPUART Instance
  946. * @retval Returned value can be one of the following values:
  947. * @arg @ref LL_LPUART_STOPBITS_1
  948. * @arg @ref LL_LPUART_STOPBITS_2
  949. */
  950. __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(const USART_TypeDef *LPUARTx)
  951. {
  952. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP));
  953. }
  954. /**
  955. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  956. * @note Call of this function is equivalent to following function call sequence :
  957. * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function
  958. * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function
  959. * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function
  960. * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n
  961. * CR1 PCE LL_LPUART_ConfigCharacter\n
  962. * CR1 M LL_LPUART_ConfigCharacter\n
  963. * CR2 STOP LL_LPUART_ConfigCharacter
  964. * @param LPUARTx LPUART Instance
  965. * @param DataWidth This parameter can be one of the following values:
  966. * @arg @ref LL_LPUART_DATAWIDTH_7B
  967. * @arg @ref LL_LPUART_DATAWIDTH_8B
  968. * @arg @ref LL_LPUART_DATAWIDTH_9B
  969. * @param Parity This parameter can be one of the following values:
  970. * @arg @ref LL_LPUART_PARITY_NONE
  971. * @arg @ref LL_LPUART_PARITY_EVEN
  972. * @arg @ref LL_LPUART_PARITY_ODD
  973. * @param StopBits This parameter can be one of the following values:
  974. * @arg @ref LL_LPUART_STOPBITS_1
  975. * @arg @ref LL_LPUART_STOPBITS_2
  976. * @retval None
  977. */
  978. __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity,
  979. uint32_t StopBits)
  980. {
  981. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  982. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  983. }
  984. /**
  985. * @brief Configure TX/RX pins swapping setting.
  986. * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap
  987. * @param LPUARTx LPUART Instance
  988. * @param SwapConfig This parameter can be one of the following values:
  989. * @arg @ref LL_LPUART_TXRX_STANDARD
  990. * @arg @ref LL_LPUART_TXRX_SWAPPED
  991. * @retval None
  992. */
  993. __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig)
  994. {
  995. MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig);
  996. }
  997. /**
  998. * @brief Retrieve TX/RX pins swapping configuration.
  999. * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap
  1000. * @param LPUARTx LPUART Instance
  1001. * @retval Returned value can be one of the following values:
  1002. * @arg @ref LL_LPUART_TXRX_STANDARD
  1003. * @arg @ref LL_LPUART_TXRX_SWAPPED
  1004. */
  1005. __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(const USART_TypeDef *LPUARTx)
  1006. {
  1007. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP));
  1008. }
  1009. /**
  1010. * @brief Configure RX pin active level logic
  1011. * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel
  1012. * @param LPUARTx LPUART Instance
  1013. * @param PinInvMethod This parameter can be one of the following values:
  1014. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  1015. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  1016. * @retval None
  1017. */
  1018. __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  1019. {
  1020. MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  1021. }
  1022. /**
  1023. * @brief Retrieve RX pin active level logic configuration
  1024. * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel
  1025. * @param LPUARTx LPUART Instance
  1026. * @retval Returned value can be one of the following values:
  1027. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  1028. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  1029. */
  1030. __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(const USART_TypeDef *LPUARTx)
  1031. {
  1032. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV));
  1033. }
  1034. /**
  1035. * @brief Configure TX pin active level logic
  1036. * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel
  1037. * @param LPUARTx LPUART Instance
  1038. * @param PinInvMethod This parameter can be one of the following values:
  1039. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  1040. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  1041. * @retval None
  1042. */
  1043. __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  1044. {
  1045. MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  1046. }
  1047. /**
  1048. * @brief Retrieve TX pin active level logic configuration
  1049. * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel
  1050. * @param LPUARTx LPUART Instance
  1051. * @retval Returned value can be one of the following values:
  1052. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  1053. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  1054. */
  1055. __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(const USART_TypeDef *LPUARTx)
  1056. {
  1057. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV));
  1058. }
  1059. /**
  1060. * @brief Configure Binary data logic.
  1061. *
  1062. * @note Allow to define how Logical data from the data register are send/received :
  1063. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  1064. * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic
  1065. * @param LPUARTx LPUART Instance
  1066. * @param DataLogic This parameter can be one of the following values:
  1067. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  1068. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  1069. * @retval None
  1070. */
  1071. __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic)
  1072. {
  1073. MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic);
  1074. }
  1075. /**
  1076. * @brief Retrieve Binary data configuration
  1077. * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic
  1078. * @param LPUARTx LPUART Instance
  1079. * @retval Returned value can be one of the following values:
  1080. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  1081. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  1082. */
  1083. __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(const USART_TypeDef *LPUARTx)
  1084. {
  1085. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV));
  1086. }
  1087. /**
  1088. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  1089. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1090. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1091. * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder
  1092. * @param LPUARTx LPUART Instance
  1093. * @param BitOrder This parameter can be one of the following values:
  1094. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  1095. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  1096. * @retval None
  1097. */
  1098. __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder)
  1099. {
  1100. MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  1101. }
  1102. /**
  1103. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  1104. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1105. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1106. * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder
  1107. * @param LPUARTx LPUART Instance
  1108. * @retval Returned value can be one of the following values:
  1109. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  1110. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  1111. */
  1112. __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(const USART_TypeDef *LPUARTx)
  1113. {
  1114. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST));
  1115. }
  1116. /**
  1117. * @brief Set Address of the LPUART node.
  1118. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  1119. * for wake up with address mark detection.
  1120. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  1121. * (b7-b4 should be set to 0)
  1122. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  1123. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  1124. * for wake up with 7-bit address mark detection.
  1125. * The MSB of the character sent by the transmitter should be equal to 1.
  1126. * It may also be used for character detection during normal reception,
  1127. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  1128. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  1129. * value and CMF flag is set on match)
  1130. * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n
  1131. * CR2 ADDM7 LL_LPUART_ConfigNodeAddress
  1132. * @param LPUARTx LPUART Instance
  1133. * @param AddressLen This parameter can be one of the following values:
  1134. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1135. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1136. * @param NodeAddress 4 or 7 bit Address of the LPUART node.
  1137. * @retval None
  1138. */
  1139. __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress)
  1140. {
  1141. MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  1142. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  1143. }
  1144. /**
  1145. * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2.
  1146. * @note If 4-bit Address Detection is selected in ADDM7,
  1147. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  1148. * If 7-bit Address Detection is selected in ADDM7,
  1149. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  1150. * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress
  1151. * @param LPUARTx LPUART Instance
  1152. * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255)
  1153. */
  1154. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(const USART_TypeDef *LPUARTx)
  1155. {
  1156. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  1157. }
  1158. /**
  1159. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  1160. * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen
  1161. * @param LPUARTx LPUART Instance
  1162. * @retval Returned value can be one of the following values:
  1163. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1164. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1165. */
  1166. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(const USART_TypeDef *LPUARTx)
  1167. {
  1168. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7));
  1169. }
  1170. /**
  1171. * @brief Enable RTS HW Flow Control
  1172. * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl
  1173. * @param LPUARTx LPUART Instance
  1174. * @retval None
  1175. */
  1176. __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1177. {
  1178. SET_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1179. }
  1180. /**
  1181. * @brief Disable RTS HW Flow Control
  1182. * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl
  1183. * @param LPUARTx LPUART Instance
  1184. * @retval None
  1185. */
  1186. __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1187. {
  1188. CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1189. }
  1190. /**
  1191. * @brief Enable CTS HW Flow Control
  1192. * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl
  1193. * @param LPUARTx LPUART Instance
  1194. * @retval None
  1195. */
  1196. __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1197. {
  1198. SET_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1199. }
  1200. /**
  1201. * @brief Disable CTS HW Flow Control
  1202. * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl
  1203. * @param LPUARTx LPUART Instance
  1204. * @retval None
  1205. */
  1206. __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1207. {
  1208. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1209. }
  1210. /**
  1211. * @brief Configure HW Flow Control mode (both CTS and RTS)
  1212. * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n
  1213. * CR3 CTSE LL_LPUART_SetHWFlowCtrl
  1214. * @param LPUARTx LPUART Instance
  1215. * @param HardwareFlowControl This parameter can be one of the following values:
  1216. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1217. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1218. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1219. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1220. * @retval None
  1221. */
  1222. __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl)
  1223. {
  1224. MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  1225. }
  1226. /**
  1227. * @brief Return HW Flow Control configuration (both CTS and RTS)
  1228. * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n
  1229. * CR3 CTSE LL_LPUART_GetHWFlowCtrl
  1230. * @param LPUARTx LPUART Instance
  1231. * @retval Returned value can be one of the following values:
  1232. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1233. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1234. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1235. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1236. */
  1237. __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(const USART_TypeDef *LPUARTx)
  1238. {
  1239. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  1240. }
  1241. /**
  1242. * @brief Enable Overrun detection
  1243. * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect
  1244. * @param LPUARTx LPUART Instance
  1245. * @retval None
  1246. */
  1247. __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx)
  1248. {
  1249. CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1250. }
  1251. /**
  1252. * @brief Disable Overrun detection
  1253. * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect
  1254. * @param LPUARTx LPUART Instance
  1255. * @retval None
  1256. */
  1257. __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx)
  1258. {
  1259. SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1260. }
  1261. /**
  1262. * @brief Indicate if Overrun detection is enabled
  1263. * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect
  1264. * @param LPUARTx LPUART Instance
  1265. * @retval State of bit (1 or 0).
  1266. */
  1267. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(const USART_TypeDef *LPUARTx)
  1268. {
  1269. return ((READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL);
  1270. }
  1271. /**
  1272. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1273. * @rmtoll CR3 WUS LL_LPUART_SetWKUPType
  1274. * @param LPUARTx LPUART Instance
  1275. * @param Type This parameter can be one of the following values:
  1276. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1277. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1278. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1279. * @retval None
  1280. */
  1281. __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type)
  1282. {
  1283. MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type);
  1284. }
  1285. /**
  1286. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1287. * @rmtoll CR3 WUS LL_LPUART_GetWKUPType
  1288. * @param LPUARTx LPUART Instance
  1289. * @retval Returned value can be one of the following values:
  1290. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1291. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1292. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1293. */
  1294. __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(const USART_TypeDef *LPUARTx)
  1295. {
  1296. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS));
  1297. }
  1298. /**
  1299. * @brief Configure LPUART BRR register for achieving expected Baud Rate value.
  1300. *
  1301. * @note Compute and set LPUARTDIV value in BRR Register (full BRR content)
  1302. * according to used Peripheral Clock and expected Baud Rate values
  1303. * @note Peripheral clock and Baud Rate values provided as function parameters should be valid
  1304. * (Baud rate value != 0).
  1305. * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit,
  1306. * a care should be taken when generating high baud rates using high PeriphClk
  1307. * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate].
  1308. * @rmtoll BRR BRR LL_LPUART_SetBaudRate
  1309. * @param LPUARTx LPUART Instance
  1310. * @param PeriphClk Peripheral Clock
  1311. @if USART_PRESC_PRESCALER
  1312. * @param PrescalerValue This parameter can be one of the following values:
  1313. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1314. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1315. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1316. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1317. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1318. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1319. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1320. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1321. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1322. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1323. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1324. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1325. @endif
  1326. * @param BaudRate Baud Rate
  1327. * @retval None
  1328. */
  1329. #if defined(USART_PRESC_PRESCALER)
  1330. __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
  1331. uint32_t BaudRate)
  1332. #else
  1333. __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t BaudRate)
  1334. #endif /* USART_PRESC_PRESCALER */
  1335. {
  1336. #if defined(USART_PRESC_PRESCALER)
  1337. if (BaudRate != 0U)
  1338. {
  1339. LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, PrescalerValue, BaudRate);
  1340. }
  1341. #else
  1342. if (BaudRate != 0U)
  1343. {
  1344. LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, BaudRate);
  1345. }
  1346. #endif /* USART_PRESC_PRESCALER */
  1347. }
  1348. /**
  1349. * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register
  1350. * (full BRR content), and to used Peripheral Clock values
  1351. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  1352. * @rmtoll BRR BRR LL_LPUART_GetBaudRate
  1353. * @param LPUARTx LPUART Instance
  1354. * @param PeriphClk Peripheral Clock
  1355. @if USART_PRESC_PRESCALER
  1356. * @param PrescalerValue This parameter can be one of the following values:
  1357. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1358. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1359. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1360. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1361. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1362. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1363. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1364. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1365. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1366. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1367. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1368. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1369. @endif
  1370. * @retval Baud Rate
  1371. */
  1372. #if defined(USART_PRESC_PRESCALER)
  1373. __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(const USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue)
  1374. #else
  1375. __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(const USART_TypeDef *LPUARTx, uint32_t PeriphClk)
  1376. #endif /* USART_PRESC_PRESCALER */
  1377. {
  1378. uint32_t lpuartdiv;
  1379. uint32_t brrresult;
  1380. #if defined(USART_PRESC_PRESCALER)
  1381. uint32_t periphclkpresc = (uint32_t)(PeriphClk / (LPUART_PRESCALER_TAB[(uint16_t)PrescalerValue]));
  1382. #endif /* USART_PRESC_PRESCALER */
  1383. lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK;
  1384. if (lpuartdiv >= LPUART_BRR_MIN_VALUE)
  1385. {
  1386. #if defined(USART_PRESC_PRESCALER)
  1387. brrresult = (uint32_t)(((uint64_t)(periphclkpresc) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv);
  1388. #else
  1389. brrresult = (uint32_t)(((uint64_t)(PeriphClk) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv);
  1390. #endif /* USART_PRESC_PRESCALER */
  1391. }
  1392. else
  1393. {
  1394. brrresult = 0x0UL;
  1395. }
  1396. return (brrresult);
  1397. }
  1398. /**
  1399. * @}
  1400. */
  1401. /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1402. * @{
  1403. */
  1404. /**
  1405. * @brief Enable Single Wire Half-Duplex mode
  1406. * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex
  1407. * @param LPUARTx LPUART Instance
  1408. * @retval None
  1409. */
  1410. __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx)
  1411. {
  1412. SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1413. }
  1414. /**
  1415. * @brief Disable Single Wire Half-Duplex mode
  1416. * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex
  1417. * @param LPUARTx LPUART Instance
  1418. * @retval None
  1419. */
  1420. __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx)
  1421. {
  1422. CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1423. }
  1424. /**
  1425. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1426. * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex
  1427. * @param LPUARTx LPUART Instance
  1428. * @retval State of bit (1 or 0).
  1429. */
  1430. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(const USART_TypeDef *LPUARTx)
  1431. {
  1432. return ((READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL);
  1433. }
  1434. /**
  1435. * @}
  1436. */
  1437. /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1438. * @{
  1439. */
  1440. /**
  1441. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1442. * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime
  1443. * @param LPUARTx LPUART Instance
  1444. * @param Time Value between Min_Data=0 and Max_Data=31
  1445. * @retval None
  1446. */
  1447. __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1448. {
  1449. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1450. }
  1451. /**
  1452. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1453. * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime
  1454. * @param LPUARTx LPUART Instance
  1455. * @retval Time value expressed on 5 bits ([4:0] bits) : c
  1456. */
  1457. __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(const USART_TypeDef *LPUARTx)
  1458. {
  1459. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1460. }
  1461. /**
  1462. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1463. * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime
  1464. * @param LPUARTx LPUART Instance
  1465. * @param Time Value between Min_Data=0 and Max_Data=31
  1466. * @retval None
  1467. */
  1468. __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1469. {
  1470. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1471. }
  1472. /**
  1473. * @brief Return DEAT (Driver Enable Assertion Time)
  1474. * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime
  1475. * @param LPUARTx LPUART Instance
  1476. * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31
  1477. */
  1478. __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(const USART_TypeDef *LPUARTx)
  1479. {
  1480. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  1481. }
  1482. /**
  1483. * @brief Enable Driver Enable (DE) Mode
  1484. * @rmtoll CR3 DEM LL_LPUART_EnableDEMode
  1485. * @param LPUARTx LPUART Instance
  1486. * @retval None
  1487. */
  1488. __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx)
  1489. {
  1490. SET_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1491. }
  1492. /**
  1493. * @brief Disable Driver Enable (DE) Mode
  1494. * @rmtoll CR3 DEM LL_LPUART_DisableDEMode
  1495. * @param LPUARTx LPUART Instance
  1496. * @retval None
  1497. */
  1498. __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx)
  1499. {
  1500. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1501. }
  1502. /**
  1503. * @brief Indicate if Driver Enable (DE) Mode is enabled
  1504. * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode
  1505. * @param LPUARTx LPUART Instance
  1506. * @retval State of bit (1 or 0).
  1507. */
  1508. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(const USART_TypeDef *LPUARTx)
  1509. {
  1510. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL);
  1511. }
  1512. /**
  1513. * @brief Select Driver Enable Polarity
  1514. * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity
  1515. * @param LPUARTx LPUART Instance
  1516. * @param Polarity This parameter can be one of the following values:
  1517. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1518. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1519. * @retval None
  1520. */
  1521. __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity)
  1522. {
  1523. MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity);
  1524. }
  1525. /**
  1526. * @brief Return Driver Enable Polarity
  1527. * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity
  1528. * @param LPUARTx LPUART Instance
  1529. * @retval Returned value can be one of the following values:
  1530. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1531. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1532. */
  1533. __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(const USART_TypeDef *LPUARTx)
  1534. {
  1535. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP));
  1536. }
  1537. /**
  1538. * @}
  1539. */
  1540. /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management
  1541. * @{
  1542. */
  1543. /**
  1544. * @brief Check if the LPUART Parity Error Flag is set or not
  1545. * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE
  1546. * @param LPUARTx LPUART Instance
  1547. * @retval State of bit (1 or 0).
  1548. */
  1549. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(const USART_TypeDef *LPUARTx)
  1550. {
  1551. return ((READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL);
  1552. }
  1553. /**
  1554. * @brief Check if the LPUART Framing Error Flag is set or not
  1555. * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE
  1556. * @param LPUARTx LPUART Instance
  1557. * @retval State of bit (1 or 0).
  1558. */
  1559. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(const USART_TypeDef *LPUARTx)
  1560. {
  1561. return ((READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL);
  1562. }
  1563. /**
  1564. * @brief Check if the LPUART Noise error detected Flag is set or not
  1565. * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE
  1566. * @param LPUARTx LPUART Instance
  1567. * @retval State of bit (1 or 0).
  1568. */
  1569. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(const USART_TypeDef *LPUARTx)
  1570. {
  1571. return ((READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL);
  1572. }
  1573. /**
  1574. * @brief Check if the LPUART OverRun Error Flag is set or not
  1575. * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE
  1576. * @param LPUARTx LPUART Instance
  1577. * @retval State of bit (1 or 0).
  1578. */
  1579. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(const USART_TypeDef *LPUARTx)
  1580. {
  1581. return ((READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL);
  1582. }
  1583. /**
  1584. * @brief Check if the LPUART IDLE line detected Flag is set or not
  1585. * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE
  1586. * @param LPUARTx LPUART Instance
  1587. * @retval State of bit (1 or 0).
  1588. */
  1589. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(const USART_TypeDef *LPUARTx)
  1590. {
  1591. return ((READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL);
  1592. }
  1593. #if defined(USART_CR1_FIFOEN)
  1594. /* Legacy define */
  1595. #define LL_LPUART_IsActiveFlag_RXNE LL_LPUART_IsActiveFlag_RXNE_RXFNE
  1596. /**
  1597. * @brief Check if the LPUART Read Data Register or LPUART RX FIFO Not Empty Flag is set or not
  1598. * @rmtoll ISR RXNE_RXFNE LL_LPUART_IsActiveFlag_RXNE_RXFNE
  1599. * @param LPUARTx LPUART Instance
  1600. * @retval State of bit (1 or 0).
  1601. */
  1602. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE_RXFNE(const USART_TypeDef *LPUARTx)
  1603. {
  1604. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL);
  1605. }
  1606. #else
  1607. /**
  1608. * @brief Check if the LPUART Read Data Register Not Empty Flag is set or not
  1609. * @rmtoll ISR RXNE LL_LPUART_IsActiveFlag_RXNE
  1610. * @param LPUARTx LPUART Instance
  1611. * @retval State of bit (1 or 0).
  1612. */
  1613. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE(const USART_TypeDef *LPUARTx)
  1614. {
  1615. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE)) ? 1UL : 0UL);
  1616. }
  1617. #endif /* USART_CR1_FIFOEN */
  1618. /**
  1619. * @brief Check if the LPUART Transmission Complete Flag is set or not
  1620. * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC
  1621. * @param LPUARTx LPUART Instance
  1622. * @retval State of bit (1 or 0).
  1623. */
  1624. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(const USART_TypeDef *LPUARTx)
  1625. {
  1626. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL);
  1627. }
  1628. #if defined(USART_CR1_FIFOEN)
  1629. /* Legacy define */
  1630. #define LL_LPUART_IsActiveFlag_TXE LL_LPUART_IsActiveFlag_TXE_TXFNF
  1631. /**
  1632. * @brief Check if the LPUART Transmit Data Register Empty or LPUART TX FIFO Not Full Flag is set or not
  1633. * @rmtoll ISR TXE_TXFNF LL_LPUART_IsActiveFlag_TXE_TXFNF
  1634. * @param LPUARTx LPUART Instance
  1635. * @retval State of bit (1 or 0).
  1636. */
  1637. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE_TXFNF(const USART_TypeDef *LPUARTx)
  1638. {
  1639. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL);
  1640. }
  1641. #else
  1642. /**
  1643. * @brief Check if the LPUART Transmit Data Register Empty Flag is set or not
  1644. * @rmtoll ISR TXE LL_LPUART_IsActiveFlag_TXE
  1645. * @param LPUARTx LPUART Instance
  1646. * @retval State of bit (1 or 0).
  1647. */
  1648. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE(const USART_TypeDef *LPUARTx)
  1649. {
  1650. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE)) ? 1UL : 0UL);
  1651. }
  1652. #endif /* USART_CR1_FIFOEN */
  1653. /**
  1654. * @brief Check if the LPUART CTS interrupt Flag is set or not
  1655. * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS
  1656. * @param LPUARTx LPUART Instance
  1657. * @retval State of bit (1 or 0).
  1658. */
  1659. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(const USART_TypeDef *LPUARTx)
  1660. {
  1661. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL);
  1662. }
  1663. /**
  1664. * @brief Check if the LPUART CTS Flag is set or not
  1665. * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS
  1666. * @param LPUARTx LPUART Instance
  1667. * @retval State of bit (1 or 0).
  1668. */
  1669. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(const USART_TypeDef *LPUARTx)
  1670. {
  1671. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL);
  1672. }
  1673. /**
  1674. * @brief Check if the LPUART Busy Flag is set or not
  1675. * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY
  1676. * @param LPUARTx LPUART Instance
  1677. * @retval State of bit (1 or 0).
  1678. */
  1679. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(const USART_TypeDef *LPUARTx)
  1680. {
  1681. return ((READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL);
  1682. }
  1683. /**
  1684. * @brief Check if the LPUART Character Match Flag is set or not
  1685. * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM
  1686. * @param LPUARTx LPUART Instance
  1687. * @retval State of bit (1 or 0).
  1688. */
  1689. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(const USART_TypeDef *LPUARTx)
  1690. {
  1691. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL);
  1692. }
  1693. /**
  1694. * @brief Check if the LPUART Send Break Flag is set or not
  1695. * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK
  1696. * @param LPUARTx LPUART Instance
  1697. * @retval State of bit (1 or 0).
  1698. */
  1699. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(const USART_TypeDef *LPUARTx)
  1700. {
  1701. return ((READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL);
  1702. }
  1703. /**
  1704. * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not
  1705. * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU
  1706. * @param LPUARTx LPUART Instance
  1707. * @retval State of bit (1 or 0).
  1708. */
  1709. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(const USART_TypeDef *LPUARTx)
  1710. {
  1711. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL);
  1712. }
  1713. /**
  1714. * @brief Check if the LPUART Wake Up from stop mode Flag is set or not
  1715. * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP
  1716. * @param LPUARTx LPUART Instance
  1717. * @retval State of bit (1 or 0).
  1718. */
  1719. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(const USART_TypeDef *LPUARTx)
  1720. {
  1721. return ((READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL);
  1722. }
  1723. /**
  1724. * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not
  1725. * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK
  1726. * @param LPUARTx LPUART Instance
  1727. * @retval State of bit (1 or 0).
  1728. */
  1729. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(const USART_TypeDef *LPUARTx)
  1730. {
  1731. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL);
  1732. }
  1733. /**
  1734. * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not
  1735. * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK
  1736. * @param LPUARTx LPUART Instance
  1737. * @retval State of bit (1 or 0).
  1738. */
  1739. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(const USART_TypeDef *LPUARTx)
  1740. {
  1741. return ((READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL);
  1742. }
  1743. #if defined(USART_CR1_FIFOEN)
  1744. /**
  1745. * @brief Check if the LPUART TX FIFO Empty Flag is set or not
  1746. * @rmtoll ISR TXFE LL_LPUART_IsActiveFlag_TXFE
  1747. * @param LPUARTx LPUART Instance
  1748. * @retval State of bit (1 or 0).
  1749. */
  1750. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFE(const USART_TypeDef *LPUARTx)
  1751. {
  1752. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL);
  1753. }
  1754. /**
  1755. * @brief Check if the LPUART RX FIFO Full Flag is set or not
  1756. * @rmtoll ISR RXFF LL_LPUART_IsActiveFlag_RXFF
  1757. * @param LPUARTx LPUART Instance
  1758. * @retval State of bit (1 or 0).
  1759. */
  1760. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFF(const USART_TypeDef *LPUARTx)
  1761. {
  1762. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL);
  1763. }
  1764. /**
  1765. * @brief Check if the LPUART TX FIFO Threshold Flag is set or not
  1766. * @rmtoll ISR TXFT LL_LPUART_IsActiveFlag_TXFT
  1767. * @param LPUARTx LPUART Instance
  1768. * @retval State of bit (1 or 0).
  1769. */
  1770. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFT(const USART_TypeDef *LPUARTx)
  1771. {
  1772. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL);
  1773. }
  1774. /**
  1775. * @brief Check if the LPUART RX FIFO Threshold Flag is set or not
  1776. * @rmtoll ISR RXFT LL_LPUART_IsActiveFlag_RXFT
  1777. * @param LPUARTx LPUART Instance
  1778. * @retval State of bit (1 or 0).
  1779. */
  1780. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFT(const USART_TypeDef *LPUARTx)
  1781. {
  1782. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL);
  1783. }
  1784. #endif /* USART_CR1_FIFOEN */
  1785. /**
  1786. * @brief Clear Parity Error Flag
  1787. * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE
  1788. * @param LPUARTx LPUART Instance
  1789. * @retval None
  1790. */
  1791. __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx)
  1792. {
  1793. WRITE_REG(LPUARTx->ICR, USART_ICR_PECF);
  1794. }
  1795. /**
  1796. * @brief Clear Framing Error Flag
  1797. * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE
  1798. * @param LPUARTx LPUART Instance
  1799. * @retval None
  1800. */
  1801. __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx)
  1802. {
  1803. WRITE_REG(LPUARTx->ICR, USART_ICR_FECF);
  1804. }
  1805. /**
  1806. * @brief Clear Noise detected Flag
  1807. * @rmtoll ICR NECF LL_LPUART_ClearFlag_NE
  1808. * @param LPUARTx LPUART Instance
  1809. * @retval None
  1810. */
  1811. __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx)
  1812. {
  1813. WRITE_REG(LPUARTx->ICR, USART_ICR_NECF);
  1814. }
  1815. /**
  1816. * @brief Clear OverRun Error Flag
  1817. * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE
  1818. * @param LPUARTx LPUART Instance
  1819. * @retval None
  1820. */
  1821. __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx)
  1822. {
  1823. WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF);
  1824. }
  1825. /**
  1826. * @brief Clear IDLE line detected Flag
  1827. * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE
  1828. * @param LPUARTx LPUART Instance
  1829. * @retval None
  1830. */
  1831. __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx)
  1832. {
  1833. WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF);
  1834. }
  1835. /**
  1836. * @brief Clear Transmission Complete Flag
  1837. * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC
  1838. * @param LPUARTx LPUART Instance
  1839. * @retval None
  1840. */
  1841. __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx)
  1842. {
  1843. WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF);
  1844. }
  1845. /**
  1846. * @brief Clear CTS Interrupt Flag
  1847. * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS
  1848. * @param LPUARTx LPUART Instance
  1849. * @retval None
  1850. */
  1851. __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx)
  1852. {
  1853. WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF);
  1854. }
  1855. /**
  1856. * @brief Clear Character Match Flag
  1857. * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM
  1858. * @param LPUARTx LPUART Instance
  1859. * @retval None
  1860. */
  1861. __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx)
  1862. {
  1863. WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF);
  1864. }
  1865. /**
  1866. * @brief Clear Wake Up from stop mode Flag
  1867. * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP
  1868. * @param LPUARTx LPUART Instance
  1869. * @retval None
  1870. */
  1871. __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx)
  1872. {
  1873. WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF);
  1874. }
  1875. /**
  1876. * @}
  1877. */
  1878. /** @defgroup LPUART_LL_EF_IT_Management IT_Management
  1879. * @{
  1880. */
  1881. /**
  1882. * @brief Enable IDLE Interrupt
  1883. * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE
  1884. * @param LPUARTx LPUART Instance
  1885. * @retval None
  1886. */
  1887. __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx)
  1888. {
  1889. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1890. }
  1891. #if defined(USART_CR1_FIFOEN)
  1892. /* Legacy define */
  1893. #define LL_LPUART_EnableIT_RXNE LL_LPUART_EnableIT_RXNE_RXFNE
  1894. /**
  1895. * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt
  1896. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_EnableIT_RXNE_RXFNE
  1897. * @param LPUARTx LPUART Instance
  1898. * @retval None
  1899. */
  1900. __STATIC_INLINE void LL_LPUART_EnableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1901. {
  1902. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  1903. }
  1904. #else
  1905. /**
  1906. * @brief Enable RX Not Empty Interrupt
  1907. * @rmtoll CR1 RXNEIE LL_LPUART_EnableIT_RXNE
  1908. * @param LPUARTx LPUART Instance
  1909. * @retval None
  1910. */
  1911. __STATIC_INLINE void LL_LPUART_EnableIT_RXNE(USART_TypeDef *LPUARTx)
  1912. {
  1913. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE);
  1914. }
  1915. #endif /* USART_CR1_FIFOEN */
  1916. /**
  1917. * @brief Enable Transmission Complete Interrupt
  1918. * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC
  1919. * @param LPUARTx LPUART Instance
  1920. * @retval None
  1921. */
  1922. __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx)
  1923. {
  1924. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1925. }
  1926. #if defined(USART_CR1_FIFOEN)
  1927. /* Legacy define */
  1928. #define LL_LPUART_EnableIT_TXE LL_LPUART_EnableIT_TXE_TXFNF
  1929. /**
  1930. * @brief Enable TX Empty and TX FIFO Not Full Interrupt
  1931. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_EnableIT_TXE_TXFNF
  1932. * @param LPUARTx LPUART Instance
  1933. * @retval None
  1934. */
  1935. __STATIC_INLINE void LL_LPUART_EnableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1936. {
  1937. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  1938. }
  1939. #else
  1940. /**
  1941. * @brief Enable TX Empty Interrupt
  1942. * @rmtoll CR1 TXEIE LL_LPUART_EnableIT_TXE
  1943. * @param LPUARTx LPUART Instance
  1944. * @retval None
  1945. */
  1946. __STATIC_INLINE void LL_LPUART_EnableIT_TXE(USART_TypeDef *LPUARTx)
  1947. {
  1948. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE);
  1949. }
  1950. #endif /* USART_CR1_FIFOEN */
  1951. /**
  1952. * @brief Enable Parity Error Interrupt
  1953. * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE
  1954. * @param LPUARTx LPUART Instance
  1955. * @retval None
  1956. */
  1957. __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx)
  1958. {
  1959. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1960. }
  1961. /**
  1962. * @brief Enable Character Match Interrupt
  1963. * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM
  1964. * @param LPUARTx LPUART Instance
  1965. * @retval None
  1966. */
  1967. __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx)
  1968. {
  1969. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1970. }
  1971. #if defined(USART_CR1_FIFOEN)
  1972. /**
  1973. * @brief Enable TX FIFO Empty Interrupt
  1974. * @rmtoll CR1 TXFEIE LL_LPUART_EnableIT_TXFE
  1975. * @param LPUARTx LPUART Instance
  1976. * @retval None
  1977. */
  1978. __STATIC_INLINE void LL_LPUART_EnableIT_TXFE(USART_TypeDef *LPUARTx)
  1979. {
  1980. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  1981. }
  1982. /**
  1983. * @brief Enable RX FIFO Full Interrupt
  1984. * @rmtoll CR1 RXFFIE LL_LPUART_EnableIT_RXFF
  1985. * @param LPUARTx LPUART Instance
  1986. * @retval None
  1987. */
  1988. __STATIC_INLINE void LL_LPUART_EnableIT_RXFF(USART_TypeDef *LPUARTx)
  1989. {
  1990. ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  1991. }
  1992. #endif /* USART_CR1_FIFOEN */
  1993. /**
  1994. * @brief Enable Error Interrupt
  1995. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1996. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1997. * - 0: Interrupt is inhibited
  1998. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1999. * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR
  2000. * @param LPUARTx LPUART Instance
  2001. * @retval None
  2002. */
  2003. __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx)
  2004. {
  2005. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_EIE);
  2006. }
  2007. /**
  2008. * @brief Enable CTS Interrupt
  2009. * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS
  2010. * @param LPUARTx LPUART Instance
  2011. * @retval None
  2012. */
  2013. __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx)
  2014. {
  2015. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  2016. }
  2017. /**
  2018. * @brief Enable Wake Up from Stop Mode Interrupt
  2019. * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP
  2020. * @param LPUARTx LPUART Instance
  2021. * @retval None
  2022. */
  2023. __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx)
  2024. {
  2025. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  2026. }
  2027. #if defined(USART_CR1_FIFOEN)
  2028. /**
  2029. * @brief Enable TX FIFO Threshold Interrupt
  2030. * @rmtoll CR3 TXFTIE LL_LPUART_EnableIT_TXFT
  2031. * @param LPUARTx LPUART Instance
  2032. * @retval None
  2033. */
  2034. __STATIC_INLINE void LL_LPUART_EnableIT_TXFT(USART_TypeDef *LPUARTx)
  2035. {
  2036. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  2037. }
  2038. /**
  2039. * @brief Enable RX FIFO Threshold Interrupt
  2040. * @rmtoll CR3 RXFTIE LL_LPUART_EnableIT_RXFT
  2041. * @param LPUARTx LPUART Instance
  2042. * @retval None
  2043. */
  2044. __STATIC_INLINE void LL_LPUART_EnableIT_RXFT(USART_TypeDef *LPUARTx)
  2045. {
  2046. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  2047. }
  2048. #endif /* USART_CR1_FIFOEN */
  2049. /**
  2050. * @brief Disable IDLE Interrupt
  2051. * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE
  2052. * @param LPUARTx LPUART Instance
  2053. * @retval None
  2054. */
  2055. __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx)
  2056. {
  2057. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  2058. }
  2059. #if defined(USART_CR1_FIFOEN)
  2060. /* Legacy define */
  2061. #define LL_LPUART_DisableIT_RXNE LL_LPUART_DisableIT_RXNE_RXFNE
  2062. /**
  2063. * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt
  2064. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_DisableIT_RXNE_RXFNE
  2065. * @param LPUARTx LPUART Instance
  2066. * @retval None
  2067. */
  2068. __STATIC_INLINE void LL_LPUART_DisableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  2069. {
  2070. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  2071. }
  2072. #else
  2073. /**
  2074. * @brief Disable RX Not Empty Interrupt
  2075. * @rmtoll CR1 RXNEIE LL_LPUART_DisableIT_RXNE
  2076. * @param LPUARTx LPUART Instance
  2077. * @retval None
  2078. */
  2079. __STATIC_INLINE void LL_LPUART_DisableIT_RXNE(USART_TypeDef *LPUARTx)
  2080. {
  2081. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE);
  2082. }
  2083. #endif /* USART_CR1_FIFOEN */
  2084. /**
  2085. * @brief Disable Transmission Complete Interrupt
  2086. * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC
  2087. * @param LPUARTx LPUART Instance
  2088. * @retval None
  2089. */
  2090. __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx)
  2091. {
  2092. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  2093. }
  2094. #if defined(USART_CR1_FIFOEN)
  2095. /* Legacy define */
  2096. #define LL_LPUART_DisableIT_TXE LL_LPUART_DisableIT_TXE_TXFNF
  2097. /**
  2098. * @brief Disable TX Empty and TX FIFO Not Full Interrupt
  2099. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_DisableIT_TXE_TXFNF
  2100. * @param LPUARTx LPUART Instance
  2101. * @retval None
  2102. */
  2103. __STATIC_INLINE void LL_LPUART_DisableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  2104. {
  2105. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  2106. }
  2107. #else
  2108. /**
  2109. * @brief Disable TX Empty Interrupt
  2110. * @rmtoll CR1 TXEIE LL_LPUART_DisableIT_TXE
  2111. * @param LPUARTx LPUART Instance
  2112. * @retval None
  2113. */
  2114. __STATIC_INLINE void LL_LPUART_DisableIT_TXE(USART_TypeDef *LPUARTx)
  2115. {
  2116. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE);
  2117. }
  2118. #endif /* USART_CR1_FIFOEN */
  2119. /**
  2120. * @brief Disable Parity Error Interrupt
  2121. * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE
  2122. * @param LPUARTx LPUART Instance
  2123. * @retval None
  2124. */
  2125. __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx)
  2126. {
  2127. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  2128. }
  2129. /**
  2130. * @brief Disable Character Match Interrupt
  2131. * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM
  2132. * @param LPUARTx LPUART Instance
  2133. * @retval None
  2134. */
  2135. __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx)
  2136. {
  2137. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  2138. }
  2139. #if defined(USART_CR1_FIFOEN)
  2140. /**
  2141. * @brief Disable TX FIFO Empty Interrupt
  2142. * @rmtoll CR1 TXFEIE LL_LPUART_DisableIT_TXFE
  2143. * @param LPUARTx LPUART Instance
  2144. * @retval None
  2145. */
  2146. __STATIC_INLINE void LL_LPUART_DisableIT_TXFE(USART_TypeDef *LPUARTx)
  2147. {
  2148. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  2149. }
  2150. /**
  2151. * @brief Disable RX FIFO Full Interrupt
  2152. * @rmtoll CR1 RXFFIE LL_LPUART_DisableIT_RXFF
  2153. * @param LPUARTx LPUART Instance
  2154. * @retval None
  2155. */
  2156. __STATIC_INLINE void LL_LPUART_DisableIT_RXFF(USART_TypeDef *LPUARTx)
  2157. {
  2158. ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  2159. }
  2160. #endif /* USART_CR1_FIFOEN */
  2161. /**
  2162. * @brief Disable Error Interrupt
  2163. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  2164. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  2165. * - 0: Interrupt is inhibited
  2166. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  2167. * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR
  2168. * @param LPUARTx LPUART Instance
  2169. * @retval None
  2170. */
  2171. __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx)
  2172. {
  2173. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE);
  2174. }
  2175. /**
  2176. * @brief Disable CTS Interrupt
  2177. * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS
  2178. * @param LPUARTx LPUART Instance
  2179. * @retval None
  2180. */
  2181. __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx)
  2182. {
  2183. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  2184. }
  2185. /**
  2186. * @brief Disable Wake Up from Stop Mode Interrupt
  2187. * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP
  2188. * @param LPUARTx LPUART Instance
  2189. * @retval None
  2190. */
  2191. __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx)
  2192. {
  2193. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  2194. }
  2195. #if defined(USART_CR1_FIFOEN)
  2196. /**
  2197. * @brief Disable TX FIFO Threshold Interrupt
  2198. * @rmtoll CR3 TXFTIE LL_LPUART_DisableIT_TXFT
  2199. * @param LPUARTx LPUART Instance
  2200. * @retval None
  2201. */
  2202. __STATIC_INLINE void LL_LPUART_DisableIT_TXFT(USART_TypeDef *LPUARTx)
  2203. {
  2204. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  2205. }
  2206. /**
  2207. * @brief Disable RX FIFO Threshold Interrupt
  2208. * @rmtoll CR3 RXFTIE LL_LPUART_DisableIT_RXFT
  2209. * @param LPUARTx LPUART Instance
  2210. * @retval None
  2211. */
  2212. __STATIC_INLINE void LL_LPUART_DisableIT_RXFT(USART_TypeDef *LPUARTx)
  2213. {
  2214. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  2215. }
  2216. #endif /* USART_CR1_FIFOEN */
  2217. /**
  2218. * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled.
  2219. * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE
  2220. * @param LPUARTx LPUART Instance
  2221. * @retval State of bit (1 or 0).
  2222. */
  2223. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(const USART_TypeDef *LPUARTx)
  2224. {
  2225. return ((READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL);
  2226. }
  2227. #if defined(USART_CR1_FIFOEN)
  2228. /* Legacy define */
  2229. #define LL_LPUART_IsEnabledIT_RXNE LL_LPUART_IsEnabledIT_RXNE_RXFNE
  2230. /**
  2231. * @brief Check if the LPUART RX Not Empty and LPUART RX FIFO Not Empty Interrupt is enabled or disabled.
  2232. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_IsEnabledIT_RXNE_RXFNE
  2233. * @param LPUARTx LPUART Instance
  2234. * @retval State of bit (1 or 0).
  2235. */
  2236. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE_RXFNE(const USART_TypeDef *LPUARTx)
  2237. {
  2238. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL);
  2239. }
  2240. #else
  2241. /**
  2242. * @brief Check if the LPUART RX Not Empty Interrupt is enabled or disabled.
  2243. * @rmtoll CR1 RXNEIE LL_LPUART_IsEnabledIT_RXNE
  2244. * @param LPUARTx LPUART Instance
  2245. * @retval State of bit (1 or 0).
  2246. */
  2247. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE(const USART_TypeDef *LPUARTx)
  2248. {
  2249. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)) ? 1UL : 0UL);
  2250. }
  2251. #endif /* USART_CR1_FIFOEN */
  2252. /**
  2253. * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled.
  2254. * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC
  2255. * @param LPUARTx LPUART Instance
  2256. * @retval State of bit (1 or 0).
  2257. */
  2258. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(const USART_TypeDef *LPUARTx)
  2259. {
  2260. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL);
  2261. }
  2262. #if defined(USART_CR1_FIFOEN)
  2263. /* Legacy define */
  2264. #define LL_LPUART_IsEnabledIT_TXE LL_LPUART_IsEnabledIT_TXE_TXFNF
  2265. /**
  2266. * @brief Check if the LPUART TX Empty and LPUART TX FIFO Not Full Interrupt is enabled or disabled
  2267. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_IsEnabledIT_TXE_TXFNF
  2268. * @param LPUARTx LPUART Instance
  2269. * @retval State of bit (1 or 0).
  2270. */
  2271. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE_TXFNF(const USART_TypeDef *LPUARTx)
  2272. {
  2273. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL);
  2274. }
  2275. #else
  2276. /**
  2277. * @brief Check if the LPUART TX Empty Interrupt is enabled or disabled.
  2278. * @rmtoll CR1 TXEIE LL_LPUART_IsEnabledIT_TXE
  2279. * @param LPUARTx LPUART Instance
  2280. * @retval State of bit (1 or 0).
  2281. */
  2282. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE(const USART_TypeDef *LPUARTx)
  2283. {
  2284. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)) ? 1UL : 0UL);
  2285. }
  2286. #endif /* USART_CR1_FIFOEN */
  2287. /**
  2288. * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled.
  2289. * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE
  2290. * @param LPUARTx LPUART Instance
  2291. * @retval State of bit (1 or 0).
  2292. */
  2293. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(const USART_TypeDef *LPUARTx)
  2294. {
  2295. return ((READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL);
  2296. }
  2297. /**
  2298. * @brief Check if the LPUART Character Match Interrupt is enabled or disabled.
  2299. * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM
  2300. * @param LPUARTx LPUART Instance
  2301. * @retval State of bit (1 or 0).
  2302. */
  2303. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(const USART_TypeDef *LPUARTx)
  2304. {
  2305. return ((READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL);
  2306. }
  2307. #if defined(USART_CR1_FIFOEN)
  2308. /**
  2309. * @brief Check if the LPUART TX FIFO Empty Interrupt is enabled or disabled
  2310. * @rmtoll CR1 TXFEIE LL_LPUART_IsEnabledIT_TXFE
  2311. * @param LPUARTx LPUART Instance
  2312. * @retval State of bit (1 or 0).
  2313. */
  2314. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFE(const USART_TypeDef *LPUARTx)
  2315. {
  2316. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL);
  2317. }
  2318. /**
  2319. * @brief Check if the LPUART RX FIFO Full Interrupt is enabled or disabled
  2320. * @rmtoll CR1 RXFFIE LL_LPUART_IsEnabledIT_RXFF
  2321. * @param LPUARTx LPUART Instance
  2322. * @retval State of bit (1 or 0).
  2323. */
  2324. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFF(const USART_TypeDef *LPUARTx)
  2325. {
  2326. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL);
  2327. }
  2328. #endif /* USART_CR1_FIFOEN */
  2329. /**
  2330. * @brief Check if the LPUART Error Interrupt is enabled or disabled.
  2331. * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR
  2332. * @param LPUARTx LPUART Instance
  2333. * @retval State of bit (1 or 0).
  2334. */
  2335. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(const USART_TypeDef *LPUARTx)
  2336. {
  2337. return ((READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL);
  2338. }
  2339. /**
  2340. * @brief Check if the LPUART CTS Interrupt is enabled or disabled.
  2341. * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS
  2342. * @param LPUARTx LPUART Instance
  2343. * @retval State of bit (1 or 0).
  2344. */
  2345. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(const USART_TypeDef *LPUARTx)
  2346. {
  2347. return ((READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL);
  2348. }
  2349. /**
  2350. * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled.
  2351. * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP
  2352. * @param LPUARTx LPUART Instance
  2353. * @retval State of bit (1 or 0).
  2354. */
  2355. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(const USART_TypeDef *LPUARTx)
  2356. {
  2357. return ((READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL);
  2358. }
  2359. #if defined(USART_CR1_FIFOEN)
  2360. /**
  2361. * @brief Check if LPUART TX FIFO Threshold Interrupt is enabled or disabled
  2362. * @rmtoll CR3 TXFTIE LL_LPUART_IsEnabledIT_TXFT
  2363. * @param LPUARTx LPUART Instance
  2364. * @retval State of bit (1 or 0).
  2365. */
  2366. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFT(const USART_TypeDef *LPUARTx)
  2367. {
  2368. return ((READ_BIT(LPUARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL);
  2369. }
  2370. /**
  2371. * @brief Check if LPUART RX FIFO Threshold Interrupt is enabled or disabled
  2372. * @rmtoll CR3 RXFTIE LL_LPUART_IsEnabledIT_RXFT
  2373. * @param LPUARTx LPUART Instance
  2374. * @retval State of bit (1 or 0).
  2375. */
  2376. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFT(const USART_TypeDef *LPUARTx)
  2377. {
  2378. return ((READ_BIT(LPUARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL);
  2379. }
  2380. #endif /* USART_CR1_FIFOEN */
  2381. /**
  2382. * @}
  2383. */
  2384. /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management
  2385. * @{
  2386. */
  2387. /**
  2388. * @brief Enable DMA Mode for reception
  2389. * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX
  2390. * @param LPUARTx LPUART Instance
  2391. * @retval None
  2392. */
  2393. __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx)
  2394. {
  2395. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2396. }
  2397. /**
  2398. * @brief Disable DMA Mode for reception
  2399. * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX
  2400. * @param LPUARTx LPUART Instance
  2401. * @retval None
  2402. */
  2403. __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx)
  2404. {
  2405. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2406. }
  2407. /**
  2408. * @brief Check if DMA Mode is enabled for reception
  2409. * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX
  2410. * @param LPUARTx LPUART Instance
  2411. * @retval State of bit (1 or 0).
  2412. */
  2413. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(const USART_TypeDef *LPUARTx)
  2414. {
  2415. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL);
  2416. }
  2417. /**
  2418. * @brief Enable DMA Mode for transmission
  2419. * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX
  2420. * @param LPUARTx LPUART Instance
  2421. * @retval None
  2422. */
  2423. __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx)
  2424. {
  2425. ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2426. }
  2427. /**
  2428. * @brief Disable DMA Mode for transmission
  2429. * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX
  2430. * @param LPUARTx LPUART Instance
  2431. * @retval None
  2432. */
  2433. __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx)
  2434. {
  2435. ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2436. }
  2437. /**
  2438. * @brief Check if DMA Mode is enabled for transmission
  2439. * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX
  2440. * @param LPUARTx LPUART Instance
  2441. * @retval State of bit (1 or 0).
  2442. */
  2443. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(const USART_TypeDef *LPUARTx)
  2444. {
  2445. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL);
  2446. }
  2447. /**
  2448. * @brief Enable DMA Disabling on Reception Error
  2449. * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr
  2450. * @param LPUARTx LPUART Instance
  2451. * @retval None
  2452. */
  2453. __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2454. {
  2455. SET_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2456. }
  2457. /**
  2458. * @brief Disable DMA Disabling on Reception Error
  2459. * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr
  2460. * @param LPUARTx LPUART Instance
  2461. * @retval None
  2462. */
  2463. __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2464. {
  2465. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2466. }
  2467. /**
  2468. * @brief Indicate if DMA Disabling on Reception Error is disabled
  2469. * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr
  2470. * @param LPUARTx LPUART Instance
  2471. * @retval State of bit (1 or 0).
  2472. */
  2473. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(const USART_TypeDef *LPUARTx)
  2474. {
  2475. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL);
  2476. }
  2477. /**
  2478. * @brief Get the LPUART data register address used for DMA transfer
  2479. * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n
  2480. * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr
  2481. * @param LPUARTx LPUART Instance
  2482. * @param Direction This parameter can be one of the following values:
  2483. * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT
  2484. * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE
  2485. * @retval Address of data register
  2486. */
  2487. __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(const USART_TypeDef *LPUARTx, uint32_t Direction)
  2488. {
  2489. uint32_t data_reg_addr;
  2490. if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT)
  2491. {
  2492. /* return address of TDR register */
  2493. data_reg_addr = (uint32_t) &(LPUARTx->TDR);
  2494. }
  2495. else
  2496. {
  2497. /* return address of RDR register */
  2498. data_reg_addr = (uint32_t) &(LPUARTx->RDR);
  2499. }
  2500. return data_reg_addr;
  2501. }
  2502. /**
  2503. * @}
  2504. */
  2505. /** @defgroup LPUART_LL_EF_Data_Management Data_Management
  2506. * @{
  2507. */
  2508. /**
  2509. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  2510. * @rmtoll RDR RDR LL_LPUART_ReceiveData8
  2511. * @param LPUARTx LPUART Instance
  2512. * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF
  2513. */
  2514. __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(const USART_TypeDef *LPUARTx)
  2515. {
  2516. return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR) & 0xFFU);
  2517. }
  2518. /**
  2519. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  2520. * @rmtoll RDR RDR LL_LPUART_ReceiveData9
  2521. * @param LPUARTx LPUART Instance
  2522. * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF
  2523. */
  2524. __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(const USART_TypeDef *LPUARTx)
  2525. {
  2526. return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR));
  2527. }
  2528. /**
  2529. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  2530. * @rmtoll TDR TDR LL_LPUART_TransmitData8
  2531. * @param LPUARTx LPUART Instance
  2532. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  2533. * @retval None
  2534. */
  2535. __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value)
  2536. {
  2537. LPUARTx->TDR = Value;
  2538. }
  2539. /**
  2540. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  2541. * @rmtoll TDR TDR LL_LPUART_TransmitData9
  2542. * @param LPUARTx LPUART Instance
  2543. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  2544. * @retval None
  2545. */
  2546. __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value)
  2547. {
  2548. LPUARTx->TDR = Value & 0x1FFUL;
  2549. }
  2550. /**
  2551. * @}
  2552. */
  2553. /** @defgroup LPUART_LL_EF_Execution Execution
  2554. * @{
  2555. */
  2556. /**
  2557. * @brief Request Break sending
  2558. * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending
  2559. * @param LPUARTx LPUART Instance
  2560. * @retval None
  2561. */
  2562. __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx)
  2563. {
  2564. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_SBKRQ);
  2565. }
  2566. /**
  2567. * @brief Put LPUART in mute mode and set the RWU flag
  2568. * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode
  2569. * @param LPUARTx LPUART Instance
  2570. * @retval None
  2571. */
  2572. __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx)
  2573. {
  2574. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_MMRQ);
  2575. }
  2576. /**
  2577. @if USART_CR1_FIFOEN
  2578. * @brief Request a Receive Data and FIFO flush
  2579. * @note Allows to discard the received data without reading them, and avoid an overrun
  2580. * condition.
  2581. @else
  2582. * @brief Request a Receive Data flush
  2583. @endif
  2584. * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush
  2585. * @param LPUARTx LPUART Instance
  2586. * @retval None
  2587. */
  2588. __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx)
  2589. {
  2590. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_RXFRQ);
  2591. }
  2592. /**
  2593. * @}
  2594. */
  2595. #if defined(USE_FULL_LL_DRIVER)
  2596. /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions
  2597. * @{
  2598. */
  2599. ErrorStatus LL_LPUART_DeInit(const USART_TypeDef *LPUARTx);
  2600. ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, const LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2601. void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2602. /**
  2603. * @}
  2604. */
  2605. #endif /* USE_FULL_LL_DRIVER */
  2606. /**
  2607. * @}
  2608. */
  2609. /**
  2610. * @}
  2611. */
  2612. #endif /* LPUART1 */
  2613. /**
  2614. * @}
  2615. */
  2616. #ifdef __cplusplus
  2617. }
  2618. #endif
  2619. #endif /* STM32L4xx_LL_LPUART_H */