altos: Move ao_config declarations to ao_config.h
[fw/altos] / src / kernel / ao_host.h
1 /*
2  * Copyright © 2009 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; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #define _GNU_SOURCE
19
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #define AO_ADC_RING     64
27 #define ao_adc_ring_next(n)     (((n) + 1) & (AO_ADC_RING - 1))
28 #define ao_adc_ring_prev(n)     (((n) - 1) & (AO_ADC_RING - 1))
29
30 /*
31  * One set of samples read from the A/D converter
32  */
33 struct ao_adc {
34         uint16_t        tick;           /* tick when the sample was read */
35         int16_t         accel;          /* accelerometer */
36         int16_t         pres;           /* pressure sensor */
37         int16_t         temp;           /* temperature sensor */
38         int16_t         v_batt;         /* battery voltage */
39         int16_t         sense_d;        /* drogue continuity sense */
40         int16_t         sense_m;        /* main continuity sense */
41 };
42
43 #define __pdata
44 #define __data
45 #define __xdata
46 #define __code
47 #define __reentrant
48
49 #define DATA_TO_XDATA(a)        (a)
50 #define PDATA_TO_XDATA(a)       (a)
51 #define CODE_TO_XDATA(a)        (a)
52
53 enum ao_flight_state {
54         ao_flight_startup = 0,
55         ao_flight_idle = 1,
56         ao_flight_pad = 2,
57         ao_flight_boost = 3,
58         ao_flight_fast = 4,
59         ao_flight_coast = 5,
60         ao_flight_drogue = 6,
61         ao_flight_main = 7,
62         ao_flight_landed = 8,
63         ao_flight_invalid = 9
64 };
65
66 struct ao_adc ao_adc_ring[AO_ADC_RING];
67 uint8_t ao_adc_head;
68
69 #define ao_led_on(l)
70 #define ao_led_off(l)
71 #define ao_timer_set_adc_interval(i)
72 #define ao_wakeup(wchan) ao_dump_state(wchan)
73 #define ao_cmd_register(c)
74 #define ao_usb_disable()
75 #define ao_telemetry_set_interval(x)
76 #define ao_delay(x)
77
78 enum ao_igniter {
79         ao_igniter_drogue = 0,
80         ao_igniter_main = 1
81 };
82
83 void
84 ao_ignite(enum ao_igniter igniter)
85 {
86         printf ("ignite %s\n", igniter == ao_igniter_drogue ? "drogue" : "main");
87 }
88
89 struct ao_task {
90         int dummy;
91 };
92
93 #define ao_add_task(t,f,n)
94
95 #define ao_log_start()
96 #define ao_log_stop()
97
98 #define AO_MS_TO_TICKS(ms)      ((ms) / 10)
99 #define AO_SEC_TO_TICKS(s)      ((s) * 100)
100
101 #define AO_FLIGHT_TEST
102
103 struct ao_adc ao_adc_static;
104
105 FILE *emulator_in;
106
107 void
108 ao_dump_state(void *wchan);
109
110 void
111 ao_sleep(void *wchan);
112
113 const char const * const ao_state_names[] = {
114         "startup", "idle", "pad", "boost", "fast",
115         "coast", "drogue", "main", "landed", "invalid"
116 };
117
118 struct ao_cmds {
119         void            (*func)(void);
120         const char      *help;
121 };
122
123
124 struct ao_config {
125         uint16_t        main_deploy;
126         int16_t         accel_zero_g;
127 };
128
129 #define ao_config_get()
130
131 struct ao_config ao_config = { 250, 16000 };
132
133 #define ao_xmemcpy(d,s,c) memcpy(d,s,c)
134 #define ao_xmemset(d,v,c) memset(d,v,c)
135 #define ao_xmemcmp(d,s,c) memcmp(d,s,c)