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