请教:cc1310 SPI示例中为啥主机与从机为啥没有连接成功?新手求help
代码是TI的示例:
MASTER
#define SPI_TASK_STACK_SIZE 1024
#define SPI_TASK_PRIORITY 2
#define SPITASKSTACKSIZE 768
static uint8_t SPITaskStack[SPITASKSTACKSIZE];
static PIN_Handle pinHandle;
static PIN_State pinState;
PIN_Config SPIpinTable[] = {
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_SPI0_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
Board_SPI0_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, // IOID_15 Ensure SPI slave 0 is not selected
Board_SPI1_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, // IOID_18 Ensure SPI slave 1 is not selected
PIN_TERMINATE
};
static void taskFxn(UArg a0, UArg a1)
{
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 = NULL;
// Open the SPI and perform the transfer
handle = SPI_open(Board_SPI0, ¶ms);
SPI_transfer(handle, &transaction);
PIN_setOutputValue(pinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1));
}
SALVE
PIN_Config SPIpinTable[] = {
//Board_SPI0_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_SPI0_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
Board_SPI0_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, // IOID_15 Ensure SPI slave 0 is not selected
Board_SPI1_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, // IOID_18 Ensure SPI slave 1 is not selected
PIN_TERMINATE
};
static void taskFxn(UArg a0, UArg a1)
{
SPI_Handle handle;
SPI_Params params;
SPI_Transaction transaction;
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_SLAVE;
// Configure the transaction
transaction.count = 11;
transaction.txBuf = NULL;
transaction.rxBuf = rxBuf;
// Open the SPI and perform the transfer
handle = SPI_open(Board_SPI0, ¶ms);
SPI_transfer(handle, &transaction);
PIN_setOutputValue(pinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1));
}
您是用TI例程进行实验的?您现在使用的是TI的板子还是自己的板子?
这是购买的一套实验板,选用http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_14_02_22/exports/tirtos_full_2_14_02_22/docs/doxygen/html/_s_p_i_c_c26_x_x_d_m_a_8h.html
这TI里面的例程,不能实现这个功能是引脚配置出问题还是?