程序配置如下,有哪位大佬有时间看下吗 ?
void SPI_FullDuplex_Init()
{
GPIO_Config_T gpioConfig;
SPI_Config_T spiConfig;
/* Enable related Clock */
RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_SPI1);
RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_GPIOA);
/* config PIN_6 MISO */
gpioConfig.pin = GPIO_PIN_6 ;
gpioConfig.mode = GPIO_MODE_AF_PP;
gpioConfig.speed = GPIO_SPEED_50MHz;
GPIO_Config(GPIOA, &gpioConfig);
/* config PIN_5->SCK , PIN_7->MOSI */
gpioConfig.pin = GPIO_PIN_5 | GPIO_PIN_7;
gpioConfig.mode = GPIO_MODE_AF_PP;
gpioConfig.speed = GPIO_SPEED_50MHz;
GPIO_Config(GPIOA, &gpioConfig);
SPI_ConfigStructInit(&spiConfig);
spiConfig.length = SPI_DATA_LENGTH_16B;
spiConfig.baudrateDiv = SPI_BAUDRATE_DIV_32;
/* 2 line full duplex */
spiConfig.direction = SPI_DIRECTION_1LINE_TX;
/* LSB first */
spiConfig.firstBit = SPI_FIRSTBIT_MSB;
/* Slave mode */
spiConfig.mode = SPI_MODE_MASTER;
/* Polarity is low */
spiConfig.polarity = SPI_CLKPOL_LOW;
/* Software select slave enable */
spiConfig.nss = SPI_NSS_SOFT;
/* Phase is 1 edge */
spiConfig.phase = SPI_CLKPHA_1EDGE;
/* SPI config */
SPI_Config(SPI1, &spiConfig);
SPI_ConfigDataSize(SPI1, SPI_DATA_LENGTH_16B);
SPI_Enable(SPI1);
} |