Hi,
I have not checked if that is something that can be changed in the module configuration but to overcome that, I created the below function that sorts the data so the ECSPI module sends it correctly.
u8 __attribute__ ((aligned(4))) g_spi_bcm89501_tx_buf[SPI_BCM_XFER_SZ];
u8 __attribute__ ((aligned(4))) g_spi_bcm89501_rx_buf[SPI_BCM_XFER_SZ];
int spi_XXX_xfer(unsigned char * u8ptrTx,unsigned char * u8ptrRx, int length)
{
int i;
int byteiterations, currentiteration;
unsigned char * u8ptrStartTx = u8ptrTx;
unsigned char * u8ptrStartRx = u8ptrRx;
int ByteOffset;
int nbytesoffset;
ByteOffset = length % 4;
nbytesoffset = 4 - ByteOffset;
if(ByteOffset == 0)
{
nbytesoffset = 0;
}
/*Get remaining of data*/
if(u8ptrTx != NULL)
{
u8ptrTx = u8ptrTx + ByteOffset;
currentiteration = 1;
byteiterations = length/4;
while( currentiteration <=byteiterations)
{
i = 4 * currentiteration++;
g_spi_bcm89501_tx_buf[i + 3] = *u8ptrTx++;
g_spi_bcm89501_tx_buf[i + 2] = *u8ptrTx++;
g_spi_bcm89501_tx_buf[i + 1] = *u8ptrTx++;
g_spi_bcm89501_tx_buf[i] = *u8ptrTx++;
}
/*point to beginnig of frame*/
u8ptrTx = u8ptrStartTx;
/*Copy the remainning bytes, they are the first ones*/
for(i = 3 ; i >= nbytesoffset ; i--)
{
g_spi_bcm89501_tx_buf[i - nbytesoffset] = *u8ptrTx++;
}
}
/*Begin Transfer*/
imx_ecspi_xfer(&imx_spi_bcm89501, g_spi_bcm89501_tx_buf, g_spi_bcm89501_rx_buf, (length) * 8);
/*Copy data from spi driver*/
if(u8ptrRx != NULL)
{
u8ptrRx = u8ptrRx + ByteOffset;
currentiteration = 1;
byteiterations = length/4;
while( currentiteration <=byteiterations)
{
i = 4 * currentiteration++;
*u8ptrRx++ = g_spi_bcm89501_rx_buf[i + 3];
*u8ptrRx++ = g_spi_bcm89501_rx_buf[i + 2];
*u8ptrRx++ = g_spi_bcm89501_rx_buf[i + 1];
*u8ptrRx++ = g_spi_bcm89501_rx_buf[i];
}
/*point to beginnig of frame*/
u8ptrRx = u8ptrStartRx;
/*Copy the remainning bytes, they are the first ones*/
for(i = 3 ; i >= nbytesoffset ; i--)
{
*u8ptrRx++ = g_spi_bcm89501_rx_buf[i - nbytesoffset];
}
}
return 0;
}
I hope you find that useful.
/Alejandro