altos: Shuffle LCO functions around, add telelco first cut
[fw/altos] / src / telelco-v0.1 / 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; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #ifndef _AO_PINS_H_
19 #define _AO_PINS_H_
20
21 /* 8MHz High speed external crystal */
22 #define AO_HSE                  8000000
23
24 /* PLLVCO = 96MHz (so that USB will work) */
25 #define AO_PLLMUL               12
26 #define AO_RCC_CFGR_PLLMUL      (STM_RCC_CFGR_PLLMUL_12)
27
28 /* SYSCLK = 32MHz (no need to go faster than CPU) */
29 #define AO_PLLDIV               3
30 #define AO_RCC_CFGR_PLLDIV      (STM_RCC_CFGR_PLLDIV_3)
31
32 /* HCLK = 32MHz (CPU clock) */
33 #define AO_AHB_PRESCALER        1
34 #define AO_RCC_CFGR_HPRE_DIV    STM_RCC_CFGR_HPRE_DIV_1
35
36 /* Run APB1 at 16MHz (HCLK/2) */
37 #define AO_APB1_PRESCALER       2
38 #define AO_RCC_CFGR_PPRE1_DIV   STM_RCC_CFGR_PPRE2_DIV_2
39
40 /* Run APB2 at 16MHz (HCLK/2) */
41 #define AO_APB2_PRESCALER       2
42 #define AO_RCC_CFGR_PPRE2_DIV   STM_RCC_CFGR_PPRE2_DIV_2
43
44 #define HAS_EEPROM              1
45 #define USE_INTERNAL_FLASH      1
46 #define HAS_USB                 1
47 #define HAS_BEEP                1
48 #define HAS_RADIO               1
49 #define HAS_TELEMETRY           0
50 #define HAS_AES                 1
51
52 #define HAS_SPI_1               1
53 #define SPI_1_PA5_PA6_PA7       1
54 #define SPI_1_PB3_PB4_PB5       0
55 #define SPI_1_PE13_PE14_PE15    0
56
57 #define HAS_SPI_2               1
58 #define SPI_2_PB13_PB14_PB15    1
59 #define SPI_2_PD1_PD3_PD4       0
60 #define SPI_2_GPIO              (&stm_gpiob)
61 #define SPI_2_SCK               13
62 #define SPI_2_MISO              14
63 #define SPI_2_MOSI              15
64
65 #define HAS_I2C_1               0
66
67 #define HAS_I2C_2               0
68
69 #define PACKET_HAS_SLAVE        0
70 #define PACKET_HAS_MASTER       0
71
72 /*
73  * Radio is a cc1111 connected via SPI
74  */
75 #define AO_RADIO_CAL_DEFAULT    1186611
76
77 #define AO_RADIO_SPI_BUS        AO_SPI_2_PB13_PB14_PB15
78 #define AO_RADIO_CS_PORT        (&stm_gpiob)
79 #define AO_RADIO_CS_PIN         12
80
81 #define AO_RADIO_INT_PORT       (&stm_gpioc)
82 #define AO_RADIO_INT_PIN        14
83
84 #define LOW_LEVEL_DEBUG         0
85
86 #define LED_PORT_ENABLE         STM_RCC_AHBENR_GPIOCEN
87 #define LED_PORT                (&stm_gpioc)
88 #define LED_PIN_RED             7
89 #define LED_PIN_GREEN           8
90 #define LED_PIN_CONTINUITY_3    9
91 #define LED_PIN_CONTINUITY_2    10
92 #define LED_PIN_CONTINUITY_1    11
93 #define LED_PIN_CONTINUITY_0    12
94 #define LED_PIN_REMOTE_ARM      13
95 #define AO_LED_RED              (1 << LED_PIN_RED)
96 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
97 #define AO_LED_CONTINUITY_3     (1 << LED_PIN_CONTINUITY_3)
98 #define AO_LED_CONTINUITY_2     (1 << LED_PIN_CONTINUITY_2)
99 #define AO_LED_CONTINUITY_1     (1 << LED_PIN_CONTINUITY_1)
100 #define AO_LED_CONTINUITY_0     (1 << LED_PIN_CONTINUITY_0)
101
102 #define AO_LED_CONTINUITY_NUM   4
103
104 #define AO_LED_REMOTE_ARM       (1 << LED_PIN_REMOTE_ARM)
105
106 #define LEDS_AVAILABLE          (AO_LED_RED |           \
107                                  AO_LED_GREEN |         \
108                                  AO_LED_CONTINUITY_3 |  \
109                                  AO_LED_CONTINUITY_2 |  \
110                                  AO_LED_CONTINUITY_1 |  \
111                                  AO_LED_CONTINUITY_0 |  \
112                                  AO_LED_REMOTE_ARM)
113
114 /* LCD displays */
115
116 #define AO_LCD_STM_SEG_ENABLED_0 (              \
117                 (1 << 0) | /* PA1 */            \
118                 (1 << 1) | /* PA2 */            \
119                 (1 << 2) | /* PA3 */            \
120                 (1 << 3) | /* PA6 */            \
121                 (1 << 4) | /* PA7 */            \
122                 (1 << 5) | /* PB0 */            \
123                 (1 << 6) | /* PB1 */            \
124                 (1 << 7) | /* PB3 */            \
125                 (0 << 8) | /* PB4 */            \
126                 (0 << 9) | /* PB5 */            \
127                 (0 << 10) | /* PB10 */          \
128                 (0 << 11) | /* PB11 */          \
129                 (0 << 12) | /* PB12 */          \
130                 (0 << 13) | /* PB13 */          \
131                 (0 << 14) | /* PB14 */          \
132                 (0 << 15) | /* PB15 */          \
133                 (0 << 16) | /* PB8 */           \
134                 (0 << 17) | /* PA15 */          \
135                 (0 << 18) | /* PC0 */           \
136                 (0 << 19) | /* PC1 */           \
137                 (0 << 20) | /* PC2 */           \
138                 (0 << 21) | /* PC3 */           \
139                 (0 << 22) | /* PC4 */           \
140                 (0 << 23) | /* PC5 */           \
141                 (0 << 24) | /* PC6 */           \
142                 (0 << 25) | /* PC7 */           \
143                 (0 << 26) | /* PC8 */           \
144                 (0 << 27) | /* PC9 */           \
145                 (0 << 28) | /* PC10 or PD8 */   \
146                 (0 << 29) | /* PC11 or PD9 */   \
147                 (0 << 30) | /* PC12 or PD10 */  \
148                 (0 << 31))  /* PD2 or PD11 */
149
150 #define AO_LCD_STM_SEG_ENABLED_1 (              \
151                 (0 << 0) | /* PD12 */           \
152                 (0 << 1) | /* PD13 */           \
153                 (0 << 2) | /* PD14 */           \
154                 (0 << 3) | /* PD15 */           \
155                 (0 << 4) | /* PE0 */            \
156                 (0 << 5) | /* PE1 */            \
157                 (0 << 6) | /* PE2 */            \
158                 (0 << 7))  /* PE3 */
159
160 #define AO_LCD_STM_COM_ENABLED (                \
161                 (1 << 0) | /* PA8 */            \
162                 (1 << 1) | /* PA9 */            \
163                 (1 << 2) | /* PA10 */           \
164                 (0 << 3) | /* PB9 */            \
165                 (0 << 4) | /* PC10 */           \
166                 (0 << 5) | /* PC11 */           \
167                 (0 << 6)) /* PC12 */
168
169 #define AO_LCD_28_ON_C  0
170
171 #define AO_LCD_DUTY     STM_LCD_CR_DUTY_1_4
172
173 #define AO_SEGMENT_0            0
174 #define AO_SEGMENT_1            5
175 #define AO_SEGMENT_2            1
176 #define AO_SEGMENT_3            6
177 #define AO_SEGMENT_4            4
178 #define AO_SEGMENT_5            2
179 #define AO_SEGMENT_6            3
180 #define AO_SEGMENT_7            7
181
182 /*
183  * Use event queue for input devices
184  */
185
186 #define AO_EVENT                1
187
188 /*
189  * Knobs
190  */
191
192 #define AO_QUADRATURE_COUNT     2
193 #define AO_QUADRATURE_MODE      0
194
195 #define AO_QUADRATURE_0_PORT    &stm_gpioc
196 #define AO_QUADRATURE_0_A       3
197 #define AO_QUADRATURE_0_B       2
198
199 #define AO_QUADRATURE_PAD       0
200
201 #define AO_QUADRATURE_1_PORT    &stm_gpioc
202 #define AO_QUADRATURE_1_A       1
203 #define AO_QUADRATURE_1_B       0
204
205 #define AO_QUADRATURE_BOX       1
206
207 /*
208  * Buttons
209  */
210
211 #define AO_BUTTON_COUNT         2
212 #define AO_BUTTON_MODE          AO_EXTI_MODE_PULL_UP
213
214 #define AO_BUTTON_0_PORT        &stm_gpioc
215 #define AO_BUTTON_0             4
216
217 #define AO_BUTTON_ARM           0
218
219 #define AO_BUTTON_1_PORT        &stm_gpioc
220 #define AO_BUTTON_1             5
221
222 #define AO_BUTTON_FIRE          1
223
224 #endif /* _AO_PINS_H_ */