stm32f4xx_spi.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_spi.h
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  7. * @brief This file contains all the functions prototypes for the SPI
  8. * firmware library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2016 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F4xx_SPI_H
  23. #define __STM32F4xx_SPI_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f4xx.h"
  29. /** @addtogroup STM32F4xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup SPI
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /**
  37. * @brief SPI Init structure definition
  38. */
  39. typedef struct
  40. {
  41. uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
  42. This parameter can be a value of @ref SPI_data_direction */
  43. uint16_t SPI_Mode; /*!< Specifies the SPI operating mode.
  44. This parameter can be a value of @ref SPI_mode */
  45. uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
  46. This parameter can be a value of @ref SPI_data_size */
  47. uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
  48. This parameter can be a value of @ref SPI_Clock_Polarity */
  49. uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
  50. This parameter can be a value of @ref SPI_Clock_Phase */
  51. uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
  52. hardware (NSS pin) or by software using the SSI bit.
  53. This parameter can be a value of @ref SPI_Slave_Select_management */
  54. uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
  55. used to configure the transmit and receive SCK clock.
  56. This parameter can be a value of @ref SPI_BaudRate_Prescaler
  57. @note The communication clock is derived from the master
  58. clock. The slave clock does not need to be set. */
  59. uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
  60. This parameter can be a value of @ref SPI_MSB_LSB_transmission */
  61. uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
  62. }SPI_InitTypeDef;
  63. /**
  64. * @brief I2S Init structure definition
  65. */
  66. typedef struct
  67. {
  68. uint16_t I2S_Mode; /*!< Specifies the I2S operating mode.
  69. This parameter can be a value of @ref I2S_Mode */
  70. uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication.
  71. This parameter can be a value of @ref I2S_Standard */
  72. uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication.
  73. This parameter can be a value of @ref I2S_Data_Format */
  74. uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
  75. This parameter can be a value of @ref I2S_MCLK_Output */
  76. uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
  77. This parameter can be a value of @ref I2S_Audio_Frequency */
  78. uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock.
  79. This parameter can be a value of @ref I2S_Clock_Polarity */
  80. }I2S_InitTypeDef;
  81. /* Exported constants --------------------------------------------------------*/
  82. /** @defgroup SPI_Exported_Constants
  83. * @{
  84. */
  85. #define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \
  86. ((PERIPH) == SPI2) || \
  87. ((PERIPH) == SPI3) || \
  88. ((PERIPH) == SPI4) || \
  89. ((PERIPH) == SPI5) || \
  90. ((PERIPH) == SPI6))
  91. #define IS_SPI_ALL_PERIPH_EXT(PERIPH) (((PERIPH) == SPI1) || \
  92. ((PERIPH) == SPI2) || \
  93. ((PERIPH) == SPI3) || \
  94. ((PERIPH) == SPI4) || \
  95. ((PERIPH) == SPI5) || \
  96. ((PERIPH) == SPI6) || \
  97. ((PERIPH) == I2S2ext) || \
  98. ((PERIPH) == I2S3ext))
  99. #define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \
  100. ((PERIPH) == SPI3))
  101. #define IS_SPI_23_PERIPH_EXT(PERIPH) (((PERIPH) == SPI2) || \
  102. ((PERIPH) == SPI3) || \
  103. ((PERIPH) == I2S2ext) || \
  104. ((PERIPH) == I2S3ext))
  105. #define IS_I2S_EXT_PERIPH(PERIPH) (((PERIPH) == I2S2ext) || \
  106. ((PERIPH) == I2S3ext))
  107. /** @defgroup SPI_data_direction
  108. * @{
  109. */
  110. #define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)
  111. #define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)
  112. #define SPI_Direction_1Line_Rx ((uint16_t)0x8000)
  113. #define SPI_Direction_1Line_Tx ((uint16_t)0xC000)
  114. #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \
  115. ((MODE) == SPI_Direction_2Lines_RxOnly) || \
  116. ((MODE) == SPI_Direction_1Line_Rx) || \
  117. ((MODE) == SPI_Direction_1Line_Tx))
  118. /**
  119. * @}
  120. */
  121. /** @defgroup SPI_mode
  122. * @{
  123. */
  124. #define SPI_Mode_Master ((uint16_t)0x0104)
  125. #define SPI_Mode_Slave ((uint16_t)0x0000)
  126. #define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \
  127. ((MODE) == SPI_Mode_Slave))
  128. /**
  129. * @}
  130. */
  131. /** @defgroup SPI_data_size
  132. * @{
  133. */
  134. #define SPI_DataSize_16b ((uint16_t)0x0800)
  135. #define SPI_DataSize_8b ((uint16_t)0x0000)
  136. #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DataSize_16b) || \
  137. ((DATASIZE) == SPI_DataSize_8b))
  138. /**
  139. * @}
  140. */
  141. /** @defgroup SPI_Clock_Polarity
  142. * @{
  143. */
  144. #define SPI_CPOL_Low ((uint16_t)0x0000)
  145. #define SPI_CPOL_High ((uint16_t)0x0002)
  146. #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \
  147. ((CPOL) == SPI_CPOL_High))
  148. /**
  149. * @}
  150. */
  151. /** @defgroup SPI_Clock_Phase
  152. * @{
  153. */
  154. #define SPI_CPHA_1Edge ((uint16_t)0x0000)
  155. #define SPI_CPHA_2Edge ((uint16_t)0x0001)
  156. #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \
  157. ((CPHA) == SPI_CPHA_2Edge))
  158. /**
  159. * @}
  160. */
  161. /** @defgroup SPI_Slave_Select_management
  162. * @{
  163. */
  164. #define SPI_NSS_Soft ((uint16_t)0x0200)
  165. #define SPI_NSS_Hard ((uint16_t)0x0000)
  166. #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \
  167. ((NSS) == SPI_NSS_Hard))
  168. /**
  169. * @}
  170. */
  171. /** @defgroup SPI_BaudRate_Prescaler
  172. * @{
  173. */
  174. #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
  175. #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
  176. #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
  177. #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
  178. #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
  179. #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
  180. #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
  181. #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
  182. #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \
  183. ((PRESCALER) == SPI_BaudRatePrescaler_4) || \
  184. ((PRESCALER) == SPI_BaudRatePrescaler_8) || \
  185. ((PRESCALER) == SPI_BaudRatePrescaler_16) || \
  186. ((PRESCALER) == SPI_BaudRatePrescaler_32) || \
  187. ((PRESCALER) == SPI_BaudRatePrescaler_64) || \
  188. ((PRESCALER) == SPI_BaudRatePrescaler_128) || \
  189. ((PRESCALER) == SPI_BaudRatePrescaler_256))
  190. /**
  191. * @}
  192. */
  193. /** @defgroup SPI_MSB_LSB_transmission
  194. * @{
  195. */
  196. #define SPI_FirstBit_MSB ((uint16_t)0x0000)
  197. #define SPI_FirstBit_LSB ((uint16_t)0x0080)
  198. #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \
  199. ((BIT) == SPI_FirstBit_LSB))
  200. /**
  201. * @}
  202. */
  203. /** @defgroup SPI_I2S_Mode
  204. * @{
  205. */
  206. #define I2S_Mode_SlaveTx ((uint16_t)0x0000)
  207. #define I2S_Mode_SlaveRx ((uint16_t)0x0100)
  208. #define I2S_Mode_MasterTx ((uint16_t)0x0200)
  209. #define I2S_Mode_MasterRx ((uint16_t)0x0300)
  210. #define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \
  211. ((MODE) == I2S_Mode_SlaveRx) || \
  212. ((MODE) == I2S_Mode_MasterTx)|| \
  213. ((MODE) == I2S_Mode_MasterRx))
  214. /**
  215. * @}
  216. */
  217. /** @defgroup SPI_I2S_Standard
  218. * @{
  219. */
  220. #define I2S_Standard_Phillips ((uint16_t)0x0000)
  221. #define I2S_Standard_MSB ((uint16_t)0x0010)
  222. #define I2S_Standard_LSB ((uint16_t)0x0020)
  223. #define I2S_Standard_PCMShort ((uint16_t)0x0030)
  224. #define I2S_Standard_PCMLong ((uint16_t)0x00B0)
  225. #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \
  226. ((STANDARD) == I2S_Standard_MSB) || \
  227. ((STANDARD) == I2S_Standard_LSB) || \
  228. ((STANDARD) == I2S_Standard_PCMShort) || \
  229. ((STANDARD) == I2S_Standard_PCMLong))
  230. /**
  231. * @}
  232. */
  233. /** @defgroup SPI_I2S_Data_Format
  234. * @{
  235. */
  236. #define I2S_DataFormat_16b ((uint16_t)0x0000)
  237. #define I2S_DataFormat_16bextended ((uint16_t)0x0001)
  238. #define I2S_DataFormat_24b ((uint16_t)0x0003)
  239. #define I2S_DataFormat_32b ((uint16_t)0x0005)
  240. #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \
  241. ((FORMAT) == I2S_DataFormat_16bextended) || \
  242. ((FORMAT) == I2S_DataFormat_24b) || \
  243. ((FORMAT) == I2S_DataFormat_32b))
  244. /**
  245. * @}
  246. */
  247. /** @defgroup SPI_I2S_MCLK_Output
  248. * @{
  249. */
  250. #define I2S_MCLKOutput_Enable ((uint16_t)0x0200)
  251. #define I2S_MCLKOutput_Disable ((uint16_t)0x0000)
  252. #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \
  253. ((OUTPUT) == I2S_MCLKOutput_Disable))
  254. /**
  255. * @}
  256. */
  257. /** @defgroup SPI_I2S_Audio_Frequency
  258. * @{
  259. */
  260. #define I2S_AudioFreq_192k ((uint32_t)192000)
  261. #define I2S_AudioFreq_96k ((uint32_t)96000)
  262. #define I2S_AudioFreq_48k ((uint32_t)48000)
  263. #define I2S_AudioFreq_44k ((uint32_t)44100)
  264. #define I2S_AudioFreq_32k ((uint32_t)32000)
  265. #define I2S_AudioFreq_22k ((uint32_t)22050)
  266. #define I2S_AudioFreq_16k ((uint32_t)16000)
  267. #define I2S_AudioFreq_11k ((uint32_t)11025)
  268. #define I2S_AudioFreq_8k ((uint32_t)8000)
  269. #define I2S_AudioFreq_Default ((uint32_t)2)
  270. #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \
  271. ((FREQ) <= I2S_AudioFreq_192k)) || \
  272. ((FREQ) == I2S_AudioFreq_Default))
  273. /**
  274. * @}
  275. */
  276. /** @defgroup SPI_I2S_Clock_Polarity
  277. * @{
  278. */
  279. #define I2S_CPOL_Low ((uint16_t)0x0000)
  280. #define I2S_CPOL_High ((uint16_t)0x0008)
  281. #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \
  282. ((CPOL) == I2S_CPOL_High))
  283. /**
  284. * @}
  285. */
  286. /** @defgroup SPI_I2S_DMA_transfer_requests
  287. * @{
  288. */
  289. #define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002)
  290. #define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001)
  291. #define IS_SPI_I2S_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFFFC) == 0x00) && ((DMAREQ) != 0x00))
  292. /**
  293. * @}
  294. */
  295. /** @defgroup SPI_NSS_internal_software_management
  296. * @{
  297. */
  298. #define SPI_NSSInternalSoft_Set ((uint16_t)0x0100)
  299. #define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF)
  300. #define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \
  301. ((INTERNAL) == SPI_NSSInternalSoft_Reset))
  302. /**
  303. * @}
  304. */
  305. /** @defgroup SPI_CRC_Transmit_Receive
  306. * @{
  307. */
  308. #define SPI_CRC_Tx ((uint8_t)0x00)
  309. #define SPI_CRC_Rx ((uint8_t)0x01)
  310. #define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx))
  311. /**
  312. * @}
  313. */
  314. /** @defgroup SPI_direction_transmit_receive
  315. * @{
  316. */
  317. #define SPI_Direction_Rx ((uint16_t)0xBFFF)
  318. #define SPI_Direction_Tx ((uint16_t)0x4000)
  319. #define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \
  320. ((DIRECTION) == SPI_Direction_Tx))
  321. /**
  322. * @}
  323. */
  324. /** @defgroup SPI_I2S_interrupts_definition
  325. * @{
  326. */
  327. #define SPI_I2S_IT_TXE ((uint8_t)0x71)
  328. #define SPI_I2S_IT_RXNE ((uint8_t)0x60)
  329. #define SPI_I2S_IT_ERR ((uint8_t)0x50)
  330. #define I2S_IT_UDR ((uint8_t)0x53)
  331. #define SPI_I2S_IT_TIFRFE ((uint8_t)0x58)
  332. #define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \
  333. ((IT) == SPI_I2S_IT_RXNE) || \
  334. ((IT) == SPI_I2S_IT_ERR))
  335. #define SPI_I2S_IT_OVR ((uint8_t)0x56)
  336. #define SPI_IT_MODF ((uint8_t)0x55)
  337. #define SPI_IT_CRCERR ((uint8_t)0x54)
  338. #define IS_SPI_I2S_CLEAR_IT(IT) (((IT) == SPI_IT_CRCERR))
  339. #define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE)|| ((IT) == SPI_I2S_IT_TXE) || \
  340. ((IT) == SPI_IT_CRCERR) || ((IT) == SPI_IT_MODF) || \
  341. ((IT) == SPI_I2S_IT_OVR) || ((IT) == I2S_IT_UDR) ||\
  342. ((IT) == SPI_I2S_IT_TIFRFE))
  343. /**
  344. * @}
  345. */
  346. /** @defgroup SPI_I2S_flags_definition
  347. * @{
  348. */
  349. #define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)
  350. #define SPI_I2S_FLAG_TXE ((uint16_t)0x0002)
  351. #define I2S_FLAG_CHSIDE ((uint16_t)0x0004)
  352. #define I2S_FLAG_UDR ((uint16_t)0x0008)
  353. #define SPI_FLAG_CRCERR ((uint16_t)0x0010)
  354. #define SPI_FLAG_MODF ((uint16_t)0x0020)
  355. #define SPI_I2S_FLAG_OVR ((uint16_t)0x0040)
  356. #define SPI_I2S_FLAG_BSY ((uint16_t)0x0080)
  357. #define SPI_I2S_FLAG_TIFRFE ((uint16_t)0x0100)
  358. #define IS_SPI_I2S_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR))
  359. #define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \
  360. ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \
  361. ((FLAG) == I2S_FLAG_UDR) || ((FLAG) == I2S_FLAG_CHSIDE) || \
  362. ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE)|| \
  363. ((FLAG) == SPI_I2S_FLAG_TIFRFE))
  364. /**
  365. * @}
  366. */
  367. /** @defgroup SPI_CRC_polynomial
  368. * @{
  369. */
  370. #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1)
  371. /**
  372. * @}
  373. */
  374. /** @defgroup SPI_I2S_Legacy
  375. * @{
  376. */
  377. #define SPI_DMAReq_Tx SPI_I2S_DMAReq_Tx
  378. #define SPI_DMAReq_Rx SPI_I2S_DMAReq_Rx
  379. #define SPI_IT_TXE SPI_I2S_IT_TXE
  380. #define SPI_IT_RXNE SPI_I2S_IT_RXNE
  381. #define SPI_IT_ERR SPI_I2S_IT_ERR
  382. #define SPI_IT_OVR SPI_I2S_IT_OVR
  383. #define SPI_FLAG_RXNE SPI_I2S_FLAG_RXNE
  384. #define SPI_FLAG_TXE SPI_I2S_FLAG_TXE
  385. #define SPI_FLAG_OVR SPI_I2S_FLAG_OVR
  386. #define SPI_FLAG_BSY SPI_I2S_FLAG_BSY
  387. #define SPI_DeInit SPI_I2S_DeInit
  388. #define SPI_ITConfig SPI_I2S_ITConfig
  389. #define SPI_DMACmd SPI_I2S_DMACmd
  390. #define SPI_SendData SPI_I2S_SendData
  391. #define SPI_ReceiveData SPI_I2S_ReceiveData
  392. #define SPI_GetFlagStatus SPI_I2S_GetFlagStatus
  393. #define SPI_ClearFlag SPI_I2S_ClearFlag
  394. #define SPI_GetITStatus SPI_I2S_GetITStatus
  395. #define SPI_ClearITPendingBit SPI_I2S_ClearITPendingBit
  396. /**
  397. * @}
  398. */
  399. /**
  400. * @}
  401. */
  402. /* Exported macro ------------------------------------------------------------*/
  403. /* Exported functions --------------------------------------------------------*/
  404. /* Function used to set the SPI configuration to the default reset state *****/
  405. void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
  406. /* Initialization and Configuration functions *********************************/
  407. void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
  408. void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
  409. void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
  410. void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
  411. void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  412. void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  413. void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
  414. void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
  415. void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
  416. void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  417. void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  418. void I2S_FullDuplexConfig(SPI_TypeDef* I2Sxext, I2S_InitTypeDef* I2S_InitStruct);
  419. /* Data transfers functions ***************************************************/
  420. void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
  421. uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
  422. /* Hardware CRC Calculation functions *****************************************/
  423. void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
  424. void SPI_TransmitCRC(SPI_TypeDef* SPIx);
  425. uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
  426. uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
  427. /* DMA transfers management functions *****************************************/
  428. void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);
  429. /* Interrupts and flags management functions **********************************/
  430. void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
  431. FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
  432. void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
  433. ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
  434. void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
  435. #ifdef __cplusplus
  436. }
  437. #endif
  438. #endif /*__STM32F4xx_SPI_H */
  439. /**
  440. * @}
  441. */
  442. /**
  443. * @}
  444. */