/** * @brief Time management handler. * @note This handler has to be invoked by a periodic ISR in order to * reschedule the waiting threads. * * @iclass */ void nilSysTimerHandlerI(void) { #if NIL_CFG_TIMEDELTA == 0 thread_ref_t tr = &nil.threads[0]; nil.systime++; do { /* Is the thread in a wait state with timeout?.*/ if (tr->timeout > 0) { nilDbgAssert(!NIL_THD_IS_READY(tr), "nilSysTimerHandlerI(), #1", "is ready"); /* Did the timer reach zero?*/ if (--tr->timeout == 0) { /* Timeout on semaphores requires a special handling because the semaphore counter must be incremented.*/ if (NIL_THD_IS_WTSEM(tr)) tr->u1.semp->cnt++; else if (NIL_THD_IS_SUSP(tr)) tr->u1.trp = NULL; nilSchReadyI(tr, NIL_MSG_TMO); } } /* Lock released in order to give a preemption chance on those architectures supporting IRQ preemption.*/ nilSysUnlockFromISR(); tr++; nilSysLockFromISR(); #if WHG_MOD } while (tr < nil.idlep); #else /* WHG_MOD */ } while (tr < &nil.threads[NIL_CFG_NUM_THREADS]);
void imu_isr() { #ifdef IRQ_DEBUG #ifdef __BOARD_YUN__ Console.print(F("ISR")); #else Serial.print(F("ISR")); #endif #endif #ifdef USE_NILRTOS NIL_IRQ_PROLOGUE(); #endif mpuInterrupt = true; #ifdef USE_NILRTOS nilSysLockFromISR(); nilSemSignalI(&dmpSem); nilSysUnlockFromISR(); NIL_IRQ_EPILOGUE(); #endif }