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 11 #ifndef __DRV_SPI_H__ 12 #define __DRV_SPI_H__ 13 14 #include <rthw.h> 15 #include <rtthread.h> 16 #include <board.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 struct gd32_spi_cs 23 { 24 uint32_t GPIOx; 25 uint32_t GPIO_Pin; 26 }; 27 28 /* gd32 spi dirver class */ 29 struct gd32_spi 30 { 31 uint32_t spi_periph; 32 char *bus_name; 33 rcu_periph_enum spi_clk; 34 rcu_periph_enum gpio_clk; 35 struct rt_spi_bus *spi_bus; 36 uint32_t spi_port; 37 #if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x 38 uint32_t alt_func_num; 39 #endif 40 uint16_t sck_pin; 41 uint16_t miso_pin; 42 uint16_t mosi_pin; 43 }; 44 45 rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif /* __DRV_SPI_H__ */ 52 53