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.

CC1310: SPI Slave Mode

Part Number: CC1310

Hello,

we want to use the SPI Slave mode of the CC1310 device.

But we can't receive any packet.

If we use SPI Master mode, everything is fine.

So i think the IO Port definition and initialisation of the SPI is OK.

The external Master send a packet with 32 Bytes and 0,75 Mbit, but we never seen a callback ...

Our Code

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include <ti/display/Display.h>

/* Example/Board Header files */
#include "Board.h"

#define SPI_MSG_LENGTH  (32)
#define SLAVE_MSG       ("Hello from slave, msg#: ")

#define MAX_LOOP        (10)

unsigned char slaveRxBuffer[SPI_MSG_LENGTH];
unsigned char slaveTxBuffer[SPI_MSG_LENGTH];

unsigned char txSPIBuf[SPI_MSG_LENGTH];
unsigned char rxSPIBuf[SPI_MSG_LENGTH];

#define SPICC26XXDMA_CMD_RETURN_PARTIAL_ENABLE  (SPI_CMD_RESERVED + 0)

bool Received = false;


void transferCallback(SPI_Handle handle, SPI_Transaction *transaction)
{

    Received = true;

}

#define SPICC26XXDMA_CMD_RETURN_PARTIAL_ENABLE  (SPI_CMD_RESERVED + 0)

void Test(void)
{

    SPI_Handle handle;
    SPI_Params params;
    SPI_Transaction transaction;
     bool transferOK;
     uint8_t Buffer[SPI_MSG_LENGTH];
    uint8_t i;

    SPI_init();

    SPI_Params_init(&params);
    params.bitRate = 1000000; // Maximum bit rate as slave
    params.frameFormat = SPI_POL0_PHA1;
    params.mode = SPI_SLAVE;
    // params.mode = SPI_MASTER;

    params.transferMode = SPI_MODE_CALLBACK;
    params.dataSize = 8;
    params.transferCallbackFxn = transferCallback;

    /********************************************
     * Configure the transaction
     ********************************************/
    transaction.count = SPI_MSG_LENGTH;
    transaction.txBuf = (void *) txSPIBuf;
    transaction.rxBuf = (void *) rxSPIBuf;

    /********************************************
     * Open the SPI and initiate the first transfer
     ********************************************/
    handle = SPI_open(Board_SPI0, &params);

    /********************************************
     * Start and wait for Master CLK
     ********************************************/
    SPI_transfer(handle, &transaction);


    // SPI_control(handle, SPICC26XXDMA_CMD_RETURN_PARTIAL_ENABLE, NULL);


    strncpy((char *) txSPIBuf, SLAVE_MSG, SPI_MSG_LENGTH);


    while (1)
    {

        if (Received == true)
        {
            transferOK = SPI_transfer(handle, &transaction);

            for (i = 0; i < SPI_MSG_LENGTH; i++)
                Buffer[i] = rxSPIBuf[i];

            Received = false;

            i = 1 ;

            txSPIBuf[sizeof(SLAVE_MSG) - 1] = (i % 10) + '0';
            memset((void *) rxSPIBuf, 0, SPI_MSG_LENGTH);
            transaction.count = SPI_MSG_LENGTH;
            transaction.txBuf = (void *) txSPIBuf;
            transaction.rxBuf = (void *) rxSPIBuf;


        }

    }

}

regards Andreas