This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PSP SPI driver

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?

  • Hi,

    Mark Rae said:
    Can I call stream_write () and keep CS low so I can implement the Flash command with 2 Stream_write calls?

    If you are asking if the CS can be kept for two successive requests (Stream_write/read) from the application, you can use Spi_CSHOLD option with Spi_CSHOLD_FOR_MULTI_TRANSCEIVE. This will hold the CS active for mutiple transfers.

    Mark Rae said:
    Is there a good explanation of the dataparam.flags, dataparam.chipSelect; parameters and how it effects the CS on the SPI peripheral?

    Please refer to SPI User guide sections, 7.4.3 (should actually read as Spi_DataParam). Some explanation is also available in section 7.7 also.

    Please note that the information I have provided is by referring to BIOS PSP release 01.30.01. So, if you are using a different release please locate the sections appropriately in the user guide.