stm32l1xx_ll_spi.h 64 KB

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