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.

CCS/AM3358: SPI example question

Part Number: AM3358

Tool/software: Code Composer Studio

MCSPI_SlaveMode_MasterExample_bbbAM335x_armExampleProject

the callback function is

/* Callback mode functions */
void SPI_callback(SPI_Handle handle, SPI_Transaction *transaction)
{
    SPI_osalPostLock(cbSem[0]);
}

typedef struct SPI_Transaction_s {

/* User input (write-only) fields */

size_t count; /*!< Number of frames for this transaction */

void *txBuf; /*!< void * to a buffer with data to be transmitted */

void *rxBuf; /*!< void * to a buffer to receive data */

void *arg; /*!< Argument to be passed to the callback function */ <======== variable I care

/* User output (read-only) fields */

SPI_Status status; /*!< Status code set by SPI_transfer */

/* Driver-use only fields */

} SPI_Transaction;

my question is how to set transaction->arg if my callback function has two arguments, char *msg_data and int msg_length? Thanks

  • You will need to put the *msg_data and msg_length into a structure and then pass address of the structure as an argument.  We don`t have many examples that implement this since the count and the txbuf and rxbuf in the transaction suffices to configure the transaction. however, one example for passing the transaction.arg can be seen in the function SPI_test_xfer_error where the terminateXfer flag is passed as an argument to the callback function in the SPI master slave example.

    Locate the source here:

    pdk_am335x_1_0_xx\packages\ti\drv\spi\example\mcspi_slavemode\src

    Hope this helps.

    Regards,

    Rahul