14 #if UAVCAN_STM32_NUTTX 16 BusEvent::BusEvent(CanDriver &can_driver)
18 sem_init(&sem_, 0, 0);
19 sem_setprotocol(&sem_, SEM_PRIO_NONE);
27 bool BusEvent::wait(uavcan::MonotonicDuration duration)
29 if (duration.isPositive()) {
32 if (clock_gettime(CLOCK_REALTIME, &abstime) == 0) {
33 const unsigned billion = 1000 * 1000 * 1000;
34 uint64_t nsecs = abstime.tv_nsec + (uint64_t)duration.toUSec() * 1000;
35 abstime.tv_sec += nsecs / billion;
36 nsecs -= (nsecs / billion) * billion;
37 abstime.tv_nsec = nsecs;
41 while ((ret = sem_timedwait(&sem_, &abstime)) == -1 && errno == EINTR);
54 void BusEvent::signalFromInterrupt()
56 if (sem_.semcount <= 0) {
57 (void)sem_post(&sem_);