embeddedsw
embeddedsw copied to clipboard
Varible type lead to error action in xspi.c
https://github.com/Xilinx/embeddedsw/blob/8fca1ac929453ba06613b5417141483b4c2d8cf3/XilinxProcessorIPLib/drivers/spi/src/xspi.c#L627C1-L650C3
I discover that the var RemainingBytes
is unsigned int,so if my tansfer data bytes is not the times of DataWidth
, it will fill the fifo untill it's full.
so, i think here the while loop should be :
while (((StatusReg & XSP_SR_TX_FULL_MASK) == 0) &&
(InstancePtr->RemainingBytes > 0)) {
if (DataWidth == XSP_DATAWIDTH_BYTE) {
/*
* Data Transfer Width is Byte (8 bit).
*/
Data = *InstancePtr->SendBufferPtr;
} else if (DataWidth == XSP_DATAWIDTH_HALF_WORD) {
/*
* Data Transfer Width is Half Word (16 bit).
*/
Data = *(u16 *)InstancePtr->SendBufferPtr;
} else if (DataWidth == XSP_DATAWIDTH_WORD){
/*
* Data Transfer Width is Word (32 bit).
*/
Data = *(u32 *)InstancePtr->SendBufferPtr;
}
XSpi_WriteReg(InstancePtr->BaseAddr, XSP_DTR_OFFSET, Data);
InstancePtr->SendBufferPtr += (DataWidth >> 3);
//********************************************************************
if(InstancePtr->RemainingBytes <(DataWidth >> 3))
{
StatusReg = XSpi_GetStatusReg(InstancePtr);
break;
}
//********************************************************************
InstancePtr->RemainingBytes -= (DataWidth >> 3);
StatusReg = XSpi_GetStatusReg(InstancePtr);
}