45c6891d8ad790c8b8b3c32090f89cf38db0033f
[fw/altos] / src / easymini-v1.0 / ao_pins.h
1 /*
2  * Copyright © 2013 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 #define HAS_BEEP                1
20 #define HAS_BATTERY_REPORT      1
21
22 #define AO_STACK_SIZE   376
23
24 #define IS_FLASH_LOADER 0
25
26 /* Crystal on the board */
27 #define AO_LPC_CLKIN    12000000
28
29 /* Main clock frequency. 48MHz for USB so we don't use the USB PLL */
30 #define AO_LPC_CLKOUT   48000000
31
32 /* System clock frequency */
33 #define AO_LPC_SYSCLK   24000000
34
35 #define HAS_USB         1
36
37 #define HAS_USB_CONNECT 0
38 #define HAS_USB_VBUS    0
39 #define HAS_USB_PULLUP  1
40 #define AO_USB_PULLUP_PORT      0
41 #define AO_USB_PULLUP_PIN       20
42
43 #define PACKET_HAS_SLAVE        0
44
45 #define AO_LOG_FORMAT           AO_LOG_FORMAT_EASYMINI1
46
47 /* USART */
48
49 #define HAS_SERIAL              0
50 #define USE_SERIAL_0_STDIN      1
51 #define SERIAL_0_18_19          1
52 #define SERIAL_0_14_15          0
53 #define SERIAL_0_17_18          0
54 #define SERIAL_0_26_27          0
55
56 /* SPI */
57
58 #define HAS_SPI_0               1
59 #define SPI_SCK0_P0_6           1
60 #define HAS_SPI_1               1
61 #define SPI_SCK1_P1_15          1
62 #define SPI_MISO1_P0_22         1
63 #define SPI_MOSI1_P0_21         1
64
65 /* M25 */
66
67 #define M25_MAX_CHIPS           1
68 #define AO_M25_SPI_CS_PORT      0
69 #define AO_M25_SPI_CS_MASK      (1 << 23)
70 #define AO_M25_SPI_BUS          1
71
72 /* MS5607 */
73
74 #define HAS_MS5607              1
75 #define HAS_MS5611              0
76 #define AO_MS5607_PRIVATE_PINS  0
77 #define AO_MS5607_CS_PORT       0
78 #define AO_MS5607_CS_PIN        7
79 #define AO_MS5607_CS_MASK       (1 << AO_MS5607_CS_PIN)
80 #define AO_MS5607_MISO_PORT     0
81 #define AO_MS5607_MISO_PIN      8
82 #define AO_MS5607_MISO_MASK     (1 << AO_MS5607_MISO_PIN)
83 #define AO_MS5607_SPI_INDEX     0
84
85 #define HAS_ACCEL               0
86 #define HAS_GPS                 0
87 #define HAS_RADIO               0
88 #define HAS_FLIGHT              1
89 #define HAS_EEPROM              1
90 #define HAS_TELEMETRY           0
91 #define HAS_APRS                0
92 #define HAS_LOG                 1
93 #define USE_INTERNAL_FLASH      0
94 #define HAS_IGNITE              1
95 #define HAS_IGNITE_REPORT       1
96
97 #define AO_DATA_RING            16
98
99 /*
100  * ADC
101  */
102
103 #define HAS_ADC                 1
104
105 #define AO_NUM_ADC              3
106
107 #define AO_ADC_0                1
108 #define AO_ADC_1                1
109 #define AO_ADC_2                1
110
111 struct ao_adc {
112         int16_t         sense_a;
113         int16_t         sense_m;
114         int16_t         v_batt;
115 };
116
117 /*
118  * Igniter
119  */
120
121 #define AO_IGNITER_CLOSED       400
122 #define AO_IGNITER_OPEN         60
123
124 #define AO_IGNITER_DROGUE_PORT  0
125 #define AO_IGNITER_DROGUE_PIN   2
126 #define AO_IGNITER_SET_DROGUE(v)        ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v)
127
128 #define AO_IGNITER_MAIN_PORT    0
129 #define AO_IGNITER_MAIN_PIN     3
130 #define AO_IGNITER_SET_MAIN(v)          ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v)
131
132 #define AO_SENSE_DROGUE(p)      ((p)->adc.sense_a)
133 #define AO_SENSE_MAIN(p)        ((p)->adc.sense_m)
134
135 #define AO_ADC_DUMP(p) \
136         printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \
137                (p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt)
138
139 /*
140  * Voltage divider on ADC battery sampler
141  */
142 #define AO_BATTERY_DIV_PLUS     100     /* 100k */
143 #define AO_BATTERY_DIV_MINUS    27      /* 27k */
144
145 /*
146  * Voltage divider on ADC igniter samplers
147  */
148 #define AO_IGNITE_DIV_PLUS      100     /* 100k */
149 #define AO_IGNITE_DIV_MINUS     27      /* 27k */
150
151 /*
152  * ADC reference in decivolts
153  */
154 #define AO_ADC_REFERENCE_DV     33