You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stm32l1xx_ll_spi.h 63KB

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