stm32l4xx_ll_swpmi.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_swpmi.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of SWPMI LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L4xx_LL_SWPMI_H
  39. #define __STM32L4xx_LL_SWPMI_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx.h"
  45. /** @addtogroup STM32L4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (SWPMI1)
  49. /** @defgroup SWPMI_LL SWPMI
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /* Private macros ------------------------------------------------------------*/
  56. #if defined(USE_FULL_LL_DRIVER)
  57. /** @defgroup SWPMI_LL_Private_Macros SWPMI Private Macros
  58. * @{
  59. */
  60. /**
  61. * @}
  62. */
  63. #endif /*USE_FULL_LL_DRIVER*/
  64. /* Exported types ------------------------------------------------------------*/
  65. #if defined(USE_FULL_LL_DRIVER)
  66. /** @defgroup SWPMI_LL_ES_INIT SWPMI Exported Init structure
  67. * @{
  68. */
  69. /**
  70. * @brief SWPMI Init structures definition
  71. */
  72. typedef struct
  73. {
  74. uint32_t VoltageClass; /*!< Specifies the SWP Voltage Class.
  75. This parameter can be a value of @ref SWPMI_LL_EC_VOLTAGE_CLASS
  76. This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetVoltageClass. */
  77. uint32_t BitRatePrescaler; /*!< Specifies the SWPMI bitrate prescaler.
  78. This parameter must be a number between Min_Data=0 and Max_Data=63.
  79. The value can be calculated thanks to helper macro @ref __LL_SWPMI_CALC_BITRATE_PRESCALER
  80. This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetBitRatePrescaler. */
  81. uint32_t TxBufferingMode; /*!< Specifies the transmission buffering mode.
  82. This parameter can be a value of @ref SWPMI_LL_EC_SW_BUFFER_TX
  83. This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetTransmissionMode. */
  84. uint32_t RxBufferingMode; /*!< Specifies the reception buffering mode.
  85. This parameter can be a value of @ref SWPMI_LL_EC_SW_BUFFER_RX
  86. This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetReceptionMode. */
  87. } LL_SWPMI_InitTypeDef;
  88. /**
  89. * @}
  90. */
  91. #endif /* USE_FULL_LL_DRIVER */
  92. /* Exported constants --------------------------------------------------------*/
  93. /** @defgroup SWPMI_LL_Exported_Constants SWPMI Exported Constants
  94. * @{
  95. */
  96. /** @defgroup SWPMI_LL_EC_CLEAR_FLAG Clear Flags Defines
  97. * @brief Flags defines which can be used with LL_SWPMI_WriteReg function
  98. * @{
  99. */
  100. #define LL_SWPMI_ICR_CRXBFF SWPMI_ICR_CRXBFF /*!< Clear receive buffer full flag */
  101. #define LL_SWPMI_ICR_CTXBEF SWPMI_ICR_CTXBEF /*!< Clear transmit buffer empty flag */
  102. #define LL_SWPMI_ICR_CRXBERF SWPMI_ICR_CRXBERF /*!< Clear receive CRC error flag */
  103. #define LL_SWPMI_ICR_CRXOVRF SWPMI_ICR_CRXOVRF /*!< Clear receive overrun error flag */
  104. #define LL_SWPMI_ICR_CTXUNRF SWPMI_ICR_CTXUNRF /*!< Clear transmit underrun error flag */
  105. #define LL_SWPMI_ICR_CTCF SWPMI_ICR_CTCF /*!< Clear transfer complete flag */
  106. #define LL_SWPMI_ICR_CSRF SWPMI_ICR_CSRF /*!< Clear slave resume flag */
  107. /**
  108. * @}
  109. */
  110. /** @defgroup SWPMI_LL_EC_GET_FLAG Get Flags Defines
  111. * @brief Flags defines which can be used with LL_SWPMI_ReadReg function
  112. * @{
  113. */
  114. #define LL_SWPMI_ISR_RXBFF SWPMI_ISR_RXBFF /*!< Receive buffer full flag */
  115. #define LL_SWPMI_ISR_TXBEF SWPMI_ISR_TXBEF /*!< Transmit buffer empty flag */
  116. #define LL_SWPMI_ISR_RXBERF SWPMI_ISR_RXBERF /*!< Receive CRC error flag */
  117. #define LL_SWPMI_ISR_RXOVRF SWPMI_ISR_RXOVRF /*!< Receive overrun error flag */
  118. #define LL_SWPMI_ISR_TXUNRF SWPMI_ISR_TXUNRF /*!< Transmit underrun error flag */
  119. #define LL_SWPMI_ISR_RXNE SWPMI_ISR_RXNE /*!< Receive data register not empty */
  120. #define LL_SWPMI_ISR_TXE SWPMI_ISR_TXE /*!< Transmit data register empty */
  121. #define LL_SWPMI_ISR_TCF SWPMI_ISR_TCF /*!< Transfer complete flag */
  122. #define LL_SWPMI_ISR_SRF SWPMI_ISR_SRF /*!< Slave resume flag */
  123. #define LL_SWPMI_ISR_SUSP SWPMI_ISR_SUSP /*!< SUSPEND flag */
  124. #define LL_SWPMI_ISR_DEACTF SWPMI_ISR_DEACTF /*!< DEACTIVATED flag */
  125. /**
  126. * @}
  127. */
  128. /** @defgroup SWPMI_LL_EC_IT IT Defines
  129. * @brief IT defines which can be used with LL_SWPMI_ReadReg and LL_SWPMI_WriteReg functions
  130. * @{
  131. */
  132. #define LL_SWPMI_IER_SRIE SWPMI_IER_SRIE /*!< Slave resume interrupt enable */
  133. #define LL_SWPMI_IER_TCIE SWPMI_IER_TCIE /*!< Transmit complete interrupt enable */
  134. #define LL_SWPMI_IER_TIE SWPMI_IER_TIE /*!< Transmit interrupt enable */
  135. #define LL_SWPMI_IER_RIE SWPMI_IER_RIE /*!< Receive interrupt enable */
  136. #define LL_SWPMI_IER_TXUNRIE SWPMI_IER_TXUNRIE /*!< Transmit underrun error interrupt enable */
  137. #define LL_SWPMI_IER_RXOVRIE SWPMI_IER_RXOVRIE /*!< Receive overrun error interrupt enable */
  138. #define LL_SWPMI_IER_RXBERIE SWPMI_IER_RXBERIE /*!< Receive CRC error interrupt enable */
  139. #define LL_SWPMI_IER_TXBEIE SWPMI_IER_TXBEIE /*!< Transmit buffer empty interrupt enable */
  140. #define LL_SWPMI_IER_RXBFIE SWPMI_IER_RXBFIE /*!< Receive buffer full interrupt enable */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup SWPMI_LL_EC_SW_BUFFER_RX SW BUFFER RX
  145. * @{
  146. */
  147. #define LL_SWPMI_SW_BUFFER_RX_SINGLE ((uint32_t)0x00000000) /*!< Single software buffer mode for reception */
  148. #define LL_SWPMI_SW_BUFFER_RX_MULTI SWPMI_CR_RXMODE /*!< Multi software buffermode for reception */
  149. /**
  150. * @}
  151. */
  152. /** @defgroup SWPMI_LL_EC_SW_BUFFER_TX SW BUFFER TX
  153. * @{
  154. */
  155. #define LL_SWPMI_SW_BUFFER_TX_SINGLE ((uint32_t)0x00000000) /*!< Single software buffer mode for transmission */
  156. #define LL_SWPMI_SW_BUFFER_TX_MULTI SWPMI_CR_TXMODE /*!< Multi software buffermode for transmission */
  157. /**
  158. * @}
  159. */
  160. /** @defgroup SWPMI_LL_EC_VOLTAGE_CLASS VOLTAGE CLASS
  161. * @{
  162. */
  163. #define LL_SWPMI_VOLTAGE_CLASS_C ((uint32_t)0x00000000) /*!< SWPMI_IO uses directly VDD voltage to operate in class C */
  164. #define LL_SWPMI_VOLTAGE_CLASS_B SWPMI_OR_CLASS /*!< SWPMI_IO uses an internal voltage regulator to operate in class B */
  165. /**
  166. * @}
  167. */
  168. /** @defgroup SWPMI_LL_EC_DMA_REG_DATA DMA register data
  169. * @{
  170. */
  171. #define LL_SWPMI_DMA_REG_DATA_TRANSMIT (uint32_t)0 /*!< Get address of data register used for transmission */
  172. #define LL_SWPMI_DMA_REG_DATA_RECEIVE (uint32_t)1 /*!< Get address of data register used for reception */
  173. /**
  174. * @}
  175. */
  176. /**
  177. * @}
  178. */
  179. /* Exported macro ------------------------------------------------------------*/
  180. /** @defgroup SWPMI_LL_Exported_Macros SWPMI Exported Macros
  181. * @{
  182. */
  183. /** @defgroup SWPMI_LL_EM_WRITE_READ Common Write and read registers Macros
  184. * @{
  185. */
  186. /**
  187. * @brief Write a value in SWPMI register
  188. * @param __INSTANCE__ SWPMI Instance
  189. * @param __REG__ Register to be written
  190. * @param __VALUE__ Value to be written in the register
  191. * @retval None
  192. */
  193. #define LL_SWPMI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  194. /**
  195. * @brief Read a value in SWPMI register
  196. * @param __INSTANCE__ SWPMI Instance
  197. * @param __REG__ Register to be read
  198. * @retval Register value
  199. */
  200. #define LL_SWPMI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  201. /**
  202. * @}
  203. */
  204. /** @defgroup SWPMI_LL_EM_BitRate Bit rate calculation helper Macros
  205. * @{
  206. */
  207. /**
  208. * @brief Helper macro to calculate bit rate value to set in BRR register (@ref LL_SWPMI_SetBitRatePrescaler function)
  209. * @note ex: @ref __LL_SWPMI_CALC_BITRATE_PRESCALER(2000000, 80000000);
  210. * @param __FSWP__ Within the following range: from 100 Kbit/s up to 2Mbit/s (in bit/s)
  211. * @param __FSWPCLK__ PCLK or HSI frequency (in Hz)
  212. * @retval Bitrate prescaler (BRR register)
  213. */
  214. #define __LL_SWPMI_CALC_BITRATE_PRESCALER(__FSWP__, __FSWPCLK__) ((uint32_t)(((__FSWPCLK__) / ((__FSWP__) * 4)) - 1))
  215. /**
  216. * @}
  217. */
  218. /**
  219. * @}
  220. */
  221. /* Exported functions --------------------------------------------------------*/
  222. /** @defgroup SWPMI_LL_Exported_Functions SWPMI Exported Functions
  223. * @{
  224. */
  225. /** @defgroup SWPMI_LL_EF_Configuration Configuration
  226. * @{
  227. */
  228. /**
  229. * @brief Set Reception buffering mode
  230. * @note If Multi software buffer mode is chosen, RXDMA bits must also be set.
  231. * @rmtoll CR RXMODE LL_SWPMI_SetReceptionMode
  232. * @param SWPMIx SWPMI Instance
  233. * @param RxBufferingMode This parameter can be one of the following values:
  234. * @arg @ref LL_SWPMI_SW_BUFFER_RX_SINGLE
  235. * @arg @ref LL_SWPMI_SW_BUFFER_RX_MULTI
  236. * @retval None
  237. */
  238. __STATIC_INLINE void LL_SWPMI_SetReceptionMode(SWPMI_TypeDef *SWPMIx, uint32_t RxBufferingMode)
  239. {
  240. MODIFY_REG(SWPMIx->CR, SWPMI_CR_RXMODE, RxBufferingMode);
  241. }
  242. /**
  243. * @brief Get Reception buffering mode
  244. * @rmtoll CR RXMODE LL_SWPMI_GetReceptionMode
  245. * @param SWPMIx SWPMI Instance
  246. * @retval Returned value can be one of the following values:
  247. * @arg @ref LL_SWPMI_SW_BUFFER_RX_SINGLE
  248. * @arg @ref LL_SWPMI_SW_BUFFER_RX_MULTI
  249. */
  250. __STATIC_INLINE uint32_t LL_SWPMI_GetReceptionMode(SWPMI_TypeDef *SWPMIx)
  251. {
  252. return (uint32_t)(READ_BIT(SWPMIx->CR, SWPMI_CR_RXMODE));
  253. }
  254. /**
  255. * @brief Set Transmission buffering mode
  256. * @note If Multi software buffer mode is chosen, TXDMA bits must also be set.
  257. * @rmtoll CR TXMODE LL_SWPMI_SetTransmissionMode
  258. * @param SWPMIx SWPMI Instance
  259. * @param TxBufferingMode This parameter can be one of the following values:
  260. * @arg @ref LL_SWPMI_SW_BUFFER_TX_SINGLE
  261. * @arg @ref LL_SWPMI_SW_BUFFER_TX_MULTI
  262. * @retval None
  263. */
  264. __STATIC_INLINE void LL_SWPMI_SetTransmissionMode(SWPMI_TypeDef *SWPMIx, uint32_t TxBufferingMode)
  265. {
  266. MODIFY_REG(SWPMIx->CR, SWPMI_CR_TXMODE, TxBufferingMode);
  267. }
  268. /**
  269. * @brief Get Transmission buffering mode
  270. * @rmtoll CR TXMODE LL_SWPMI_GetTransmissionMode
  271. * @param SWPMIx SWPMI Instance
  272. * @retval Returned value can be one of the following values:
  273. * @arg @ref LL_SWPMI_SW_BUFFER_TX_SINGLE
  274. * @arg @ref LL_SWPMI_SW_BUFFER_TX_MULTI
  275. */
  276. __STATIC_INLINE uint32_t LL_SWPMI_GetTransmissionMode(SWPMI_TypeDef *SWPMIx)
  277. {
  278. return (uint32_t)(READ_BIT(SWPMIx->CR, SWPMI_CR_TXMODE));
  279. }
  280. /**
  281. * @brief Enable loopback mode
  282. * @rmtoll CR LPBK LL_SWPMI_EnableLoopback
  283. * @param SWPMIx SWPMI Instance
  284. * @retval None
  285. */
  286. __STATIC_INLINE void LL_SWPMI_EnableLoopback(SWPMI_TypeDef *SWPMIx)
  287. {
  288. SET_BIT(SWPMIx->CR, SWPMI_CR_LPBK);
  289. }
  290. /**
  291. * @brief Disable loopback mode
  292. * @rmtoll CR LPBK LL_SWPMI_DisableLoopback
  293. * @param SWPMIx SWPMI Instance
  294. * @retval None
  295. */
  296. __STATIC_INLINE void LL_SWPMI_DisableLoopback(SWPMI_TypeDef *SWPMIx)
  297. {
  298. CLEAR_BIT(SWPMIx->CR, SWPMI_CR_LPBK);
  299. }
  300. /**
  301. * @brief Activate Single wire protocol bus (SUSPENDED or ACTIVATED state)
  302. * @note SWP bus stays in the ACTIVATED state as long as there is a communication
  303. * with the slave, either in transmission or in reception. The SWP bus switches back
  304. * to the SUSPENDED state as soon as there is no more transmission or reception
  305. * activity, after 7 idle bits.
  306. * @rmtoll CR SWPACT LL_SWPMI_Activate
  307. * @param SWPMIx SWPMI Instance
  308. * @retval None
  309. */
  310. __STATIC_INLINE void LL_SWPMI_Activate(SWPMI_TypeDef *SWPMIx)
  311. {
  312. /* In order to activate SWP again, the software must clear DEACT bit*/
  313. CLEAR_BIT(SWPMIx->CR, SWPMI_CR_DEACT);
  314. /* Set SWACT bit */
  315. SET_BIT(SWPMIx->CR, SWPMI_CR_SWPACT);
  316. }
  317. /**
  318. * @brief Check if Single wire protocol bus is in ACTIVATED state.
  319. * @rmtoll CR SWPACT LL_SWPMI_Activate
  320. * @param SWPMIx SWPMI Instance
  321. * @retval State of bit (1 or 0).
  322. */
  323. __STATIC_INLINE uint32_t LL_SWPMI_IsActivated(SWPMI_TypeDef *SWPMIx)
  324. {
  325. return (READ_BIT(SWPMIx->CR, SWPMI_CR_SWPACT) == (SWPMI_CR_SWPACT));
  326. }
  327. /**
  328. * @brief Deactivate immediately Single wire protocol bus (immediate transition to
  329. * DEACTIVATED state)
  330. * @rmtoll CR SWPACT LL_SWPMI_Deactivate
  331. * @param SWPMIx SWPMI Instance
  332. * @retval None
  333. */
  334. __STATIC_INLINE void LL_SWPMI_Deactivate(SWPMI_TypeDef *SWPMIx)
  335. {
  336. CLEAR_BIT(SWPMIx->CR, SWPMI_CR_SWPACT);
  337. }
  338. /**
  339. * @brief Request a deactivation of Single wire protocol bus (request to go in DEACTIVATED
  340. * state if no resume from slave)
  341. * @rmtoll CR DEACT LL_SWPMI_RequestDeactivation
  342. * @param SWPMIx SWPMI Instance
  343. * @retval None
  344. */
  345. __STATIC_INLINE void LL_SWPMI_RequestDeactivation(SWPMI_TypeDef *SWPMIx)
  346. {
  347. SET_BIT(SWPMIx->CR, SWPMI_CR_DEACT);
  348. }
  349. /**
  350. * @brief Set Bitrate prescaler SWPMI_freq = SWPMI_clk / (((BitRate) + 1) * 4)
  351. * @rmtoll BRR BR LL_SWPMI_SetBitRatePrescaler
  352. * @param SWPMIx SWPMI Instance
  353. * @param BitRatePrescaler A number between Min_Data=0 and Max_Data=63
  354. * @retval None
  355. */
  356. __STATIC_INLINE void LL_SWPMI_SetBitRatePrescaler(SWPMI_TypeDef *SWPMIx, uint32_t BitRatePrescaler)
  357. {
  358. WRITE_REG(SWPMIx->BRR, BitRatePrescaler);
  359. }
  360. /**
  361. * @brief Get Bitrate prescaler
  362. * @rmtoll BRR BR LL_SWPMI_GetBitRatePrescaler
  363. * @param SWPMIx SWPMI Instance
  364. * @retval A number between Min_Data=0 and Max_Data=63
  365. */
  366. __STATIC_INLINE uint32_t LL_SWPMI_GetBitRatePrescaler(SWPMI_TypeDef *SWPMIx)
  367. {
  368. return (uint32_t)(READ_BIT(SWPMIx->BRR, SWPMI_BRR_BR));
  369. }
  370. /**
  371. * @brief Set SWP Voltage Class
  372. * @rmtoll OR CLASS LL_SWPMI_SetVoltageClass
  373. * @param SWPMIx SWPMI Instance
  374. * @param VoltageClass This parameter can be one of the following values:
  375. * @arg @ref LL_SWPMI_VOLTAGE_CLASS_C
  376. * @arg @ref LL_SWPMI_VOLTAGE_CLASS_B
  377. * @retval None
  378. */
  379. __STATIC_INLINE void LL_SWPMI_SetVoltageClass(SWPMI_TypeDef *SWPMIx, uint32_t VoltageClass)
  380. {
  381. MODIFY_REG(SWPMIx->OR, SWPMI_OR_CLASS, VoltageClass);
  382. }
  383. /**
  384. * @brief Get SWP Voltage Class
  385. * @rmtoll OR CLASS LL_SWPMI_GetVoltageClass
  386. * @param SWPMIx SWPMI Instance
  387. * @retval Returned value can be one of the following values:
  388. * @arg @ref LL_SWPMI_VOLTAGE_CLASS_C
  389. * @arg @ref LL_SWPMI_VOLTAGE_CLASS_B
  390. */
  391. __STATIC_INLINE uint32_t LL_SWPMI_GetVoltageClass(SWPMI_TypeDef *SWPMIx)
  392. {
  393. return (uint32_t)(READ_BIT(SWPMIx->OR, SWPMI_OR_CLASS));
  394. }
  395. /**
  396. * @}
  397. */
  398. /** @defgroup SWPMI_LL_EF_FLAG_Management FLAG_Management
  399. * @{
  400. */
  401. /**
  402. * @brief Check if the last word of the frame under reception has arrived in SWPMI_RDR.
  403. * @rmtoll ISR RXBFF LL_SWPMI_IsActiveFlag_RXBF
  404. * @param SWPMIx SWPMI Instance
  405. * @retval State of bit (1 or 0).
  406. */
  407. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXBF(SWPMI_TypeDef *SWPMIx)
  408. {
  409. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXBFF) == (SWPMI_ISR_RXBFF));
  410. }
  411. /**
  412. * @brief Check if Frame transmission buffer has been emptied
  413. * @rmtoll ISR TXBEF LL_SWPMI_IsActiveFlag_TXBE
  414. * @param SWPMIx SWPMI Instance
  415. * @retval State of bit (1 or 0).
  416. */
  417. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXBE(SWPMI_TypeDef *SWPMIx)
  418. {
  419. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXBEF) == (SWPMI_ISR_TXBEF));
  420. }
  421. /**
  422. * @brief Check if CRC error in reception has been detected
  423. * @rmtoll ISR RXBERF LL_SWPMI_IsActiveFlag_RXBER
  424. * @param SWPMIx SWPMI Instance
  425. * @retval State of bit (1 or 0).
  426. */
  427. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXBER(SWPMI_TypeDef *SWPMIx)
  428. {
  429. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXBERF) == (SWPMI_ISR_RXBERF));
  430. }
  431. /**
  432. * @brief Check if Overrun in reception has been detected
  433. * @rmtoll ISR RXOVRF LL_SWPMI_IsActiveFlag_RXOVR
  434. * @param SWPMIx SWPMI Instance
  435. * @retval State of bit (1 or 0).
  436. */
  437. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
  438. {
  439. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXOVRF) == (SWPMI_ISR_RXOVRF));
  440. }
  441. /**
  442. * @brief Check if underrun error in transmission has been detected
  443. * @rmtoll ISR TXUNRF LL_SWPMI_IsActiveFlag_TXUNR
  444. * @param SWPMIx SWPMI Instance
  445. * @retval State of bit (1 or 0).
  446. */
  447. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXUNR(SWPMI_TypeDef *SWPMIx)
  448. {
  449. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXUNRF) == (SWPMI_ISR_TXUNRF));
  450. }
  451. /**
  452. * @brief Check if Receive data register not empty (it means that Received data is ready
  453. * to be read in the SWPMI_RDR register)
  454. * @rmtoll ISR RXNE LL_SWPMI_IsActiveFlag_RXNE
  455. * @param SWPMIx SWPMI Instance
  456. * @retval State of bit (1 or 0).
  457. */
  458. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXNE(SWPMI_TypeDef *SWPMIx)
  459. {
  460. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXNE) == (SWPMI_ISR_RXNE));
  461. }
  462. /**
  463. * @brief Check if Transmit data register is empty (it means that Data written in transmit
  464. * data register SWPMI_TDR has been transmitted and SWPMI_TDR can be written to again)
  465. * @rmtoll ISR TXE LL_SWPMI_IsActiveFlag_TXE
  466. * @param SWPMIx SWPMI Instance
  467. * @retval State of bit (1 or 0).
  468. */
  469. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXE(SWPMI_TypeDef *SWPMIx)
  470. {
  471. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXE) == (SWPMI_ISR_TXE));
  472. }
  473. /**
  474. * @brief Check if Both transmission and reception are completed and SWP is switched to
  475. * the SUSPENDED state
  476. * @rmtoll ISR TCF LL_SWPMI_IsActiveFlag_TC
  477. * @param SWPMIx SWPMI Instance
  478. * @retval State of bit (1 or 0).
  479. */
  480. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TC(SWPMI_TypeDef *SWPMIx)
  481. {
  482. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_TCF) == (SWPMI_ISR_TCF));
  483. }
  484. /**
  485. * @brief Check if a Resume by slave state has been detected during the SWP bus SUSPENDED
  486. * state
  487. * @rmtoll ISR SRF LL_SWPMI_IsActiveFlag_SR
  488. * @param SWPMIx SWPMI Instance
  489. * @retval State of bit (1 or 0).
  490. */
  491. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_SR(SWPMI_TypeDef *SWPMIx)
  492. {
  493. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_SRF) == (SWPMI_ISR_SRF));
  494. }
  495. /**
  496. * @brief Check if SWP bus is in SUSPENDED or DEACTIVATED state
  497. * @rmtoll ISR SUSP LL_SWPMI_IsActiveFlag_SUSP
  498. * @param SWPMIx SWPMI Instance
  499. * @retval State of bit (1 or 0).
  500. */
  501. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_SUSP(SWPMI_TypeDef *SWPMIx)
  502. {
  503. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_SUSP) == (SWPMI_ISR_SUSP));
  504. }
  505. /**
  506. * @brief Check if SWP bus is in DEACTIVATED state
  507. * @rmtoll ISR DEACTF LL_SWPMI_IsActiveFlag_DEACT
  508. * @param SWPMIx SWPMI Instance
  509. * @retval State of bit (1 or 0).
  510. */
  511. __STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_DEACT(SWPMI_TypeDef *SWPMIx)
  512. {
  513. return (READ_BIT(SWPMIx->ISR, SWPMI_ISR_DEACTF) == (SWPMI_ISR_DEACTF));
  514. }
  515. /**
  516. * @brief Clear receive buffer full flag
  517. * @rmtoll ICR CRXBFF LL_SWPMI_ClearFlag_RXBF
  518. * @param SWPMIx SWPMI Instance
  519. * @retval None
  520. */
  521. __STATIC_INLINE void LL_SWPMI_ClearFlag_RXBF(SWPMI_TypeDef *SWPMIx)
  522. {
  523. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXBFF);
  524. }
  525. /**
  526. * @brief Clear transmit buffer empty flag
  527. * @rmtoll ICR CTXBEF LL_SWPMI_ClearFlag_TXBE
  528. * @param SWPMIx SWPMI Instance
  529. * @retval None
  530. */
  531. __STATIC_INLINE void LL_SWPMI_ClearFlag_TXBE(SWPMI_TypeDef *SWPMIx)
  532. {
  533. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTXBEF);
  534. }
  535. /**
  536. * @brief Clear receive CRC error flag
  537. * @rmtoll ICR CRXBERF LL_SWPMI_ClearFlag_RXBER
  538. * @param SWPMIx SWPMI Instance
  539. * @retval None
  540. */
  541. __STATIC_INLINE void LL_SWPMI_ClearFlag_RXBER(SWPMI_TypeDef *SWPMIx)
  542. {
  543. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXBERF);
  544. }
  545. /**
  546. * @brief Clear receive overrun error flag
  547. * @rmtoll ICR CRXOVRF LL_SWPMI_ClearFlag_RXOVR
  548. * @param SWPMIx SWPMI Instance
  549. * @retval None
  550. */
  551. __STATIC_INLINE void LL_SWPMI_ClearFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
  552. {
  553. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXOVRF);
  554. }
  555. /**
  556. * @brief Clear transmit underrun error flag
  557. * @rmtoll ICR CTXUNRF LL_SWPMI_ClearFlag_TXUNR
  558. * @param SWPMIx SWPMI Instance
  559. * @retval None
  560. */
  561. __STATIC_INLINE void LL_SWPMI_ClearFlag_TXUNR(SWPMI_TypeDef *SWPMIx)
  562. {
  563. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTXUNRF);
  564. }
  565. /**
  566. * @brief Clear transfer complete flag
  567. * @rmtoll ICR CTCF LL_SWPMI_ClearFlag_TC
  568. * @param SWPMIx SWPMI Instance
  569. * @retval None
  570. */
  571. __STATIC_INLINE void LL_SWPMI_ClearFlag_TC(SWPMI_TypeDef *SWPMIx)
  572. {
  573. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTCF);
  574. }
  575. /**
  576. * @brief Clear slave resume flag
  577. * @rmtoll ICR CSRF LL_SWPMI_ClearFlag_SR
  578. * @param SWPMIx SWPMI Instance
  579. * @retval None
  580. */
  581. __STATIC_INLINE void LL_SWPMI_ClearFlag_SR(SWPMI_TypeDef *SWPMIx)
  582. {
  583. WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CSRF);
  584. }
  585. /**
  586. * @}
  587. */
  588. /** @defgroup SWPMI_LL_EF_IT_Management IT_Management
  589. * @{
  590. */
  591. /**
  592. * @brief Enable Slave resume interrupt
  593. * @rmtoll IER SRIE LL_SWPMI_EnableIT_SR
  594. * @param SWPMIx SWPMI Instance
  595. * @retval None
  596. */
  597. __STATIC_INLINE void LL_SWPMI_EnableIT_SR(SWPMI_TypeDef *SWPMIx)
  598. {
  599. SET_BIT(SWPMIx->IER, SWPMI_IER_SRIE);
  600. }
  601. /**
  602. * @brief Enable Transmit complete interrupt
  603. * @rmtoll IER TCIE LL_SWPMI_EnableIT_TC
  604. * @param SWPMIx SWPMI Instance
  605. * @retval None
  606. */
  607. __STATIC_INLINE void LL_SWPMI_EnableIT_TC(SWPMI_TypeDef *SWPMIx)
  608. {
  609. SET_BIT(SWPMIx->IER, SWPMI_IER_TCIE);
  610. }
  611. /**
  612. * @brief Enable Transmit interrupt
  613. * @rmtoll IER TIE LL_SWPMI_EnableIT_TX
  614. * @param SWPMIx SWPMI Instance
  615. * @retval None
  616. */
  617. __STATIC_INLINE void LL_SWPMI_EnableIT_TX(SWPMI_TypeDef *SWPMIx)
  618. {
  619. SET_BIT(SWPMIx->IER, SWPMI_IER_TIE);
  620. }
  621. /**
  622. * @brief Enable Receive interrupt
  623. * @rmtoll IER RIE LL_SWPMI_EnableIT_RX
  624. * @param SWPMIx SWPMI Instance
  625. * @retval None
  626. */
  627. __STATIC_INLINE void LL_SWPMI_EnableIT_RX(SWPMI_TypeDef *SWPMIx)
  628. {
  629. SET_BIT(SWPMIx->IER, SWPMI_IER_RIE);
  630. }
  631. /**
  632. * @brief Enable Transmit underrun error interrupt
  633. * @rmtoll IER TXUNRIE LL_SWPMI_EnableIT_TXUNR
  634. * @param SWPMIx SWPMI Instance
  635. * @retval None
  636. */
  637. __STATIC_INLINE void LL_SWPMI_EnableIT_TXUNR(SWPMI_TypeDef *SWPMIx)
  638. {
  639. SET_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE);
  640. }
  641. /**
  642. * @brief Enable Receive overrun error interrupt
  643. * @rmtoll IER RXOVRIE LL_SWPMI_EnableIT_RXOVR
  644. * @param SWPMIx SWPMI Instance
  645. * @retval None
  646. */
  647. __STATIC_INLINE void LL_SWPMI_EnableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
  648. {
  649. SET_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE);
  650. }
  651. /**
  652. * @brief Enable Receive CRC error interrupt
  653. * @rmtoll IER RXBERIE LL_SWPMI_EnableIT_RXBER
  654. * @param SWPMIx SWPMI Instance
  655. * @retval None
  656. */
  657. __STATIC_INLINE void LL_SWPMI_EnableIT_RXBER(SWPMI_TypeDef *SWPMIx)
  658. {
  659. SET_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE);
  660. }
  661. /**
  662. * @brief Enable Transmit buffer empty interrupt
  663. * @rmtoll IER TXBEIE LL_SWPMI_EnableIT_TXBE
  664. * @param SWPMIx SWPMI Instance
  665. * @retval None
  666. */
  667. __STATIC_INLINE void LL_SWPMI_EnableIT_TXBE(SWPMI_TypeDef *SWPMIx)
  668. {
  669. SET_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE);
  670. }
  671. /**
  672. * @brief Enable Receive buffer full interrupt
  673. * @rmtoll IER RXBFIE LL_SWPMI_EnableIT_RXBF
  674. * @param SWPMIx SWPMI Instance
  675. * @retval None
  676. */
  677. __STATIC_INLINE void LL_SWPMI_EnableIT_RXBF(SWPMI_TypeDef *SWPMIx)
  678. {
  679. SET_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE);
  680. }
  681. /**
  682. * @brief Disable Slave resume interrupt
  683. * @rmtoll IER SRIE LL_SWPMI_DisableIT_SR
  684. * @param SWPMIx SWPMI Instance
  685. * @retval None
  686. */
  687. __STATIC_INLINE void LL_SWPMI_DisableIT_SR(SWPMI_TypeDef *SWPMIx)
  688. {
  689. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_SRIE);
  690. }
  691. /**
  692. * @brief Disable Transmit complete interrupt
  693. * @rmtoll IER TCIE LL_SWPMI_DisableIT_TC
  694. * @param SWPMIx SWPMI Instance
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_SWPMI_DisableIT_TC(SWPMI_TypeDef *SWPMIx)
  698. {
  699. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TCIE);
  700. }
  701. /**
  702. * @brief Disable Transmit interrupt
  703. * @rmtoll IER TIE LL_SWPMI_DisableIT_TX
  704. * @param SWPMIx SWPMI Instance
  705. * @retval None
  706. */
  707. __STATIC_INLINE void LL_SWPMI_DisableIT_TX(SWPMI_TypeDef *SWPMIx)
  708. {
  709. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TIE);
  710. }
  711. /**
  712. * @brief Disable Receive interrupt
  713. * @rmtoll IER RIE LL_SWPMI_DisableIT_RX
  714. * @param SWPMIx SWPMI Instance
  715. * @retval None
  716. */
  717. __STATIC_INLINE void LL_SWPMI_DisableIT_RX(SWPMI_TypeDef *SWPMIx)
  718. {
  719. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RIE);
  720. }
  721. /**
  722. * @brief Disable Transmit underrun error interrupt
  723. * @rmtoll IER TXUNRIE LL_SWPMI_DisableIT_TXUNR
  724. * @param SWPMIx SWPMI Instance
  725. * @retval None
  726. */
  727. __STATIC_INLINE void LL_SWPMI_DisableIT_TXUNR(SWPMI_TypeDef *SWPMIx)
  728. {
  729. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE);
  730. }
  731. /**
  732. * @brief Disable Receive overrun error interrupt
  733. * @rmtoll IER RXOVRIE LL_SWPMI_DisableIT_RXOVR
  734. * @param SWPMIx SWPMI Instance
  735. * @retval None
  736. */
  737. __STATIC_INLINE void LL_SWPMI_DisableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
  738. {
  739. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE);
  740. }
  741. /**
  742. * @brief Disable Receive CRC error interrupt
  743. * @rmtoll IER RXBERIE LL_SWPMI_DisableIT_RXBER
  744. * @param SWPMIx SWPMI Instance
  745. * @retval None
  746. */
  747. __STATIC_INLINE void LL_SWPMI_DisableIT_RXBER(SWPMI_TypeDef *SWPMIx)
  748. {
  749. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE);
  750. }
  751. /**
  752. * @brief Disable Transmit buffer empty interrupt
  753. * @rmtoll IER TXBEIE LL_SWPMI_DisableIT_TXBE
  754. * @param SWPMIx SWPMI Instance
  755. * @retval None
  756. */
  757. __STATIC_INLINE void LL_SWPMI_DisableIT_TXBE(SWPMI_TypeDef *SWPMIx)
  758. {
  759. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE);
  760. }
  761. /**
  762. * @brief Disable Receive buffer full interrupt
  763. * @rmtoll IER RXBFIE LL_SWPMI_DisableIT_RXBF
  764. * @param SWPMIx SWPMI Instance
  765. * @retval None
  766. */
  767. __STATIC_INLINE void LL_SWPMI_DisableIT_RXBF(SWPMI_TypeDef *SWPMIx)
  768. {
  769. CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE);
  770. }
  771. /**
  772. * @brief Check if Slave resume interrupt is enabled
  773. * @rmtoll IER SRIE LL_SWPMI_IsEnabledIT_SR
  774. * @param SWPMIx SWPMI Instance
  775. * @retval State of bit (1 or 0).
  776. */
  777. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_SR(SWPMI_TypeDef *SWPMIx)
  778. {
  779. return (READ_BIT(SWPMIx->IER, SWPMI_IER_SRIE) == (SWPMI_IER_SRIE));
  780. }
  781. /**
  782. * @brief Check if Transmit complete interrupt is enabled
  783. * @rmtoll IER TCIE LL_SWPMI_IsEnabledIT_TC
  784. * @param SWPMIx SWPMI Instance
  785. * @retval State of bit (1 or 0).
  786. */
  787. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TC(SWPMI_TypeDef *SWPMIx)
  788. {
  789. return (READ_BIT(SWPMIx->IER, SWPMI_IER_TCIE) == (SWPMI_IER_TCIE));
  790. }
  791. /**
  792. * @brief Check if Transmit interrupt is enabled
  793. * @rmtoll IER TIE LL_SWPMI_IsEnabledIT_TX
  794. * @param SWPMIx SWPMI Instance
  795. * @retval State of bit (1 or 0).
  796. */
  797. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TX(SWPMI_TypeDef *SWPMIx)
  798. {
  799. return (READ_BIT(SWPMIx->IER, SWPMI_IER_TIE) == (SWPMI_IER_TIE));
  800. }
  801. /**
  802. * @brief Check if Receive interrupt is enabled
  803. * @rmtoll IER RIE LL_SWPMI_IsEnabledIT_RX
  804. * @param SWPMIx SWPMI Instance
  805. * @retval State of bit (1 or 0).
  806. */
  807. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RX(SWPMI_TypeDef *SWPMIx)
  808. {
  809. return (READ_BIT(SWPMIx->IER, SWPMI_IER_RIE) == (SWPMI_IER_RIE));
  810. }
  811. /**
  812. * @brief Check if Transmit underrun error interrupt is enabled
  813. * @rmtoll IER TXUNRIE LL_SWPMI_IsEnabledIT_TXUNR
  814. * @param SWPMIx SWPMI Instance
  815. * @retval State of bit (1 or 0).
  816. */
  817. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TXUNR(SWPMI_TypeDef *SWPMIx)
  818. {
  819. return (READ_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE) == (SWPMI_IER_TXUNRIE));
  820. }
  821. /**
  822. * @brief Check if Receive overrun error interrupt is enabled
  823. * @rmtoll IER RXOVRIE LL_SWPMI_IsEnabledIT_RXOVR
  824. * @param SWPMIx SWPMI Instance
  825. * @retval State of bit (1 or 0).
  826. */
  827. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXOVR(SWPMI_TypeDef *SWPMIx)
  828. {
  829. return (READ_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE) == (SWPMI_IER_RXOVRIE));
  830. }
  831. /**
  832. * @brief Check if Receive CRC error interrupt is enabled
  833. * @rmtoll IER RXBERIE LL_SWPMI_IsEnabledIT_RXBER
  834. * @param SWPMIx SWPMI Instance
  835. * @retval State of bit (1 or 0).
  836. */
  837. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXBER(SWPMI_TypeDef *SWPMIx)
  838. {
  839. return (READ_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE) == (SWPMI_IER_RXBERIE));
  840. }
  841. /**
  842. * @brief Check if Transmit buffer empty interrupt is enabled
  843. * @rmtoll IER TXBEIE LL_SWPMI_IsEnabledIT_TXBE
  844. * @param SWPMIx SWPMI Instance
  845. * @retval State of bit (1 or 0).
  846. */
  847. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TXBE(SWPMI_TypeDef *SWPMIx)
  848. {
  849. return (READ_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE) == (SWPMI_IER_TXBEIE));
  850. }
  851. /**
  852. * @brief Check if Receive buffer full interrupt is enabled
  853. * @rmtoll IER RXBFIE LL_SWPMI_IsEnabledIT_RXBF
  854. * @param SWPMIx SWPMI Instance
  855. * @retval State of bit (1 or 0).
  856. */
  857. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXBF(SWPMI_TypeDef *SWPMIx)
  858. {
  859. return (READ_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE) == (SWPMI_IER_RXBFIE));
  860. }
  861. /**
  862. * @}
  863. */
  864. /** @defgroup SWPMI_LL_EF_DMA_Management DMA_Management
  865. * @{
  866. */
  867. /**
  868. * @brief Enable DMA mode for reception
  869. * @rmtoll CR RXDMA LL_SWPMI_EnableDMAReq_RX
  870. * @param SWPMIx SWPMI Instance
  871. * @retval None
  872. */
  873. __STATIC_INLINE void LL_SWPMI_EnableDMAReq_RX(SWPMI_TypeDef *SWPMIx)
  874. {
  875. SET_BIT(SWPMIx->CR, SWPMI_CR_RXDMA);
  876. }
  877. /**
  878. * @brief Disable DMA mode for reception
  879. * @rmtoll CR RXDMA LL_SWPMI_DisableDMAReq_RX
  880. * @param SWPMIx SWPMI Instance
  881. * @retval None
  882. */
  883. __STATIC_INLINE void LL_SWPMI_DisableDMAReq_RX(SWPMI_TypeDef *SWPMIx)
  884. {
  885. CLEAR_BIT(SWPMIx->CR, SWPMI_CR_RXDMA);
  886. }
  887. /**
  888. * @brief Check if DMA mode for reception is enabled
  889. * @rmtoll CR RXDMA LL_SWPMI_IsEnabledDMAReq_RX
  890. * @param SWPMIx SWPMI Instance
  891. * @retval State of bit (1 or 0).
  892. */
  893. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledDMAReq_RX(SWPMI_TypeDef *SWPMIx)
  894. {
  895. return (READ_BIT(SWPMIx->CR, SWPMI_CR_RXDMA) == (SWPMI_CR_RXDMA));
  896. }
  897. /**
  898. * @brief Enable DMA mode for transmission
  899. * @rmtoll CR TXDMA LL_SWPMI_EnableDMAReq_TX
  900. * @param SWPMIx SWPMI Instance
  901. * @retval None
  902. */
  903. __STATIC_INLINE void LL_SWPMI_EnableDMAReq_TX(SWPMI_TypeDef *SWPMIx)
  904. {
  905. SET_BIT(SWPMIx->CR, SWPMI_CR_TXDMA);
  906. }
  907. /**
  908. * @brief Disable DMA mode for transmission
  909. * @rmtoll CR TXDMA LL_SWPMI_DisableDMAReq_TX
  910. * @param SWPMIx SWPMI Instance
  911. * @retval None
  912. */
  913. __STATIC_INLINE void LL_SWPMI_DisableDMAReq_TX(SWPMI_TypeDef *SWPMIx)
  914. {
  915. CLEAR_BIT(SWPMIx->CR, SWPMI_CR_TXDMA);
  916. }
  917. /**
  918. * @brief Check if DMA mode for transmission is enabled
  919. * @rmtoll CR TXDMA LL_SWPMI_IsEnabledDMAReq_TX
  920. * @param SWPMIx SWPMI Instance
  921. * @retval State of bit (1 or 0).
  922. */
  923. __STATIC_INLINE uint32_t LL_SWPMI_IsEnabledDMAReq_TX(SWPMI_TypeDef *SWPMIx)
  924. {
  925. return (READ_BIT(SWPMIx->CR, SWPMI_CR_TXDMA) == (SWPMI_CR_TXDMA));
  926. }
  927. /**
  928. * @brief Get the data register address used for DMA transfer
  929. * @rmtoll TDR TD LL_SWPMI_DMA_GetRegAddr\n
  930. * RDR RD LL_SWPMI_DMA_GetRegAddr
  931. * @param SWPMIx SWPMI Instance
  932. * @param Direction This parameter can be one of the following values:
  933. * @arg @ref LL_SWPMI_DMA_REG_DATA_TRANSMIT
  934. * @arg @ref LL_SWPMI_DMA_REG_DATA_RECEIVE
  935. * @retval Address of data register
  936. */
  937. __STATIC_INLINE uint32_t LL_SWPMI_DMA_GetRegAddr(SWPMI_TypeDef *SWPMIx, uint32_t Direction)
  938. {
  939. register uint32_t data_reg_addr = 0;
  940. if (Direction == LL_SWPMI_DMA_REG_DATA_TRANSMIT)
  941. {
  942. /* return address of TDR register */
  943. data_reg_addr = (uint32_t)&(SWPMIx->TDR);
  944. }
  945. else
  946. {
  947. /* return address of RDR register */
  948. data_reg_addr = (uint32_t)&(SWPMIx->RDR);
  949. }
  950. return data_reg_addr;
  951. }
  952. /**
  953. * @}
  954. */
  955. /** @defgroup SWPMI_LL_EF_Data_Management Data_Management
  956. * @{
  957. */
  958. /**
  959. * @brief Retrieve number of data bytes present in payload of received frame
  960. * @rmtoll RFL RFL LL_SWPMI_GetReceiveFrameLength
  961. * @param SWPMIx SWPMI Instance
  962. * @retval Value between Min_Data=0x00 and Max_Data=0x1F
  963. */
  964. __STATIC_INLINE uint32_t LL_SWPMI_GetReceiveFrameLength(SWPMI_TypeDef *SWPMIx)
  965. {
  966. return (uint32_t)(READ_BIT(SWPMIx->RFL, SWPMI_RFL_RFL));
  967. }
  968. /**
  969. * @brief Transmit Data Register
  970. * @rmtoll TDR TD LL_SWPMI_TransmitData32
  971. * @param SWPMIx SWPMI Instance
  972. * @param TxData Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  973. * @retval None
  974. */
  975. __STATIC_INLINE void LL_SWPMI_TransmitData32(SWPMI_TypeDef *SWPMIx, uint32_t TxData)
  976. {
  977. WRITE_REG(SWPMIx->TDR, TxData);
  978. }
  979. /**
  980. * @brief Receive Data Register
  981. * @rmtoll RDR RD LL_SWPMI_ReceiveData32
  982. * @param SWPMIx SWPMI Instance
  983. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  984. */
  985. __STATIC_INLINE uint32_t LL_SWPMI_ReceiveData32(SWPMI_TypeDef *SWPMIx)
  986. {
  987. return (uint32_t)(READ_BIT(SWPMIx->RDR, SWPMI_RDR_RD));
  988. }
  989. /**
  990. * @brief Enable SWP Transceiver Bypass
  991. * @note The external interface for SWPMI is SWPMI_IO
  992. * (SWPMI_RX, SWPMI_TX and SWPMI_SUSPEND signals are not available on GPIOs)
  993. * @rmtoll OR TBYP LL_SWPMI_EnableTXBypass
  994. * @param SWPMIx SWPMI Instance
  995. * @retval None
  996. */
  997. __STATIC_INLINE void LL_SWPMI_EnableTXBypass(SWPMI_TypeDef *SWPMIx)
  998. {
  999. CLEAR_BIT(SWPMIx->OR, SWPMI_OR_TBYP);
  1000. }
  1001. /**
  1002. * @brief Disable SWP Transceiver Bypass
  1003. * @note SWPMI_RX, SWPMI_TX and SWPMI_SUSPEND signals are available as alternate
  1004. * function on GPIOs. This configuration is selected to connect an external transceiver
  1005. * @rmtoll OR TBYP LL_SWPMI_DisableTXBypass
  1006. * @param SWPMIx SWPMI Instance
  1007. * @retval None
  1008. */
  1009. __STATIC_INLINE void LL_SWPMI_DisableTXBypass(SWPMI_TypeDef *SWPMIx)
  1010. {
  1011. SET_BIT(SWPMIx->OR, SWPMI_OR_TBYP);
  1012. }
  1013. /**
  1014. * @}
  1015. */
  1016. #if defined(USE_FULL_LL_DRIVER)
  1017. /** @defgroup SWPMI_LL_EF_Init Initialization and de-initialization functions
  1018. * @{
  1019. */
  1020. ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx);
  1021. ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct);
  1022. void LL_SWPMI_StructInit(LL_SWPMI_InitTypeDef *SWPMI_InitStruct);
  1023. /**
  1024. * @}
  1025. */
  1026. #endif /*USE_FULL_LL_DRIVER*/
  1027. /**
  1028. * @}
  1029. */
  1030. /**
  1031. * @}
  1032. */
  1033. #endif /* defined (SWPMI1) */
  1034. /**
  1035. * @}
  1036. */
  1037. #ifdef __cplusplus
  1038. }
  1039. #endif
  1040. #endif /* __STM32L4xx_LL_SWPMI_H */
  1041. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/