SPI的硬件初始化最重要的函数就是spi_init ()。 登录后复制voidspi_init(uint32_tspi_periph, spi_parameter_struct *spi_struct) 其中SPI参数配置的结构体为spi_parameter_struct;。 登录后复制/* SPI and I2S parameter struct definitions */typedefstruct{uint32_tdevice_mode;/*!< SPI master or slave *...
spi.c 文件 #include "spi.h" void SPI_Init(void) { spi_parameter_struct spi_init_struct; rcu_periph_clock_enable(RCU_GPIOB); rcu_periph_clock_enable(RCU_GPIOD); rcu_periph_clock_enable(RCU_SPI0); /* GPIOC config, PC10(LCD_SPI_CLK), PC11(SPI0_MISO), PC12(LCD_SPI_MOSI) */...
void spi_config(void){#if defined GD32F10X_HD|| GD32F30X_HD || GD32F1X0 || GD32F20X_CL || GD32F4XX || GD32F3X0 || GD32E10X || GD32E23X spi_parameter_struct spi_init_struct; /* SPI0 parameter config */ spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_init...
GD32E23X spi_parameter_struct spi_init_struct; /* SPI0 parameter config */ spi_init_struct.trans_mode=SPI_TRANSMODE_FULLDUPLEX; spi_init_struct.device_mode=SPI_MASTER; spi_init_struct.frame_size=SPI_FRAMESIZE_8BIT; spi_init_struct.clock_polarity_phase=SPI_CK_PL_LOW_PH_1EDGE; spi_init...
spi_parameter_struct spi_init_struct; /* SPI0 parameter config */ spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_init_struct.device_mode = SPI_MASTER; spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT; spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; spi_in...
spi_parameter_struct spi_init_struct; /* SPI0 parameter config */ spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_init_struct.device_mode = SPI_MASTER; spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT; spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; ...
spi_parameter_struct spi_init_struct; /* deinitialize SPI and the parameters */ spi_i2s_deinit(SPI0); spi_struct_para_init(&spi_init_struct); /* configure SPI0 parameters */ spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX;
void driver_spi_init(typdef_spi_struct *spix) { spi_parameter_struct spi_init_struct; rcu_periph_clock_enable(spix->rcu_spi_x); /* spi configure */ spi_i2s_deinit(spix->spi_x); driver_gpio_general_init(spix->spi_cs_gpio);
{spi_parameter_struct spi_init_struct;spi_i2s_deinit(CURRENT_SPI);rcu_periph_clock_enable(CURRENT_SPI_RCU);/* SPI_MOSI */gpio_init_af_mode(RTC_RCU,RTC_GPIO,RTC_DATA_PIN,GPIO_OSPEED_50MHZ,GPIO_AF_6);/* SPI_SCK */gpio_init_af_mode(RTC_RCU,RTC_GPIO,RTC_SCK_PIN,GPIO_OSPEED_50...
spi_parameter_struct spi_init_struct;rcu_periph_clock_enable(spix->rcu_spi_x);/* spi configure...