stm32l4xx_ll_spi.h 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_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 __STM32L4xx_LL_SPI_H
  37. #define __STM32L4xx_LL_SPI_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx.h"
  43. /** @addtogroup STM32L4xx_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. /** @defgroup SPI_LL_EC_PROTOCOL Serial Protocol
  136. * @{
  137. */
  138. #define LL_SPI_PROTOCOL_MOTOROLA 0x00000000U /*!< Motorola mode. Used as default value */
  139. #define LL_SPI_PROTOCOL_TI (SPI_CR2_FRF) /*!< TI mode */
  140. /**
  141. * @}
  142. */
  143. /** @defgroup SPI_LL_EC_PHASE Clock Phase
  144. * @{
  145. */
  146. #define LL_SPI_PHASE_1EDGE 0x00000000U /*!< First clock transition is the first data capture edge */
  147. #define LL_SPI_PHASE_2EDGE (SPI_CR1_CPHA) /*!< Second clock transition is the first data capture edge */
  148. /**
  149. * @}
  150. */
  151. /** @defgroup SPI_LL_EC_POLARITY Clock Polarity
  152. * @{
  153. */
  154. #define LL_SPI_POLARITY_LOW 0x00000000U /*!< Clock to 0 when idle */
  155. #define LL_SPI_POLARITY_HIGH (SPI_CR1_CPOL) /*!< Clock to 1 when idle */
  156. /**
  157. * @}
  158. */
  159. /** @defgroup SPI_LL_EC_BAUDRATEPRESCALER Baud Rate Prescaler
  160. * @{
  161. */
  162. #define LL_SPI_BAUDRATEPRESCALER_DIV2 0x00000000U /*!< BaudRate control equal to fPCLK/2 */
  163. #define LL_SPI_BAUDRATEPRESCALER_DIV4 (SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/4 */
  164. #define LL_SPI_BAUDRATEPRESCALER_DIV8 (SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/8 */
  165. #define LL_SPI_BAUDRATEPRESCALER_DIV16 (SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/16 */
  166. #define LL_SPI_BAUDRATEPRESCALER_DIV32 (SPI_CR1_BR_2) /*!< BaudRate control equal to fPCLK/32 */
  167. #define LL_SPI_BAUDRATEPRESCALER_DIV64 (SPI_CR1_BR_2 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/64 */
  168. #define LL_SPI_BAUDRATEPRESCALER_DIV128 (SPI_CR1_BR_2 | SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/128 */
  169. #define LL_SPI_BAUDRATEPRESCALER_DIV256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/256 */
  170. /**
  171. * @}
  172. */
  173. /** @defgroup SPI_LL_EC_BIT_ORDER Transmission Bit Order
  174. * @{
  175. */
  176. #define LL_SPI_LSB_FIRST (SPI_CR1_LSBFIRST) /*!< Data is transmitted/received with the LSB first */
  177. #define LL_SPI_MSB_FIRST 0x00000000U /*!< Data is transmitted/received with the MSB first */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup SPI_LL_EC_TRANSFER_MODE Transfer Mode
  182. * @{
  183. */
  184. #define LL_SPI_FULL_DUPLEX 0x00000000U /*!< Full-Duplex mode. Rx and Tx transfer on 2 lines */
  185. #define LL_SPI_SIMPLEX_RX (SPI_CR1_RXONLY) /*!< Simplex Rx mode. Rx transfer only on 1 line */
  186. #define LL_SPI_HALF_DUPLEX_RX (SPI_CR1_BIDIMODE) /*!< Half-Duplex Rx mode. Rx transfer on 1 line */
  187. #define LL_SPI_HALF_DUPLEX_TX (SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE) /*!< Half-Duplex Tx mode. Tx transfer on 1 line */
  188. /**
  189. * @}
  190. */
  191. /** @defgroup SPI_LL_EC_NSS_MODE Slave Select Pin Mode
  192. * @{
  193. */
  194. #define LL_SPI_NSS_SOFT (SPI_CR1_SSM) /*!< NSS managed internally. NSS pin not used and free */
  195. #define LL_SPI_NSS_HARD_INPUT 0x00000000U /*!< NSS pin used in Input. Only used in Master mode */
  196. #define LL_SPI_NSS_HARD_OUTPUT (((uint32_t)SPI_CR2_SSOE << 16U)) /*!< NSS pin used in Output. Only used in Slave mode as chip select */
  197. /**
  198. * @}
  199. */
  200. /** @defgroup SPI_LL_EC_DATAWIDTH Datawidth
  201. * @{
  202. */
  203. #define LL_SPI_DATAWIDTH_4BIT (SPI_CR2_DS_0 | SPI_CR2_DS_1) /*!< Data length for SPI transfer: 4 bits */
  204. #define LL_SPI_DATAWIDTH_5BIT (SPI_CR2_DS_2) /*!< Data length for SPI transfer: 5 bits */
  205. #define LL_SPI_DATAWIDTH_6BIT (SPI_CR2_DS_2 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 6 bits */
  206. #define LL_SPI_DATAWIDTH_7BIT (SPI_CR2_DS_2 | SPI_CR2_DS_1) /*!< Data length for SPI transfer: 7 bits */
  207. #define LL_SPI_DATAWIDTH_8BIT (SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 8 bits */
  208. #define LL_SPI_DATAWIDTH_9BIT (SPI_CR2_DS_3) /*!< Data length for SPI transfer: 9 bits */
  209. #define LL_SPI_DATAWIDTH_10BIT (SPI_CR2_DS_3 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 10 bits */
  210. #define LL_SPI_DATAWIDTH_11BIT (SPI_CR2_DS_3 | SPI_CR2_DS_1) /*!< Data length for SPI transfer: 11 bits */
  211. #define LL_SPI_DATAWIDTH_12BIT (SPI_CR2_DS_3 | SPI_CR2_DS_1 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 12 bits */
  212. #define LL_SPI_DATAWIDTH_13BIT (SPI_CR2_DS_3 | SPI_CR2_DS_2) /*!< Data length for SPI transfer: 13 bits */
  213. #define LL_SPI_DATAWIDTH_14BIT (SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 14 bits */
  214. #define LL_SPI_DATAWIDTH_15BIT (SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1) /*!< Data length for SPI transfer: 15 bits */
  215. #define LL_SPI_DATAWIDTH_16BIT (SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0) /*!< Data length for SPI transfer: 16 bits */
  216. /**
  217. * @}
  218. */
  219. #if defined(USE_FULL_LL_DRIVER)
  220. /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation
  221. * @{
  222. */
  223. #define LL_SPI_CRCCALCULATION_DISABLE 0x00000000U /*!< CRC calculation disabled */
  224. #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CR1_CRCEN) /*!< CRC calculation enabled */
  225. /**
  226. * @}
  227. */
  228. #endif /* USE_FULL_LL_DRIVER */
  229. /** @defgroup SPI_LL_EC_CRC_LENGTH CRC Length
  230. * @{
  231. */
  232. #define LL_SPI_CRC_8BIT 0x00000000U /*!< 8-bit CRC length */
  233. #define LL_SPI_CRC_16BIT (SPI_CR1_CRCL) /*!< 16-bit CRC length */
  234. /**
  235. * @}
  236. */
  237. /** @defgroup SPI_LL_EC_RX_FIFO_TH RX FIFO Threshold
  238. * @{
  239. */
  240. #define LL_SPI_RX_FIFO_TH_HALF 0x00000000U /*!< RXNE event is generated if FIFO level is greater than or equel to 1/2 (16-bit) */
  241. #define LL_SPI_RX_FIFO_TH_QUARTER (SPI_CR2_FRXTH) /*!< RXNE event is generated if FIFO level is greater than or equel to 1/4 (8-bit) */
  242. /**
  243. * @}
  244. */
  245. /** @defgroup SPI_LL_EC_RX_FIFO RX FIFO Level
  246. * @{
  247. */
  248. #define LL_SPI_RX_FIFO_EMPTY 0x00000000U /*!< FIFO reception empty */
  249. #define LL_SPI_RX_FIFO_QUARTER_FULL (SPI_SR_FRLVL_0) /*!< FIFO reception 1/4 */
  250. #define LL_SPI_RX_FIFO_HALF_FULL (SPI_SR_FRLVL_1) /*!< FIFO reception 1/2 */
  251. #define LL_SPI_RX_FIFO_FULL (SPI_SR_FRLVL_1 | SPI_SR_FRLVL_0) /*!< FIFO reception full */
  252. /**
  253. * @}
  254. */
  255. /** @defgroup SPI_LL_EC_TX_FIFO TX FIFO Level
  256. * @{
  257. */
  258. #define LL_SPI_TX_FIFO_EMPTY 0x00000000U /*!< FIFO transmission empty */
  259. #define LL_SPI_TX_FIFO_QUARTER_FULL (SPI_SR_FTLVL_0) /*!< FIFO transmission 1/4 */
  260. #define LL_SPI_TX_FIFO_HALF_FULL (SPI_SR_FTLVL_1) /*!< FIFO transmission 1/2 */
  261. #define LL_SPI_TX_FIFO_FULL (SPI_SR_FTLVL_1 | SPI_SR_FTLVL_0) /*!< FIFO transmission full */
  262. /**
  263. * @}
  264. */
  265. /** @defgroup SPI_LL_EC_DMA_PARITY DMA Parity
  266. * @{
  267. */
  268. #define LL_SPI_DMA_PARITY_EVEN 0x00000000U /*!< Select DMA parity Even */
  269. #define LL_SPI_DMA_PARITY_ODD 0x00000001U /*!< Select DMA parity Odd */
  270. /**
  271. * @}
  272. */
  273. /**
  274. * @}
  275. */
  276. /* Exported macro ------------------------------------------------------------*/
  277. /** @defgroup SPI_LL_Exported_Macros SPI Exported Macros
  278. * @{
  279. */
  280. /** @defgroup SPI_LL_EM_WRITE_READ Common Write and read registers Macros
  281. * @{
  282. */
  283. /**
  284. * @brief Write a value in SPI register
  285. * @param __INSTANCE__ SPI Instance
  286. * @param __REG__ Register to be written
  287. * @param __VALUE__ Value to be written in the register
  288. * @retval None
  289. */
  290. #define LL_SPI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  291. /**
  292. * @brief Read a value in SPI register
  293. * @param __INSTANCE__ SPI Instance
  294. * @param __REG__ Register to be read
  295. * @retval Register value
  296. */
  297. #define LL_SPI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  298. /**
  299. * @}
  300. */
  301. /**
  302. * @}
  303. */
  304. /* Exported functions --------------------------------------------------------*/
  305. /** @defgroup SPI_LL_Exported_Functions SPI Exported Functions
  306. * @{
  307. */
  308. /** @defgroup SPI_LL_EF_Configuration Configuration
  309. * @{
  310. */
  311. /**
  312. * @brief Enable SPI peripheral
  313. * @rmtoll CR1 SPE LL_SPI_Enable
  314. * @param SPIx SPI Instance
  315. * @retval None
  316. */
  317. __STATIC_INLINE void LL_SPI_Enable(SPI_TypeDef *SPIx)
  318. {
  319. SET_BIT(SPIx->CR1, SPI_CR1_SPE);
  320. }
  321. /**
  322. * @brief Disable SPI peripheral
  323. * @note When disabling the SPI, follow the procedure described in the Reference Manual.
  324. * @rmtoll CR1 SPE LL_SPI_Disable
  325. * @param SPIx SPI Instance
  326. * @retval None
  327. */
  328. __STATIC_INLINE void LL_SPI_Disable(SPI_TypeDef *SPIx)
  329. {
  330. CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  331. }
  332. /**
  333. * @brief Check if SPI peripheral is enabled
  334. * @rmtoll CR1 SPE LL_SPI_IsEnabled
  335. * @param SPIx SPI Instance
  336. * @retval State of bit (1 or 0).
  337. */
  338. __STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx)
  339. {
  340. return (READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE));
  341. }
  342. /**
  343. * @brief Set SPI operation mode to Master or Slave
  344. * @note This bit should not be changed when communication is ongoing.
  345. * @rmtoll CR1 MSTR LL_SPI_SetMode\n
  346. * CR1 SSI LL_SPI_SetMode
  347. * @param SPIx SPI Instance
  348. * @param Mode This parameter can be one of the following values:
  349. * @arg @ref LL_SPI_MODE_MASTER
  350. * @arg @ref LL_SPI_MODE_SLAVE
  351. * @retval None
  352. */
  353. __STATIC_INLINE void LL_SPI_SetMode(SPI_TypeDef *SPIx, uint32_t Mode)
  354. {
  355. MODIFY_REG(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI, Mode);
  356. }
  357. /**
  358. * @brief Get SPI operation mode (Master or Slave)
  359. * @rmtoll CR1 MSTR LL_SPI_GetMode\n
  360. * CR1 SSI LL_SPI_GetMode
  361. * @param SPIx SPI Instance
  362. * @retval Returned value can be one of the following values:
  363. * @arg @ref LL_SPI_MODE_MASTER
  364. * @arg @ref LL_SPI_MODE_SLAVE
  365. */
  366. __STATIC_INLINE uint32_t LL_SPI_GetMode(SPI_TypeDef *SPIx)
  367. {
  368. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI));
  369. }
  370. /**
  371. * @brief Set serial protocol used
  372. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  373. * @rmtoll CR2 FRF LL_SPI_SetStandard
  374. * @param SPIx SPI Instance
  375. * @param Standard This parameter can be one of the following values:
  376. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  377. * @arg @ref LL_SPI_PROTOCOL_TI
  378. * @retval None
  379. */
  380. __STATIC_INLINE void LL_SPI_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard)
  381. {
  382. MODIFY_REG(SPIx->CR2, SPI_CR2_FRF, Standard);
  383. }
  384. /**
  385. * @brief Get serial protocol used
  386. * @rmtoll CR2 FRF LL_SPI_GetStandard
  387. * @param SPIx SPI Instance
  388. * @retval Returned value can be one of the following values:
  389. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  390. * @arg @ref LL_SPI_PROTOCOL_TI
  391. */
  392. __STATIC_INLINE uint32_t LL_SPI_GetStandard(SPI_TypeDef *SPIx)
  393. {
  394. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRF));
  395. }
  396. /**
  397. * @brief Set clock phase
  398. * @note This bit should not be changed when communication is ongoing.
  399. * This bit is not used in SPI TI mode.
  400. * @rmtoll CR1 CPHA LL_SPI_SetClockPhase
  401. * @param SPIx SPI Instance
  402. * @param ClockPhase This parameter can be one of the following values:
  403. * @arg @ref LL_SPI_PHASE_1EDGE
  404. * @arg @ref LL_SPI_PHASE_2EDGE
  405. * @retval None
  406. */
  407. __STATIC_INLINE void LL_SPI_SetClockPhase(SPI_TypeDef *SPIx, uint32_t ClockPhase)
  408. {
  409. MODIFY_REG(SPIx->CR1, SPI_CR1_CPHA, ClockPhase);
  410. }
  411. /**
  412. * @brief Get clock phase
  413. * @rmtoll CR1 CPHA LL_SPI_GetClockPhase
  414. * @param SPIx SPI Instance
  415. * @retval Returned value can be one of the following values:
  416. * @arg @ref LL_SPI_PHASE_1EDGE
  417. * @arg @ref LL_SPI_PHASE_2EDGE
  418. */
  419. __STATIC_INLINE uint32_t LL_SPI_GetClockPhase(SPI_TypeDef *SPIx)
  420. {
  421. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPHA));
  422. }
  423. /**
  424. * @brief Set clock polarity
  425. * @note This bit should not be changed when communication is ongoing.
  426. * This bit is not used in SPI TI mode.
  427. * @rmtoll CR1 CPOL LL_SPI_SetClockPolarity
  428. * @param SPIx SPI Instance
  429. * @param ClockPolarity This parameter can be one of the following values:
  430. * @arg @ref LL_SPI_POLARITY_LOW
  431. * @arg @ref LL_SPI_POLARITY_HIGH
  432. * @retval None
  433. */
  434. __STATIC_INLINE void LL_SPI_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity)
  435. {
  436. MODIFY_REG(SPIx->CR1, SPI_CR1_CPOL, ClockPolarity);
  437. }
  438. /**
  439. * @brief Get clock polarity
  440. * @rmtoll CR1 CPOL LL_SPI_GetClockPolarity
  441. * @param SPIx SPI Instance
  442. * @retval Returned value can be one of the following values:
  443. * @arg @ref LL_SPI_POLARITY_LOW
  444. * @arg @ref LL_SPI_POLARITY_HIGH
  445. */
  446. __STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(SPI_TypeDef *SPIx)
  447. {
  448. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPOL));
  449. }
  450. /**
  451. * @brief Set baud rate prescaler
  452. * @note These bits should not be changed when communication is ongoing. SPI BaudRate = fPCLK/Prescaler.
  453. * @rmtoll CR1 BR LL_SPI_SetBaudRatePrescaler
  454. * @param SPIx SPI Instance
  455. * @param BaudRate This parameter can be one of the following values:
  456. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  457. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  458. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  459. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  460. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  461. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  462. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  463. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  464. * @retval None
  465. */
  466. __STATIC_INLINE void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef *SPIx, uint32_t BaudRate)
  467. {
  468. MODIFY_REG(SPIx->CR1, SPI_CR1_BR, BaudRate);
  469. }
  470. /**
  471. * @brief Get baud rate prescaler
  472. * @rmtoll CR1 BR LL_SPI_GetBaudRatePrescaler
  473. * @param SPIx SPI Instance
  474. * @retval Returned value can be one of the following values:
  475. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  476. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  477. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  478. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  479. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  480. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  481. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  482. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  483. */
  484. __STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(SPI_TypeDef *SPIx)
  485. {
  486. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_BR));
  487. }
  488. /**
  489. * @brief Set transfer bit order
  490. * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
  491. * @rmtoll CR1 LSBFIRST LL_SPI_SetTransferBitOrder
  492. * @param SPIx SPI Instance
  493. * @param BitOrder This parameter can be one of the following values:
  494. * @arg @ref LL_SPI_LSB_FIRST
  495. * @arg @ref LL_SPI_MSB_FIRST
  496. * @retval None
  497. */
  498. __STATIC_INLINE void LL_SPI_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder)
  499. {
  500. MODIFY_REG(SPIx->CR1, SPI_CR1_LSBFIRST, BitOrder);
  501. }
  502. /**
  503. * @brief Get transfer bit order
  504. * @rmtoll CR1 LSBFIRST LL_SPI_GetTransferBitOrder
  505. * @param SPIx SPI Instance
  506. * @retval Returned value can be one of the following values:
  507. * @arg @ref LL_SPI_LSB_FIRST
  508. * @arg @ref LL_SPI_MSB_FIRST
  509. */
  510. __STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(SPI_TypeDef *SPIx)
  511. {
  512. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_LSBFIRST));
  513. }
  514. /**
  515. * @brief Set transfer direction mode
  516. * @note For Half-Duplex mode, Rx Direction is set by default.
  517. * In master mode, the MOSI pin is used and in slave mode, the MISO pin is used for Half-Duplex.
  518. * @rmtoll CR1 RXONLY LL_SPI_SetTransferDirection\n
  519. * CR1 BIDIMODE LL_SPI_SetTransferDirection\n
  520. * CR1 BIDIOE LL_SPI_SetTransferDirection
  521. * @param SPIx SPI Instance
  522. * @param TransferDirection This parameter can be one of the following values:
  523. * @arg @ref LL_SPI_FULL_DUPLEX
  524. * @arg @ref LL_SPI_SIMPLEX_RX
  525. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  526. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  527. * @retval None
  528. */
  529. __STATIC_INLINE void LL_SPI_SetTransferDirection(SPI_TypeDef *SPIx, uint32_t TransferDirection)
  530. {
  531. MODIFY_REG(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE, TransferDirection);
  532. }
  533. /**
  534. * @brief Get transfer direction mode
  535. * @rmtoll CR1 RXONLY LL_SPI_GetTransferDirection\n
  536. * CR1 BIDIMODE LL_SPI_GetTransferDirection\n
  537. * CR1 BIDIOE LL_SPI_GetTransferDirection
  538. * @param SPIx SPI Instance
  539. * @retval Returned value can be one of the following values:
  540. * @arg @ref LL_SPI_FULL_DUPLEX
  541. * @arg @ref LL_SPI_SIMPLEX_RX
  542. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  543. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  544. */
  545. __STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(SPI_TypeDef *SPIx)
  546. {
  547. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE));
  548. }
  549. /**
  550. * @brief Set frame data width
  551. * @rmtoll CR2 DS LL_SPI_SetDataWidth
  552. * @param SPIx SPI Instance
  553. * @param DataWidth This parameter can be one of the following values:
  554. * @arg @ref LL_SPI_DATAWIDTH_4BIT
  555. * @arg @ref LL_SPI_DATAWIDTH_5BIT
  556. * @arg @ref LL_SPI_DATAWIDTH_6BIT
  557. * @arg @ref LL_SPI_DATAWIDTH_7BIT
  558. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  559. * @arg @ref LL_SPI_DATAWIDTH_9BIT
  560. * @arg @ref LL_SPI_DATAWIDTH_10BIT
  561. * @arg @ref LL_SPI_DATAWIDTH_11BIT
  562. * @arg @ref LL_SPI_DATAWIDTH_12BIT
  563. * @arg @ref LL_SPI_DATAWIDTH_13BIT
  564. * @arg @ref LL_SPI_DATAWIDTH_14BIT
  565. * @arg @ref LL_SPI_DATAWIDTH_15BIT
  566. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  567. * @retval None
  568. */
  569. __STATIC_INLINE void LL_SPI_SetDataWidth(SPI_TypeDef *SPIx, uint32_t DataWidth)
  570. {
  571. MODIFY_REG(SPIx->CR2, SPI_CR2_DS, DataWidth);
  572. }
  573. /**
  574. * @brief Get frame data width
  575. * @rmtoll CR2 DS LL_SPI_GetDataWidth
  576. * @param SPIx SPI Instance
  577. * @retval Returned value can be one of the following values:
  578. * @arg @ref LL_SPI_DATAWIDTH_4BIT
  579. * @arg @ref LL_SPI_DATAWIDTH_5BIT
  580. * @arg @ref LL_SPI_DATAWIDTH_6BIT
  581. * @arg @ref LL_SPI_DATAWIDTH_7BIT
  582. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  583. * @arg @ref LL_SPI_DATAWIDTH_9BIT
  584. * @arg @ref LL_SPI_DATAWIDTH_10BIT
  585. * @arg @ref LL_SPI_DATAWIDTH_11BIT
  586. * @arg @ref LL_SPI_DATAWIDTH_12BIT
  587. * @arg @ref LL_SPI_DATAWIDTH_13BIT
  588. * @arg @ref LL_SPI_DATAWIDTH_14BIT
  589. * @arg @ref LL_SPI_DATAWIDTH_15BIT
  590. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  591. */
  592. __STATIC_INLINE uint32_t LL_SPI_GetDataWidth(SPI_TypeDef *SPIx)
  593. {
  594. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_DS));
  595. }
  596. /**
  597. * @brief Set threshold of RXFIFO that triggers an RXNE event
  598. * @rmtoll CR2 FRXTH LL_SPI_SetRxFIFOThreshold
  599. * @param SPIx SPI Instance
  600. * @param Threshold This parameter can be one of the following values:
  601. * @arg @ref LL_SPI_RX_FIFO_TH_HALF
  602. * @arg @ref LL_SPI_RX_FIFO_TH_QUARTER
  603. * @retval None
  604. */
  605. __STATIC_INLINE void LL_SPI_SetRxFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Threshold)
  606. {
  607. MODIFY_REG(SPIx->CR2, SPI_CR2_FRXTH, Threshold);
  608. }
  609. /**
  610. * @brief Get threshold of RXFIFO that triggers an RXNE event
  611. * @rmtoll CR2 FRXTH LL_SPI_GetRxFIFOThreshold
  612. * @param SPIx SPI Instance
  613. * @retval Returned value can be one of the following values:
  614. * @arg @ref LL_SPI_RX_FIFO_TH_HALF
  615. * @arg @ref LL_SPI_RX_FIFO_TH_QUARTER
  616. */
  617. __STATIC_INLINE uint32_t LL_SPI_GetRxFIFOThreshold(SPI_TypeDef *SPIx)
  618. {
  619. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRXTH));
  620. }
  621. /**
  622. * @}
  623. */
  624. /** @defgroup SPI_LL_EF_CRC_Management CRC Management
  625. * @{
  626. */
  627. /**
  628. * @brief Enable CRC
  629. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  630. * @rmtoll CR1 CRCEN LL_SPI_EnableCRC
  631. * @param SPIx SPI Instance
  632. * @retval None
  633. */
  634. __STATIC_INLINE void LL_SPI_EnableCRC(SPI_TypeDef *SPIx)
  635. {
  636. SET_BIT(SPIx->CR1, SPI_CR1_CRCEN);
  637. }
  638. /**
  639. * @brief Disable CRC
  640. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  641. * @rmtoll CR1 CRCEN LL_SPI_DisableCRC
  642. * @param SPIx SPI Instance
  643. * @retval None
  644. */
  645. __STATIC_INLINE void LL_SPI_DisableCRC(SPI_TypeDef *SPIx)
  646. {
  647. CLEAR_BIT(SPIx->CR1, SPI_CR1_CRCEN);
  648. }
  649. /**
  650. * @brief Check if CRC is enabled
  651. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  652. * @rmtoll CR1 CRCEN LL_SPI_IsEnabledCRC
  653. * @param SPIx SPI Instance
  654. * @retval State of bit (1 or 0).
  655. */
  656. __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx)
  657. {
  658. return (READ_BIT(SPIx->CR1, SPI_CR1_CRCEN) == (SPI_CR1_CRCEN));
  659. }
  660. /**
  661. * @brief Set CRC Length
  662. * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
  663. * @rmtoll CR1 CRCL LL_SPI_SetCRCWidth
  664. * @param SPIx SPI Instance
  665. * @param CRCLength This parameter can be one of the following values:
  666. * @arg @ref LL_SPI_CRC_8BIT
  667. * @arg @ref LL_SPI_CRC_16BIT
  668. * @retval None
  669. */
  670. __STATIC_INLINE void LL_SPI_SetCRCWidth(SPI_TypeDef *SPIx, uint32_t CRCLength)
  671. {
  672. MODIFY_REG(SPIx->CR1, SPI_CR1_CRCL, CRCLength);
  673. }
  674. /**
  675. * @brief Get CRC Length
  676. * @rmtoll CR1 CRCL LL_SPI_GetCRCWidth
  677. * @param SPIx SPI Instance
  678. * @retval Returned value can be one of the following values:
  679. * @arg @ref LL_SPI_CRC_8BIT
  680. * @arg @ref LL_SPI_CRC_16BIT
  681. */
  682. __STATIC_INLINE uint32_t LL_SPI_GetCRCWidth(SPI_TypeDef *SPIx)
  683. {
  684. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CRCL));
  685. }
  686. /**
  687. * @brief Set CRCNext to transfer CRC on the line
  688. * @note This bit has to be written as soon as the last data is written in the SPIx_DR register.
  689. * @rmtoll CR1 CRCNEXT LL_SPI_SetCRCNext
  690. * @param SPIx SPI Instance
  691. * @retval None
  692. */
  693. __STATIC_INLINE void LL_SPI_SetCRCNext(SPI_TypeDef *SPIx)
  694. {
  695. SET_BIT(SPIx->CR1, SPI_CR1_CRCNEXT);
  696. }
  697. /**
  698. * @brief Set polynomial for CRC calculation
  699. * @rmtoll CRCPR CRCPOLY LL_SPI_SetCRCPolynomial
  700. * @param SPIx SPI Instance
  701. * @param CRCPoly This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  702. * @retval None
  703. */
  704. __STATIC_INLINE void LL_SPI_SetCRCPolynomial(SPI_TypeDef *SPIx, uint32_t CRCPoly)
  705. {
  706. WRITE_REG(SPIx->CRCPR, (uint16_t)CRCPoly);
  707. }
  708. /**
  709. * @brief Get polynomial for CRC calculation
  710. * @rmtoll CRCPR CRCPOLY LL_SPI_GetCRCPolynomial
  711. * @param SPIx SPI Instance
  712. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  713. */
  714. __STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef *SPIx)
  715. {
  716. return (uint32_t)(READ_REG(SPIx->CRCPR));
  717. }
  718. /**
  719. * @brief Get Rx CRC
  720. * @rmtoll RXCRCR RXCRC LL_SPI_GetRxCRC
  721. * @param SPIx SPI Instance
  722. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  723. */
  724. __STATIC_INLINE uint32_t LL_SPI_GetRxCRC(SPI_TypeDef *SPIx)
  725. {
  726. return (uint32_t)(READ_REG(SPIx->RXCRCR));
  727. }
  728. /**
  729. * @brief Get Tx CRC
  730. * @rmtoll TXCRCR TXCRC LL_SPI_GetTxCRC
  731. * @param SPIx SPI Instance
  732. * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
  733. */
  734. __STATIC_INLINE uint32_t LL_SPI_GetTxCRC(SPI_TypeDef *SPIx)
  735. {
  736. return (uint32_t)(READ_REG(SPIx->TXCRCR));
  737. }
  738. /**
  739. * @}
  740. */
  741. /** @defgroup SPI_LL_EF_NSS_Management Slave Select Pin Management
  742. * @{
  743. */
  744. /**
  745. * @brief Set NSS mode
  746. * @note LL_SPI_NSS_SOFT Mode is not used in SPI TI mode.
  747. * @rmtoll CR1 SSM LL_SPI_SetNSSMode\n
  748. * @rmtoll CR2 SSOE LL_SPI_SetNSSMode
  749. * @param SPIx SPI Instance
  750. * @param NSS This parameter can be one of the following values:
  751. * @arg @ref LL_SPI_NSS_SOFT
  752. * @arg @ref LL_SPI_NSS_HARD_INPUT
  753. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  754. * @retval None
  755. */
  756. __STATIC_INLINE void LL_SPI_SetNSSMode(SPI_TypeDef *SPIx, uint32_t NSS)
  757. {
  758. MODIFY_REG(SPIx->CR1, SPI_CR1_SSM, NSS);
  759. MODIFY_REG(SPIx->CR2, SPI_CR2_SSOE, ((uint32_t)(NSS >> 16U)));
  760. }
  761. /**
  762. * @brief Get NSS mode
  763. * @rmtoll CR1 SSM LL_SPI_GetNSSMode\n
  764. * @rmtoll CR2 SSOE LL_SPI_GetNSSMode
  765. * @param SPIx SPI Instance
  766. * @retval Returned value can be one of the following values:
  767. * @arg @ref LL_SPI_NSS_SOFT
  768. * @arg @ref LL_SPI_NSS_HARD_INPUT
  769. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  770. */
  771. __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx)
  772. {
  773. register uint32_t Ssm = (READ_BIT(SPIx->CR1, SPI_CR1_SSM));
  774. register uint32_t Ssoe = (READ_BIT(SPIx->CR2, SPI_CR2_SSOE) << 16U);
  775. return (Ssm | Ssoe);
  776. }
  777. /**
  778. * @brief Enable NSS pulse management
  779. * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
  780. * @rmtoll CR2 NSSP LL_SPI_EnableNSSPulseMgt
  781. * @param SPIx SPI Instance
  782. * @retval None
  783. */
  784. __STATIC_INLINE void LL_SPI_EnableNSSPulseMgt(SPI_TypeDef *SPIx)
  785. {
  786. SET_BIT(SPIx->CR2, SPI_CR2_NSSP);
  787. }
  788. /**
  789. * @brief Disable NSS pulse management
  790. * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
  791. * @rmtoll CR2 NSSP LL_SPI_DisableNSSPulseMgt
  792. * @param SPIx SPI Instance
  793. * @retval None
  794. */
  795. __STATIC_INLINE void LL_SPI_DisableNSSPulseMgt(SPI_TypeDef *SPIx)
  796. {
  797. CLEAR_BIT(SPIx->CR2, SPI_CR2_NSSP);
  798. }
  799. /**
  800. * @brief Check if NSS pulse is enabled
  801. * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
  802. * @rmtoll CR2 NSSP LL_SPI_IsEnabledNSSPulse
  803. * @param SPIx SPI Instance
  804. * @retval State of bit (1 or 0).
  805. */
  806. __STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(SPI_TypeDef *SPIx)
  807. {
  808. return (READ_BIT(SPIx->CR2, SPI_CR2_NSSP) == (SPI_CR2_NSSP));
  809. }
  810. /**
  811. * @}
  812. */
  813. /** @defgroup SPI_LL_EF_FLAG_Management FLAG Management
  814. * @{
  815. */
  816. /**
  817. * @brief Check if Rx buffer is not empty
  818. * @rmtoll SR RXNE LL_SPI_IsActiveFlag_RXNE
  819. * @param SPIx SPI Instance
  820. * @retval State of bit (1 or 0).
  821. */
  822. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef *SPIx)
  823. {
  824. return (READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE));
  825. }
  826. /**
  827. * @brief Check if Tx buffer is empty
  828. * @rmtoll SR TXE LL_SPI_IsActiveFlag_TXE
  829. * @param SPIx SPI Instance
  830. * @retval State of bit (1 or 0).
  831. */
  832. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef *SPIx)
  833. {
  834. return (READ_BIT(SPIx->SR, SPI_SR_TXE) == (SPI_SR_TXE));
  835. }
  836. /**
  837. * @brief Get CRC error flag
  838. * @rmtoll SR CRCERR LL_SPI_IsActiveFlag_CRCERR
  839. * @param SPIx SPI Instance
  840. * @retval State of bit (1 or 0).
  841. */
  842. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx)
  843. {
  844. return (READ_BIT(SPIx->SR, SPI_SR_CRCERR) == (SPI_SR_CRCERR));
  845. }
  846. /**
  847. * @brief Get mode fault error flag
  848. * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF
  849. * @param SPIx SPI Instance
  850. * @retval State of bit (1 or 0).
  851. */
  852. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx)
  853. {
  854. return (READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF));
  855. }
  856. /**
  857. * @brief Get overrun error flag
  858. * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR
  859. * @param SPIx SPI Instance
  860. * @retval State of bit (1 or 0).
  861. */
  862. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx)
  863. {
  864. return (READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR));
  865. }
  866. /**
  867. * @brief Get busy flag
  868. * @note The BSY flag is cleared under any one of the following conditions:
  869. * -When the SPI is correctly disabled
  870. * -When a fault is detected in Master mode (MODF bit set to 1)
  871. * -In Master mode, when it finishes a data transmission and no new data is ready to be
  872. * sent
  873. * -In Slave mode, when the BSY flag is set to '0' for at least one SPI clock cycle between
  874. * each data transfer.
  875. * @rmtoll SR BSY LL_SPI_IsActiveFlag_BSY
  876. * @param SPIx SPI Instance
  877. * @retval State of bit (1 or 0).
  878. */
  879. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef *SPIx)
  880. {
  881. return (READ_BIT(SPIx->SR, SPI_SR_BSY) == (SPI_SR_BSY));
  882. }
  883. /**
  884. * @brief Get frame format error flag
  885. * @rmtoll SR FRE LL_SPI_IsActiveFlag_FRE
  886. * @param SPIx SPI Instance
  887. * @retval State of bit (1 or 0).
  888. */
  889. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(SPI_TypeDef *SPIx)
  890. {
  891. return (READ_BIT(SPIx->SR, SPI_SR_FRE) == (SPI_SR_FRE));
  892. }
  893. /**
  894. * @brief Get FIFO reception Level
  895. * @rmtoll SR FRLVL LL_SPI_GetRxFIFOLevel
  896. * @param SPIx SPI Instance
  897. * @retval Returned value can be one of the following values:
  898. * @arg @ref LL_SPI_RX_FIFO_EMPTY
  899. * @arg @ref LL_SPI_RX_FIFO_QUARTER_FULL
  900. * @arg @ref LL_SPI_RX_FIFO_HALF_FULL
  901. * @arg @ref LL_SPI_RX_FIFO_FULL
  902. */
  903. __STATIC_INLINE uint32_t LL_SPI_GetRxFIFOLevel(SPI_TypeDef *SPIx)
  904. {
  905. return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_FRLVL));
  906. }
  907. /**
  908. * @brief Get FIFO Transmission Level
  909. * @rmtoll SR FTLVL LL_SPI_GetTxFIFOLevel
  910. * @param SPIx SPI Instance
  911. * @retval Returned value can be one of the following values:
  912. * @arg @ref LL_SPI_TX_FIFO_EMPTY
  913. * @arg @ref LL_SPI_TX_FIFO_QUARTER_FULL
  914. * @arg @ref LL_SPI_TX_FIFO_HALF_FULL
  915. * @arg @ref LL_SPI_TX_FIFO_FULL
  916. */
  917. __STATIC_INLINE uint32_t LL_SPI_GetTxFIFOLevel(SPI_TypeDef *SPIx)
  918. {
  919. return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_FTLVL));
  920. }
  921. /**
  922. * @brief Clear CRC error flag
  923. * @rmtoll SR CRCERR LL_SPI_ClearFlag_CRCERR
  924. * @param SPIx SPI Instance
  925. * @retval None
  926. */
  927. __STATIC_INLINE void LL_SPI_ClearFlag_CRCERR(SPI_TypeDef *SPIx)
  928. {
  929. CLEAR_BIT(SPIx->SR, SPI_SR_CRCERR);
  930. }
  931. /**
  932. * @brief Clear mode fault error flag
  933. * @note Clearing this flag is done by a read access to the SPIx_SR
  934. * register followed by a write access to the SPIx_CR1 register
  935. * @rmtoll SR MODF LL_SPI_ClearFlag_MODF
  936. * @param SPIx SPI Instance
  937. * @retval None
  938. */
  939. __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx)
  940. {
  941. __IO uint32_t tmpreg;
  942. tmpreg = SPIx->SR;
  943. (void) tmpreg;
  944. tmpreg = CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  945. (void) tmpreg;
  946. }
  947. /**
  948. * @brief Clear overrun error flag
  949. * @note Clearing this flag is done by a read access to the SPIx_DR
  950. * register followed by a read access to the SPIx_SR register
  951. * @rmtoll SR OVR LL_SPI_ClearFlag_OVR
  952. * @param SPIx SPI Instance
  953. * @retval None
  954. */
  955. __STATIC_INLINE void LL_SPI_ClearFlag_OVR(SPI_TypeDef *SPIx)
  956. {
  957. __IO uint32_t tmpreg;
  958. tmpreg = SPIx->DR;
  959. (void) tmpreg;
  960. tmpreg = SPIx->SR;
  961. (void) tmpreg;
  962. }
  963. /**
  964. * @brief Clear frame format error flag
  965. * @note Clearing this flag is done by reading SPIx_SR register
  966. * @rmtoll SR FRE LL_SPI_ClearFlag_FRE
  967. * @param SPIx SPI Instance
  968. * @retval None
  969. */
  970. __STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx)
  971. {
  972. __IO uint32_t tmpreg;
  973. tmpreg = SPIx->SR;
  974. (void) tmpreg;
  975. }
  976. /**
  977. * @}
  978. */
  979. /** @defgroup SPI_LL_EF_IT_Management Interrupt Management
  980. * @{
  981. */
  982. /**
  983. * @brief Enable error interrupt
  984. * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
  985. * @rmtoll CR2 ERRIE LL_SPI_EnableIT_ERR
  986. * @param SPIx SPI Instance
  987. * @retval None
  988. */
  989. __STATIC_INLINE void LL_SPI_EnableIT_ERR(SPI_TypeDef *SPIx)
  990. {
  991. SET_BIT(SPIx->CR2, SPI_CR2_ERRIE);
  992. }
  993. /**
  994. * @brief Enable Rx buffer not empty interrupt
  995. * @rmtoll CR2 RXNEIE LL_SPI_EnableIT_RXNE
  996. * @param SPIx SPI Instance
  997. * @retval None
  998. */
  999. __STATIC_INLINE void LL_SPI_EnableIT_RXNE(SPI_TypeDef *SPIx)
  1000. {
  1001. SET_BIT(SPIx->CR2, SPI_CR2_RXNEIE);
  1002. }
  1003. /**
  1004. * @brief Enable Tx buffer empty interrupt
  1005. * @rmtoll CR2 TXEIE LL_SPI_EnableIT_TXE
  1006. * @param SPIx SPI Instance
  1007. * @retval None
  1008. */
  1009. __STATIC_INLINE void LL_SPI_EnableIT_TXE(SPI_TypeDef *SPIx)
  1010. {
  1011. SET_BIT(SPIx->CR2, SPI_CR2_TXEIE);
  1012. }
  1013. /**
  1014. * @brief Disable error interrupt
  1015. * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
  1016. * @rmtoll CR2 ERRIE LL_SPI_DisableIT_ERR
  1017. * @param SPIx SPI Instance
  1018. * @retval None
  1019. */
  1020. __STATIC_INLINE void LL_SPI_DisableIT_ERR(SPI_TypeDef *SPIx)
  1021. {
  1022. CLEAR_BIT(SPIx->CR2, SPI_CR2_ERRIE);
  1023. }
  1024. /**
  1025. * @brief Disable Rx buffer not empty interrupt
  1026. * @rmtoll CR2 RXNEIE LL_SPI_DisableIT_RXNE
  1027. * @param SPIx SPI Instance
  1028. * @retval None
  1029. */
  1030. __STATIC_INLINE void LL_SPI_DisableIT_RXNE(SPI_TypeDef *SPIx)
  1031. {
  1032. CLEAR_BIT(SPIx->CR2, SPI_CR2_RXNEIE);
  1033. }
  1034. /**
  1035. * @brief Disable Tx buffer empty interrupt
  1036. * @rmtoll CR2 TXEIE LL_SPI_DisableIT_TXE
  1037. * @param SPIx SPI Instance
  1038. * @retval None
  1039. */
  1040. __STATIC_INLINE void LL_SPI_DisableIT_TXE(SPI_TypeDef *SPIx)
  1041. {
  1042. CLEAR_BIT(SPIx->CR2, SPI_CR2_TXEIE);
  1043. }
  1044. /**
  1045. * @brief Check if error interrupt is enabled
  1046. * @rmtoll CR2 ERRIE LL_SPI_IsEnabledIT_ERR
  1047. * @param SPIx SPI Instance
  1048. * @retval State of bit (1 or 0).
  1049. */
  1050. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef *SPIx)
  1051. {
  1052. return (READ_BIT(SPIx->CR2, SPI_CR2_ERRIE) == (SPI_CR2_ERRIE));
  1053. }
  1054. /**
  1055. * @brief Check if Rx buffer not empty interrupt is enabled
  1056. * @rmtoll CR2 RXNEIE LL_SPI_IsEnabledIT_RXNE
  1057. * @param SPIx SPI Instance
  1058. * @retval State of bit (1 or 0).
  1059. */
  1060. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef *SPIx)
  1061. {
  1062. return (READ_BIT(SPIx->CR2, SPI_CR2_RXNEIE) == (SPI_CR2_RXNEIE));
  1063. }
  1064. /**
  1065. * @brief Check if Tx buffer empty interrupt
  1066. * @rmtoll CR2 TXEIE LL_SPI_IsEnabledIT_TXE
  1067. * @param SPIx SPI Instance
  1068. * @retval State of bit (1 or 0).
  1069. */
  1070. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(SPI_TypeDef *SPIx)
  1071. {
  1072. return (READ_BIT(SPIx->CR2, SPI_CR2_TXEIE) == (SPI_CR2_TXEIE));
  1073. }
  1074. /**
  1075. * @}
  1076. */
  1077. /** @defgroup SPI_LL_EF_DMA_Management DMA Management
  1078. * @{
  1079. */
  1080. /**
  1081. * @brief Enable DMA Rx
  1082. * @rmtoll CR2 RXDMAEN LL_SPI_EnableDMAReq_RX
  1083. * @param SPIx SPI Instance
  1084. * @retval None
  1085. */
  1086. __STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx)
  1087. {
  1088. SET_BIT(SPIx->CR2, SPI_CR2_RXDMAEN);
  1089. }
  1090. /**
  1091. * @brief Disable DMA Rx
  1092. * @rmtoll CR2 RXDMAEN LL_SPI_DisableDMAReq_RX
  1093. * @param SPIx SPI Instance
  1094. * @retval None
  1095. */
  1096. __STATIC_INLINE void LL_SPI_DisableDMAReq_RX(SPI_TypeDef *SPIx)
  1097. {
  1098. CLEAR_BIT(SPIx->CR2, SPI_CR2_RXDMAEN);
  1099. }
  1100. /**
  1101. * @brief Check if DMA Rx is enabled
  1102. * @rmtoll CR2 RXDMAEN LL_SPI_IsEnabledDMAReq_RX
  1103. * @param SPIx SPI Instance
  1104. * @retval State of bit (1 or 0).
  1105. */
  1106. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx)
  1107. {
  1108. return (READ_BIT(SPIx->CR2, SPI_CR2_RXDMAEN) == (SPI_CR2_RXDMAEN));
  1109. }
  1110. /**
  1111. * @brief Enable DMA Tx
  1112. * @rmtoll CR2 TXDMAEN LL_SPI_EnableDMAReq_TX
  1113. * @param SPIx SPI Instance
  1114. * @retval None
  1115. */
  1116. __STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx)
  1117. {
  1118. SET_BIT(SPIx->CR2, SPI_CR2_TXDMAEN);
  1119. }
  1120. /**
  1121. * @brief Disable DMA Tx
  1122. * @rmtoll CR2 TXDMAEN LL_SPI_DisableDMAReq_TX
  1123. * @param SPIx SPI Instance
  1124. * @retval None
  1125. */
  1126. __STATIC_INLINE void LL_SPI_DisableDMAReq_TX(SPI_TypeDef *SPIx)
  1127. {
  1128. CLEAR_BIT(SPIx->CR2, SPI_CR2_TXDMAEN);
  1129. }
  1130. /**
  1131. * @brief Check if DMA Tx is enabled
  1132. * @rmtoll CR2 TXDMAEN LL_SPI_IsEnabledDMAReq_TX
  1133. * @param SPIx SPI Instance
  1134. * @retval State of bit (1 or 0).
  1135. */
  1136. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx)
  1137. {
  1138. return (READ_BIT(SPIx->CR2, SPI_CR2_TXDMAEN) == (SPI_CR2_TXDMAEN));
  1139. }
  1140. /**
  1141. * @brief Set parity of Last DMA reception
  1142. * @rmtoll CR2 LDMARX LL_SPI_SetDMAParity_RX
  1143. * @param SPIx SPI Instance
  1144. * @param Parity This parameter can be one of the following values:
  1145. * @arg @ref LL_SPI_DMA_PARITY_ODD
  1146. * @arg @ref LL_SPI_DMA_PARITY_EVEN
  1147. * @retval None
  1148. */
  1149. __STATIC_INLINE void LL_SPI_SetDMAParity_RX(SPI_TypeDef *SPIx, uint32_t Parity)
  1150. {
  1151. MODIFY_REG(SPIx->CR2, SPI_CR2_LDMARX, (Parity << SPI_CR2_LDMARX_Pos));
  1152. }
  1153. /**
  1154. * @brief Get parity configuration for Last DMA reception
  1155. * @rmtoll CR2 LDMARX LL_SPI_GetDMAParity_RX
  1156. * @param SPIx SPI Instance
  1157. * @retval Returned value can be one of the following values:
  1158. * @arg @ref LL_SPI_DMA_PARITY_ODD
  1159. * @arg @ref LL_SPI_DMA_PARITY_EVEN
  1160. */
  1161. __STATIC_INLINE uint32_t LL_SPI_GetDMAParity_RX(SPI_TypeDef *SPIx)
  1162. {
  1163. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_LDMARX) >> SPI_CR2_LDMARX_Pos);
  1164. }
  1165. /**
  1166. * @brief Set parity of Last DMA transmission
  1167. * @rmtoll CR2 LDMATX LL_SPI_SetDMAParity_TX
  1168. * @param SPIx SPI Instance
  1169. * @param Parity This parameter can be one of the following values:
  1170. * @arg @ref LL_SPI_DMA_PARITY_ODD
  1171. * @arg @ref LL_SPI_DMA_PARITY_EVEN
  1172. * @retval None
  1173. */
  1174. __STATIC_INLINE void LL_SPI_SetDMAParity_TX(SPI_TypeDef *SPIx, uint32_t Parity)
  1175. {
  1176. MODIFY_REG(SPIx->CR2, SPI_CR2_LDMATX, (Parity << SPI_CR2_LDMATX_Pos));
  1177. }
  1178. /**
  1179. * @brief Get parity configuration for Last DMA transmission
  1180. * @rmtoll CR2 LDMATX LL_SPI_GetDMAParity_TX
  1181. * @param SPIx SPI Instance
  1182. * @retval Returned value can be one of the following values:
  1183. * @arg @ref LL_SPI_DMA_PARITY_ODD
  1184. * @arg @ref LL_SPI_DMA_PARITY_EVEN
  1185. */
  1186. __STATIC_INLINE uint32_t LL_SPI_GetDMAParity_TX(SPI_TypeDef *SPIx)
  1187. {
  1188. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_LDMATX) >> SPI_CR2_LDMATX_Pos);
  1189. }
  1190. /**
  1191. * @brief Get the data register address used for DMA transfer
  1192. * @rmtoll DR DR LL_SPI_DMA_GetRegAddr
  1193. * @param SPIx SPI Instance
  1194. * @retval Address of data register
  1195. */
  1196. __STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(SPI_TypeDef *SPIx)
  1197. {
  1198. return (uint32_t) & (SPIx->DR);
  1199. }
  1200. /**
  1201. * @}
  1202. */
  1203. /** @defgroup SPI_LL_EF_DATA_Management DATA Management
  1204. * @{
  1205. */
  1206. /**
  1207. * @brief Read 8-Bits in the data register
  1208. * @rmtoll DR DR LL_SPI_ReceiveData8
  1209. * @param SPIx SPI Instance
  1210. * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFF
  1211. */
  1212. __STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)
  1213. {
  1214. return (uint8_t)(READ_REG(SPIx->DR));
  1215. }
  1216. /**
  1217. * @brief Read 16-Bits in the data register
  1218. * @rmtoll DR DR LL_SPI_ReceiveData16
  1219. * @param SPIx SPI Instance
  1220. * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFFFF
  1221. */
  1222. __STATIC_INLINE uint16_t LL_SPI_ReceiveData16(SPI_TypeDef *SPIx)
  1223. {
  1224. return (uint16_t)(READ_REG(SPIx->DR));
  1225. }
  1226. /**
  1227. * @brief Write 8-Bits in the data register
  1228. * @rmtoll DR DR LL_SPI_TransmitData8
  1229. * @param SPIx SPI Instance
  1230. * @param TxData Value between Min_Data=0x00 and Max_Data=0xFF
  1231. * @retval None
  1232. */
  1233. __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
  1234. {
  1235. *((__IO uint8_t *)&SPIx->DR) = TxData;
  1236. }
  1237. /**
  1238. * @brief Write 16-Bits in the data register
  1239. * @rmtoll DR DR LL_SPI_TransmitData16
  1240. * @param SPIx SPI Instance
  1241. * @param TxData Value between Min_Data=0x00 and Max_Data=0xFFFF
  1242. * @retval None
  1243. */
  1244. __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
  1245. {
  1246. *((__IO uint16_t *)&SPIx->DR) = TxData;
  1247. }
  1248. /**
  1249. * @}
  1250. */
  1251. #if defined(USE_FULL_LL_DRIVER)
  1252. /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions
  1253. * @{
  1254. */
  1255. ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx);
  1256. ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct);
  1257. void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct);
  1258. /**
  1259. * @}
  1260. */
  1261. #endif /* USE_FULL_LL_DRIVER */
  1262. /**
  1263. * @}
  1264. */
  1265. /**
  1266. * @}
  1267. */
  1268. #endif /* defined (SPI1) || defined (SPI2) || defined (SPI3) */
  1269. /**
  1270. * @}
  1271. */
  1272. #ifdef __cplusplus
  1273. }
  1274. #endif
  1275. #endif /* __STM32L4xx_LL_SPI_H */
  1276. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/