在out of box例程中添加timer.h,发现Timer_config没有定义,导致出错。请问,我应该怎样去才可以调用呢,或者有更好的办法
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.
在out of box例程中添加timer.h,发现Timer_config没有定义,导致出错。请问,我应该怎样去才可以调用呢,或者有更好的办法
可以使用POSIX,
static void tempSensorTimeoutFxn(sigval arg)
{
LED_toggle(1); Test
}
void SetTimer(void)
{
timer_t timer;
sigevent sev;
struct itimerspec value;
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_notify_function = &tempSensorTimeoutFxn; //定时器回调函数
timer_create(CLOCK_MONOTONIC, &sev, &timer);
value.it_interval.tv_sec = 3; //定时器调用tempSensorTimeoutFxn间隔,如果设为0则it_value记到0后只调用一次,
value.it_interval.tv_nsec = 0;
value.it_value.tv_sec = 3; //0则关闭定时器,非零则打开定时器且如果it_interval非零则直接决定了定时器回调函数的执行间隔时间
value.it_value.tv_nsec = 0;
timer_settime(timer, 0, &value, NULL); //启动1定时器
}