diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 5cdbcb0..14f405d 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -187,25 +187,10 @@ runModules: pop r16 #endif -#ifdef MODULES_COMONUART0 push r16 - bigcall ComOnUart0_Run + rcall runComModules pop r16 sbci r16, 0 -#endif - -#ifdef MODULES_COMONUART1 - push r16 - bigcall ComOnUart1_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_STATS - push r16 - bigcall Stats_Run - pop r16 -#endif ; add more modules here @@ -218,6 +203,43 @@ runModules_end: ret +; run until every module idle + +runComModules: + clr r17 +runComModules_loop: + push r17 + clr r16 +#ifdef MODULES_COMONUART0 + push r16 + bigcall ComOnUart0_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COMONUART1 + push r16 + bigcall ComOnUart1_Run + pop r16 + sbci r16, 0 +#endif + pop r17 + ; check for repeat request + tst r16 + clc + breq runComModules_loopEnd + inc r17 + cpi r17, 2 + brne runComModules_loop +runComModules_loopEnd: + tst r17 + clc + breq runComModules_end + sec +runComModules_end: + ret + + mainModulesOnPacketReceived: