请问有谁调试成功过CY8C21434 SPIM 模块的读操作,我可以向SPI从设备写操作,但是死活都不能进行读操作,
请高手指点:
void SPI_Write(unsigned char dig)
{
PRT2DR |= CS;
while(!(SPIM_1_bReadStatus() & SPIM_1_SPIM_TX_BUFFER_EMPTY)){};
PRT2DR &= ~CS; // set slave select low
SPIM_1_SendTxData(dig); // set message to transmit
while(!(SPIM_1_bReadStatus() & SPIM_1_SPIM_SPI_COMPLETE)){};
PRT2DR |= CS; //
}
unsigned char SPI_Read(void)
{
unsigned char ReceivedData;
PRT2DR |= CS;
PRT2DR &= ~CS;
SPIM_1_SendTxData(0x00); // 写伪数据,以便读到数据
while(!(SPIM_1_bReadStatus() & SPIM_1_SPIM_RX_BUFFER_FULL));//RX Buffer register has received current data
ReceivedData = SPIM_1_bReadRxData();
PRT2DR |= CS;
return ReceivedData;
} |