No bugs detected
Signed-off-by: Keith Packard <keithp@keithp.com>
{
int16_t sample_count;
int16_t log_count;
{
int16_t sample_count;
int16_t log_count;
uint32_t pa_interval_min, pa_interval_max;
int32_t pa_diff;
uint8_t h;
uint32_t pa_interval_min, pa_interval_max;
int32_t pa_diff;
uint8_t h;
#endif
pa_hist[h] = pa;
h = SKIP_PA_HIST(h,1);
#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 */
#if BOOST_DETECT
/* Check for a significant pressure change */
pa_min = ao_pa;
if (sample_count == (GROUND_AVG - 1)) {
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)
/* Check to see if the pressure is now stable */
if (pa_diff < LAND_DETECT)
void
ao_microkalman_init(void)
{
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)
{
}
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;
}
ao_k_pa_speed += (int32_t) ao_pa_accel * AO_MK_STEP;
}
{
int16_t e; /* Height error in Pa */
{
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_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);