drivers/ao_packet: Switch time values to AO_TICK_TYPE
authorKeith Packard <keithp@keithp.com>
Fri, 28 Jan 2022 22:00:43 +0000 (14:00 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
Make sure times are kept in the right type. Also resolved other
-Wconversion issues.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_packet_master.c
src/drivers/ao_packet_slave.c

index a44b34cf0acdd84cd0905f745066dec630f6a08b..688ab6db557db23a3140b329c409ac8647ea1bfd 100644 (file)
@@ -45,14 +45,14 @@ ao_packet_echo(void)
        while (ao_packet_enable) {
                c = ao_packet_getchar();
                if (c != AO_READ_AGAIN)
-                       putchar(c);
+                       putchar((char) c);
        }
        ao_exit();
 }
 
 static struct ao_task  ao_packet_echo_task;
-static uint16_t                ao_packet_master_delay;
-static uint16_t                ao_packet_master_time;
+static AO_TICK_TYPE    ao_packet_master_delay;
+static AO_TICK_TYPE    ao_packet_master_time;
 
 #define AO_PACKET_MASTER_DELAY_SHORT   AO_MS_TO_TICKS(100)
 #define AO_PACKET_MASTER_DELAY_LONG    AO_MS_TO_TICKS(1000)
@@ -74,10 +74,10 @@ ao_packet_master_busy(void)
 static void
 ao_packet_master_check_busy(void)
 {
-       int16_t idle;
+       AO_TICK_SIGNED  idle;
        if (ao_packet_master_delay != AO_PACKET_MASTER_DELAY_SHORT)
                return;
-       idle = (int16_t) (ao_time() - ao_packet_master_time);
+       idle = (AO_TICK_SIGNED) (ao_time() - ao_packet_master_time);
 
        if (idle > AO_PACKET_MASTER_DELAY_TIMEOUT)
                ao_packet_master_delay = AO_PACKET_MASTER_DELAY_LONG;
@@ -87,7 +87,7 @@ static void
 ao_packet_master(void)
 {
        ao_config_get();
-       ao_tx_packet.addr = ao_serial_number;
+       ao_tx_packet.addr = (uint8_t) ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        ao_packet_master_time = ao_time();
        ao_packet_master_delay = AO_PACKET_MASTER_DELAY_SHORT;
index 314ce14a2bc3866406e54c9306eefc842ec307b0..74b6d296d1fc45ab626238a3b7c08c830d0bd0d2 100644 (file)
@@ -21,7 +21,7 @@
 static void
 ao_packet_slave(void)
 {
-       ao_tx_packet.addr = ao_serial_number;
+       ao_tx_packet.addr = (uint8_t) ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        ao_packet_restart = 1;
        while (ao_packet_enable) {