X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fdrivers%2Fao_pad.c;fp=src%2Fdrivers%2Fao_pad.c;h=07c49afc6b890a4094a842360223eddc52eef715;hp=2592a084261bec25640f0820dfc018c579f44486;hb=54e98a498db0d7026ce16c3ad53bc60986c68253;hpb=366c1422f6d34c8f616dc95c2767d01c4f53f581 diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index 2592a084..07c49afc 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -26,10 +26,10 @@ static uint8_t ao_pad_ignite; static struct ao_pad_command command; static struct ao_pad_query query; static uint8_t ao_pad_armed; -static uint16_t ao_pad_arm_time; +static AO_TICK_TYPE ao_pad_arm_time; static uint8_t ao_pad_box; static uint8_t ao_pad_disabled; -static uint16_t ao_pad_packet_time; +static AO_TICK_TYPE ao_pad_packet_time; #ifndef AO_PAD_RSSI_MINIMUM #define AO_PAD_RSSI_MINIMUM -90 @@ -288,7 +288,7 @@ ao_pad_monitor(void) prev = cur; } - if (ao_pad_armed && (int16_t) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME) + if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME) ao_pad_armed = 0; if (ao_pad_armed) { @@ -369,7 +369,7 @@ static int ao_pad_read_box(void) { static void ao_pad(void) { - int16_t time_difference; + int16_t tick_difference; int8_t ret; ao_pad_box = 0; @@ -398,12 +398,12 @@ ao_pad(void) if (command.channels & ~(AO_PAD_ALL_CHANNELS)) break; - time_difference = command.tick - ao_time(); - PRINTD ("arm tick %d local tick %d\n", command.tick, ao_time()); - if (time_difference < 0) - time_difference = -time_difference; - if (time_difference > 10) { - PRINTD ("time difference too large %d\n", time_difference); + tick_difference = command.tick - (uint16_t) ao_time(); + PRINTD ("arm tick %d local tick %d\n", command.tick, (uint16_t) ao_time()); + if (tick_difference < 0) + tick_difference = -tick_difference; + if (tick_difference > 10) { + PRINTD ("tick difference too large %d\n", tick_difference); break; } if (query.arm_status != AO_PAD_ARM_STATUS_ARMED) { @@ -439,7 +439,7 @@ ao_pad(void) PRINTD ("not armed\n"); break; } - if ((uint16_t) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) { + if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) { PRINTD ("late pad arm_time %d time %d\n", ao_pad_arm_time, ao_time()); break; @@ -457,7 +457,7 @@ ao_pad(void) #if HAS_LOG if (!ao_log_running) ao_log_start(); #endif - if ((uint16_t) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) { + if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) { PRINTD ("late pad arm_time %d time %d\n", ao_pad_arm_time, ao_time()); break;