Merge remote-tracking branch 'mjb/altosdroid'
[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               0
53 #define SPI_1_PA5_PA6_PA7       0
54 #define SPI_1_PB3_PB4_PB5       0
55 #define SPI_1_PE13_PE14_PE15    0
56
57 #define HAS_SPI_2               1       /* CC1111 */
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 #define SPI_2_OSPEEDR           STM_OSPEEDR_10MHz
65
66 #define HAS_I2C_1               0
67
68 #define HAS_I2C_2               0
69
70 #define PACKET_HAS_SLAVE        0
71 #define PACKET_HAS_MASTER       0
72
73 /*
74  * Radio is a cc1111 connected via SPI
75  */
76 #define AO_RADIO_CAL_DEFAULT    1186611
77
78 #define AO_RADIO_SPI_BUS        AO_SPI_2_PB13_PB14_PB15
79 #define AO_RADIO_CS_PORT        (&stm_gpiob)
80 #define AO_RADIO_CS_PIN         12
81
82 #define AO_RADIO_INT_PORT       (&stm_gpioc)
83 #define AO_RADIO_INT_PIN        14
84
85 #define LOW_LEVEL_DEBUG         0
86
87 #define LED_PORT_ENABLE         STM_RCC_AHBENR_GPIOCEN
88 #define LED_PORT                (&stm_gpioc)
89 #define LED_PIN_RED             7
90 #define LED_PIN_GREEN           8
91 #define LED_PIN_CONTINUITY_3    9
92 #define LED_PIN_CONTINUITY_2    10
93 #define LED_PIN_CONTINUITY_1    11
94 #define LED_PIN_CONTINUITY_0    12
95 #define LED_PIN_REMOTE_ARM      13
96 #define AO_LED_RED              (1 << LED_PIN_RED)
97 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
98 #define AO_LED_CONTINUITY_3     (1 << LED_PIN_CONTINUITY_3)
99 #define AO_LED_CONTINUITY_2     (1 << LED_PIN_CONTINUITY_2)
100 #define AO_LED_CONTINUITY_1     (1 << LED_PIN_CONTINUITY_1)
101 #define AO_LED_CONTINUITY_0     (1 << LED_PIN_CONTINUITY_0)
102
103 #define AO_LED_CONTINUITY_NUM   4
104
105 #define AO_LED_REMOTE_ARM       (1 << LED_PIN_REMOTE_ARM)
106
107 #define LEDS_AVAILABLE          (AO_LED_RED |           \
108                                  AO_LED_GREEN |         \
109                                  AO_LED_CONTINUITY_3 |  \
110                                  AO_LED_CONTINUITY_2 |  \
111                                  AO_LED_CONTINUITY_1 |  \
112                                  AO_LED_CONTINUITY_0 |  \
113                                  AO_LED_REMOTE_ARM)
114
115 /* LCD displays */
116
117 #define AO_LCD_STM_SEG_ENABLED_0 (              \
118                 (1 << 0) | /* PA1 */            \
119                 (1 << 1) | /* PA2 */            \
120                 (1 << 2) | /* PA3 */            \
121                 (1 << 3) | /* PA6 */            \
122                 (1 << 4) | /* PA7 */            \
123                 (1 << 5) | /* PB0 */            \
124                 (1 << 6) | /* PB1 */            \
125                 (1 << 7) | /* PB3 */            \
126                 (0 << 8) | /* PB4 */            \
127                 (0 << 9) | /* PB5 */            \
128                 (0 << 10) | /* PB10 */          \
129                 (0 << 11) | /* PB11 */          \
130                 (0 << 12) | /* PB12 */          \
131                 (0 << 13) | /* PB13 */          \
132                 (0 << 14) | /* PB14 */          \
133                 (0 << 15) | /* PB15 */          \
134                 (0 << 16) | /* PB8 */           \
135                 (0 << 17) | /* PA15 */          \
136                 (0 << 18) | /* PC0 */           \
137                 (0 << 19) | /* PC1 */           \
138                 (0 << 20) | /* PC2 */           \
139                 (0 << 21) | /* PC3 */           \
140                 (0 << 22) | /* PC4 */           \
141                 (0 << 23) | /* PC5 */           \
142                 (0 << 24) | /* PC6 */           \
143                 (0 << 25) | /* PC7 */           \
144                 (0 << 26) | /* PC8 */           \
145                 (0 << 27) | /* PC9 */           \
146                 (0 << 28) | /* PC10 or PD8 */   \
147                 (0 << 29) | /* PC11 or PD9 */   \
148                 (0 << 30) | /* PC12 or PD10 */  \
149                 (0 << 31))  /* PD2 or PD11 */
150
151 #define AO_LCD_STM_SEG_ENABLED_1 (              \
152                 (0 << 0) | /* PD12 */           \
153                 (0 << 1) | /* PD13 */           \
154                 (0 << 2) | /* PD14 */           \
155                 (0 << 3) | /* PD15 */           \
156                 (0 << 4) | /* PE0 */            \
157                 (0 << 5) | /* PE1 */            \
158                 (0 << 6) | /* PE2 */            \
159                 (0 << 7))  /* PE3 */
160
161 #define AO_LCD_STM_COM_ENABLED (                \
162                 (1 << 0) | /* PA8 */            \
163                 (1 << 1) | /* PA9 */            \
164                 (1 << 2) | /* PA10 */           \
165                 (0 << 3) | /* PB9 */            \
166                 (0 << 4) | /* PC10 */           \
167                 (0 << 5) | /* PC11 */           \
168                 (0 << 6)) /* PC12 */
169
170 #define AO_LCD_28_ON_C  0
171
172 #define AO_LCD_DUTY     STM_LCD_CR_DUTY_1_4
173
174 #define AO_SEGMENT_0            0
175 #define AO_SEGMENT_1            5
176 #define AO_SEGMENT_2            1
177 #define AO_SEGMENT_3            6
178 #define AO_SEGMENT_4            4
179 #define AO_SEGMENT_5            2
180 #define AO_SEGMENT_6            3
181 #define AO_SEGMENT_7            7
182
183 /*
184  * Use event queue for input devices
185  */
186
187 #define AO_EVENT                1
188
189 /*
190  * Knobs
191  */
192
193 #define AO_QUADRATURE_COUNT     2
194 #define AO_QUADRATURE_MODE      0
195
196 #define AO_QUADRATURE_0_PORT    &stm_gpioc
197 #define AO_QUADRATURE_0_A       3
198 #define AO_QUADRATURE_0_B       2
199
200 #define AO_QUADRATURE_PAD       0
201
202 #define AO_QUADRATURE_1_PORT    &stm_gpioc
203 #define AO_QUADRATURE_1_A       1
204 #define AO_QUADRATURE_1_B       0
205
206 #define AO_QUADRATURE_BOX       1
207
208 /*
209  * Buttons
210  */
211
212 #define AO_BUTTON_COUNT         2
213 #define AO_BUTTON_MODE          AO_EXTI_MODE_PULL_UP
214
215 #define AO_BUTTON_0_PORT        &stm_gpioc
216 #define AO_BUTTON_0             4
217
218 #define AO_BUTTON_ARM           0
219
220 #define AO_BUTTON_1_PORT        &stm_gpioc
221 #define AO_BUTTON_1             5
222
223 #define AO_BUTTON_FIRE          1
224
225 #endif /* _AO_PINS_H_ */