stm32l0xx_ll_spi.h 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_ll_spi.h
  4. * @author MCD Application Team
  5. * @brief Header file of SPI LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 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 STM32L0xx_LL_SPI_H
  20. #define STM32L0xx_LL_SPI_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l0xx.h"
  26. /** @addtogroup STM32L0xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (SPI1) || defined (SPI2)
  30. /** @defgroup SPI_LL SPI
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private macros ------------------------------------------------------------*/
  36. /* Exported types ------------------------------------------------------------*/
  37. #if defined(USE_FULL_LL_DRIVER)
  38. /** @defgroup SPI_LL_ES_INIT SPI Exported Init structure
  39. * @{
  40. */
  41. /**
  42. * @brief SPI Init structures definition
  43. */
  44. typedef struct
  45. {
  46. uint32_t TransferDirection; /*!< Specifies the SPI unidirectional or bidirectional data mode.
  47. This parameter can be a value of @ref SPI_LL_EC_TRANSFER_MODE.
  48. This feature can be modified afterwards using unitary
  49. function @ref LL_SPI_SetTransferDirection().*/
  50. uint32_t Mode; /*!< Specifies the SPI mode (Master/Slave).
  51. This parameter can be a value of @ref SPI_LL_EC_MODE.
  52. This feature can be modified afterwards using unitary
  53. function @ref LL_SPI_SetMode().*/
  54. uint32_t DataWidth; /*!< Specifies the SPI data width.
  55. This parameter can be a value of @ref SPI_LL_EC_DATAWIDTH.
  56. This feature can be modified afterwards using unitary
  57. function @ref LL_SPI_SetDataWidth().*/
  58. uint32_t ClockPolarity; /*!< Specifies the serial clock steady state.
  59. This parameter can be a value of @ref SPI_LL_EC_POLARITY.
  60. This feature can be modified afterwards using unitary
  61. function @ref LL_SPI_SetClockPolarity().*/
  62. uint32_t ClockPhase; /*!< Specifies the clock active edge for the bit capture.
  63. This parameter can be a value of @ref SPI_LL_EC_PHASE.
  64. This feature can be modified afterwards using unitary
  65. function @ref LL_SPI_SetClockPhase().*/
  66. uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin)
  67. or by software using the SSI bit.
  68. This parameter can be a value of @ref SPI_LL_EC_NSS_MODE.
  69. This feature can be modified afterwards using unitary
  70. function @ref LL_SPI_SetNSSMode().*/
  71. uint32_t BaudRate; /*!< Specifies the BaudRate prescaler value which will be used
  72. to configure the transmit and receive SCK clock.
  73. This parameter can be a value of @ref SPI_LL_EC_BAUDRATEPRESCALER.
  74. @note The communication clock is derived from the master clock.
  75. The slave clock does not need to be set.
  76. This feature can be modified afterwards using unitary
  77. function @ref LL_SPI_SetBaudRatePrescaler().*/
  78. uint32_t BitOrder; /*!< Specifies whether data transfers start from MSB or LSB bit.
  79. This parameter can be a value of @ref SPI_LL_EC_BIT_ORDER.
  80. This feature can be modified afterwards using unitary
  81. function @ref LL_SPI_SetTransferBitOrder().*/
  82. uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
  83. This parameter can be a value of @ref SPI_LL_EC_CRC_CALCULATION.
  84. This feature can be modified afterwards using unitary
  85. functions @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/
  86. uint32_t CRCPoly; /*!< Specifies the polynomial used for the CRC calculation.
  87. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF.
  88. This feature can be modified afterwards using unitary
  89. function @ref LL_SPI_SetCRCPolynomial().*/
  90. } LL_SPI_InitTypeDef;
  91. /**
  92. * @}
  93. */
  94. #endif /* USE_FULL_LL_DRIVER */
  95. /* Exported constants --------------------------------------------------------*/
  96. /** @defgroup SPI_LL_Exported_Constants SPI Exported Constants
  97. * @{
  98. */
  99. /** @defgroup SPI_LL_EC_GET_FLAG Get Flags Defines
  100. * @brief Flags defines which can be used with LL_SPI_ReadReg function
  101. * @{
  102. */
  103. #define LL_SPI_SR_RXNE SPI_SR_RXNE /*!< Rx buffer not empty flag */
  104. #define LL_SPI_SR_TXE SPI_SR_TXE /*!< Tx buffer empty flag */
  105. #define LL_SPI_SR_BSY SPI_SR_BSY /*!< Busy flag */
  106. #define LL_SPI_SR_CRCERR SPI_SR_CRCERR /*!< CRC error flag */
  107. #define LL_SPI_SR_MODF SPI_SR_MODF /*!< Mode fault flag */
  108. #define LL_SPI_SR_OVR SPI_SR_OVR /*!< Overrun flag */
  109. #define LL_SPI_SR_FRE SPI_SR_FRE /*!< TI mode frame format error flag */
  110. /**
  111. * @}
  112. */
  113. /** @defgroup SPI_LL_EC_IT IT Defines
  114. * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions
  115. * @{
  116. */
  117. #define LL_SPI_CR2_RXNEIE SPI_CR2_RXNEIE /*!< Rx buffer not empty interrupt enable */
  118. #define LL_SPI_CR2_TXEIE SPI_CR2_TXEIE /*!< Tx buffer empty interrupt enable */
  119. #define LL_SPI_CR2_ERRIE SPI_CR2_ERRIE /*!< Error interrupt enable */
  120. /**
  121. * @}
  122. */
  123. /** @defgroup SPI_LL_EC_MODE Operation Mode
  124. * @{
  125. */
  126. #define LL_SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) /*!< Master configuration */
  127. #define LL_SPI_MODE_SLAVE 0x00000000U /*!< Slave configuration */
  128. /**
  129. * @}
  130. */
  131. /** @defgroup SPI_LL_EC_PROTOCOL Serial Protocol
  132. * @{
  133. */
  134. #define LL_SPI_PROTOCOL_MOTOROLA 0x00000000U /*!< Motorola mode. Used as default value */
  135. #define LL_SPI_PROTOCOL_TI (SPI_CR2_FRF) /*!< TI mode */
  136. /**
  137. * @}
  138. */
  139. /** @defgroup SPI_LL_EC_PHASE Clock Phase
  140. * @{
  141. */
  142. #define LL_SPI_PHASE_1EDGE 0x00000000U /*!< First clock transition is the first data capture edge */
  143. #define LL_SPI_PHASE_2EDGE (SPI_CR1_CPHA) /*!< Second clock transition is the first data capture edge */
  144. /**
  145. * @}
  146. */
  147. /** @defgroup SPI_LL_EC_POLARITY Clock Polarity
  148. * @{
  149. */
  150. #define LL_SPI_POLARITY_LOW 0x00000000U /*!< Clock to 0 when idle */
  151. #define LL_SPI_POLARITY_HIGH (SPI_CR1_CPOL) /*!< Clock to 1 when idle */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup SPI_LL_EC_BAUDRATEPRESCALER Baud Rate Prescaler
  156. * @{
  157. */
  158. #define LL_SPI_BAUDRATEPRESCALER_DIV2 0x00000000U /*!< BaudRate control equal to fPCLK/2 */
  159. #define LL_SPI_BAUDRATEPRESCALER_DIV4 (SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/4 */
  160. #define LL_SPI_BAUDRATEPRESCALER_DIV8 (SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/8 */
  161. #define LL_SPI_BAUDRATEPRESCALER_DIV16 (SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/16 */
  162. #define LL_SPI_BAUDRATEPRESCALER_DIV32 (SPI_CR1_BR_2) /*!< BaudRate control equal to fPCLK/32 */
  163. #define LL_SPI_BAUDRATEPRESCALER_DIV64 (SPI_CR1_BR_2 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/64 */
  164. #define LL_SPI_BAUDRATEPRESCALER_DIV128 (SPI_CR1_BR_2 | SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/128 */
  165. #define LL_SPI_BAUDRATEPRESCALER_DIV256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/256 */
  166. /**
  167. * @}
  168. */
  169. /** @defgroup SPI_LL_EC_BIT_ORDER Transmission Bit Order
  170. * @{
  171. */
  172. #define LL_SPI_LSB_FIRST (SPI_CR1_LSBFIRST) /*!< Data is transmitted/received with the LSB first */
  173. #define LL_SPI_MSB_FIRST 0x00000000U /*!< Data is transmitted/received with the MSB first */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup SPI_LL_EC_TRANSFER_MODE Transfer Mode
  178. * @{
  179. */
  180. #define LL_SPI_FULL_DUPLEX 0x00000000U /*!< Full-Duplex mode. Rx and Tx transfer on 2 lines */
  181. #define LL_SPI_SIMPLEX_RX (SPI_CR1_RXONLY) /*!< Simplex Rx mode. Rx transfer only on 1 line */
  182. #define LL_SPI_HALF_DUPLEX_RX (SPI_CR1_BIDIMODE) /*!< Half-Duplex Rx mode. Rx transfer on 1 line */
  183. #define LL_SPI_HALF_DUPLEX_TX (SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE) /*!< Half-Duplex Tx mode. Tx transfer on 1 line */
  184. /**
  185. * @}
  186. */
  187. /** @defgroup SPI_LL_EC_NSS_MODE Slave Select Pin Mode
  188. * @{
  189. */
  190. #define LL_SPI_NSS_SOFT (SPI_CR1_SSM) /*!< NSS managed internally. NSS pin not used and free */
  191. #define LL_SPI_NSS_HARD_INPUT 0x00000000U /*!< NSS pin used in Input. Only used in Master mode */
  192. #define LL_SPI_NSS_HARD_OUTPUT (((uint32_t)SPI_CR2_SSOE << 16U)) /*!< NSS pin used in Output. Only used in Slave mode as chip select */
  193. /**
  194. * @}
  195. */
  196. /** @defgroup SPI_LL_EC_DATAWIDTH Datawidth
  197. * @{
  198. */
  199. #define LL_SPI_DATAWIDTH_8BIT 0x00000000U /*!< Data length for SPI transfer: 8 bits */
  200. #define LL_SPI_DATAWIDTH_16BIT (SPI_CR1_DFF) /*!< Data length for SPI transfer: 16 bits */
  201. /**
  202. * @}
  203. */
  204. #if defined(USE_FULL_LL_DRIVER)
  205. /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation
  206. * @{
  207. */
  208. #define LL_SPI_CRCCALCULATION_DISABLE 0x00000000U /*!< CRC calculation disabled */
  209. #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CR1_CRCEN) /*!< CRC calculation enabled */
  210. /**
  211. * @}
  212. */
  213. #endif /* USE_FULL_LL_DRIVER */
  214. /**
  215. * @}
  216. */
  217. /* Exported macro ------------------------------------------------------------*/
  218. /** @defgroup SPI_LL_Exported_Macros SPI Exported Macros
  219. * @{
  220. */
  221. /** @defgroup SPI_LL_EM_WRITE_READ Common Write and read registers Macros
  222. * @{
  223. */
  224. /**
  225. * @brief Write a value in SPI register
  226. * @param __INSTANCE__ SPI Instance
  227. * @param __REG__ Register to be written
  228. * @param __VALUE__ Value to be written in the register
  229. * @retval None
  230. */
  231. #define LL_SPI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  232. /**
  233. * @brief Read a value in SPI register
  234. * @param __INSTANCE__ SPI Instance
  235. * @param __REG__ Register to be read
  236. * @retval Register value
  237. */
  238. #define LL_SPI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  239. /**
  240. * @}
  241. */
  242. /**
  243. * @}
  244. */
  245. /* Exported functions --------------------------------------------------------*/
  246. /** @defgroup SPI_LL_Exported_Functions SPI Exported Functions
  247. * @{
  248. */
  249. /** @defgroup SPI_LL_EF_Configuration Configuration
  250. * @{
  251. */
  252. /**
  253. * @brief Enable SPI peripheral
  254. * @rmtoll CR1 SPE LL_SPI_Enable
  255. * @param SPIx SPI Instance
  256. * @retval None
  257. */
  258. __STATIC_INLINE void LL_SPI_Enable(SPI_TypeDef *SPIx)
  259. {
  260. SET_BIT(SPIx->CR1, SPI_CR1_SPE);
  261. }
  262. /**
  263. * @brief Disable SPI peripheral
  264. * @note When disabling the SPI, follow the procedure described in the Reference Manual.
  265. * @rmtoll CR1 SPE LL_SPI_Disable
  266. * @param SPIx SPI Instance
  267. * @retval None
  268. */
  269. __STATIC_INLINE void LL_SPI_Disable(SPI_TypeDef *SPIx)
  270. {
  271. CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  272. }
  273. /**
  274. * @brief Check if SPI peripheral is enabled
  275. * @rmtoll CR1 SPE LL_SPI_IsEnabled
  276. * @param SPIx SPI Instance
  277. * @retval State of bit (1 or 0).
  278. */
  279. __STATIC_INLINE uint32_t LL_SPI_IsEnabled(const SPI_TypeDef *SPIx)
  280. {
  281. return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL);
  282. }
  283. /**
  284. * @brief Set SPI operation mode to Master or Slave
  285. * @note This bit should not be changed when communication is ongoing.
  286. * @rmtoll CR1 MSTR LL_SPI_SetMode\n
  287. * CR1 SSI LL_SPI_SetMode
  288. * @param SPIx SPI Instance
  289. * @param Mode This parameter can be one of the following values:
  290. * @arg @ref LL_SPI_MODE_MASTER
  291. * @arg @ref LL_SPI_MODE_SLAVE
  292. * @retval None
  293. */
  294. __STATIC_INLINE void LL_SPI_SetMode(SPI_TypeDef *SPIx, uint32_t Mode)
  295. {
  296. MODIFY_REG(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI, Mode);
  297. }
  298. /**
  299. * @brief Get SPI operation mode (Master or Slave)
  300. * @rmtoll CR1 MSTR LL_SPI_GetMode\n
  301. * CR1 SSI LL_SPI_GetMode
  302. * @param SPIx SPI Instance
  303. * @retval Returned value can be one of the following values:
  304. * @arg @ref LL_SPI_MODE_MASTER
  305. * @arg @ref LL_SPI_MODE_SLAVE
  306. */
  307. __STATIC_INLINE uint32_t LL_SPI_GetMode(const SPI_TypeDef *SPIx)
  308. {
  309. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI));
  310. }
  311. /**
  312. * @brief Set serial protocol used
  313. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  314. * @rmtoll CR2 FRF LL_SPI_SetStandard
  315. * @param SPIx SPI Instance
  316. * @param Standard This parameter can be one of the following values:
  317. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  318. * @arg @ref LL_SPI_PROTOCOL_TI
  319. * @retval None
  320. */
  321. __STATIC_INLINE void LL_SPI_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard)
  322. {
  323. MODIFY_REG(SPIx->CR2, SPI_CR2_FRF, Standard);
  324. }
  325. /**
  326. * @brief Get serial protocol used
  327. * @rmtoll CR2 FRF LL_SPI_GetStandard
  328. * @param SPIx SPI Instance
  329. * @retval Returned value can be one of the following values:
  330. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  331. * @arg @ref LL_SPI_PROTOCOL_TI
  332. */
  333. __STATIC_INLINE uint32_t LL_SPI_GetStandard(const SPI_TypeDef *SPIx)
  334. {
  335. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRF));
  336. }
  337. /**
  338. * @brief Set clock phase
  339. * @note This bit should not be changed when communication is ongoing.
  340. * This bit is not used in SPI TI mode.
  341. * @rmtoll CR1 CPHA LL_SPI_SetClockPhase
  342. * @param SPIx SPI Instance
  343. * @param ClockPhase This parameter can be one of the following values:
  344. * @arg @ref LL_SPI_PHASE_1EDGE
  345. * @arg @ref LL_SPI_PHASE_2EDGE
  346. * @retval None
  347. */
  348. __STATIC_INLINE void LL_SPI_SetClockPhase(SPI_TypeDef *SPIx, uint32_t ClockPhase)
  349. {
  350. MODIFY_REG(SPIx->CR1, SPI_CR1_CPHA, ClockPhase);
  351. }
  352. /**
  353. * @brief Get clock phase
  354. * @rmtoll CR1 CPHA LL_SPI_GetClockPhase
  355. * @param SPIx SPI Instance
  356. * @retval Returned value can be one of the following values:
  357. * @arg @ref LL_SPI_PHASE_1EDGE
  358. * @arg @ref LL_SPI_PHASE_2EDGE
  359. */
  360. __STATIC_INLINE uint32_t LL_SPI_GetClockPhase(const SPI_TypeDef *SPIx)
  361. {
  362. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPHA));
  363. }
  364. /**
  365. * @brief Set clock polarity
  366. * @note This bit should not be changed when communication is ongoing.
  367. * This bit is not used in SPI TI mode.
  368. * @rmtoll CR1 CPOL LL_SPI_SetClockPolarity
  369. * @param SPIx SPI Instance
  370. * @param ClockPolarity This parameter can be one of the following values:
  371. * @arg @ref LL_SPI_POLARITY_LOW
  372. * @arg @ref LL_SPI_POLARITY_HIGH
  373. * @retval None
  374. */
  375. __STATIC_INLINE void LL_SPI_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity)
  376. {
  377. MODIFY_REG(SPIx->CR1, SPI_CR1_CPOL, ClockPolarity);
  378. }
  379. /**
  380. * @brief Get clock polarity
  381. * @rmtoll CR1 CPOL LL_SPI_GetClockPolarity
  382. * @param SPIx SPI Instance
  383. * @retval Returned value can be one of the following values:
  384. * @arg @ref LL_SPI_POLARITY_LOW
  385. * @arg @ref LL_SPI_POLARITY_HIGH
  386. */
  387. __STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(const SPI_TypeDef *SPIx)
  388. {
  389. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPOL));
  390. }
  391. /**
  392. * @brief Set baud rate prescaler
  393. * @note These bits should not be changed when communication is ongoing. SPI BaudRate = fPCLK/Prescaler.
  394. * @rmtoll CR1 BR LL_SPI_SetBaudRatePrescaler
  395. * @param SPIx SPI Instance
  396. * @param BaudRate This parameter can be one of the following values:
  397. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  398. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  399. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  400. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  401. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  402. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  403. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  404. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  405. * @retval None
  406. */
  407. __STATIC_INLINE void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef *SPIx, uint32_t BaudRate)
  408. {
  409. MODIFY_REG(SPIx->CR1, SPI_CR1_BR, BaudRate);
  410. }
  411. /**
  412. * @brief Get baud rate prescaler
  413. * @rmtoll CR1 BR LL_SPI_GetBaudRatePrescaler
  414. * @param SPIx SPI Instance
  415. * @retval Returned value can be one of the following values:
  416. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  417. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  418. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  419. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  420. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  421. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  422. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  423. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  424. */
  425. __STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(const SPI_TypeDef *SPIx)
  426. {
  427. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_BR));
  428. }
  429. /**
  430. * @brief Set transfer bit order
  431. * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
  432. * @rmtoll CR1 LSBFIRST LL_SPI_SetTransferBitOrder
  433. * @param SPIx SPI Instance
  434. * @param BitOrder This parameter can be one of the following values:
  435. * @arg @ref LL_SPI_LSB_FIRST
  436. * @arg @ref LL_SPI_MSB_FIRST
  437. * @retval None
  438. */
  439. __STATIC_INLINE void LL_SPI_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder)
  440. {
  441. MODIFY_REG(SPIx->CR1, SPI_CR1_LSBFIRST, BitOrder);
  442. }
  443. /**
  444. * @brief Get transfer bit order
  445. * @rmtoll CR1 LSBFIRST LL_SPI_GetTransferBitOrder
  446. * @param SPIx SPI Instance
  447. * @retval Returned value can be one of the following values:
  448. * @arg @ref LL_SPI_LSB_FIRST
  449. * @arg @ref LL_SPI_MSB_FIRST
  450. */
  451. __STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(const SPI_TypeDef *SPIx)
  452. {
  453. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_LSBFIRST));
  454. }
  455. /**
  456. * @brief Set transfer direction mode
  457. * @note For Half-Duplex mode, Rx Direction is set by default.
  458. * In master mode, the MOSI pin is used and in slave mode, the MISO pin is used for Half-Duplex.
  459. * @rmtoll CR1 RXONLY LL_SPI_SetTransferDirection\n
  460. * CR1 BIDIMODE LL_SPI_SetTransferDirection\n
  461. * CR1 BIDIOE LL_SPI_SetTransferDirection
  462. * @param SPIx SPI Instance
  463. * @param TransferDirection This parameter can be one of the following values:
  464. * @arg @ref LL_SPI_FULL_DUPLEX
  465. * @arg @ref LL_SPI_SIMPLEX_RX
  466. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  467. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  468. * @retval None
  469. */
  470. __STATIC_INLINE void LL_SPI_SetTransferDirection(SPI_TypeDef *SPIx, uint32_t TransferDirection)
  471. {
  472. MODIFY_REG(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE, TransferDirection);
  473. }
  474. /**
  475. * @brief Get transfer direction mode
  476. * @rmtoll CR1 RXONLY LL_SPI_GetTransferDirection\n
  477. * CR1 BIDIMODE LL_SPI_GetTransferDirection\n
  478. * CR1 BIDIOE LL_SPI_GetTransferDirection
  479. * @param SPIx SPI Instance
  480. * @retval Returned value can be one of the following values:
  481. * @arg @ref LL_SPI_FULL_DUPLEX
  482. * @arg @ref LL_SPI_SIMPLEX_RX
  483. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  484. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  485. */
  486. __STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(const SPI_TypeDef *SPIx)
  487. {
  488. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE));
  489. }
  490. /**
  491. * @brief Set frame data width
  492. * @rmtoll CR1 DFF LL_SPI_SetDataWidth
  493. * @param SPIx SPI Instance
  494. * @param DataWidth This parameter can be one of the following values:
  495. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  496. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  497. * @retval None
  498. */
  499. __STATIC_INLINE void LL_SPI_SetDataWidth(SPI_TypeDef *SPIx, uint32_t DataWidth)
  500. {
  501. MODIFY_REG(SPIx->CR1, SPI_CR1_DFF, DataWidth);
  502. }
  503. /**
  504. * @brief Get frame data width
  505. * @rmtoll CR1 DFF LL_SPI_GetDataWidth
  506. * @param SPIx SPI Instance
  507. * @retval Returned value can be one of the following values:
  508. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  509. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  510. */
  511. __STATIC_INLINE uint32_t LL_SPI_GetDataWidth(const SPI_TypeDef *SPIx)
  512. {
  513. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_DFF));
  514. }
  515. /**
  516. * @}
  517. */
  518. /** @defgroup SPI_LL_EF_CRC_Management CRC Management
  519. * @{
  520. */
  521. /**
  522. * @brief Enable CRC
  523. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  524. * @rmtoll CR1 CRCEN LL_SPI_EnableCRC
  525. * @param SPIx SPI Instance
  526. * @retval None
  527. */
  528. __STATIC_INLINE void LL_SPI_EnableCRC(SPI_TypeDef *SPIx)
  529. {
  530. SET_BIT(SPIx->CR1, SPI_CR1_CRCEN);
  531. }
  532. /**
  533. * @brief Disable CRC
  534. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  535. * @rmtoll CR1 CRCEN LL_SPI_DisableCRC
  536. * @param SPIx SPI Instance
  537. * @retval None
  538. */
  539. __STATIC_INLINE void LL_SPI_DisableCRC(SPI_TypeDef *SPIx)
  540. {
  541. CLEAR_BIT(SPIx->CR1, SPI_CR1_CRCEN);
  542. }
  543. /**
  544. * @brief Check if CRC is enabled
  545. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  546. * @rmtoll CR1 CRCEN LL_SPI_IsEnabledCRC
  547. * @param SPIx SPI Instance
  548. * @retval State of bit (1 or 0).
  549. */
  550. __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(const SPI_TypeDef *SPIx)
  551. {
  552. return ((READ_BIT(SPIx->CR1, SPI_CR1_CRCEN) == (SPI_CR1_CRCEN)) ? 1UL : 0UL);
  553. }
  554. /**
  555. * @brief Set CRCNext to transfer CRC on the line
  556. * @note This bit has to be written as soon as the last data is written in the SPIx_DR register.
  557. * @rmtoll CR1 CRCNEXT LL_SPI_SetCRCNext
  558. * @param SPIx SPI Instance
  559. * @retval None
  560. */
  561. __STATIC_INLINE void LL_SPI_SetCRCNext(SPI_TypeDef *SPIx)
  562. {
  563. SET_BIT(SPIx->CR1, SPI_CR1_CRCNEXT);
  564. }
  565. /**
  566. * @brief Set polynomial for CRC calculation
  567. * @rmtoll CRCPR CRCPOLY LL_SPI_SetCRCPolynomial
  568. * @param SPIx SPI Instance
  569. * @param CRCPoly This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  570. * @retval None
  571. */
  572. __STATIC_INLINE void LL_SPI_SetCRCPolynomial(SPI_TypeDef *SPIx, uint32_t CRCPoly)
  573. {
  574. WRITE_REG(SPIx->CRCPR, (uint16_t)CRCPoly);
  575. }
  576. /**
  577. * @brief Get polynomial for CRC calculation
  578. * @rmtoll CRCPR CRCPOLY LL_SPI_GetCRCPolynomial
  579. * @param SPIx SPI Instance
  580. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  581. */
  582. __STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(const SPI_TypeDef *SPIx)
  583. {
  584. return (uint32_t)(READ_REG(SPIx->CRCPR));
  585. }
  586. /**
  587. * @brief Get Rx CRC
  588. * @rmtoll RXCRCR RXCRC LL_SPI_GetRxCRC
  589. * @param SPIx SPI Instance
  590. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  591. */
  592. __STATIC_INLINE uint32_t LL_SPI_GetRxCRC(const SPI_TypeDef *SPIx)
  593. {
  594. return (uint32_t)(READ_REG(SPIx->RXCRCR));
  595. }
  596. /**
  597. * @brief Get Tx CRC
  598. * @rmtoll TXCRCR TXCRC LL_SPI_GetTxCRC
  599. * @param SPIx SPI Instance
  600. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  601. */
  602. __STATIC_INLINE uint32_t LL_SPI_GetTxCRC(const SPI_TypeDef *SPIx)
  603. {
  604. return (uint32_t)(READ_REG(SPIx->TXCRCR));
  605. }
  606. /**
  607. * @}
  608. */
  609. /** @defgroup SPI_LL_EF_NSS_Management Slave Select Pin Management
  610. * @{
  611. */
  612. /**
  613. * @brief Set NSS mode
  614. * @note LL_SPI_NSS_SOFT Mode is not used in SPI TI mode.
  615. * @rmtoll CR1 SSM LL_SPI_SetNSSMode\n
  616. * @rmtoll CR2 SSOE LL_SPI_SetNSSMode
  617. * @param SPIx SPI Instance
  618. * @param NSS This parameter can be one of the following values:
  619. * @arg @ref LL_SPI_NSS_SOFT
  620. * @arg @ref LL_SPI_NSS_HARD_INPUT
  621. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  622. * @retval None
  623. */
  624. __STATIC_INLINE void LL_SPI_SetNSSMode(SPI_TypeDef *SPIx, uint32_t NSS)
  625. {
  626. MODIFY_REG(SPIx->CR1, SPI_CR1_SSM, NSS);
  627. MODIFY_REG(SPIx->CR2, SPI_CR2_SSOE, ((uint32_t)(NSS >> 16U)));
  628. }
  629. /**
  630. * @brief Get NSS mode
  631. * @rmtoll CR1 SSM LL_SPI_GetNSSMode\n
  632. * @rmtoll CR2 SSOE LL_SPI_GetNSSMode
  633. * @param SPIx SPI Instance
  634. * @retval Returned value can be one of the following values:
  635. * @arg @ref LL_SPI_NSS_SOFT
  636. * @arg @ref LL_SPI_NSS_HARD_INPUT
  637. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  638. */
  639. __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(const SPI_TypeDef *SPIx)
  640. {
  641. uint32_t Ssm = (READ_BIT(SPIx->CR1, SPI_CR1_SSM));
  642. uint32_t Ssoe = (READ_BIT(SPIx->CR2, SPI_CR2_SSOE) << 16U);
  643. return (Ssm | Ssoe);
  644. }
  645. /**
  646. * @}
  647. */
  648. /** @defgroup SPI_LL_EF_FLAG_Management FLAG Management
  649. * @{
  650. */
  651. /**
  652. * @brief Check if Rx buffer is not empty
  653. * @rmtoll SR RXNE LL_SPI_IsActiveFlag_RXNE
  654. * @param SPIx SPI Instance
  655. * @retval State of bit (1 or 0).
  656. */
  657. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(const SPI_TypeDef *SPIx)
  658. {
  659. return ((READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)) ? 1UL : 0UL);
  660. }
  661. /**
  662. * @brief Check if Tx buffer is empty
  663. * @rmtoll SR TXE LL_SPI_IsActiveFlag_TXE
  664. * @param SPIx SPI Instance
  665. * @retval State of bit (1 or 0).
  666. */
  667. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(const SPI_TypeDef *SPIx)
  668. {
  669. return ((READ_BIT(SPIx->SR, SPI_SR_TXE) == (SPI_SR_TXE)) ? 1UL : 0UL);
  670. }
  671. /**
  672. * @brief Get CRC error flag
  673. * @rmtoll SR CRCERR LL_SPI_IsActiveFlag_CRCERR
  674. * @param SPIx SPI Instance
  675. * @retval State of bit (1 or 0).
  676. */
  677. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(const SPI_TypeDef *SPIx)
  678. {
  679. return ((READ_BIT(SPIx->SR, SPI_SR_CRCERR) == (SPI_SR_CRCERR)) ? 1UL : 0UL);
  680. }
  681. /**
  682. * @brief Get mode fault error flag
  683. * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF
  684. * @param SPIx SPI Instance
  685. * @retval State of bit (1 or 0).
  686. */
  687. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(const SPI_TypeDef *SPIx)
  688. {
  689. return ((READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)) ? 1UL : 0UL);
  690. }
  691. /**
  692. * @brief Get overrun error flag
  693. * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR
  694. * @param SPIx SPI Instance
  695. * @retval State of bit (1 or 0).
  696. */
  697. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(const SPI_TypeDef *SPIx)
  698. {
  699. return ((READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)) ? 1UL : 0UL);
  700. }
  701. /**
  702. * @brief Get busy flag
  703. * @note The BSY flag is cleared under any one of the following conditions:
  704. * -When the SPI is correctly disabled
  705. * -When a fault is detected in Master mode (MODF bit set to 1)
  706. * -In Master mode, when it finishes a data transmission and no new data is ready to be
  707. * sent
  708. * -In Slave mode, when the BSY flag is set to '0' for at least one SPI clock cycle between
  709. * each data transfer.
  710. * @rmtoll SR BSY LL_SPI_IsActiveFlag_BSY
  711. * @param SPIx SPI Instance
  712. * @retval State of bit (1 or 0).
  713. */
  714. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(const SPI_TypeDef *SPIx)
  715. {
  716. return ((READ_BIT(SPIx->SR, SPI_SR_BSY) == (SPI_SR_BSY)) ? 1UL : 0UL);
  717. }
  718. /**
  719. * @brief Get frame format error flag
  720. * @rmtoll SR FRE LL_SPI_IsActiveFlag_FRE
  721. * @param SPIx SPI Instance
  722. * @retval State of bit (1 or 0).
  723. */
  724. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(const SPI_TypeDef *SPIx)
  725. {
  726. return ((READ_BIT(SPIx->SR, SPI_SR_FRE) == (SPI_SR_FRE)) ? 1UL : 0UL);
  727. }
  728. /**
  729. * @brief Clear CRC error flag
  730. * @rmtoll SR CRCERR LL_SPI_ClearFlag_CRCERR
  731. * @param SPIx SPI Instance
  732. * @retval None
  733. */
  734. __STATIC_INLINE void LL_SPI_ClearFlag_CRCERR(SPI_TypeDef *SPIx)
  735. {
  736. CLEAR_BIT(SPIx->SR, SPI_SR_CRCERR);
  737. }
  738. /**
  739. * @brief Clear mode fault error flag
  740. * @note Clearing this flag is done by a read access to the SPIx_SR
  741. * register followed by a write access to the SPIx_CR1 register
  742. * @rmtoll SR MODF LL_SPI_ClearFlag_MODF
  743. * @param SPIx SPI Instance
  744. * @retval None
  745. */
  746. __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx)
  747. {
  748. __IO uint32_t tmpreg_sr;
  749. tmpreg_sr = SPIx->SR;
  750. (void) tmpreg_sr;
  751. CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  752. }
  753. /**
  754. * @brief Clear overrun error flag
  755. * @note Clearing this flag is done by a read access to the SPIx_DR
  756. * register followed by a read access to the SPIx_SR register
  757. * @rmtoll SR OVR LL_SPI_ClearFlag_OVR
  758. * @param SPIx SPI Instance
  759. * @retval None
  760. */
  761. __STATIC_INLINE void LL_SPI_ClearFlag_OVR(const SPI_TypeDef *SPIx)
  762. {
  763. __IO uint32_t tmpreg;
  764. tmpreg = SPIx->DR;
  765. (void) tmpreg;
  766. tmpreg = SPIx->SR;
  767. (void) tmpreg;
  768. }
  769. /**
  770. * @brief Clear frame format error flag
  771. * @note Clearing this flag is done by reading SPIx_SR register
  772. * @rmtoll SR FRE LL_SPI_ClearFlag_FRE
  773. * @param SPIx SPI Instance
  774. * @retval None
  775. */
  776. __STATIC_INLINE void LL_SPI_ClearFlag_FRE(const SPI_TypeDef *SPIx)
  777. {
  778. __IO uint32_t tmpreg;
  779. tmpreg = SPIx->SR;
  780. (void) tmpreg;
  781. }
  782. /**
  783. * @}
  784. */
  785. /** @defgroup SPI_LL_EF_IT_Management Interrupt Management
  786. * @{
  787. */
  788. /**
  789. * @brief Enable error interrupt
  790. * @note This bit controls the generation of an interrupt when an error condition
  791. * occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
  792. * @rmtoll CR2 ERRIE LL_SPI_EnableIT_ERR
  793. * @param SPIx SPI Instance
  794. * @retval None
  795. */
  796. __STATIC_INLINE void LL_SPI_EnableIT_ERR(SPI_TypeDef *SPIx)
  797. {
  798. SET_BIT(SPIx->CR2, SPI_CR2_ERRIE);
  799. }
  800. /**
  801. * @brief Enable Rx buffer not empty interrupt
  802. * @rmtoll CR2 RXNEIE LL_SPI_EnableIT_RXNE
  803. * @param SPIx SPI Instance
  804. * @retval None
  805. */
  806. __STATIC_INLINE void LL_SPI_EnableIT_RXNE(SPI_TypeDef *SPIx)
  807. {
  808. SET_BIT(SPIx->CR2, SPI_CR2_RXNEIE);
  809. }
  810. /**
  811. * @brief Enable Tx buffer empty interrupt
  812. * @rmtoll CR2 TXEIE LL_SPI_EnableIT_TXE
  813. * @param SPIx SPI Instance
  814. * @retval None
  815. */
  816. __STATIC_INLINE void LL_SPI_EnableIT_TXE(SPI_TypeDef *SPIx)
  817. {
  818. SET_BIT(SPIx->CR2, SPI_CR2_TXEIE);
  819. }
  820. /**
  821. * @brief Disable error interrupt
  822. * @note This bit controls the generation of an interrupt when an error condition
  823. * occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
  824. * @rmtoll CR2 ERRIE LL_SPI_DisableIT_ERR
  825. * @param SPIx SPI Instance
  826. * @retval None
  827. */
  828. __STATIC_INLINE void LL_SPI_DisableIT_ERR(SPI_TypeDef *SPIx)
  829. {
  830. CLEAR_BIT(SPIx->CR2, SPI_CR2_ERRIE);
  831. }
  832. /**
  833. * @brief Disable Rx buffer not empty interrupt
  834. * @rmtoll CR2 RXNEIE LL_SPI_DisableIT_RXNE
  835. * @param SPIx SPI Instance
  836. * @retval None
  837. */
  838. __STATIC_INLINE void LL_SPI_DisableIT_RXNE(SPI_TypeDef *SPIx)
  839. {
  840. CLEAR_BIT(SPIx->CR2, SPI_CR2_RXNEIE);
  841. }
  842. /**
  843. * @brief Disable Tx buffer empty interrupt
  844. * @rmtoll CR2 TXEIE LL_SPI_DisableIT_TXE
  845. * @param SPIx SPI Instance
  846. * @retval None
  847. */
  848. __STATIC_INLINE void LL_SPI_DisableIT_TXE(SPI_TypeDef *SPIx)
  849. {
  850. CLEAR_BIT(SPIx->CR2, SPI_CR2_TXEIE);
  851. }
  852. /**
  853. * @brief Check if error interrupt is enabled
  854. * @rmtoll CR2 ERRIE LL_SPI_IsEnabledIT_ERR
  855. * @param SPIx SPI Instance
  856. * @retval State of bit (1 or 0).
  857. */
  858. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(const SPI_TypeDef *SPIx)
  859. {
  860. return ((READ_BIT(SPIx->CR2, SPI_CR2_ERRIE) == (SPI_CR2_ERRIE)) ? 1UL : 0UL);
  861. }
  862. /**
  863. * @brief Check if Rx buffer not empty interrupt is enabled
  864. * @rmtoll CR2 RXNEIE LL_SPI_IsEnabledIT_RXNE
  865. * @param SPIx SPI Instance
  866. * @retval State of bit (1 or 0).
  867. */
  868. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(const SPI_TypeDef *SPIx)
  869. {
  870. return ((READ_BIT(SPIx->CR2, SPI_CR2_RXNEIE) == (SPI_CR2_RXNEIE)) ? 1UL : 0UL);
  871. }
  872. /**
  873. * @brief Check if Tx buffer empty interrupt
  874. * @rmtoll CR2 TXEIE LL_SPI_IsEnabledIT_TXE
  875. * @param SPIx SPI Instance
  876. * @retval State of bit (1 or 0).
  877. */
  878. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(const SPI_TypeDef *SPIx)
  879. {
  880. return ((READ_BIT(SPIx->CR2, SPI_CR2_TXEIE) == (SPI_CR2_TXEIE)) ? 1UL : 0UL);
  881. }
  882. /**
  883. * @}
  884. */
  885. /** @defgroup SPI_LL_EF_DMA_Management DMA Management
  886. * @{
  887. */
  888. /**
  889. * @brief Enable DMA Rx
  890. * @rmtoll CR2 RXDMAEN LL_SPI_EnableDMAReq_RX
  891. * @param SPIx SPI Instance
  892. * @retval None
  893. */
  894. __STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx)
  895. {
  896. SET_BIT(SPIx->CR2, SPI_CR2_RXDMAEN);
  897. }
  898. /**
  899. * @brief Disable DMA Rx
  900. * @rmtoll CR2 RXDMAEN LL_SPI_DisableDMAReq_RX
  901. * @param SPIx SPI Instance
  902. * @retval None
  903. */
  904. __STATIC_INLINE void LL_SPI_DisableDMAReq_RX(SPI_TypeDef *SPIx)
  905. {
  906. CLEAR_BIT(SPIx->CR2, SPI_CR2_RXDMAEN);
  907. }
  908. /**
  909. * @brief Check if DMA Rx is enabled
  910. * @rmtoll CR2 RXDMAEN LL_SPI_IsEnabledDMAReq_RX
  911. * @param SPIx SPI Instance
  912. * @retval State of bit (1 or 0).
  913. */
  914. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(const SPI_TypeDef *SPIx)
  915. {
  916. return ((READ_BIT(SPIx->CR2, SPI_CR2_RXDMAEN) == (SPI_CR2_RXDMAEN)) ? 1UL : 0UL);
  917. }
  918. /**
  919. * @brief Enable DMA Tx
  920. * @rmtoll CR2 TXDMAEN LL_SPI_EnableDMAReq_TX
  921. * @param SPIx SPI Instance
  922. * @retval None
  923. */
  924. __STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx)
  925. {
  926. SET_BIT(SPIx->CR2, SPI_CR2_TXDMAEN);
  927. }
  928. /**
  929. * @brief Disable DMA Tx
  930. * @rmtoll CR2 TXDMAEN LL_SPI_DisableDMAReq_TX
  931. * @param SPIx SPI Instance
  932. * @retval None
  933. */
  934. __STATIC_INLINE void LL_SPI_DisableDMAReq_TX(SPI_TypeDef *SPIx)
  935. {
  936. CLEAR_BIT(SPIx->CR2, SPI_CR2_TXDMAEN);
  937. }
  938. /**
  939. * @brief Check if DMA Tx is enabled
  940. * @rmtoll CR2 TXDMAEN LL_SPI_IsEnabledDMAReq_TX
  941. * @param SPIx SPI Instance
  942. * @retval State of bit (1 or 0).
  943. */
  944. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(const SPI_TypeDef *SPIx)
  945. {
  946. return ((READ_BIT(SPIx->CR2, SPI_CR2_TXDMAEN) == (SPI_CR2_TXDMAEN)) ? 1UL : 0UL);
  947. }
  948. /**
  949. * @brief Get the data register address used for DMA transfer
  950. * @rmtoll DR DR LL_SPI_DMA_GetRegAddr
  951. * @param SPIx SPI Instance
  952. * @retval Address of data register
  953. */
  954. __STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(const SPI_TypeDef *SPIx)
  955. {
  956. return (uint32_t) &(SPIx->DR);
  957. }
  958. /**
  959. * @}
  960. */
  961. /** @defgroup SPI_LL_EF_DATA_Management DATA Management
  962. * @{
  963. */
  964. /**
  965. * @brief Read 8-Bits in the data register
  966. * @rmtoll DR DR LL_SPI_ReceiveData8
  967. * @param SPIx SPI Instance
  968. * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFF
  969. */
  970. __STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)
  971. {
  972. return (*((__IO uint8_t *)&SPIx->DR));
  973. }
  974. /**
  975. * @brief Read 16-Bits in the data register
  976. * @rmtoll DR DR LL_SPI_ReceiveData16
  977. * @param SPIx SPI Instance
  978. * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFFFF
  979. */
  980. __STATIC_INLINE uint16_t LL_SPI_ReceiveData16(SPI_TypeDef *SPIx)
  981. {
  982. return (uint16_t)(READ_REG(SPIx->DR));
  983. }
  984. /**
  985. * @brief Write 8-Bits in the data register
  986. * @rmtoll DR DR LL_SPI_TransmitData8
  987. * @param SPIx SPI Instance
  988. * @param TxData Value between Min_Data=0x00 and Max_Data=0xFF
  989. * @retval None
  990. */
  991. __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
  992. {
  993. #if defined (__GNUC__)
  994. __IO uint8_t *spidr = ((__IO uint8_t *)&SPIx->DR);
  995. *spidr = TxData;
  996. #else
  997. *((__IO uint8_t *)&SPIx->DR) = TxData;
  998. #endif /* __GNUC__ */
  999. }
  1000. /**
  1001. * @brief Write 16-Bits in the data register
  1002. * @rmtoll DR DR LL_SPI_TransmitData16
  1003. * @param SPIx SPI Instance
  1004. * @param TxData Value between Min_Data=0x00 and Max_Data=0xFFFF
  1005. * @retval None
  1006. */
  1007. __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
  1008. {
  1009. #if defined (__GNUC__)
  1010. __IO uint16_t *spidr = ((__IO uint16_t *)&SPIx->DR);
  1011. *spidr = TxData;
  1012. #else
  1013. SPIx->DR = TxData;
  1014. #endif /* __GNUC__ */
  1015. }
  1016. /**
  1017. * @}
  1018. */
  1019. #if defined(USE_FULL_LL_DRIVER)
  1020. /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions
  1021. * @{
  1022. */
  1023. ErrorStatus LL_SPI_DeInit(const SPI_TypeDef *SPIx);
  1024. ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct);
  1025. void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct);
  1026. /**
  1027. * @}
  1028. */
  1029. #endif /* USE_FULL_LL_DRIVER */
  1030. /**
  1031. * @}
  1032. */
  1033. /**
  1034. * @}
  1035. */
  1036. #if defined(SPI_I2S_SUPPORT)
  1037. /** @defgroup I2S_LL I2S
  1038. * @{
  1039. */
  1040. /* Private variables ---------------------------------------------------------*/
  1041. /* Private constants ---------------------------------------------------------*/
  1042. /* Private macros ------------------------------------------------------------*/
  1043. /* Exported types ------------------------------------------------------------*/
  1044. #if defined(USE_FULL_LL_DRIVER)
  1045. /** @defgroup I2S_LL_ES_INIT I2S Exported Init structure
  1046. * @{
  1047. */
  1048. /**
  1049. * @brief I2S Init structure definition
  1050. */
  1051. typedef struct
  1052. {
  1053. uint32_t Mode; /*!< Specifies the I2S operating mode.
  1054. This parameter can be a value of @ref I2S_LL_EC_MODE
  1055. This feature can be modified afterwards using unitary function @ref LL_I2S_SetTransferMode().*/
  1056. uint32_t Standard; /*!< Specifies the standard used for the I2S communication.
  1057. This parameter can be a value of @ref I2S_LL_EC_STANDARD
  1058. This feature can be modified afterwards using unitary function @ref LL_I2S_SetStandard().*/
  1059. uint32_t DataFormat; /*!< Specifies the data format for the I2S communication.
  1060. This parameter can be a value of @ref I2S_LL_EC_DATA_FORMAT
  1061. This feature can be modified afterwards using unitary function @ref LL_I2S_SetDataFormat().*/
  1062. uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
  1063. This parameter can be a value of @ref I2S_LL_EC_MCLK_OUTPUT
  1064. This feature can be modified afterwards using unitary functions @ref LL_I2S_EnableMasterClock() or @ref LL_I2S_DisableMasterClock.*/
  1065. uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
  1066. This parameter can be a value of @ref I2S_LL_EC_AUDIO_FREQ
  1067. Audio Frequency can be modified afterwards using Reference manual formulas to calculate Prescaler Linear, Parity
  1068. and unitary functions @ref LL_I2S_SetPrescalerLinear() and @ref LL_I2S_SetPrescalerParity() to set it.*/
  1069. uint32_t ClockPolarity; /*!< Specifies the idle state of the I2S clock.
  1070. This parameter can be a value of @ref I2S_LL_EC_POLARITY
  1071. This feature can be modified afterwards using unitary function @ref LL_I2S_SetClockPolarity().*/
  1072. } LL_I2S_InitTypeDef;
  1073. /**
  1074. * @}
  1075. */
  1076. #endif /*USE_FULL_LL_DRIVER*/
  1077. /* Exported constants --------------------------------------------------------*/
  1078. /** @defgroup I2S_LL_Exported_Constants I2S Exported Constants
  1079. * @{
  1080. */
  1081. /** @defgroup I2S_LL_EC_GET_FLAG Get Flags Defines
  1082. * @brief Flags defines which can be used with LL_I2S_ReadReg function
  1083. * @{
  1084. */
  1085. #define LL_I2S_SR_RXNE LL_SPI_SR_RXNE /*!< Rx buffer not empty flag */
  1086. #define LL_I2S_SR_TXE LL_SPI_SR_TXE /*!< Tx buffer empty flag */
  1087. #define LL_I2S_SR_BSY LL_SPI_SR_BSY /*!< Busy flag */
  1088. #define LL_I2S_SR_UDR SPI_SR_UDR /*!< Underrun flag */
  1089. #define LL_I2S_SR_OVR LL_SPI_SR_OVR /*!< Overrun flag */
  1090. #define LL_I2S_SR_FRE LL_SPI_SR_FRE /*!< TI mode frame format error flag */
  1091. /**
  1092. * @}
  1093. */
  1094. /** @defgroup SPI_LL_EC_IT IT Defines
  1095. * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions
  1096. * @{
  1097. */
  1098. #define LL_I2S_CR2_RXNEIE LL_SPI_CR2_RXNEIE /*!< Rx buffer not empty interrupt enable */
  1099. #define LL_I2S_CR2_TXEIE LL_SPI_CR2_TXEIE /*!< Tx buffer empty interrupt enable */
  1100. #define LL_I2S_CR2_ERRIE LL_SPI_CR2_ERRIE /*!< Error interrupt enable */
  1101. /**
  1102. * @}
  1103. */
  1104. /** @defgroup I2S_LL_EC_DATA_FORMAT Data format
  1105. * @{
  1106. */
  1107. #define LL_I2S_DATAFORMAT_16B 0x00000000U /*!< Data length 16 bits, Channel length 16bit */
  1108. #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) /*!< Data length 16 bits, Channel length 32bit */
  1109. #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0) /*!< Data length 24 bits, Channel length 32bit */
  1110. #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1) /*!< Data length 16 bits, Channel length 32bit */
  1111. /**
  1112. * @}
  1113. */
  1114. /** @defgroup I2S_LL_EC_POLARITY Clock Polarity
  1115. * @{
  1116. */
  1117. #define LL_I2S_POLARITY_LOW 0x00000000U /*!< Clock steady state is low level */
  1118. #define LL_I2S_POLARITY_HIGH (SPI_I2SCFGR_CKPOL) /*!< Clock steady state is high level */
  1119. /**
  1120. * @}
  1121. */
  1122. /** @defgroup I2S_LL_EC_STANDARD I2s Standard
  1123. * @{
  1124. */
  1125. #define LL_I2S_STANDARD_PHILIPS 0x00000000U /*!< I2S standard philips */
  1126. #define LL_I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0) /*!< MSB justified standard (left justified) */
  1127. #define LL_I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1) /*!< LSB justified standard (right justified) */
  1128. #define LL_I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1) /*!< PCM standard, short frame synchronization */
  1129. #define LL_I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC) /*!< PCM standard, long frame synchronization */
  1130. /**
  1131. * @}
  1132. */
  1133. /** @defgroup I2S_LL_EC_MODE Operation Mode
  1134. * @{
  1135. */
  1136. #define LL_I2S_MODE_SLAVE_TX 0x00000000U /*!< Slave Tx configuration */
  1137. #define LL_I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0) /*!< Slave Rx configuration */
  1138. #define LL_I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1) /*!< Master Tx configuration */
  1139. #define LL_I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1) /*!< Master Rx configuration */
  1140. /**
  1141. * @}
  1142. */
  1143. /** @defgroup I2S_LL_EC_PRESCALER_FACTOR Prescaler Factor
  1144. * @{
  1145. */
  1146. #define LL_I2S_PRESCALER_PARITY_EVEN 0x00000000U /*!< Odd factor: Real divider value is = I2SDIV * 2 */
  1147. #define LL_I2S_PRESCALER_PARITY_ODD (SPI_I2SPR_ODD >> 8U) /*!< Odd factor: Real divider value is = (I2SDIV * 2)+1 */
  1148. /**
  1149. * @}
  1150. */
  1151. #if defined(USE_FULL_LL_DRIVER)
  1152. /** @defgroup I2S_LL_EC_MCLK_OUTPUT MCLK Output
  1153. * @{
  1154. */
  1155. #define LL_I2S_MCLK_OUTPUT_DISABLE 0x00000000U /*!< Master clock output is disabled */
  1156. #define LL_I2S_MCLK_OUTPUT_ENABLE (SPI_I2SPR_MCKOE) /*!< Master clock output is enabled */
  1157. /**
  1158. * @}
  1159. */
  1160. /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency
  1161. * @{
  1162. */
  1163. #define LL_I2S_AUDIOFREQ_192K 192000U /*!< Audio Frequency configuration 192000 Hz */
  1164. #define LL_I2S_AUDIOFREQ_96K 96000U /*!< Audio Frequency configuration 96000 Hz */
  1165. #define LL_I2S_AUDIOFREQ_48K 48000U /*!< Audio Frequency configuration 48000 Hz */
  1166. #define LL_I2S_AUDIOFREQ_44K 44100U /*!< Audio Frequency configuration 44100 Hz */
  1167. #define LL_I2S_AUDIOFREQ_32K 32000U /*!< Audio Frequency configuration 32000 Hz */
  1168. #define LL_I2S_AUDIOFREQ_22K 22050U /*!< Audio Frequency configuration 22050 Hz */
  1169. #define LL_I2S_AUDIOFREQ_16K 16000U /*!< Audio Frequency configuration 16000 Hz */
  1170. #define LL_I2S_AUDIOFREQ_11K 11025U /*!< Audio Frequency configuration 11025 Hz */
  1171. #define LL_I2S_AUDIOFREQ_8K 8000U /*!< Audio Frequency configuration 8000 Hz */
  1172. #define LL_I2S_AUDIOFREQ_DEFAULT 2U /*!< Audio Freq not specified. Register I2SDIV = 2 */
  1173. /**
  1174. * @}
  1175. */
  1176. #endif /* USE_FULL_LL_DRIVER */
  1177. /**
  1178. * @}
  1179. */
  1180. /* Exported macro ------------------------------------------------------------*/
  1181. /** @defgroup I2S_LL_Exported_Macros I2S Exported Macros
  1182. * @{
  1183. */
  1184. /** @defgroup I2S_LL_EM_WRITE_READ Common Write and read registers Macros
  1185. * @{
  1186. */
  1187. /**
  1188. * @brief Write a value in I2S register
  1189. * @param __INSTANCE__ I2S Instance
  1190. * @param __REG__ Register to be written
  1191. * @param __VALUE__ Value to be written in the register
  1192. * @retval None
  1193. */
  1194. #define LL_I2S_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1195. /**
  1196. * @brief Read a value in I2S register
  1197. * @param __INSTANCE__ I2S Instance
  1198. * @param __REG__ Register to be read
  1199. * @retval Register value
  1200. */
  1201. #define LL_I2S_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1202. /**
  1203. * @}
  1204. */
  1205. /**
  1206. * @}
  1207. */
  1208. /* Exported functions --------------------------------------------------------*/
  1209. /** @defgroup I2S_LL_Exported_Functions I2S Exported Functions
  1210. * @{
  1211. */
  1212. /** @defgroup I2S_LL_EF_Configuration Configuration
  1213. * @{
  1214. */
  1215. /**
  1216. * @brief Select I2S mode and Enable I2S peripheral
  1217. * @rmtoll I2SCFGR I2SMOD LL_I2S_Enable\n
  1218. * I2SCFGR I2SE LL_I2S_Enable
  1219. * @param SPIx SPI Instance
  1220. * @retval None
  1221. */
  1222. __STATIC_INLINE void LL_I2S_Enable(SPI_TypeDef *SPIx)
  1223. {
  1224. SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SE);
  1225. }
  1226. /**
  1227. * @brief Disable I2S peripheral
  1228. * @rmtoll I2SCFGR I2SE LL_I2S_Disable
  1229. * @param SPIx SPI Instance
  1230. * @retval None
  1231. */
  1232. __STATIC_INLINE void LL_I2S_Disable(SPI_TypeDef *SPIx)
  1233. {
  1234. CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SE);
  1235. }
  1236. /**
  1237. * @brief Check if I2S peripheral is enabled
  1238. * @rmtoll I2SCFGR I2SE LL_I2S_IsEnabled
  1239. * @param SPIx SPI Instance
  1240. * @retval State of bit (1 or 0).
  1241. */
  1242. __STATIC_INLINE uint32_t LL_I2S_IsEnabled(const SPI_TypeDef *SPIx)
  1243. {
  1244. return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SE) == (SPI_I2SCFGR_I2SE)) ? 1UL : 0UL);
  1245. }
  1246. /**
  1247. * @brief Set I2S data frame length
  1248. * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n
  1249. * I2SCFGR CHLEN LL_I2S_SetDataFormat
  1250. * @param SPIx SPI Instance
  1251. * @param DataFormat This parameter can be one of the following values:
  1252. * @arg @ref LL_I2S_DATAFORMAT_16B
  1253. * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
  1254. * @arg @ref LL_I2S_DATAFORMAT_24B
  1255. * @arg @ref LL_I2S_DATAFORMAT_32B
  1256. * @retval None
  1257. */
  1258. __STATIC_INLINE void LL_I2S_SetDataFormat(SPI_TypeDef *SPIx, uint32_t DataFormat)
  1259. {
  1260. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN, DataFormat);
  1261. }
  1262. /**
  1263. * @brief Get I2S data frame length
  1264. * @rmtoll I2SCFGR DATLEN LL_I2S_GetDataFormat\n
  1265. * I2SCFGR CHLEN LL_I2S_GetDataFormat
  1266. * @param SPIx SPI Instance
  1267. * @retval Returned value can be one of the following values:
  1268. * @arg @ref LL_I2S_DATAFORMAT_16B
  1269. * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
  1270. * @arg @ref LL_I2S_DATAFORMAT_24B
  1271. * @arg @ref LL_I2S_DATAFORMAT_32B
  1272. */
  1273. __STATIC_INLINE uint32_t LL_I2S_GetDataFormat(const SPI_TypeDef *SPIx)
  1274. {
  1275. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN));
  1276. }
  1277. /**
  1278. * @brief Set I2S clock polarity
  1279. * @rmtoll I2SCFGR CKPOL LL_I2S_SetClockPolarity
  1280. * @param SPIx SPI Instance
  1281. * @param ClockPolarity This parameter can be one of the following values:
  1282. * @arg @ref LL_I2S_POLARITY_LOW
  1283. * @arg @ref LL_I2S_POLARITY_HIGH
  1284. * @retval None
  1285. */
  1286. __STATIC_INLINE void LL_I2S_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity)
  1287. {
  1288. SET_BIT(SPIx->I2SCFGR, ClockPolarity);
  1289. }
  1290. /**
  1291. * @brief Get I2S clock polarity
  1292. * @rmtoll I2SCFGR CKPOL LL_I2S_GetClockPolarity
  1293. * @param SPIx SPI Instance
  1294. * @retval Returned value can be one of the following values:
  1295. * @arg @ref LL_I2S_POLARITY_LOW
  1296. * @arg @ref LL_I2S_POLARITY_HIGH
  1297. */
  1298. __STATIC_INLINE uint32_t LL_I2S_GetClockPolarity(const SPI_TypeDef *SPIx)
  1299. {
  1300. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL));
  1301. }
  1302. /**
  1303. * @brief Set I2S standard protocol
  1304. * @rmtoll I2SCFGR I2SSTD LL_I2S_SetStandard\n
  1305. * I2SCFGR PCMSYNC LL_I2S_SetStandard
  1306. * @param SPIx SPI Instance
  1307. * @param Standard This parameter can be one of the following values:
  1308. * @arg @ref LL_I2S_STANDARD_PHILIPS
  1309. * @arg @ref LL_I2S_STANDARD_MSB
  1310. * @arg @ref LL_I2S_STANDARD_LSB
  1311. * @arg @ref LL_I2S_STANDARD_PCM_SHORT
  1312. * @arg @ref LL_I2S_STANDARD_PCM_LONG
  1313. * @retval None
  1314. */
  1315. __STATIC_INLINE void LL_I2S_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard)
  1316. {
  1317. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC, Standard);
  1318. }
  1319. /**
  1320. * @brief Get I2S standard protocol
  1321. * @rmtoll I2SCFGR I2SSTD LL_I2S_GetStandard\n
  1322. * I2SCFGR PCMSYNC LL_I2S_GetStandard
  1323. * @param SPIx SPI Instance
  1324. * @retval Returned value can be one of the following values:
  1325. * @arg @ref LL_I2S_STANDARD_PHILIPS
  1326. * @arg @ref LL_I2S_STANDARD_MSB
  1327. * @arg @ref LL_I2S_STANDARD_LSB
  1328. * @arg @ref LL_I2S_STANDARD_PCM_SHORT
  1329. * @arg @ref LL_I2S_STANDARD_PCM_LONG
  1330. */
  1331. __STATIC_INLINE uint32_t LL_I2S_GetStandard(const SPI_TypeDef *SPIx)
  1332. {
  1333. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC));
  1334. }
  1335. /**
  1336. * @brief Set I2S transfer mode
  1337. * @rmtoll I2SCFGR I2SCFG LL_I2S_SetTransferMode
  1338. * @param SPIx SPI Instance
  1339. * @param Mode This parameter can be one of the following values:
  1340. * @arg @ref LL_I2S_MODE_SLAVE_TX
  1341. * @arg @ref LL_I2S_MODE_SLAVE_RX
  1342. * @arg @ref LL_I2S_MODE_MASTER_TX
  1343. * @arg @ref LL_I2S_MODE_MASTER_RX
  1344. * @retval None
  1345. */
  1346. __STATIC_INLINE void LL_I2S_SetTransferMode(SPI_TypeDef *SPIx, uint32_t Mode)
  1347. {
  1348. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG, Mode);
  1349. }
  1350. /**
  1351. * @brief Get I2S transfer mode
  1352. * @rmtoll I2SCFGR I2SCFG LL_I2S_GetTransferMode
  1353. * @param SPIx SPI Instance
  1354. * @retval Returned value can be one of the following values:
  1355. * @arg @ref LL_I2S_MODE_SLAVE_TX
  1356. * @arg @ref LL_I2S_MODE_SLAVE_RX
  1357. * @arg @ref LL_I2S_MODE_MASTER_TX
  1358. * @arg @ref LL_I2S_MODE_MASTER_RX
  1359. */
  1360. __STATIC_INLINE uint32_t LL_I2S_GetTransferMode(const SPI_TypeDef *SPIx)
  1361. {
  1362. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG));
  1363. }
  1364. /**
  1365. * @brief Set I2S linear prescaler
  1366. * @rmtoll I2SPR I2SDIV LL_I2S_SetPrescalerLinear
  1367. * @param SPIx SPI Instance
  1368. * @param PrescalerLinear Value between Min_Data=0x02 and Max_Data=0xFF
  1369. * @retval None
  1370. */
  1371. __STATIC_INLINE void LL_I2S_SetPrescalerLinear(SPI_TypeDef *SPIx, uint8_t PrescalerLinear)
  1372. {
  1373. MODIFY_REG(SPIx->I2SPR, SPI_I2SPR_I2SDIV, PrescalerLinear);
  1374. }
  1375. /**
  1376. * @brief Get I2S linear prescaler
  1377. * @rmtoll I2SPR I2SDIV LL_I2S_GetPrescalerLinear
  1378. * @param SPIx SPI Instance
  1379. * @retval PrescalerLinear Value between Min_Data=0x02 and Max_Data=0xFF
  1380. */
  1381. __STATIC_INLINE uint32_t LL_I2S_GetPrescalerLinear(const SPI_TypeDef *SPIx)
  1382. {
  1383. return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_I2SDIV));
  1384. }
  1385. /**
  1386. * @brief Set I2S parity prescaler
  1387. * @rmtoll I2SPR ODD LL_I2S_SetPrescalerParity
  1388. * @param SPIx SPI Instance
  1389. * @param PrescalerParity This parameter can be one of the following values:
  1390. * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
  1391. * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
  1392. * @retval None
  1393. */
  1394. __STATIC_INLINE void LL_I2S_SetPrescalerParity(SPI_TypeDef *SPIx, uint32_t PrescalerParity)
  1395. {
  1396. MODIFY_REG(SPIx->I2SPR, SPI_I2SPR_ODD, PrescalerParity << 8U);
  1397. }
  1398. /**
  1399. * @brief Get I2S parity prescaler
  1400. * @rmtoll I2SPR ODD LL_I2S_GetPrescalerParity
  1401. * @param SPIx SPI Instance
  1402. * @retval Returned value can be one of the following values:
  1403. * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
  1404. * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
  1405. */
  1406. __STATIC_INLINE uint32_t LL_I2S_GetPrescalerParity(const SPI_TypeDef *SPIx)
  1407. {
  1408. return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_ODD) >> 8U);
  1409. }
  1410. /**
  1411. * @brief Enable the master clock output (Pin MCK)
  1412. * @rmtoll I2SPR MCKOE LL_I2S_EnableMasterClock
  1413. * @param SPIx SPI Instance
  1414. * @retval None
  1415. */
  1416. __STATIC_INLINE void LL_I2S_EnableMasterClock(SPI_TypeDef *SPIx)
  1417. {
  1418. SET_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE);
  1419. }
  1420. /**
  1421. * @brief Disable the master clock output (Pin MCK)
  1422. * @rmtoll I2SPR MCKOE LL_I2S_DisableMasterClock
  1423. * @param SPIx SPI Instance
  1424. * @retval None
  1425. */
  1426. __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx)
  1427. {
  1428. CLEAR_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE);
  1429. }
  1430. /**
  1431. * @brief Check if the master clock output (Pin MCK) is enabled
  1432. * @rmtoll I2SPR MCKOE LL_I2S_IsEnabledMasterClock
  1433. * @param SPIx SPI Instance
  1434. * @retval State of bit (1 or 0).
  1435. */
  1436. __STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(const SPI_TypeDef *SPIx)
  1437. {
  1438. return ((READ_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE) == (SPI_I2SPR_MCKOE)) ? 1UL : 0UL);
  1439. }
  1440. #if defined(SPI_I2SCFGR_ASTRTEN)
  1441. /**
  1442. * @brief Enable asynchronous start
  1443. * @rmtoll I2SCFGR ASTRTEN LL_I2S_EnableAsyncStart
  1444. * @param SPIx SPI Instance
  1445. * @retval None
  1446. */
  1447. __STATIC_INLINE void LL_I2S_EnableAsyncStart(SPI_TypeDef *SPIx)
  1448. {
  1449. SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ASTRTEN);
  1450. }
  1451. /**
  1452. * @brief Disable asynchronous start
  1453. * @rmtoll I2SCFGR ASTRTEN LL_I2S_DisableAsyncStart
  1454. * @param SPIx SPI Instance
  1455. * @retval None
  1456. */
  1457. __STATIC_INLINE void LL_I2S_DisableAsyncStart(SPI_TypeDef *SPIx)
  1458. {
  1459. CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ASTRTEN);
  1460. }
  1461. /**
  1462. * @brief Check if asynchronous start is enabled
  1463. * @rmtoll I2SCFGR ASTRTEN LL_I2S_IsEnabledAsyncStart
  1464. * @param SPIx SPI Instance
  1465. * @retval State of bit (1 or 0).
  1466. */
  1467. __STATIC_INLINE uint32_t LL_I2S_IsEnabledAsyncStart(const SPI_TypeDef *SPIx)
  1468. {
  1469. return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ASTRTEN) == (SPI_I2SCFGR_ASTRTEN)) ? 1UL : 0UL);
  1470. }
  1471. #endif /* SPI_I2SCFGR_ASTRTEN */
  1472. /**
  1473. * @}
  1474. */
  1475. /** @defgroup I2S_LL_EF_FLAG FLAG Management
  1476. * @{
  1477. */
  1478. /**
  1479. * @brief Check if Rx buffer is not empty
  1480. * @rmtoll SR RXNE LL_I2S_IsActiveFlag_RXNE
  1481. * @param SPIx SPI Instance
  1482. * @retval State of bit (1 or 0).
  1483. */
  1484. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXNE(const SPI_TypeDef *SPIx)
  1485. {
  1486. return LL_SPI_IsActiveFlag_RXNE(SPIx);
  1487. }
  1488. /**
  1489. * @brief Check if Tx buffer is empty
  1490. * @rmtoll SR TXE LL_I2S_IsActiveFlag_TXE
  1491. * @param SPIx SPI Instance
  1492. * @retval State of bit (1 or 0).
  1493. */
  1494. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXE(const SPI_TypeDef *SPIx)
  1495. {
  1496. return LL_SPI_IsActiveFlag_TXE(SPIx);
  1497. }
  1498. /**
  1499. * @brief Get busy flag
  1500. * @rmtoll SR BSY LL_I2S_IsActiveFlag_BSY
  1501. * @param SPIx SPI Instance
  1502. * @retval State of bit (1 or 0).
  1503. */
  1504. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_BSY(const SPI_TypeDef *SPIx)
  1505. {
  1506. return LL_SPI_IsActiveFlag_BSY(SPIx);
  1507. }
  1508. /**
  1509. * @brief Get overrun error flag
  1510. * @rmtoll SR OVR LL_I2S_IsActiveFlag_OVR
  1511. * @param SPIx SPI Instance
  1512. * @retval State of bit (1 or 0).
  1513. */
  1514. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(const SPI_TypeDef *SPIx)
  1515. {
  1516. return LL_SPI_IsActiveFlag_OVR(SPIx);
  1517. }
  1518. /**
  1519. * @brief Get underrun error flag
  1520. * @rmtoll SR UDR LL_I2S_IsActiveFlag_UDR
  1521. * @param SPIx SPI Instance
  1522. * @retval State of bit (1 or 0).
  1523. */
  1524. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(const SPI_TypeDef *SPIx)
  1525. {
  1526. return ((READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)) ? 1UL : 0UL);
  1527. }
  1528. /**
  1529. * @brief Get frame format error flag
  1530. * @rmtoll SR FRE LL_I2S_IsActiveFlag_FRE
  1531. * @param SPIx SPI Instance
  1532. * @retval State of bit (1 or 0).
  1533. */
  1534. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(const SPI_TypeDef *SPIx)
  1535. {
  1536. return LL_SPI_IsActiveFlag_FRE(SPIx);
  1537. }
  1538. /**
  1539. * @brief Get channel side flag.
  1540. * @note 0: Channel Left has to be transmitted or has been received\n
  1541. * 1: Channel Right has to be transmitted or has been received\n
  1542. * It has no significance in PCM mode.
  1543. * @rmtoll SR CHSIDE LL_I2S_IsActiveFlag_CHSIDE
  1544. * @param SPIx SPI Instance
  1545. * @retval State of bit (1 or 0).
  1546. */
  1547. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_CHSIDE(const SPI_TypeDef *SPIx)
  1548. {
  1549. return ((READ_BIT(SPIx->SR, SPI_SR_CHSIDE) == (SPI_SR_CHSIDE)) ? 1UL : 0UL);
  1550. }
  1551. /**
  1552. * @brief Clear overrun error flag
  1553. * @rmtoll SR OVR LL_I2S_ClearFlag_OVR
  1554. * @param SPIx SPI Instance
  1555. * @retval None
  1556. */
  1557. __STATIC_INLINE void LL_I2S_ClearFlag_OVR(SPI_TypeDef *SPIx)
  1558. {
  1559. LL_SPI_ClearFlag_OVR(SPIx);
  1560. }
  1561. /**
  1562. * @brief Clear underrun error flag
  1563. * @rmtoll SR UDR LL_I2S_ClearFlag_UDR
  1564. * @param SPIx SPI Instance
  1565. * @retval None
  1566. */
  1567. __STATIC_INLINE void LL_I2S_ClearFlag_UDR(const SPI_TypeDef *SPIx)
  1568. {
  1569. __IO uint32_t tmpreg;
  1570. tmpreg = SPIx->SR;
  1571. (void)tmpreg;
  1572. }
  1573. /**
  1574. * @brief Clear frame format error flag
  1575. * @rmtoll SR FRE LL_I2S_ClearFlag_FRE
  1576. * @param SPIx SPI Instance
  1577. * @retval None
  1578. */
  1579. __STATIC_INLINE void LL_I2S_ClearFlag_FRE(const SPI_TypeDef *SPIx)
  1580. {
  1581. LL_SPI_ClearFlag_FRE(SPIx);
  1582. }
  1583. /**
  1584. * @}
  1585. */
  1586. /** @defgroup I2S_LL_EF_IT Interrupt Management
  1587. * @{
  1588. */
  1589. /**
  1590. * @brief Enable error IT
  1591. * @note This bit controls the generation of an interrupt when an error condition occurs (OVR, UDR and FRE in I2S mode).
  1592. * @rmtoll CR2 ERRIE LL_I2S_EnableIT_ERR
  1593. * @param SPIx SPI Instance
  1594. * @retval None
  1595. */
  1596. __STATIC_INLINE void LL_I2S_EnableIT_ERR(SPI_TypeDef *SPIx)
  1597. {
  1598. LL_SPI_EnableIT_ERR(SPIx);
  1599. }
  1600. /**
  1601. * @brief Enable Rx buffer not empty IT
  1602. * @rmtoll CR2 RXNEIE LL_I2S_EnableIT_RXNE
  1603. * @param SPIx SPI Instance
  1604. * @retval None
  1605. */
  1606. __STATIC_INLINE void LL_I2S_EnableIT_RXNE(SPI_TypeDef *SPIx)
  1607. {
  1608. LL_SPI_EnableIT_RXNE(SPIx);
  1609. }
  1610. /**
  1611. * @brief Enable Tx buffer empty IT
  1612. * @rmtoll CR2 TXEIE LL_I2S_EnableIT_TXE
  1613. * @param SPIx SPI Instance
  1614. * @retval None
  1615. */
  1616. __STATIC_INLINE void LL_I2S_EnableIT_TXE(SPI_TypeDef *SPIx)
  1617. {
  1618. LL_SPI_EnableIT_TXE(SPIx);
  1619. }
  1620. /**
  1621. * @brief Disable error IT
  1622. * @note This bit controls the generation of an interrupt when an error condition occurs (OVR, UDR and FRE in I2S mode).
  1623. * @rmtoll CR2 ERRIE LL_I2S_DisableIT_ERR
  1624. * @param SPIx SPI Instance
  1625. * @retval None
  1626. */
  1627. __STATIC_INLINE void LL_I2S_DisableIT_ERR(SPI_TypeDef *SPIx)
  1628. {
  1629. LL_SPI_DisableIT_ERR(SPIx);
  1630. }
  1631. /**
  1632. * @brief Disable Rx buffer not empty IT
  1633. * @rmtoll CR2 RXNEIE LL_I2S_DisableIT_RXNE
  1634. * @param SPIx SPI Instance
  1635. * @retval None
  1636. */
  1637. __STATIC_INLINE void LL_I2S_DisableIT_RXNE(SPI_TypeDef *SPIx)
  1638. {
  1639. LL_SPI_DisableIT_RXNE(SPIx);
  1640. }
  1641. /**
  1642. * @brief Disable Tx buffer empty IT
  1643. * @rmtoll CR2 TXEIE LL_I2S_DisableIT_TXE
  1644. * @param SPIx SPI Instance
  1645. * @retval None
  1646. */
  1647. __STATIC_INLINE void LL_I2S_DisableIT_TXE(SPI_TypeDef *SPIx)
  1648. {
  1649. LL_SPI_DisableIT_TXE(SPIx);
  1650. }
  1651. /**
  1652. * @brief Check if ERR IT is enabled
  1653. * @rmtoll CR2 ERRIE LL_I2S_IsEnabledIT_ERR
  1654. * @param SPIx SPI Instance
  1655. * @retval State of bit (1 or 0).
  1656. */
  1657. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_ERR(const SPI_TypeDef *SPIx)
  1658. {
  1659. return LL_SPI_IsEnabledIT_ERR(SPIx);
  1660. }
  1661. /**
  1662. * @brief Check if RXNE IT is enabled
  1663. * @rmtoll CR2 RXNEIE LL_I2S_IsEnabledIT_RXNE
  1664. * @param SPIx SPI Instance
  1665. * @retval State of bit (1 or 0).
  1666. */
  1667. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXNE(const SPI_TypeDef *SPIx)
  1668. {
  1669. return LL_SPI_IsEnabledIT_RXNE(SPIx);
  1670. }
  1671. /**
  1672. * @brief Check if TXE IT is enabled
  1673. * @rmtoll CR2 TXEIE LL_I2S_IsEnabledIT_TXE
  1674. * @param SPIx SPI Instance
  1675. * @retval State of bit (1 or 0).
  1676. */
  1677. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_TXE(const SPI_TypeDef *SPIx)
  1678. {
  1679. return LL_SPI_IsEnabledIT_TXE(SPIx);
  1680. }
  1681. /**
  1682. * @}
  1683. */
  1684. /** @defgroup I2S_LL_EF_DMA DMA Management
  1685. * @{
  1686. */
  1687. /**
  1688. * @brief Enable DMA Rx
  1689. * @rmtoll CR2 RXDMAEN LL_I2S_EnableDMAReq_RX
  1690. * @param SPIx SPI Instance
  1691. * @retval None
  1692. */
  1693. __STATIC_INLINE void LL_I2S_EnableDMAReq_RX(SPI_TypeDef *SPIx)
  1694. {
  1695. LL_SPI_EnableDMAReq_RX(SPIx);
  1696. }
  1697. /**
  1698. * @brief Disable DMA Rx
  1699. * @rmtoll CR2 RXDMAEN LL_I2S_DisableDMAReq_RX
  1700. * @param SPIx SPI Instance
  1701. * @retval None
  1702. */
  1703. __STATIC_INLINE void LL_I2S_DisableDMAReq_RX(SPI_TypeDef *SPIx)
  1704. {
  1705. LL_SPI_DisableDMAReq_RX(SPIx);
  1706. }
  1707. /**
  1708. * @brief Check if DMA Rx is enabled
  1709. * @rmtoll CR2 RXDMAEN LL_I2S_IsEnabledDMAReq_RX
  1710. * @param SPIx SPI Instance
  1711. * @retval State of bit (1 or 0).
  1712. */
  1713. __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_RX(const SPI_TypeDef *SPIx)
  1714. {
  1715. return LL_SPI_IsEnabledDMAReq_RX(SPIx);
  1716. }
  1717. /**
  1718. * @brief Enable DMA Tx
  1719. * @rmtoll CR2 TXDMAEN LL_I2S_EnableDMAReq_TX
  1720. * @param SPIx SPI Instance
  1721. * @retval None
  1722. */
  1723. __STATIC_INLINE void LL_I2S_EnableDMAReq_TX(SPI_TypeDef *SPIx)
  1724. {
  1725. LL_SPI_EnableDMAReq_TX(SPIx);
  1726. }
  1727. /**
  1728. * @brief Disable DMA Tx
  1729. * @rmtoll CR2 TXDMAEN LL_I2S_DisableDMAReq_TX
  1730. * @param SPIx SPI Instance
  1731. * @retval None
  1732. */
  1733. __STATIC_INLINE void LL_I2S_DisableDMAReq_TX(SPI_TypeDef *SPIx)
  1734. {
  1735. LL_SPI_DisableDMAReq_TX(SPIx);
  1736. }
  1737. /**
  1738. * @brief Check if DMA Tx is enabled
  1739. * @rmtoll CR2 TXDMAEN LL_I2S_IsEnabledDMAReq_TX
  1740. * @param SPIx SPI Instance
  1741. * @retval State of bit (1 or 0).
  1742. */
  1743. __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_TX(const SPI_TypeDef *SPIx)
  1744. {
  1745. return LL_SPI_IsEnabledDMAReq_TX(SPIx);
  1746. }
  1747. /**
  1748. * @}
  1749. */
  1750. /** @defgroup I2S_LL_EF_DATA DATA Management
  1751. * @{
  1752. */
  1753. /**
  1754. * @brief Read 16-Bits in data register
  1755. * @rmtoll DR DR LL_I2S_ReceiveData16
  1756. * @param SPIx SPI Instance
  1757. * @retval RxData Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1758. */
  1759. __STATIC_INLINE uint16_t LL_I2S_ReceiveData16(SPI_TypeDef *SPIx)
  1760. {
  1761. return LL_SPI_ReceiveData16(SPIx);
  1762. }
  1763. /**
  1764. * @brief Write 16-Bits in data register
  1765. * @rmtoll DR DR LL_I2S_TransmitData16
  1766. * @param SPIx SPI Instance
  1767. * @param TxData Value between Min_Data=0x0000 and Max_Data=0xFFFF
  1768. * @retval None
  1769. */
  1770. __STATIC_INLINE void LL_I2S_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
  1771. {
  1772. LL_SPI_TransmitData16(SPIx, TxData);
  1773. }
  1774. /**
  1775. * @}
  1776. */
  1777. #if defined(USE_FULL_LL_DRIVER)
  1778. /** @defgroup I2S_LL_EF_Init Initialization and de-initialization functions
  1779. * @{
  1780. */
  1781. ErrorStatus LL_I2S_DeInit(const SPI_TypeDef *SPIx);
  1782. ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct);
  1783. void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct);
  1784. void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity);
  1785. /**
  1786. * @}
  1787. */
  1788. #endif /* USE_FULL_LL_DRIVER */
  1789. /**
  1790. * @}
  1791. */
  1792. /**
  1793. * @}
  1794. */
  1795. #endif /* SPI_I2S_SUPPORT */
  1796. #endif /* defined (SPI1) || defined (SPI2) */
  1797. /**
  1798. * @}
  1799. */
  1800. #ifdef __cplusplus
  1801. }
  1802. #endif
  1803. #endif /* STM32L0xx_LL_SPI_H */