I am using the PSP driver to create Flash read, write, erase functions on EVM6747.
an example of one of the functions is below:
BOOL FLASHRead (unsigned int *addrSrc, void *addrDst, unsigned int numBytes)
{ /* FLASHRead. */
Spi_DataParam dataparam;
Uint32 size = 0;
BOOL bret=TRUE;
/* clear the spi params data structure */
memset(&dataparam,0x00, sizeof(Spi_DataParam));
/* read the data from the Flash */
loopWrite[0] = SPI_FLASH_READ;
loopWrite[1] = (Uint8)((((Uint32)addrSrc) >> 16)& 0xFF); // High byte
loopWrite[2] = (Uint8)((((Uint32)addrSrc) >> 8)& 0xFF); // Middle byte
loopWrite[3] = (Uint8)(addrSrc) & 0xFF; // Low byte
dataparam.flags = Spi_CSHOLD;
dataparam.chipSelect = 1;
dataparam.dataFormat = Spi_DataFormat_0;
/* ( Opcode (1byte) + address (3bytes) + (data to be read) */
dataparam.bufLen = numBytes + SPI_MAX_CMD_LEN;
dataparam.outBuffer = &loopWrite[0];
dataparam.inBuffer = &loopRead[0];
size = dataparam.bufLen;
/* read from Flash */
Stream_write(spiHandle, &dataparam, size, BIOS_WAIT_FOREVER, NULL);
memcpy(addrDst,&loopRead[4],numBytes);
return(bret);
} /* FLASHRead. */
Can I call stream_write () and keep CS low so I can implement the Flash command with 2 Stream_write calls?
dataparam.outBuffer = &loopWrite[0];
Stream_write(spiHandle, &dataparam, 4, BIOS_WAIT_FOREVER, NULL);
dataparam.outBuffer = &loopWrite[4];
Stream_write(spiHandle, &dataparam, numWords, BIOS_WAIT_FOREVER, NULL);
Is there a good explanation of the dataparam.flags, dataparam.chipSelect; parameters and how it effects the CS on the SPI peripheral?