谁用MCC配置过SPI啊?分享一下经验,初始化函数看不懂啊。
bool SPI1_Open(uint8_t spiConfigIndex)
{
bool returnValue = false;
if(false == SPI1CON0bits.EN)
{
SPI1CON0 = spi1_configuration[spiConfigIndex].con0;
SPI1CON1 = spi1_configuration[spiConfigIndex].con1;
SPI1CON2 = spi1_configuration[spiConfigIndex].con2 & ~(_SPI1CON2_SPI1RXR_MASK) & ~(_SPI1CON2_SPI1TXR_MASK);
SPI1BAUD = spi1_configuration[spiConfigIndex].baud;
SPI1CLK = spi1_configuration[spiConfigIndex].clksel;
TRISBbits.TRISB4 = 0;
SPI1CON0bits.EN = 1U;
returnValue = true;
}
else
{
returnValue = false;
}
return returnValue;
}
这谁懂啊
配置好后这么操作
SPI1_Initialize();
while(SPI1_Open(SPI1_DEFAULT)==false);
发现没反应啊,卡这走不下去。
|