SPI_GPIOConfig();
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE); //时钟
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //全双工模式
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //作为主机使用
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //数据长度8
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //软件设置NSS功能
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2,&SPI_InitStructure);
SPI_Cmd(SPI2,ENABLE);
[size=13.3333px] SPI_InitStructure.SPI_CRCPolynomial = 7;能不能设置其他模式?
|