ft32f0xx_spi.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_spi.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the SPI
  6. * firmware library.
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_SPI_H
  13. #define __FT32F0XX_SPI_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. /** @addtogroup SPI
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /**
  24. * @brief SPI Init structure definition
  25. */
  26. typedef struct
  27. {
  28. uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
  29. This parameter can be a value of @ref SPI_data_direction */
  30. uint16_t SPI_Mode; /*!< Specifies the SPI mode (Master/Slave).
  31. This parameter can be a value of @ref SPI_mode */
  32. uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
  33. This parameter can be a value of @ref SPI_data_size */
  34. uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
  35. This parameter can be a value of @ref SPI_Clock_Polarity */
  36. uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
  37. This parameter can be a value of @ref SPI_Clock_Phase */
  38. uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
  39. hardware (NSS pin) or by software using the SSI bit.
  40. This parameter can be a value of @ref SPI_Slave_Select_management */
  41. uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
  42. used to configure the transmit and receive SCK clock.
  43. This parameter can be a value of @ref SPI_BaudRate_Prescaler
  44. @note The communication clock is derived from the master
  45. clock. The slave clock does not need to be set. */
  46. uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
  47. This parameter can be a value of @ref SPI_MSB_LSB_transmission */
  48. uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
  49. }SPI_InitTypeDef;
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup SPI_Exported_Constants
  52. * @{
  53. */
  54. #define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \
  55. ((PERIPH) == SPI2))
  56. #define IS_SPI_1_PERIPH(PERIPH) (((PERIPH) == SPI1))
  57. /** @defgroup SPI_data_direction
  58. * @{
  59. */
  60. #define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)
  61. #define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)
  62. #define SPI_Direction_1Line_Rx ((uint16_t)0x8000)
  63. #define SPI_Direction_1Line_Tx ((uint16_t)0xC000)
  64. #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \
  65. ((MODE) == SPI_Direction_2Lines_RxOnly) || \
  66. ((MODE) == SPI_Direction_1Line_Rx) || \
  67. ((MODE) == SPI_Direction_1Line_Tx))
  68. /**
  69. * @}
  70. */
  71. /** @defgroup SPI_mode
  72. * @{
  73. */
  74. #define SPI_Mode_Master ((uint16_t)0x0104)
  75. #define SPI_Mode_Slave ((uint16_t)0x0000)
  76. #define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \
  77. ((MODE) == SPI_Mode_Slave))
  78. /**
  79. * @}
  80. */
  81. /** @defgroup SPI_data_size
  82. * @{
  83. */
  84. #define SPI_DataSize_4b ((uint16_t)0x0300)
  85. #define SPI_DataSize_5b ((uint16_t)0x0400)
  86. #define SPI_DataSize_6b ((uint16_t)0x0500)
  87. #define SPI_DataSize_7b ((uint16_t)0x0600)
  88. #define SPI_DataSize_8b ((uint16_t)0x0700)
  89. #define SPI_DataSize_9b ((uint16_t)0x0800)
  90. #define SPI_DataSize_10b ((uint16_t)0x0900)
  91. #define SPI_DataSize_11b ((uint16_t)0x0A00)
  92. #define SPI_DataSize_12b ((uint16_t)0x0B00)
  93. #define SPI_DataSize_13b ((uint16_t)0x0C00)
  94. #define SPI_DataSize_14b ((uint16_t)0x0D00)
  95. #define SPI_DataSize_15b ((uint16_t)0x0E00)
  96. #define SPI_DataSize_16b ((uint16_t)0x0F00)
  97. #define IS_SPI_DATA_SIZE(SIZE) (((SIZE) == SPI_DataSize_4b) || \
  98. ((SIZE) == SPI_DataSize_5b) || \
  99. ((SIZE) == SPI_DataSize_6b) || \
  100. ((SIZE) == SPI_DataSize_7b) || \
  101. ((SIZE) == SPI_DataSize_8b) || \
  102. ((SIZE) == SPI_DataSize_9b) || \
  103. ((SIZE) == SPI_DataSize_10b) || \
  104. ((SIZE) == SPI_DataSize_11b) || \
  105. ((SIZE) == SPI_DataSize_12b) || \
  106. ((SIZE) == SPI_DataSize_13b) || \
  107. ((SIZE) == SPI_DataSize_14b) || \
  108. ((SIZE) == SPI_DataSize_15b) || \
  109. ((SIZE) == SPI_DataSize_16b))
  110. /**
  111. * @}
  112. */
  113. /** @defgroup SPI_CRC_length
  114. * @{
  115. */
  116. #define SPI_CRCLength_8b ((uint16_t)0x0000)
  117. #define SPI_CRCLength_16b SPI_CR1_CRCL
  118. #define IS_SPI_CRC_LENGTH(LENGTH) (((LENGTH) == SPI_CRCLength_8b) || \
  119. ((LENGTH) == SPI_CRCLength_16b))
  120. /**
  121. * @}
  122. */
  123. /** @defgroup SPI_Clock_Polarity
  124. * @{
  125. */
  126. #define SPI_CPOL_Low ((uint16_t)0x0000)
  127. #define SPI_CPOL_High SPI_CR1_CPOL
  128. #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \
  129. ((CPOL) == SPI_CPOL_High))
  130. /**
  131. * @}
  132. */
  133. /** @defgroup SPI_Clock_Phase
  134. * @{
  135. */
  136. #define SPI_CPHA_1Edge ((uint16_t)0x0000)
  137. #define SPI_CPHA_2Edge SPI_CR1_CPHA
  138. #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \
  139. ((CPHA) == SPI_CPHA_2Edge))
  140. /**
  141. * @}
  142. */
  143. /** @defgroup SPI_Slave_Select_management
  144. * @{
  145. */
  146. #define SPI_NSS_Soft SPI_CR1_SSM
  147. #define SPI_NSS_Hard ((uint16_t)0x0000)
  148. #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \
  149. ((NSS) == SPI_NSS_Hard))
  150. /**
  151. * @}
  152. */
  153. /** @defgroup SPI_BaudRate_Prescaler
  154. * @{
  155. */
  156. #define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
  157. #define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
  158. #define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
  159. #define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
  160. #define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
  161. #define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
  162. #define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
  163. #define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
  164. #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \
  165. ((PRESCALER) == SPI_BaudRatePrescaler_4) || \
  166. ((PRESCALER) == SPI_BaudRatePrescaler_8) || \
  167. ((PRESCALER) == SPI_BaudRatePrescaler_16) || \
  168. ((PRESCALER) == SPI_BaudRatePrescaler_32) || \
  169. ((PRESCALER) == SPI_BaudRatePrescaler_64) || \
  170. ((PRESCALER) == SPI_BaudRatePrescaler_128) || \
  171. ((PRESCALER) == SPI_BaudRatePrescaler_256))
  172. /**
  173. * @}
  174. */
  175. /** @defgroup SPI_MSB_LSB_transmission
  176. * @{
  177. */
  178. #define SPI_FirstBit_MSB ((uint16_t)0x0000)
  179. #define SPI_FirstBit_LSB SPI_CR1_LSBFIRST
  180. #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \
  181. ((BIT) == SPI_FirstBit_LSB))
  182. /**
  183. * @}
  184. */
  185. /** @defgroup SPI_I2S_Mode
  186. * @{
  187. */
  188. #define I2S_Mode_SlaveTx ((uint16_t)0x0000)
  189. #define I2S_Mode_SlaveRx ((uint16_t)0x0100)
  190. #define I2S_Mode_MasterTx ((uint16_t)0x0200)
  191. #define I2S_Mode_MasterRx ((uint16_t)0x0300)
  192. #define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \
  193. ((MODE) == I2S_Mode_SlaveRx) || \
  194. ((MODE) == I2S_Mode_MasterTx)|| \
  195. ((MODE) == I2S_Mode_MasterRx))
  196. /**
  197. * @}
  198. */
  199. /** @defgroup SPI_I2S_Standard
  200. * @{
  201. */
  202. #define I2S_Standard_Phillips ((uint16_t)0x0000)
  203. #define I2S_Standard_MSB ((uint16_t)0x0010)
  204. #define I2S_Standard_LSB ((uint16_t)0x0020)
  205. #define I2S_Standard_PCMShort ((uint16_t)0x0030)
  206. #define I2S_Standard_PCMLong ((uint16_t)0x00B0)
  207. #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \
  208. ((STANDARD) == I2S_Standard_MSB) || \
  209. ((STANDARD) == I2S_Standard_LSB) || \
  210. ((STANDARD) == I2S_Standard_PCMShort) || \
  211. ((STANDARD) == I2S_Standard_PCMLong))
  212. /**
  213. * @}
  214. */
  215. /** @defgroup SPI_I2S_Data_Format
  216. * @{
  217. */
  218. #define I2S_DataFormat_16b ((uint16_t)0x0000)
  219. #define I2S_DataFormat_16bextended ((uint16_t)0x0001)
  220. #define I2S_DataFormat_24b ((uint16_t)0x0003)
  221. #define I2S_DataFormat_32b ((uint16_t)0x0005)
  222. #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \
  223. ((FORMAT) == I2S_DataFormat_16bextended) || \
  224. ((FORMAT) == I2S_DataFormat_24b) || \
  225. ((FORMAT) == I2S_DataFormat_32b))
  226. /**
  227. * @}
  228. */
  229. /** @defgroup SPI_I2S_MCLK_Output
  230. * @{
  231. */
  232. #define I2S_MCLKOutput_Enable SPI_I2SPR_MCKOE
  233. #define I2S_MCLKOutput_Disable ((uint16_t)0x0000)
  234. #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \
  235. ((OUTPUT) == I2S_MCLKOutput_Disable))
  236. /**
  237. * @}
  238. */
  239. /** @defgroup SPI_I2S_Audio_Frequency
  240. * @{
  241. */
  242. #define I2S_AudioFreq_192k ((uint32_t)192000)
  243. #define I2S_AudioFreq_96k ((uint32_t)96000)
  244. #define I2S_AudioFreq_48k ((uint32_t)48000)
  245. #define I2S_AudioFreq_44k ((uint32_t)44100)
  246. #define I2S_AudioFreq_32k ((uint32_t)32000)
  247. #define I2S_AudioFreq_22k ((uint32_t)22050)
  248. #define I2S_AudioFreq_16k ((uint32_t)16000)
  249. #define I2S_AudioFreq_11k ((uint32_t)11025)
  250. #define I2S_AudioFreq_8k ((uint32_t)8000)
  251. #define I2S_AudioFreq_Default ((uint32_t)2)
  252. #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \
  253. ((FREQ) <= I2S_AudioFreq_192k)) || \
  254. ((FREQ) == I2S_AudioFreq_Default))
  255. /**
  256. * @}
  257. */
  258. /** @defgroup SPI_I2S_Clock_Polarity
  259. * @{
  260. */
  261. #define I2S_CPOL_Low ((uint16_t)0x0000)
  262. #define I2S_CPOL_High SPI_I2SCFGR_CKPOL
  263. #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \
  264. ((CPOL) == I2S_CPOL_High))
  265. /**
  266. * @}
  267. */
  268. /** @defgroup SPI_FIFO_reception_threshold
  269. * @{
  270. */
  271. #define SPI_RxFIFOThreshold_HF ((uint16_t)0x0000)
  272. #define SPI_RxFIFOThreshold_QF SPI_CR2_FRXTH
  273. #define IS_SPI_RX_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SPI_RxFIFOThreshold_HF) || \
  274. ((THRESHOLD) == SPI_RxFIFOThreshold_QF))
  275. /**
  276. * @}
  277. */
  278. /** @defgroup SPI_I2S_DMA_transfer_requests
  279. * @{
  280. */
  281. #define SPI_I2S_DMAReq_Tx SPI_CR2_TXDMAEN
  282. #define SPI_I2S_DMAReq_Rx SPI_CR2_RXDMAEN
  283. #define IS_SPI_I2S_DMA_REQ(REQ) ((((REQ) & (uint16_t)0xFFFC) == 0x00) && ((REQ) != 0x00))
  284. /**
  285. * @}
  286. */
  287. /** @defgroup SPI_last_DMA_transfers
  288. * @{
  289. */
  290. #define SPI_LastDMATransfer_TxEvenRxEven ((uint16_t)0x0000)
  291. #define SPI_LastDMATransfer_TxOddRxEven ((uint16_t)0x4000)
  292. #define SPI_LastDMATransfer_TxEvenRxOdd ((uint16_t)0x2000)
  293. #define SPI_LastDMATransfer_TxOddRxOdd ((uint16_t)0x6000)
  294. #define IS_SPI_LAST_DMA_TRANSFER(TRANSFER) (((TRANSFER) == SPI_LastDMATransfer_TxEvenRxEven) || \
  295. ((TRANSFER) == SPI_LastDMATransfer_TxOddRxEven) || \
  296. ((TRANSFER) == SPI_LastDMATransfer_TxEvenRxOdd) || \
  297. ((TRANSFER) == SPI_LastDMATransfer_TxOddRxOdd))
  298. /**
  299. * @}
  300. */
  301. /** @defgroup SPI_NSS_internal_software_management
  302. * @{
  303. */
  304. #define SPI_NSSInternalSoft_Set SPI_CR1_SSI
  305. #define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF)
  306. #define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \
  307. ((INTERNAL) == SPI_NSSInternalSoft_Reset))
  308. /**
  309. * @}
  310. */
  311. /** @defgroup SPI_CRC_Transmit_Receive
  312. * @{
  313. */
  314. #define SPI_CRC_Tx ((uint8_t)0x00)
  315. #define SPI_CRC_Rx ((uint8_t)0x01)
  316. #define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx))
  317. /**
  318. * @}
  319. */
  320. /** @defgroup SPI_direction_transmit_receive
  321. * @{
  322. */
  323. #define SPI_Direction_Rx ((uint16_t)0xBFFF)
  324. #define SPI_Direction_Tx ((uint16_t)0x4000)
  325. #define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \
  326. ((DIRECTION) == SPI_Direction_Tx))
  327. /**
  328. * @}
  329. */
  330. /** @defgroup SPI_I2S_interrupts_definition
  331. * @{
  332. */
  333. #define SPI_I2S_IT_TXE ((uint8_t)0x71)
  334. #define SPI_I2S_IT_RXNE ((uint8_t)0x60)
  335. #define SPI_I2S_IT_ERR ((uint8_t)0x50)
  336. #define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \
  337. ((IT) == SPI_I2S_IT_RXNE) || \
  338. ((IT) == SPI_I2S_IT_ERR))
  339. #define I2S_IT_UDR ((uint8_t)0x53)
  340. #define SPI_IT_MODF ((uint8_t)0x55)
  341. #define SPI_I2S_IT_OVR ((uint8_t)0x56)
  342. #define SPI_I2S_IT_FRE ((uint8_t)0x58)
  343. #define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \
  344. ((IT) == SPI_I2S_IT_OVR) || ((IT) == SPI_IT_MODF) || \
  345. ((IT) == SPI_I2S_IT_FRE)|| ((IT) == I2S_IT_UDR))
  346. /**
  347. * @}
  348. */
  349. /** @defgroup SPI_transmission_fifo_status_level
  350. * @{
  351. */
  352. #define SPI_TransmissionFIFOStatus_Empty ((uint16_t)0x0000)
  353. #define SPI_TransmissionFIFOStatus_1QuarterFull ((uint16_t)0x0800)
  354. #define SPI_TransmissionFIFOStatus_HalfFull ((uint16_t)0x1000)
  355. #define SPI_TransmissionFIFOStatus_Full ((uint16_t)0x1800)
  356. /**
  357. * @}
  358. */
  359. /** @defgroup SPI_reception_fifo_status_level
  360. * @{
  361. */
  362. #define SPI_ReceptionFIFOStatus_Empty ((uint16_t)0x0000)
  363. #define SPI_ReceptionFIFOStatus_1QuarterFull ((uint16_t)0x0200)
  364. #define SPI_ReceptionFIFOStatus_HalfFull ((uint16_t)0x0400)
  365. #define SPI_ReceptionFIFOStatus_Full ((uint16_t)0x0600)
  366. /**
  367. * @}
  368. */
  369. /** @defgroup SPI_I2S_flags_definition
  370. * @{
  371. */
  372. #define SPI_I2S_FLAG_RXNE SPI_SR_RXNE
  373. #define SPI_I2S_FLAG_TXE SPI_SR_TXE
  374. #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE
  375. #define I2S_FLAG_UDR SPI_SR_UDR
  376. #define SPI_FLAG_CRCERR SPI_SR_CRCERR
  377. #define SPI_FLAG_MODF SPI_SR_MODF
  378. #define SPI_I2S_FLAG_OVR SPI_SR_OVR
  379. #define SPI_I2S_FLAG_BSY SPI_SR_BSY
  380. #define SPI_I2S_FLAG_FRE SPI_SR_FRE
  381. #define IS_SPI_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR))
  382. #define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \
  383. ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \
  384. ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE)|| \
  385. ((FLAG) == SPI_I2S_FLAG_FRE)|| ((FLAG) == I2S_FLAG_CHSIDE)|| \
  386. ((FLAG) == I2S_FLAG_UDR))
  387. /**
  388. * @}
  389. */
  390. /** @defgroup SPI_CRC_polynomial
  391. * @{
  392. */
  393. #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1)
  394. /**
  395. * @}
  396. */
  397. /**
  398. * @}
  399. */
  400. /* Exported macro ------------------------------------------------------------*/
  401. /* Exported functions ------------------------------------------------------- */
  402. /* Initialization and Configuration functions *********************************/
  403. void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
  404. void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
  405. void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
  406. void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  407. void SPI_NSSPulseModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  408. void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  409. void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
  410. void SPI_RxFIFOThresholdConfig(SPI_TypeDef* SPIx, uint16_t SPI_RxFIFOThreshold);
  411. void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
  412. void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
  413. void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
  414. /* Data transfers functions ***************************************************/
  415. void SPI_SendData8(SPI_TypeDef* SPIx, uint8_t Data);
  416. void SPI_I2S_SendData16(SPI_TypeDef* SPIx, uint16_t Data);
  417. uint8_t SPI_ReceiveData8(SPI_TypeDef* SPIx);
  418. uint16_t SPI_I2S_ReceiveData16(SPI_TypeDef* SPIx);
  419. /* Hardware CRC Calculation functions *****************************************/
  420. void SPI_CRCLengthConfig(SPI_TypeDef* SPIx, uint16_t SPI_CRCLength);
  421. void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
  422. void SPI_TransmitCRC(SPI_TypeDef* SPIx);
  423. uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
  424. uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
  425. /* DMA transfers management functions *****************************************/
  426. void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);
  427. void SPI_LastDMATransferCmd(SPI_TypeDef* SPIx, uint16_t SPI_LastDMATransfer);
  428. /* Interrupts and flags management functions **********************************/
  429. void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
  430. uint16_t SPI_GetTransmissionFIFOStatus(SPI_TypeDef* SPIx);
  431. uint16_t SPI_GetReceptionFIFOStatus(SPI_TypeDef* SPIx);
  432. FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
  433. void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
  434. ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
  435. #ifdef __cplusplus
  436. }
  437. #endif
  438. #endif /*__FT32F0XX_SPI_H */
  439. /**
  440. * @}
  441. */
  442. /**
  443. * @}
  444. */
  445. /************************ (C) COPYRIGHT FMD *****END OF FILE****/