hk32f0xx_spi.h 21 KB

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