ao_micro: Add casts to micropeak code for -Wconversion warnings
authorKeith Packard <keithp@keithp.com>
Fri, 28 Jan 2022 23:18:49 +0000 (15:18 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
No bugs detected

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_microflight.c
src/kernel/ao_microkalman.c

index 3c6caf7bac7db7d0509e069df6c30b1c8d42632d..bf994b8f80b647f1f56825053e1e0edb1e77e288 100644 (file)
@@ -46,7 +46,7 @@ ao_microflight(void)
 {
        int16_t         sample_count;
        int16_t         log_count;
-       uint16_t        time;
+       AO_TICK_TYPE    time;
        uint32_t        pa_interval_min, pa_interval_max;
        int32_t         pa_diff;
        uint8_t         h;
@@ -76,7 +76,7 @@ ao_microflight(void)
 #endif
                pa_hist[h] = pa;
                h = SKIP_PA_HIST(h,1);
-               pa_diff = pa_ground - ao_pa;
+               pa_diff = (int32_t) (pa_ground - ao_pa);
 
 #if BOOST_DETECT
                /* Check for a significant pressure change */
@@ -145,7 +145,7 @@ ao_microflight(void)
                        pa_min = ao_pa;
 
                if (sample_count == (GROUND_AVG - 1)) {
-                       pa_diff = pa_interval_max - pa_interval_min;
+                       pa_diff = (int32_t) (pa_interval_max - pa_interval_min);
 
                        /* Check to see if the pressure is now stable */
                        if (pa_diff < LAND_DETECT)
index 3cfb87ccbfa3bf8b7b8169387858cf2286bb49db..a9b2c7092aa33e20c3716857f45e1b7550551d26 100644 (file)
@@ -70,14 +70,14 @@ int16_t             ao_pa_accel;            /* integer portion */
 void
 ao_microkalman_init(void)
 {
-       ao_pa = pa;
-       ao_k_pa = pa << 8;
+       ao_pa = (uint32_t) pa;
+       ao_k_pa = (uint32_t) (pa << 8);
 }
 
 void
 ao_microkalman_predict(void)
 {
-       ao_k_pa       += fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
+       ao_k_pa       += (uint32_t) (int32_t) fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
        ao_k_pa_speed += (int32_t) ao_pa_accel * AO_MK_STEP;
 }
 
@@ -86,12 +86,12 @@ ao_microkalman_correct(void)
 {
        int16_t e;      /* Height error in Pa */
 
-       e = pa - from_fix8(ao_k_pa);
+       e = (int16_t) (pa - from_fix8(ao_k_pa));
 
-       ao_k_pa       += fix16_to_fix8((int32_t) e * AO_K0_10);
+       ao_k_pa       += (uint32_t)(int32_t)fix16_to_fix8(e * AO_K0_10);
        ao_k_pa_speed += (int32_t) e * AO_K1_10;
        ao_k_pa_accel += (int32_t) e * AO_K2_10;
        ao_pa = from_fix8(ao_k_pa);
-       ao_pa_speed = from_fix(ao_k_pa_speed);
-       ao_pa_accel = from_fix(ao_k_pa_accel);
+       ao_pa_speed = (int16_t) from_fix(ao_k_pa_speed);
+       ao_pa_accel = (int16_t) from_fix(ao_k_pa_accel);
 }