main: Replace MOD with bitwise AND

This prevents `moduint` from being called for the superloop.

A bitwise AND is used instead of using the equivalent `% 4` as an
indication that modulo should not be used, as not using a power of 2
(which is optimized) will result in an expensive call to SDCC library
functions.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2024-01-02 17:01:07 -07:00
committed by Tim Crawford
parent 766fb738a0
commit 4b86176659

View File

@ -102,7 +102,7 @@ void main(void) {
uint32_t last_time_fan = 0;
for (main_cycle = 0;; main_cycle++) {
switch (main_cycle % 3U) {
switch (main_cycle & 3U) {
case 0:
// Handle USB-C events immediately before power states
usbpd_event();
@ -123,6 +123,11 @@ void main(void) {
// Handle lid close/open
lid_event();
break;
case 3:
// We previously used modulo to limit when the logic for other
// cases ran, so this case is unused.
break;
}
if (main_cycle == 0) {