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通信不成功

Other Parts Discussed in Thread: CC1310

Hi,

我现在使用硬件SPI,调用SPI_transfer()函数发送数据时卡死,能帮忙解决一下吗。

还有就是,默认的代码里面SPI的pin配置如下:

CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,
CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,

为什么要这样配置,没有配置输出,全是输入。

我的SPI代码如下:

static SPI_Handle spi_handle;

int spi_init(void)
{
SPI_Params spiParams;

SPI_init();

SPI_Params_init(&spiParams);

spi_handle = SPI_open(Board_SPI0, &spiParams);
if (!spi_handle) {
return false;
}

return true;
}

void spi_write_data(unsigned char data)
{
SPI_Transaction masterTransaction;

masterTransaction.count = 1;
masterTransaction.txBuf = (void *)&data;
masterTransaction.arg = NULL;
masterTransaction.rxBuf = NULL;

SPI_transfer(spi_handle, &masterTransaction);
}