d77d105a524d5aa41da53b10216dc932e545d406
[fw/altos] / src / drivers / ao_pad.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; 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 #ifndef _AO_PAD_H_
19 #define _AO_PAD_H_
20
21 #define AO_PAD_MAX_CHANNELS     8
22 #define AO_PAD_MAX_BOXES        100
23
24 struct ao_pad_command {
25         uint16_t        tick;
26         uint16_t        box;
27         uint8_t         cmd;
28         uint8_t         channels;
29 };
30
31 /* Report current telefire status.
32  */
33
34 #define AO_PAD_QUERY            1
35
36 struct ao_pad_query {
37         uint16_t        tick;           /* telefire tick */
38         uint16_t        box;            /* telefire box number */
39         uint8_t         channels;       /* which chanels are present */
40         uint8_t         armed;          /* which channels are armed */
41         uint8_t         arm_status;     /* status of arming switch */
42         uint8_t         battery;        /* battery voltage in decivolts */
43         uint8_t         igniter_status[AO_PAD_MAX_CHANNELS];    /* status for each igniter */
44 };
45
46 /* Arm pads for 3 seconds, no report
47  */
48 #define AO_PAD_ARM              2
49
50 #define AO_PAD_ARM_TIME         AO_SEC_TO_TICKS(3)
51
52 /* Fire current armed pads for 200ms, no report
53  */
54 #define AO_PAD_FIRE             3
55
56 #define AO_PAD_FIRE_TIME        AO_MS_TO_TICKS(200)
57
58 #define AO_PAD_ARM_STATUS_DISARMED      0
59 #define AO_PAD_ARM_STATUS_ARMED         1
60 #define AO_PAD_ARM_STATUS_UNKNOWN       2
61
62 #define AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN     0
63 #define AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN   1
64 #define AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_CLOSED   2
65 #define AO_PAD_IGNITER_STATUS_UNKNOWN                   3
66
67 void
68 ao_pad_init(void);
69
70 void
71 ao_pad_disable(void);
72
73 void
74 ao_pad_enable(void);
75
76 #endif /* _AO_PAD_H_ */