看N76E003里的SPI中断,看程序中,主机跟从机通讯,有点东西不太理解:
主机
void Start_Sending_SPI(UINT8 *pu8MID,UINT8 *pu8DID)
{ //SS默认是高,开始传送由高到低,所以,进入这个函数,先把SS拉低,完全接受后拉高
SS = 0;
SPDR = 0x90; // Send 0x90 to Slave ,发
PCON |= SET_BIT0; // Enter idle mode
if(SPDR != 0x4E) // Receive slave 1st DATA ,读
SPI_Error();
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x01; // Send 0x01 to Slave
PCON |= SET_BIT0; // Enter idle mode
if(SPDR != 0x55) // Receive slave 2nd DATA
SPI_Error();
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x02; // Send 0x02 to Slave
PCON |= SET_BIT0; // Enter idle mode
if(SPDR != 0x56) // Receive slave 3rd DATA
SPI_Error();
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x03; // Send 0x03 to Slave
PCON |= SET_BIT0; // Enter idle mode
if(SPDR != 0x4F) // Receive slave 4th DATA
SPI_Error();
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x04; // Send 0x04 to Slave
PCON |= SET_BIT0; // Enter idle mode
if(SPDR != 0x54) // Receive slave 5th DATA
SPI_Error();
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x4F;
PCON |= SET_BIT0; // Enter idle mode
*pu8MID = SPDR; // Receive Slave 1st DATA fron Slave
printf ("\nSlave Return %c!\n",SPDR);
SPDR = 0x4E;
PCON |= SET_BIT0; // Enter idle mode
*pu8DID = SPDR; // Receive Slave 2nd DATA from Slave
printf ("\nSlave Return %c!\n",SPDR);
SS = 1;
}其中,后面的解析,前面接从机1-5号数据,和后面的从从机接从机1-2号数据,这个有什么区别吗,还是说我理解有误 |