altos/stm: Make beeper driver support all possible tim234 configs
[fw/altos] / src / telelco-v0.3 / ao_pins.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_PINS_H_
20 #define _AO_PINS_H_
21
22 /* 8MHz High speed external crystal */
23 #define AO_HSE                  8000000
24
25 /* PLLVCO = 96MHz (so that USB will work) */
26 #define AO_PLLMUL               12
27 #define AO_RCC_CFGR_PLLMUL      (STM_RCC_CFGR_PLLMUL_12)
28
29 #define AO_CC1200_FOSC          40000000
30
31 /* SYSCLK = 32MHz (no need to go faster than CPU) */
32 #define AO_PLLDIV               3
33 #define AO_RCC_CFGR_PLLDIV      (STM_RCC_CFGR_PLLDIV_3)
34
35 /* HCLK = 32MHz (CPU clock) */
36 #define AO_AHB_PRESCALER        1
37 #define AO_RCC_CFGR_HPRE_DIV    STM_RCC_CFGR_HPRE_DIV_1
38
39 /* Run APB1 at 16MHz (HCLK/2) */
40 #define AO_APB1_PRESCALER       2
41 #define AO_RCC_CFGR_PPRE1_DIV   STM_RCC_CFGR_PPRE2_DIV_2
42
43 /* Run APB2 at 16MHz (HCLK/2) */
44 #define AO_APB2_PRESCALER       2
45 #define AO_RCC_CFGR_PPRE2_DIV   STM_RCC_CFGR_PPRE2_DIV_2
46
47 #define HAS_EEPROM              1
48 #define USE_INTERNAL_FLASH      1
49 #define USE_EEPROM_CONFIG       1
50 #define USE_STORAGE_CONFIG      0
51 #define HAS_USB                 1
52 #define HAS_BEEP                1
53 #define BEEPER_TIMER            3
54 #define BEEPER_CHANNEL          1
55 #define BEEPER_PORT             (&stm_gpioc)
56 #define BEEPER_PIN              6
57 #define HAS_RADIO               1
58 #define HAS_RADIO_RATE          1
59 #define HAS_TELEMETRY           0
60 #define HAS_AES                 1
61 #define HAS_STATIC_TEST         0
62
63
64 #define HAS_SPI_1               0
65 #define SPI_1_PA5_PA6_PA7       0
66 #define SPI_1_PB3_PB4_PB5       0
67 #define SPI_1_PE13_PE14_PE15    0
68
69 #define HAS_SPI_2               1       /* CC1120 */
70 #define SPI_2_PB13_PB14_PB15    0
71 #define SPI_2_PD1_PD3_PD4       1
72 #define SPI_2_GPIO              (&stm_gpiod)
73 #define SPI_2_SCK               1
74 #define SPI_2_MISO              3
75 #define SPI_2_MOSI              4
76 #define SPI_2_OSPEEDR           STM_OSPEEDR_10MHz
77
78 #define HAS_I2C_1               0
79
80 #define HAS_I2C_2               0
81
82 #define PACKET_HAS_SLAVE        0
83 #define PACKET_HAS_MASTER       0
84
85 #define FAST_TIMER_FREQ         10000   /* .1ms for debouncing */
86
87 /*
88  * Radio is a cc1200 connected via SPI
89  */
90
91 #define AO_RADIO_CAL_DEFAULT    5695733
92
93 #define AO_FEC_DEBUG            0
94 #define AO_CC1200_SPI_CS_PORT   (&stm_gpiod)
95 #define AO_CC1200_SPI_CS_PIN    0
96 #define AO_CC1200_SPI_BUS       AO_SPI_2_PD1_PD3_PD4
97 #define AO_CC1200_SPI           stm_spi2
98 #define AO_CC1200_SPI_SPEED     AO_SPI_SPEED_FAST
99
100 #define AO_CC1200_INT_PORT              (&stm_gpioc)
101 #define AO_CC1200_INT_PIN               (15)
102
103 #define AO_CC1200_INT_GPIO      2
104 #define AO_CC1200_INT_GPIO_IOCFG        CC1200_IOCFG2
105
106 #define LOW_LEVEL_DEBUG         0
107
108 #define LED_PORT_ENABLE         STM_RCC_AHBENR_GPIOCEN
109 #define LED_PORT                (&stm_gpioc)
110 #define LED_PIN_RED             7
111 #define LED_PIN_AMBER           8
112 #define LED_PIN_GREEN           9
113 #define LED_PIN_CONTINUITY_3    10
114 #define LED_PIN_CONTINUITY_2    11
115 #define LED_PIN_CONTINUITY_1    12
116 #define LED_PIN_CONTINUITY_0    13
117 #define LED_PIN_REMOTE_ARM      14
118 #define AO_LED_RED              (1 << LED_PIN_RED)
119 #define AO_LED_AMBER            (1 << LED_PIN_AMBER)
120 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
121 #define AO_LED_CONTINUITY_3     (1 << LED_PIN_CONTINUITY_3)
122 #define AO_LED_CONTINUITY_2     (1 << LED_PIN_CONTINUITY_2)
123 #define AO_LED_CONTINUITY_1     (1 << LED_PIN_CONTINUITY_1)
124 #define AO_LED_CONTINUITY_0     (1 << LED_PIN_CONTINUITY_0)
125
126 #define AO_LED_CONTINUITY_NUM   4
127
128 #define AO_LED_REMOTE_ARM       (1 << LED_PIN_REMOTE_ARM)
129
130 #define LEDS_AVAILABLE          (AO_LED_RED |           \
131                                  AO_LED_AMBER |         \
132                                  AO_LED_GREEN |         \
133                                  AO_LED_CONTINUITY_3 |  \
134                                  AO_LED_CONTINUITY_2 |  \
135                                  AO_LED_CONTINUITY_1 |  \
136                                  AO_LED_CONTINUITY_0 |  \
137                                  AO_LED_REMOTE_ARM)
138
139 /* LCD displays */
140
141 #define LCD_DEBUG               0
142 #define SEVEN_SEGMENT_DEBUG     0
143
144 #define AO_LCD_STM_SEG_ENABLED_0 (              \
145                 (1 << 0) | /* PA1 */            \
146                 (1 << 1) | /* PA2 */            \
147                 (1 << 2) | /* PA3 */            \
148                 (1 << 3) | /* PA6 */            \
149                 (1 << 4) | /* PA7 */            \
150                 (1 << 5) | /* PB0 */            \
151                 (1 << 6) | /* PB1 */            \
152                 (1 << 7) | /* PB3 */            \
153                 (1 << 8) | /* PB4 */            \
154                 (1 << 9) | /* PB5 */            \
155                 (1 << 10) | /* PB10 */          \
156                 (1 << 11) | /* PB11 */          \
157                 (1 << 12) | /* PB12 */          \
158                 (1 << 13) | /* PB13 */          \
159                 (1 << 14) | /* PB14 */          \
160                 (1 << 15) | /* PB15 */          \
161                 (1 << 16) | /* PB8 */           \
162                 (1 << 17) | /* PA15 */          \
163                 (1 << 18) | /* PC0 */           \
164                 (1 << 19) | /* PC1 */           \
165                 (1 << 20) | /* PC2 */           \
166                 (1 << 21) | /* PC3 */           \
167                 (1 << 22) | /* PC4 */           \
168                 (1 << 23) | /* PC5 */           \
169                 (0 << 24) | /* PC6 */           \
170                 (0 << 25) | /* PC7 */           \
171                 (0 << 26) | /* PC8 */           \
172                 (0 << 27) | /* PC9 */           \
173                 (0 << 28) | /* PC10 or PD8 */   \
174                 (0 << 29) | /* PC11 or PD9 */   \
175                 (0 << 30) | /* PC12 or PD10 */  \
176                 (0 << 31))  /* PD2 or PD11 */
177
178 #define AO_LCD_STM_SEG_ENABLED_1 (              \
179                 (0 << 0) | /* PD12 */           \
180                 (0 << 1) | /* PD13 */           \
181                 (0 << 2) | /* PD14 */           \
182                 (0 << 3) | /* PD15 */           \
183                 (0 << 4) | /* PE0 */            \
184                 (0 << 5) | /* PE1 */            \
185                 (0 << 6) | /* PE2 */            \
186                 (0 << 7))  /* PE3 */
187
188 #define AO_LCD_STM_COM_ENABLED (                \
189                 (1 << 0) | /* PA8 */            \
190                 (0 << 1) | /* PA9 */            \
191                 (0 << 2) | /* PA10 */           \
192                 (0 << 3) | /* PB9 */            \
193                 (0 << 4) | /* PC10 */           \
194                 (0 << 5) | /* PC11 */           \
195                 (0 << 6)) /* PC12 */
196
197 #define AO_LCD_28_ON_C  0
198
199 #define AO_LCD_DUTY     STM_LCD_CR_DUTY_STATIC
200
201 #define AO_LCD_PER_DIGIT        1
202
203 #define AO_LCD_DIGITS           3
204 #define AO_LCD_SEGMENTS         8
205
206 #define AO_SEGMENT_MAP {                        \
207                 /* pad segments */              \
208                 { 0, 14 },                      \
209                 { 0, 13 },                      \
210                 { 0, 15 },                      \
211                 { 0, 17 },                      \
212                 { 0, 16 },                      \
213                 { 0, 8 },                       \
214                 { 0, 9 },                       \
215                 { 0, 7 },                       \
216                 /* box1 segments */             \
217                 { 0, 10 },                      \
218                 { 0, 6 },                       \
219                 { 0, 11 },                      \
220                 { 0, 12 },                      \
221                 { 0, 21 },                      \
222                 { 0, 19 },                      \
223                 { 0, 20 },                      \
224                 { 0, 18 },                      \
225                 /* box0 segments */             \
226                 { 0, 22 },                      \
227                 { 0, 4 },                       \
228                 { 0, 23 },                      \
229                 { 0, 5 },                       \
230                 { 0, 3 },                       \
231                 { 0, 1 },                       \
232                 { 0, 2 },                       \
233                 { 0, 0 },                       \
234 }
235
236 /*
237  * Use event queue for input devices
238  */
239
240 #define AO_EVENT                1
241
242 /*
243  * Knobs
244  */
245
246 #define AO_QUADRATURE_COUNT     2
247
248 #define AO_QUADRATURE_0_PORT    &stm_gpioe
249 #define AO_QUADRATURE_0_A       3
250 #define AO_QUADRATURE_0_B       2
251
252 #define AO_QUADRATURE_PAD       0
253
254 #define AO_QUADRATURE_1_PORT    &stm_gpioe
255 #define AO_QUADRATURE_1_A       1
256 #define AO_QUADRATURE_1_B       0
257
258 #define AO_QUADRATURE_BOX       1
259 #define AO_QUADRATURE_DEBOUNCE  10
260
261 /*
262  * Buttons
263  */
264
265 #define AO_BUTTON_COUNT         2
266 #define AO_BUTTON_MODE          AO_EXTI_MODE_PULL_UP
267
268 #define AO_BUTTON_0_PORT        &stm_gpioe
269 #define AO_BUTTON_0             4
270
271 #define AO_BUTTON_ARM           0
272
273 #define AO_BUTTON_1_PORT        &stm_gpioe
274 #define AO_BUTTON_1             5
275
276 #define AO_BUTTON_FIRE          1
277
278 #endif /* _AO_PINS_H_ */