X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_flight.c;h=5a5d5b72b0adfb887f238d6512c5b91b68b8a016;hb=188f9efadd480de872f86a8eb741e8738db84c6b;hp=c2700d20bddb41801bacb0d560291a50aaad4bb0;hpb=0d57c78dde3c6e61576a4769b0e0fae7e88c107d;p=fw%2Faltos diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index c2700d20..5a5d5b72 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -47,28 +47,28 @@ /* Main flight thread. */ -__pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */ -__pdata uint16_t ao_launch_tick; /* time of first boost detect */ -__pdata uint16_t ao_motor_number; /* number of motors burned so far */ +enum ao_flight_state ao_flight_state; /* current flight state */ +uint16_t ao_boost_tick; /* time of most recent boost detect */ +uint16_t ao_launch_tick; /* time of first boost detect */ +uint16_t ao_motor_number; /* number of motors burned so far */ #if HAS_SENSOR_ERRORS /* Any sensor can set this to mark the flight computer as 'broken' */ -__xdata uint8_t ao_sensor_errors; +uint8_t ao_sensor_errors; #endif /* * track min/max data over a long interval to detect * resting */ -static __data uint16_t ao_interval_end; -static __data ao_v_t ao_interval_min_height; -static __data ao_v_t ao_interval_max_height; +static uint16_t ao_interval_end; +static ao_v_t ao_interval_min_height; +static ao_v_t ao_interval_max_height; #if HAS_ACCEL -static __data ao_v_t ao_coast_avg_accel; +static ao_v_t ao_coast_avg_accel; #endif -__pdata uint8_t ao_flight_force_idle; +uint8_t ao_flight_force_idle; /* We also have a clock, which can be used to sanity check things in * case of other failures @@ -175,7 +175,7 @@ ao_flight(void) #endif } /* wakeup threads due to state change */ - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); break; case ao_flight_pad: @@ -219,7 +219,7 @@ ao_flight(void) ao_wakeup(&ao_gps_new); #endif - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; case ao_flight_boost: @@ -244,7 +244,7 @@ ao_flight(void) ao_flight_state = ao_flight_coast; #endif ++ao_motor_number; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; #if HAS_ACCEL @@ -257,7 +257,7 @@ ao_flight(void) if (ao_speed < AO_MS_TO_SPEED(AO_MAX_BARO_SPEED)) { ao_flight_state = ao_flight_coast; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } else goto check_re_boost; break; @@ -306,7 +306,7 @@ ao_flight(void) /* and enter drogue state */ ao_flight_state = ao_flight_drogue; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } #if HAS_ACCEL else { @@ -315,7 +315,7 @@ ao_flight(void) if (ao_coast_avg_accel > AO_MSS_TO_ACCEL(20)) { ao_boost_tick = ao_sample_tick; ao_flight_state = ao_flight_boost; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } } #endif @@ -352,7 +352,7 @@ ao_flight(void) ao_interval_min_height = ao_interval_max_height = ao_avg_height; ao_flight_state = ao_flight_main; - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } break; @@ -379,7 +379,7 @@ ao_flight(void) ao_timer_set_adc_interval(0); #endif - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); + ao_wakeup(&ao_flight_state); } ao_interval_min_height = ao_interval_max_height = ao_avg_height; ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS; @@ -444,7 +444,9 @@ ao_flight_dump(void) printf (" max_height %d\n", ao_max_height); printf (" avg_height %d\n", ao_avg_height); printf (" error_h %d\n", ao_error_h); +#if !HAS_ACCEL printf (" error_avg %d\n", ao_error_h_sq_avg); +#endif } static void @@ -463,7 +465,7 @@ ao_orient_test_select(void) ao_orient_test = !ao_orient_test; } -__code struct ao_cmds ao_flight_cmds[] = { +const struct ao_cmds ao_flight_cmds[] = { { ao_flight_dump, "F\0Dump flight status" }, { ao_gyro_test, "G\0Test gyro code" }, { ao_orient_test_select,"O\0Test orientation code" }, @@ -471,7 +473,7 @@ __code struct ao_cmds ao_flight_cmds[] = { }; #endif -static __xdata struct ao_task flight_task; +static struct ao_task flight_task; void ao_flight_init(void)