Debian Codegraph @

src/telemetrum-v4.0-seeed/ao_pins.h

raw symbols SCIP
1 /*
2 * Copyright © 2022 Keith Packard <[email protected]>
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_PINS_H_
20 #define _AO_PINS_H_
21
22 #define AO_XOSC 1
23 #define AO_XOSC_FREQ 16000000
24 #define AO_XOSC_DIV 256
25 #define AO_XOSC_MUL 768
26
27 #define AO_AHB_PRESCALER 1
28 #define AO_APBA_PRESCALER 1
29
30 #define HAS_SERIAL_1 1
31 #define USE_SERIAL_1_STDIN 0
32
33 #define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX (512 * 1024)
34 #define AO_CONFIG_DEFAULT_ACCEL_PLUS_G -20
35 #define AO_CONFIG_DEFAULT_ACCEL_MINUS_G 20
36 #define AO_CONFIG_MAX_SIZE 1024
37 #define LOG_ERASE_MARK 0x55
38 #define LOG_MAX_ERASE 128
39 #define AO_LOG_FORMAT AO_LOG_FORMAT_TELEMETRUM
40
41 #define HAS_EEPROM 1
42 #define USE_INTERNAL_FLASH 0
43 #define USE_EEPROM_CONFIG 0
44 #define USE_STORAGE_CONFIG 1
45 #define HAS_USB 1
46 #define USE_USB_STDIO 1
47 #define HAS_BATTERY_REPORT 1
48 #define BEEPER_CHANNEL 4
49 #define BEEPER_TIMER 3
50 #define BEEPER_PORT (&samd21_port_a)
51 #define BEEPER_PIN 16
52 #define HAS_RADIO 1
53 #define HAS_RADIO_10MW 1
54 #define HAS_TELEMETRY 1
55 #define HAS_APRS 1
56 #define HAS_COMPANION 1
57
58 #define HAS_SPI_0 1
59 #define HAS_SPI_3 1
60 #define HAS_SPI_5 1
61
62 #define PACKET_HAS_SLAVE 1
63 #define PACKET_HAS_MASTER 0
64
65 #define LOW_LEVEL_DEBUG 0
66
67 #define HAS_LED 1
68 #define LED_0_PORT (&samd21_port_b)
69 #define LED_0_PIN 10
70 #define LED_1_PORT (&samd21_port_b)
71 #define LED_1_PIN 11
72 #define AO_LED_RED (1 << 0)
73 #define AO_LED_GREEN (1 << 1)
74
75 #define HAS_GPS 1
76 #define HAS_FLIGHT 1
77 #define HAS_ADC 1
78 #define HAS_ADC_TEMP 1
79 #define HAS_LOG 1
80
81 /*
82 * Beeper
83 */
84
85 #define HAS_BEEP 1
86 /* Beep on PA16 function E TCC2.0 */
87
88 #define AO_BEEP_TCC (&samd21_tcc2)
89 #define AO_BEEP_TCC_APBC_MASK SAMD21_PM_APBCMASK_TCC2
90 #define AO_BEEP_PORT (&samd21_port_a)
91 #define AO_BEEP_PIN (16)
92 #define AO_BEEP_FUNC SAMD21_PORT_PMUX_FUNC_E
93
94 /*
95 * Igniter
96 */
97
98 #define HAS_IGNITE 1
99 #define HAS_IGNITE_REPORT 1
100
101 #define AO_SENSE_DROGUE(p) ((p)->adc.sense_a)
102 #define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
103 #define AO_IGNITER_CLOSED 400
104 #define AO_IGNITER_OPEN 60
105
106 /* Drogue */
107 #define AO_IGNITER_DROGUE_PORT (&samd21_port_a)
108 #define AO_IGNITER_DROGUE_PIN 19
109
110 /* Main */
111 #define AO_IGNITER_MAIN_PORT (&samd21_port_a)
112 #define AO_IGNITER_MAIN_PIN 18
113
114 /*
115 * ADC
116 */
117 #define AO_DATA_RING 32
118 #define AO_ADC_NUM_SENSE 2
119
120 struct ao_adc {
121 int16_t sense_a;
122 int16_t sense_m;
123 int16_t v_batt;
124 int16_t temp;
125 };
126
127 #define AO_ADC_DUMP(p) \
128 printf("tick: %5lu drogue: %5d main: %5d batt: %5d\n", \
129 (p)->tick, \
130 (p)->adc.sense_a, (p)->adc.sense_m, \
131 (p)->adc.v_batt);
132
133 #define AO_ADC_SENSE_DROGUE 18
134 #define AO_ADC_SENSE_DROGUE_PORT (&samd21_port_a)
135 #define AO_ADC_SENSE_DROGUE_PIN 10
136
137 #define AO_ADC_SENSE_MAIN 19
138 #define AO_ADC_SENSE_MAIN_PORT (&samd21_port_a)
139 #define AO_ADC_SENSE_MAIN_PIN 11
140
141 #define AO_ADC_V_BATT 17
142 #define AO_ADC_V_BATT_PORT (&samd21_port_a)
143 #define AO_ADC_V_BATT_PIN 9
144
145 #define AO_ADC_TEMP SAMD21_ADC_INPUTCTRL_MUXPOS_TEMP
146
147 #define AO_NUM_ADC_PIN 3
148
149 #define AO_ADC_PIN0_PORT AO_ADC_SENSE_DROGUE_PORT
150 #define AO_ADC_PIN0_PIN AO_ADC_SENSE_DROGUE_PIN
151 #define AO_ADC_PIN1_PORT AO_ADC_SENSE_MAIN_PORT
152 #define AO_ADC_PIN1_PIN AO_ADC_SENSE_MAIN_PIN
153 #define AO_ADC_PIN2_PORT AO_ADC_V_BATT_PORT
154 #define AO_ADC_PIN2_PIN AO_ADC_V_BATT_PIN
155
156 #define AO_NUM_ADC (AO_NUM_ADC_PIN + 1)
157
158 #define AO_ADC_SQ0 AO_ADC_SENSE_DROGUE
159 #define AO_ADC_SQ1 AO_ADC_SENSE_MAIN
160 #define AO_ADC_SQ2 AO_ADC_V_BATT
161 #define AO_ADC_SQ3 AO_ADC_TEMP
162
163 /*
164 * Voltage divider on ADC battery sampler
165 */
166 #define AO_BATTERY_DIV_PLUS 56 /* 5.6k */
167 #define AO_BATTERY_DIV_MINUS 100 /* 10k */
168
169 /*
170 * Voltage divider on ADC igniter samplers
171 */
172 #define AO_IGNITE_DIV_PLUS 100 /* 100k */
173 #define AO_IGNITE_DIV_MINUS 27 /* 27k */
174
175 /*
176 * ADC reference in decivolts
177 */
178 #define AO_ADC_REFERENCE_DV 33
179
180 /*
181 * GPS
182 */
183
184 #define AO_SERIAL_SPEED_UBLOX AO_SERIAL_SPEED_9600
185 #define AO_UBLOX_VERSION 10
186
187 #define HAS_SERIAL_1 1
188 #define USE_SERIAL_1_STDIN 0
189 #define SERIAL_1_PA00_PA01 1
190
191 #define ao_gps_getchar ao_serial1_getchar
192 #define ao_gps_putchar ao_serial1_putchar
193 #define ao_gps_set_speed ao_serial1_set_speed
194 #define ao_gps_fifo (ao_samd21_usart1.rx_fifo)
195
196 /*
197 * Pressure sensor settings
198 */
199 #define HAS_MS5607 1
200 #define HAS_MS5611 0
201 #define AO_MS5607_PRIVATE_PINS 0
202 #define AO_MS5607_CS_PORT (&samd21_port_a)
203 #define AO_MS5607_CS_PIN 21
204 #define AO_MS5607_MISO_PORT (&samd21_port_a)
205 #define AO_MS5607_MISO_PIN 20
206 #define AO_MS5607_SPI_INDEX AO_SPI_3_PA22_PA23_PA20
207
208 /*
209 * SPI Flash memory
210 */
211
212 #define M25_MAX_CHIPS 1
213 #define AO_M25_SPI_CS_PORT (&samd21_port_a)
214 #define AO_M25_SPI_CS_MASK (1 << 27)
215 #define AO_M25_SPI_BUS AO_SPI_5_PB22_PB23_PB03
216
217
218 /*
219 * Radio (cc1200)
220 */
221
222 /* gets pretty close to 434.550 */
223
224 #define AO_RADIO_CAL_DEFAULT 5695733
225
226 #define AO_CC1200_SPI_CS_PORT (&samd21_port_a)
227 #define AO_CC1200_SPI_CS_PIN 7
228 #define AO_CC1200_SPI_BUS AO_SPI_5_PB22_PB23_PB03
229
230 #define AO_CC1200_INT_PORT (&samd21_port_b)
231 #define AO_CC1200_INT_PIN (8)
232 #define AO_CC1200_MCU_WAKEUP_PORT (&samd21_port_b)
233 #define AO_CC1200_MCU_WAKEUP_PIN (9)
234
235 #define AO_CC1200_INT_GPIO 2
236 #define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2
237
238 #define AO_CC1200_MARC_GPIO 3
239 #define AO_CC1200_MARC_GPIO_IOCFG CC1200_IOCFG3
240
241 #define HAS_BOOT_RADIO 0
242
243 #define HAS_HIGHG_ACCEL 1
244
245 /* ADXL375 */
246
247 #define HAS_ADXL375 1
248 #define AO_ADXL375_CS_PORT (&samd21_port_a)
249 #define AO_ADXL375_CS_PIN 8
250 #define AO_ADXL375_SPI_INDEX (AO_SPI_0_PA04_PA05_PA06 | AO_SPI_MODE_3)
251
252 #define AO_ADXL375_AXIS x
253 #define AO_ADXL375_INVERT 1
254
255 #define NUM_CMDS 16
256
257 /*
258 * Companion
259 */
260
261 #define AO_COMPANION_CS_PORT (&samd21_port_a)
262 #define AO_COMPANION_CS_PIN (13)
263 #define AO_COMPANION_SPI_BUS AO_SPI_5_PB22_PB23_PB03
264
265 /*
266 * Monitor
267 */
268
269 #define HAS_MONITOR 0
270 #define LEGACY_MONITOR 0
271 #define HAS_MONITOR_PUT 1
272 #define AO_MONITOR_LED 0
273 #define HAS_RSSI 0
274
275 /*
276 * Profiling Viterbi decoding
277 */
278
279 #ifndef AO_PROFILE
280 #define AO_PROFILE 0
281 #endif
282
283 #endif /* _AO_PINS_H_ */