stm32f4xx_ll_spi.h 67 KB

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