Other Parts Discussed in Thread: CC1310
Tool/software: TI-RTOS
Dear community,
for my project I need to implement a SPI communication between a Master and some Slaves.
I started with some basic examples from here.
Master: Should send "Hello World" every 3 seconds.
Debugging: The status is "SPI_TRANSFER_COMPLETED", every time.
GPIO_init(); SPI_init(); SPI_Handle handle; SPI_Params params; SPI_Transaction transaction; uint8_t txBuf[] = "Hello World"; // Transmit buffer uint8_t rxBuf[11]; // Receive buffer // Init SPI and specify non-default parameters SPI_Params_init(¶ms); params.bitRate = 1000000; params.frameFormat = SPI_POL1_PHA1; params.mode = SPI_MASTER; // Configure the transaction transaction.count = sizeof(txBuf); transaction.txBuf = txBuf; transaction.rxBuf = rxBuf; // Open the SPI and perform the transfer handle = SPI_open(Board_SPI0, ¶ms); if (handle == NULL) { /* Error opening SPI */ } while (1) { sleep(3); GPIO_toggle(Board_GPIO_LED0); SPI_transfer(handle, &transaction); transaction.txBuf = txBuf; }
-----------------------------------------------------------------------------------------------
Slave: Should receive the data and compares it
Debugging: SPI_transfer() never leaves its blocking mode.
GPIO_init(); SPI_init(); SPI_Handle handle; SPI_Params params; SPI_Transaction transaction; uint8_t rxBuf[100]; // Receive buffer uint8_t *s; // Init SPI and specify non-default parameters SPI_Params_init(¶ms); params.bitRate = 1000000; params.frameFormat = SPI_POL1_PHA1; params.mode = SPI_SLAVE; // Configure the transaction transaction.count = 100; transaction.txBuf = NULL; transaction.rxBuf = rxBuf; // Open the SPI and perform the transfer handle = SPI_open(Board_SPI0, ¶ms); if (handle == NULL) { /* Error opening SPI */ } while (1) { SPI_transfer(handle, &transaction); s = strstr(rxBuf, "Hello World"); // search for string "Hello World" in buff if (s != NULL) // if successful then s now points at "Hello World" { GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON); } // index of "Hello World" in buff can be found by pointer subtraction }
The launchpads were wired as seen below.
As I have seen in the CC1310_LAUNCHXL.h (line 131), the chip select (SPI CS, DIO 11) is unassigned.
Is an assignment required? And if so, how should it be implemented? Do I have to use the SPI_control() function with
SPICC26XXDMA_SET_CSN_PIN? If yes how is it called correctly?