altos: Add separate 'ao_launch_tick'. Use in pyro and lockout.
[fw/altos] / src / kernel / ao_flight.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_FLIGHT_H_
20 #define _AO_FLIGHT_H_
21
22
23 /*
24  * ao_flight.c
25  */
26
27 enum ao_flight_state {
28         ao_flight_startup = 0,
29         ao_flight_idle = 1,
30         ao_flight_pad = 2,
31         ao_flight_boost = 3,
32         ao_flight_fast = 4,
33         ao_flight_coast = 5,
34         ao_flight_drogue = 6,
35         ao_flight_main = 7,
36         ao_flight_landed = 8,
37         ao_flight_invalid = 9,
38         ao_flight_test = 10
39 };
40
41 extern __pdata enum ao_flight_state     ao_flight_state;
42 extern __pdata uint16_t                 ao_boost_tick;
43 extern __pdata uint16_t                 ao_launch_tick;
44 extern __pdata uint16_t                 ao_motor_number;
45
46 #if HAS_IMU || HAS_MMA655X
47 #define HAS_SENSOR_ERRORS       1
48 #endif
49
50 #if HAS_SENSOR_ERRORS
51 extern __xdata uint8_t                  ao_sensor_errors;
52 #endif
53
54 extern __pdata uint16_t                 ao_launch_time;
55 extern __pdata uint8_t                  ao_flight_force_idle;
56
57 /* Flight thread */
58 void
59 ao_flight(void);
60
61 /* Initialize flight thread */
62 void
63 ao_flight_init(void);
64
65 /*
66  * ao_flight_nano.c
67  */
68
69 void
70 ao_flight_nano_init(void);
71
72 #endif /* _AO_FLIGHT_H_ */