stm32l4xx_ll_spi.h 48 KB

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