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.

请问CC1010使用回调函数模式SPI时这样使用timeout是否正确

Other Parts Discussed in Thread: CC1310

我CC1310的SPI使用的是SDK中的回调函数模式,其中使用了sem_timedwait(&slaveSem,&timeout),要实现在回调函数模式下spi传输的超时(3ms)退出,核心代码如下所示,这样使用是否正确,求解答!!!

struct timespec timeout;

clock_gettime(clock_realtime,&timeout);

timeout.tv_nsec += 3000000;

transferOK = SPI_transfer(slaveSpi,&transaction);

if(transferOK)

{

sem_timedwait(&slaveSem,&timeout);

}