Part Number: CC2640
Other Parts Discussed in Thread: ADS1220, , ADS1292
Tool/software: TI-RTOS
Hello,
I'm really confused about adding a SPI code to my program. I want to read ADS1220 by SPI. I've followed many posts, but couldn't get my answer. here is my question: What is the difference between the following link tutorial and the code I added?
processors.wiki.ti.com/.../Cc2640_Adding_a_UART_or_SPI_driver_to_a_Sample_Project
The code I found from sensor tag example and from the .h and .c files of SPI driver is:
SPI_Params_init(&SPIparams);
SPIparams.transferMode = SPI_MODE_BLOCKING;
SPIparams.bitRate = 1000000;
SPIparams.mode = SPI_MASTER;
SPIparams.dataSize = 8;
SPIhandle = SPI_open(0, &SPIparams);
if (!SPIhandle) {
System_printf("SPI did not open");
}
else {
System_printf("SPI-0 initialized\n");
}
and for reading:
//////////////////////// SPI Reading /////////////////////////
const uint8_t *buf =0;
spiTransaction.count = 1;
spiTransaction.txBuf = (void*)buf;
spiTransaction.arg = NULL;
spiTransaction.rxBuf = NULL;
int_fast16_t ret;
ret = SPI_transfer(SPIhandle, &spiTransaction);
if (!ret) {
System_printf("Unsuccessful SPI transfer");
}
The mentioned link is really complicated and when I follow it, there are many things undefined and it seems it's not done in SensorTag as well. Why do I have to add the TL and so on?
Now, my problem is on SPI_transfer in above code. It hangs there and I can't understand why. Even when I put a probe on SCLK, MISO or MOSI pins, there is no signal on that. Do I need to have more steps to be done? and initialize the PINs? Do I need to add PIN_open(&pinState, BoardSpiInitTable); ? How the SPI understand which pins are assigned? Only if I add a table like the following, the compiler will understand?
#define Board_SPI0_MISO IOID_18 #define Board_SPI0_MOSI IOID_19 #define Board_SPI0_CLK IOID_17
I do appreciate your help as I'm really exhausted and confused about different definitions and codes.
Amir
