first test
Dependents: LoRaWAN-lmic-app_tjm
Fork of LMiC by
Diff: oslmic.cpp
- Revision:
- 5:464c1f2d6cbb
- Parent:
- 1:d3b7bde3995c
--- a/oslmic.cpp Thu Nov 26 17:17:08 2015 +0000 +++ b/oslmic.cpp Tue Feb 23 15:34:27 2016 +0000 @@ -10,25 +10,34 @@ *******************************************************************************/ #include "lmic.h" +#include "debug.h" // RUNTIME STATE -static struct { +static struct +{ osjob_t* scheduledjobs; osjob_t* runnablejobs; } OS; -void os_init () { +void os_init () +{ + debug("os_init enter\r\n"); memset(&OS, 0x00, sizeof(OS)); hal_init(); radio_init(); LMIC_init(); + debug("os_init exit\r\n"); } -ostime_t os_getTime () { +ostime_t os_getTime () +{ + debug("os_getTime enter %d\r\n",hal_ticks()); return hal_ticks(); } -static u1_t unlinkjob (osjob_t** pnext, osjob_t* job) { +static u1_t unlinkjob (osjob_t** pnext, osjob_t* job) +{ + debug("unlinkjob enter\r\n"); for( ; *pnext; pnext = &((*pnext)->next)) { if(*pnext == job) { // unlink *pnext = job->next; @@ -39,14 +48,18 @@ } // clear scheduled job -void os_clearCallback (osjob_t* job) { +void os_clearCallback (osjob_t* job) +{ + debug("os_clearCallback enter\r\n"); hal_disableIRQs(); unlinkjob(&OS.scheduledjobs, job) || unlinkjob(&OS.runnablejobs, job); hal_enableIRQs(); } // schedule immediately runnable job -void os_setCallback (osjob_t* job, osjobcb_t cb) { +void os_setCallback (osjob_t* job, osjobcb_t cb) +{ + debug("os_setCallback enter\r\n"); osjob_t** pnext; hal_disableIRQs(); // remove if job was already queued @@ -61,7 +74,9 @@ } // schedule timed job -void os_setTimedCallback (osjob_t* job, ostime_t time, osjobcb_t cb) { +void os_setTimedCallback (osjob_t* job, ostime_t time, osjobcb_t cb) +{ + debug("os_setTimedCallback enter %d\r\n",time); osjob_t** pnext; hal_disableIRQs(); // remove if job was already queued @@ -83,7 +98,9 @@ } // execute jobs from timer and from run queue -void os_runloop () { +void os_runloop () +{ + debug("os_runloop enter\r\n"); while(1) { osjob_t* j = NULL; hal_disableIRQs();