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.

SPI in TIRTOS 2.10.01.38

I have just moved a project from TI-RTSO 2.00.01 to 2.10.01.38 and am trying to find out what the two new parameters scratchBufPtr and defaultTxBufValue do in the SPITivaDMA_HWAttrs .  I looked in the manuals and cannot find any mention.  For my code I just set them both to 0 and it compiled fine and runs.  However I'd like to confirm what they should be used for to make sure I haven't introduced any issue for myself.

typedef struct SPITivaDMA_HWAttrs {

/*! SSI Peripheral's base address */

SPIBaseAddrType baseAddr;

/*! SSI TivaDMA Peripheral's interrupt vector */

unsigned int intNum;

/*! Address of a scratch buffer of size uint32_t */

uint32_t *scratchBufPtr;

/*! Default TX value if txBuf == NULL */

uint32_t defaultTxBufValue;

/*! uDMA controlTable channel index */

uint32_t rxChannelIndex;

/*! uDMA controlTable channel index */

uint32_t txChannelIndex;

/*! uDMA mapping function that maps the SPI trigger to the DMA channel */

void (*channelMappingFxn)(SPIDataType);

/*! uDMA MappingFxn arg to map the Tx channel */

uint32_t rxChannelMappingFxnArg;

/*! uDMA MappingFxn arg to map the Rx channel */

uint32_t txChannelMappingFxnArg;

} SPITivaDMA_HWAttrs;

  • Hi Barry,
    The scratch buffer is added to support the case where a NULL tx or rx buffer can be passed into a SPI_transaction structure for a SPI transfer. Say you're only interested in sending data out, you pass your tx buffer to the SPI_transaction struct and can set the rx buffer to NULL. In this case, the scratch buffer you supplied in your HwAttrs will be used as the dummy rx Buffer to read the data (you don't care about) in. In the other case where you only care about reading data in, you can set the tx buffer to NULL and the scratch buffer will be used as your tx buffer internally and the defaultTxBufValue is the value that will be sent out. Since SPI transfers happen in both ways, an rx and tx buffer need to be supplied but using the scratch buffer you don't have to supply a dummy buffer for SPI transfers you only care about what happens in one direction.

    Let me know if you have other questions.

    Moses
  • Thanks for explaining this Moses

    The Default Tx character makes sense

    It looks like the solution to the bug I reported about setting a NULL Rx buffer was to add another buffer and call it ScratchBuffer and require this to be available if you don't need an RxBuffer?

    Seem that it would have been easier to just change the documentation to say you need a dummy RxBuffer if you are just transmitting like I was when I found the bug.  Now you have another dummy buffer initialised at a different point in the code which could have been the same dummy  buffer you needed to add for Rx anyway.

    So my code which was working before will still work as I supply the RxBuffer.