///////主机配置
void SPI_CONF(void)
{
SPI_CR1 = 0x14; //禁止所有中断 MSB F/8
SPI_CR2 = 0x03; //
SPI_CR1 |= 0x40; //开启SPI设备
}
/*SPI_SCK-PC5*/
PC_DDR = 0X7F;
PC_CR1 = 0XFF;
PC_CR2 = 0X00;
///主机发送
unsigned char SPI_SendByte(void)
{
unsigned char SendDataLength = 6;
while(SendDataLength>0) //SEND 5 BYTE
{
while(!(SPI_SR & 0x02));
SPI_DR = SPI_SendBuf[SendDataLength];
}
}
|