drv_spi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-12-20 BruceOu first implementation
  9. */
  10. #include "drv_spi.h"
  11. #ifdef RT_USING_SPI
  12. #if defined(BSP_USING_SPI0) || defined(BSP_USING_SPI1) || defined(BSP_USING_SPI2) || defined(BSP_USING_SPI3) || defined(BSP_USING_SPI4) || defined(BSP_USING_SPI5)
  13. #define LOG_TAG "drv.spi"
  14. #include <rtdbg.h>
  15. #ifdef BSP_USING_SPI0
  16. static struct rt_spi_bus spi_bus0;
  17. #endif
  18. #ifdef BSP_USING_SPI1
  19. static struct rt_spi_bus spi_bus1;
  20. #endif
  21. #ifdef BSP_USING_SPI2
  22. static struct rt_spi_bus spi_bus2;
  23. #endif
  24. #ifdef BSP_USING_SPI3
  25. static struct rt_spi_bus spi_bus3;
  26. #endif
  27. #ifdef BSP_USING_SPI4
  28. static struct rt_spi_bus spi_bus4;
  29. #endif
  30. #ifdef BSP_USING_SPI5
  31. static struct rt_spi_bus spi_bus5;
  32. #endif
  33. static const struct gd32_spi spi_bus_obj[] = {
  34. #ifdef BSP_USING_SPI0
  35. {
  36. SPI0,
  37. "spi0",
  38. RCU_SPI0,
  39. RCU_GPIOA,
  40. RCU_GPIOA,
  41. RCU_GPIOA,
  42. &spi_bus0,
  43. GPIOA,
  44. GPIOA,
  45. GPIOA,
  46. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  47. GPIO_AF_5,
  48. #endif
  49. #if defined (SOC_SERIES_GD32E23x)
  50. GPIO_AF_0,
  51. #endif
  52. GPIO_PIN_5,
  53. GPIO_PIN_6,
  54. GPIO_PIN_7,
  55. },
  56. #endif /* BSP_USING_SPI0 */
  57. #ifdef BSP_USING_SPI1
  58. {
  59. SPI1,
  60. "spi1",
  61. RCU_SPI1,
  62. RCU_GPIOB,
  63. RCU_GPIOB,
  64. RCU_GPIOB,
  65. &spi_bus1,
  66. GPIOB,
  67. GPIOB,
  68. GPIOB,
  69. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  70. GPIO_AF_5,
  71. #endif
  72. #if defined SOC_SERIES_GD32E23x
  73. GPIO_AF_0,
  74. #endif
  75. GPIO_PIN_13,
  76. GPIO_PIN_14,
  77. GPIO_PIN_15,
  78. },
  79. #endif /* BSP_USING_SPI1 */
  80. #ifdef BSP_USING_SPI2
  81. {
  82. SPI2,
  83. "spi2",
  84. RCU_SPI2,
  85. RCU_GPIOB,
  86. RCU_GPIOB,
  87. RCU_GPIOB,
  88. &spi_bus2,
  89. GPIOB,
  90. GPIOB,
  91. GPIOB,
  92. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  93. GPIO_AF_6,
  94. #endif
  95. GPIO_PIN_3,
  96. GPIO_PIN_4,
  97. GPIO_PIN_5,
  98. },
  99. #endif /* BSP_USING_SPI2 */
  100. #ifdef BSP_USING_SPI3
  101. {
  102. SPI3,
  103. "spi3",
  104. RCU_SPI3,
  105. RCU_GPIOE,
  106. RCU_GPIOE,
  107. RCU_GPIOE,
  108. &spi_bus3,
  109. GPIOE,
  110. GPIOE,
  111. GPIOE,
  112. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  113. GPIO_AF_5,
  114. #endif
  115. GPIO_PIN_2,
  116. GPIO_PIN_5,
  117. GPIO_PIN_6,
  118. },
  119. #endif /* BSP_USING_SPI3 */
  120. #ifdef BSP_USING_SPI4
  121. {
  122. SPI4,
  123. "spi4",
  124. RCU_SPI4,
  125. RCU_GPIOF,
  126. RCU_GPIOF,
  127. RCU_GPIOF,
  128. &spi_bus4,
  129. GPIOF,
  130. GPIOF,
  131. GPIOF,
  132. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  133. GPIO_AF_5,
  134. #endif
  135. GPIO_PIN_7,
  136. GPIO_PIN_8,
  137. GPIO_PIN_9,
  138. },
  139. #endif /* BSP_USING_SPI4 */
  140. #ifdef BSP_USING_SPI5
  141. {
  142. SPI5,
  143. "spi5",
  144. RCU_SPI5,
  145. RCU_GPIOG,
  146. RCU_GPIOG,
  147. RCU_GPIOG,
  148. &spi_bus5,
  149. GPIOG,
  150. GPIOG,
  151. GPIOG,
  152. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx)
  153. GPIO_AF_5,
  154. #endif
  155. GPIO_PIN_13,
  156. GPIO_PIN_12,
  157. GPIO_PIN_14,
  158. }
  159. #endif /* BSP_USING_SPI5 */
  160. };
  161. /* private rt-thread spi ops function */
  162. static rt_err_t spi_configure(struct rt_spi_device* device, struct rt_spi_configuration* configuration);
  163. static rt_ssize_t spixfer(struct rt_spi_device* device, struct rt_spi_message* message);
  164. static struct rt_spi_ops gd32_spi_ops =
  165. {
  166. .configure = spi_configure,
  167. .xfer = spixfer,
  168. };
  169. /**
  170. * @brief SPI Initialization
  171. * @param gd32_spi: SPI BUS
  172. * @retval None
  173. */
  174. static void gd32_spi_init(struct gd32_spi *gd32_spi)
  175. {
  176. /* enable SPI clock */
  177. rcu_periph_clock_enable(gd32_spi->spi_clk);
  178. rcu_periph_clock_enable(gd32_spi->sck_gpio_clk);
  179. rcu_periph_clock_enable(gd32_spi->miso_gpio_clk);
  180. rcu_periph_clock_enable(gd32_spi->mosi_gpio_clk);
  181. #if defined (SOC_SERIES_GD32F4xx) || defined (SOC_SERIES_GD32H7xx) || (defined SOC_SERIES_GD32F5xx) || (defined SOC_SERIES_GD32E23x)
  182. /*GPIO pin configuration*/
  183. gpio_af_set(gd32_spi->sck_spi_port, gd32_spi->alt_func_num, gd32_spi->sck_pin);
  184. gpio_af_set(gd32_spi->miso_spi_port, gd32_spi->alt_func_num, gd32_spi->miso_pin);
  185. gpio_af_set(gd32_spi->mosi_spi_port, gd32_spi->alt_func_num, gd32_spi->mosi_pin);
  186. gpio_mode_set(gd32_spi->sck_spi_port, GPIO_MODE_AF, GPIO_PUPD_NONE, gd32_spi->sck_pin);
  187. gpio_mode_set(gd32_spi->miso_spi_port, GPIO_MODE_AF, GPIO_PUPD_NONE, gd32_spi->miso_pin);
  188. gpio_mode_set(gd32_spi->mosi_spi_port, GPIO_MODE_AF, GPIO_PUPD_NONE, gd32_spi->mosi_pin);
  189. #if defined (SOC_SERIES_GD32H7xx)
  190. gpio_output_options_set(gd32_spi->sck_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_100_220MHZ, gd32_spi->sck_pin);
  191. gpio_output_options_set(gd32_spi->miso_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_100_220MHZ, gd32_spi->miso_pin);
  192. gpio_output_options_set(gd32_spi->mosi_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_100_220MHZ, gd32_spi->mosi_pin);
  193. #elif defined (SOC_SERIES_GD32E23x)
  194. gpio_output_options_set(gd32_spi->sck_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, gd32_spi->sck_pin);
  195. gpio_output_options_set(gd32_spi->miso_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, gd32_spi->miso_pin);
  196. gpio_output_options_set(gd32_spi->mosi_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, gd32_spi->mosi_pin);
  197. #else
  198. gpio_output_options_set(gd32_spi->sck_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_MAX, gd32_spi->sck_pin);
  199. gpio_output_options_set(gd32_spi->miso_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_MAX, gd32_spi->miso_pin);
  200. gpio_output_options_set(gd32_spi->mosi_spi_port, GPIO_OTYPE_PP, GPIO_OSPEED_MAX, gd32_spi->mosi_pin);
  201. #endif
  202. #else
  203. /* Init SPI SCK MOSI */
  204. gpio_init(gd32_spi->sck_spi_port, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, gd32_spi->sck_pin);
  205. gpio_init(gd32_spi->mosi_spi_port, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, gd32_spi->mosi_pin);
  206. /* Init SPI MISO */
  207. gpio_init(gd32_spi->miso_spi_port, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, gd32_spi->miso_pin);
  208. #endif
  209. }
  210. static rt_err_t spi_configure(struct rt_spi_device* device,
  211. struct rt_spi_configuration* configuration)
  212. {
  213. struct rt_spi_bus * spi_bus = (struct rt_spi_bus *)device->bus;
  214. struct gd32_spi *spi_device = (struct gd32_spi *)spi_bus->parent.user_data;
  215. spi_parameter_struct spi_init_struct;
  216. uint32_t spi_periph = spi_device->spi_periph;
  217. RT_ASSERT(device != RT_NULL);
  218. RT_ASSERT(configuration != RT_NULL);
  219. /* Init SPI */
  220. gd32_spi_init(spi_device);
  221. #if defined SOC_SERIES_GD32H7xx
  222. /* data_width */
  223. if(configuration->data_width >=4 && configuration->data_width <= 32)
  224. {
  225. spi_init_struct.data_size = CFG0_DZ(configuration->data_width - 1);
  226. }
  227. else
  228. {
  229. return -RT_EIO;
  230. }
  231. #else
  232. /* data_width */
  233. if(configuration->data_width <= 8)
  234. {
  235. spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT;
  236. }
  237. else if(configuration->data_width <= 16)
  238. {
  239. spi_init_struct.frame_size = SPI_FRAMESIZE_16BIT;
  240. }
  241. else
  242. {
  243. return -RT_EIO;
  244. }
  245. #endif
  246. /* baudrate */
  247. {
  248. rcu_clock_freq_enum spi_src;
  249. uint32_t spi_apb_clock;
  250. uint32_t max_hz;
  251. max_hz = configuration->max_hz;
  252. LOG_D("sys freq: %d\n", rcu_clock_freq_get(CK_SYS));
  253. LOG_D("CK_APB2 freq: %d\n", rcu_clock_freq_get(CK_APB2));
  254. LOG_D("max freq: %d\n", max_hz);
  255. #if defined SOC_SERIES_GD32E23x
  256. spi_src = CK_APB2;
  257. #else
  258. if (spi_periph == SPI1 || spi_periph == SPI2)
  259. {
  260. spi_src = CK_APB1;
  261. }
  262. else
  263. {
  264. spi_src = CK_APB2;
  265. }
  266. #endif
  267. spi_apb_clock = rcu_clock_freq_get(spi_src);
  268. if(max_hz >= spi_apb_clock/2)
  269. {
  270. spi_init_struct.prescale = SPI_PSC_2;
  271. }
  272. else if (max_hz >= spi_apb_clock/4)
  273. {
  274. spi_init_struct.prescale = SPI_PSC_4;
  275. }
  276. else if (max_hz >= spi_apb_clock/8)
  277. {
  278. spi_init_struct.prescale = SPI_PSC_8;
  279. }
  280. else if (max_hz >= spi_apb_clock/16)
  281. {
  282. spi_init_struct.prescale = SPI_PSC_16;
  283. }
  284. else if (max_hz >= spi_apb_clock/32)
  285. {
  286. spi_init_struct.prescale = SPI_PSC_32;
  287. }
  288. else if (max_hz >= spi_apb_clock/64)
  289. {
  290. spi_init_struct.prescale = SPI_PSC_64;
  291. }
  292. else if (max_hz >= spi_apb_clock/128)
  293. {
  294. spi_init_struct.prescale = SPI_PSC_128;
  295. }
  296. else
  297. {
  298. /* min prescaler 256 */
  299. spi_init_struct.prescale = SPI_PSC_256;
  300. }
  301. } /* baudrate */
  302. switch(configuration->mode & RT_SPI_MODE_3)
  303. {
  304. case RT_SPI_MODE_0:
  305. spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE;
  306. break;
  307. case RT_SPI_MODE_1:
  308. spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_2EDGE;
  309. break;
  310. case RT_SPI_MODE_2:
  311. spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_1EDGE;
  312. break;
  313. case RT_SPI_MODE_3:
  314. spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_2EDGE;
  315. break;
  316. }
  317. /* MSB or LSB */
  318. if(configuration->mode & RT_SPI_MSB)
  319. {
  320. spi_init_struct.endian = SPI_ENDIAN_MSB;
  321. }
  322. else
  323. {
  324. spi_init_struct.endian = SPI_ENDIAN_LSB;
  325. }
  326. spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX;
  327. spi_init_struct.device_mode = SPI_MASTER;
  328. spi_init_struct.nss = SPI_NSS_SOFT;
  329. spi_crc_off(spi_periph);
  330. /* init SPI */
  331. spi_init(spi_periph, &spi_init_struct);
  332. /* Enable SPI_MASTER */
  333. spi_enable(spi_periph);
  334. return RT_EOK;
  335. };
  336. static rt_ssize_t spixfer(struct rt_spi_device* device, struct rt_spi_message* message)
  337. {
  338. struct rt_spi_bus * gd32_spi_bus = (struct rt_spi_bus *)device->bus;
  339. struct gd32_spi *spi_device = (struct gd32_spi *)gd32_spi_bus->parent.user_data;
  340. struct rt_spi_configuration * config = &device->config;
  341. uint32_t spi_periph = spi_device->spi_periph;
  342. RT_ASSERT(device != NULL);
  343. RT_ASSERT(message != NULL);
  344. /* take CS */
  345. if (message->cs_take && !(device->config.mode & RT_SPI_NO_CS) && (device->cs_pin != PIN_NONE))
  346. {
  347. if (device->config.mode & RT_SPI_CS_HIGH)
  348. {
  349. rt_pin_write(device->cs_pin, PIN_HIGH);
  350. }
  351. else
  352. {
  353. rt_pin_write(device->cs_pin, PIN_LOW);
  354. }
  355. }
  356. LOG_D("%s transfer prepare and start", spi_device->bus_name);
  357. LOG_D("%s sendbuf: %X, recvbuf: %X, length: %d",
  358. spi_device->bus_name,
  359. (uint32_t)message->send_buf,
  360. (uint32_t)message->recv_buf, message->length);
  361. {
  362. if(config->data_width <= 8)
  363. {
  364. const rt_uint8_t * send_ptr = message->send_buf;
  365. rt_uint8_t * recv_ptr = message->recv_buf;
  366. rt_uint32_t size = message->length;
  367. LOG_D("spi poll transfer start: %d\n", size);
  368. while(size--)
  369. {
  370. rt_uint8_t data = 0xFF;
  371. if(send_ptr != RT_NULL)
  372. {
  373. data = *send_ptr++;
  374. }
  375. /* Todo: replace register read/write by gd32f4 lib */
  376. /* Wait until the transmit buffer is empty */
  377. #if defined (SOC_SERIES_GD32H7xx)
  378. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_TP));
  379. #else
  380. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_TBE));
  381. #endif
  382. /* Send the byte */
  383. spi_i2s_data_transmit(spi_periph, data);
  384. /* Wait until a data is received */
  385. #if defined (SOC_SERIES_GD32H7xx)
  386. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_RP));
  387. #else
  388. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_RBNE));
  389. #endif
  390. /* Get the received data */
  391. data = spi_i2s_data_receive(spi_periph);
  392. if(recv_ptr != RT_NULL)
  393. {
  394. *recv_ptr++ = data;
  395. }
  396. }
  397. LOG_D("spi poll transfer finsh\n");
  398. }
  399. else if(config->data_width <= 16)
  400. {
  401. const rt_uint16_t * send_ptr = message->send_buf;
  402. rt_uint16_t * recv_ptr = message->recv_buf;
  403. rt_uint32_t size = message->length;
  404. while(size--)
  405. {
  406. rt_uint16_t data = 0xFF;
  407. if(send_ptr != RT_NULL)
  408. {
  409. data = *send_ptr++;
  410. }
  411. /* Wait until the transmit buffer is empty */
  412. #if defined (SOC_SERIES_GD32H7xx)
  413. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_TP));
  414. #else
  415. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_TBE));
  416. #endif
  417. /* Send the byte */
  418. spi_i2s_data_transmit(spi_periph, data);
  419. /* Wait until a data is received */
  420. #if defined (SOC_SERIES_GD32H7xx)
  421. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_RP));
  422. #else
  423. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_RBNE));
  424. #endif
  425. /* Get the received data */
  426. data = spi_i2s_data_receive(spi_periph);
  427. if(recv_ptr != RT_NULL)
  428. {
  429. *recv_ptr++ = data;
  430. }
  431. }
  432. }
  433. #if defined SOC_SERIES_GD32H7xx
  434. else if(config->data_width <= 32)
  435. {
  436. const rt_uint32_t * send_ptr = message->send_buf;
  437. rt_uint32_t * recv_ptr = message->recv_buf;
  438. rt_uint32_t size = message->length;
  439. while(size--)
  440. {
  441. rt_uint32_t data = 0xFF;
  442. if(send_ptr != RT_NULL)
  443. {
  444. data = *send_ptr++;
  445. }
  446. /* Wait until the transmit buffer is empty */
  447. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_TP));
  448. /* Send the byte */
  449. spi_i2s_data_transmit(spi_periph, data);
  450. /* Wait until a data is received */
  451. while(RESET == spi_i2s_flag_get(spi_periph, SPI_FLAG_RP));
  452. /* Get the received data */
  453. data = spi_i2s_data_receive(spi_periph);
  454. if(recv_ptr != RT_NULL)
  455. {
  456. *recv_ptr++ = data;
  457. }
  458. }
  459. }
  460. #endif
  461. }
  462. /* release CS */
  463. if (message->cs_release && !(device->config.mode & RT_SPI_NO_CS) && (device->cs_pin != PIN_NONE))
  464. {
  465. if (device->config.mode & RT_SPI_CS_HIGH)
  466. rt_pin_write(device->cs_pin, PIN_LOW);
  467. else
  468. rt_pin_write(device->cs_pin, PIN_HIGH);
  469. }
  470. return message->length;
  471. };
  472. /**
  473. * Attach the spi device to SPI bus, this function must be used after initialization.
  474. */
  475. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin)
  476. {
  477. RT_ASSERT(bus_name != RT_NULL);
  478. RT_ASSERT(device_name != RT_NULL);
  479. rt_err_t result;
  480. struct rt_spi_device *spi_device;
  481. /* attach the device to spi bus*/
  482. spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device));
  483. RT_ASSERT(spi_device != RT_NULL);
  484. if(cs_pin != PIN_NONE)
  485. {
  486. /* initialize the cs pin && select the slave*/
  487. rt_pin_mode(cs_pin, PIN_MODE_OUTPUT);
  488. rt_pin_write(cs_pin, PIN_HIGH);
  489. }
  490. result = rt_spi_bus_attach_device_cspin(spi_device, device_name, bus_name, cs_pin, RT_NULL);
  491. if (result != RT_EOK)
  492. {
  493. LOG_E("%s attach to %s faild, %d\n", device_name, bus_name, result);
  494. }
  495. RT_ASSERT(result == RT_EOK);
  496. LOG_D("%s attach to %s done", device_name, bus_name);
  497. return result;
  498. }
  499. int rt_hw_spi_init(void)
  500. {
  501. int result = 0;
  502. int i;
  503. for (i = 0; i < sizeof(spi_bus_obj) / sizeof(spi_bus_obj[0]); i++)
  504. {
  505. spi_bus_obj[i].spi_bus->parent.user_data = (void *)&spi_bus_obj[i];
  506. result = rt_spi_bus_register(spi_bus_obj[i].spi_bus, spi_bus_obj[i].bus_name, &gd32_spi_ops);
  507. RT_ASSERT(result == RT_EOK);
  508. LOG_D("%s bus init done", spi_bus_obj[i].bus_name);
  509. }
  510. return result;
  511. }
  512. INIT_BOARD_EXPORT(rt_hw_spi_init);
  513. #endif /* BSP_USING_SPI0 || BSP_USING_SPI1 || BSP_USING_SPI2 || BSP_USING_SPI3 || BSP_USING_SPI4 || BSP_USING_SPI5 */
  514. #endif /* RT_USING_SPI */