Tool/software: TI-RTOS
I am using simple_peripheral_cc2640relp_app project and i want to implement SPI as a slave .
1 I added #include <ti/drivers/SPI.h> in simple_perip[eral.c
2. SPI configuration
CC2640R2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
CC2640R2_LAUNCHXL_SPI0_MISO | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SPI master in - slave out */
CC2640R2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
CC2640R2_LAUNCHXL_SPI0_CSN | PIN_BM_INPUT_EN | PIN_PULLDOWN,
/* SPI Board */
#define CC2640R2_LAUNCHXL_SPI0_MISO IOID_6 //IOID_8 /* RF1.20 */
#define CC2640R2_LAUNCHXL_SPI0_MOSI IOID_7 //IOID_9 /* RF1.18 */
#define CC2640R2_LAUNCHXL_SPI0_CLK IOID_10 /* RF1.16 */
#define CC2640R2_LAUNCHXL_SPI0_CSN IOID_20 //PIN_UNASSIGNED
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SimpleBLEPeripheral_init();
// for SPI
// Callback function
SPI_init();
// Init SPI and specify non-default parameters
SPI_Params_init(&spi_params);
spi_params.bitRate = 1000000;
spi_params.frameFormat = SPI_POL0_PHA1; //SPI_POL0_PHA0;
spi_params.mode = SPI_SLAVE;
spi_params.transferMode = SPI_MODE_CALLBACK;
spi_params.transferCallbackFxn = transferCallback;
// Configure the transaction
spi_transaction.count = 5;
spi_transaction.txBuf = tbuf;
spi_transaction.rxBuf = rbuf;
// Open the SPI and initiate the first transfer
spi_handle = SPI_open(Board_SPI0, &spi_params);
if (!spi_handle) {
// Log_error0(" UnSuccessfully transfer I2C ");
Display_printf(dispHandle,0,0,"SPI do not open\n");
}
else{
Display_printf(dispHandle,0,0,"SPI intialize successfully\n");
}
status = SPI_transfer(spi_handle, &spi_transaction);
if (status == false) {
// Log_error0(" UnSuccessfully transfer I2C ");
Display_printf(dispHandle,0,0,"UnSuccessfully receive the data SPI\n");
}
else{
Display_printf(dispHandle,0,0,"Successfully receive the data SPI\n");
for(int i =0;i<5;i++)
{
Display_print1(dispHandle, 5, 0, "data : %d\n", rbuf[i]);
}
}
// Wait forever
while(true);
}
From Master i am trasnferring 5 bytes but i count receive the bytes