// execute jobs from timer and from run queue once void os_runloop_once () { osjob_t* j = NULL; hal_disableIRQs(); // check for runnable jobs if(OS.runnablejobs) { j = OS.runnablejobs; OS.runnablejobs = j->next; } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs j = OS.scheduledjobs; OS.scheduledjobs = j->next; } else { // nothing pending hal_sleep(); // wake by irq (timer already restarted) } hal_enableIRQs(); if(j) { // run job callback j->func(j); } }
// LMIC run loop, as a FreeRTOS task void os_runloop(void *pvParameters) { osjob_t *j = NULL; for(;;) { hal_disableIRQs(); // check for runnable jobs j = NULL; if(OS.runnablejobs) { j = OS.runnablejobs; OS.runnablejobs = j->next; } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs j = OS.scheduledjobs; OS.scheduledjobs = j->next; } hal_enableIRQs(); if (j) { // run job callback j->func(j); } else { //vTaskSuspend(NULL); } } }