kernel: Widen pyro time values to 32 bits
[fw/altos] / src / kernel / ao_pyro.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_PYRO_H_
20 #define _AO_PYRO_H_
21
22 enum ao_pyro_flag {
23         ao_pyro_none                    = 0x00000000,
24
25         ao_pyro_accel_less              = 0x00000001,
26         ao_pyro_accel_greater           = 0x00000002,
27
28         ao_pyro_speed_less              = 0x00000004,
29         ao_pyro_speed_greater           = 0x00000008,
30
31         ao_pyro_height_less             = 0x00000010,
32         ao_pyro_height_greater          = 0x00000020,
33
34         ao_pyro_orient_less             = 0x00000040,
35         ao_pyro_orient_greater          = 0x00000080,
36
37         ao_pyro_time_less               = 0x00000100,
38         ao_pyro_time_greater            = 0x00000200,
39
40         ao_pyro_ascending               = 0x00000400,
41         ao_pyro_descending              = 0x00000800,
42
43         ao_pyro_after_motor             = 0x00001000,
44
45         ao_pyro_delay                   = 0x00002000,
46
47         ao_pyro_state_less              = 0x00004000,
48         ao_pyro_state_greater_or_equal  = 0x00008000,
49 }
50 #ifdef __GNUC__
51         __attribute__ ((packed))
52 #endif
53         ;
54
55 struct ao_pyro_1_24 {
56         enum ao_pyro_flag       flags;
57         int16_t                 accel_less, accel_greater;
58         int16_t                 speed_less, speed_greater;
59         int16_t                 height_less, height_greater;
60         int16_t                 orient_less, orient_greater;
61         int16_t                 time_less, time_greater;
62         int16_t                 delay;
63         uint8_t                 state_less, state_greater_or_equal;
64         int16_t                 motor;
65         uint16_t                delay_done;
66         uint8_t                 _unused;        /* was 'fired' */
67 };
68
69 struct ao_pyro {
70         enum ao_pyro_flag       flags;
71         int16_t                 accel_less, accel_greater;
72         int16_t                 speed_less, speed_greater;
73         int16_t                 height_less, height_greater;
74         int16_t                 orient_less, orient_greater;
75         int32_t                 time_less, time_greater;
76         int32_t                 delay;
77         uint8_t                 state_less, state_greater_or_equal;
78         int16_t                 motor;
79         int32_t                 delay_done;
80         uint8_t                 _unused;        /* was 'fired' */
81 };
82
83 #define AO_PYRO_8_BIT_VALUE     (ao_pyro_state_less|ao_pyro_state_greater_or_equal)
84 #define AO_PYRO_32_BIT_VALUE    (ao_pyro_time_less|ao_pyro_time_greater|ao_pyro_delay)
85
86 extern uint8_t  ao_pyro_wakeup;
87
88 extern uint16_t ao_pyro_fired;
89
90 void
91 ao_pyro_set(void);
92
93 void
94 ao_pyro_show(void);
95
96 void
97 ao_pyro_init(void);
98
99 void
100 ao_pyro_update_version(void);
101
102 void
103 ao_pyro_manual(uint8_t p);
104
105 enum ao_igniter_status
106 ao_pyro_status(uint8_t p);
107
108 void
109 ao_pyro_print_status(void);
110
111 #endif