altos: Switch all tick variables to AO_TICK_TYPE/AO_TICK_SIGNED
[fw/altos] / src / stm-vga / 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 /* Bridge SB17 on the board and use the MCO from the other chip */
23 #define AO_HSE                  8000000
24 #define AO_HSE_BYPASS           1
25
26 /* PLLVCO = 96MHz (so that USB will work) */
27 #define AO_PLLMUL               12
28 #define AO_RCC_CFGR_PLLMUL      (STM_RCC_CFGR_PLLMUL_12)
29
30 /* SYSCLK = 24MHz */
31 #define AO_PLLDIV               4
32 #define AO_RCC_CFGR_PLLDIV      (STM_RCC_CFGR_PLLDIV_4)
33
34 /* HCLK = 24MHZ (CPU clock) */
35 #define AO_AHB_PRESCALER        1
36 #define AO_RCC_CFGR_HPRE_DIV    STM_RCC_CFGR_HPRE_DIV_1
37
38 /* Run APB1 at HCLK/1 */
39 #define AO_APB1_PRESCALER       1
40 #define AO_RCC_CFGR_PPRE1_DIV   STM_RCC_CFGR_PPRE2_DIV_1
41
42 /* Run APB2 at HCLK/1 */
43 #define AO_APB2_PRESCALER       1
44 #define AO_RCC_CFGR_PPRE2_DIV   STM_RCC_CFGR_PPRE2_DIV_1
45
46 /* Allow for non-maskable interrupts at priority 0 */
47 #define AO_NONMASK_INTERRUPT    1
48
49 #define HAS_SERIAL_1            0
50 #define USE_SERIAL_1_STDIN      0
51 #define SERIAL_1_PB6_PB7        1
52 #define SERIAL_1_PA9_PA10       0
53
54 #define HAS_SERIAL_2            0
55 #define USE_SERIAL_2_STDIN      0
56 #define SERIAL_2_PA2_PA3        0
57 #define SERIAL_2_PD5_PD6        1
58
59 #define HAS_SERIAL_3            0
60 #define USE_SERIAL_3_STDIN      1
61 #define SERIAL_3_PB10_PB11      0
62 #define SERIAL_3_PC10_PC11      0
63 #define SERIAL_3_PD8_PD9        1
64
65 #define HAS_SPI_1               0
66 #define SPI_1_PB3_PB4_PB5       1
67 #define SPI_1_OSPEEDR           STM_OSPEEDR_10MHz
68
69 #define HAS_SPI_2               0
70
71 #define HAS_USB                 1
72 #define HAS_BEEP                0
73 #define PACKET_HAS_SLAVE        0
74
75 #define CONSOLE_STDIN           1
76
77 #define AO_STACK_SIZE           1024
78
79 #define STM_DMA1_3_STOLEN       1
80
81 #define AO_BOOT_CHAIN           1
82
83 #define LOW_LEVEL_DEBUG         0
84
85 #define LED_PORT_ENABLE         STM_RCC_AHBENR_GPIOBEN
86 #define LED_PORT                (&stm_gpiob)
87 #define LED_PIN_GREEN           7
88 #define LED_PIN_BLUE            6
89 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
90 #define AO_LED_BLUE             (1 << LED_PIN_BLUE)
91 #define AO_LED_PANIC            AO_LED_BLUE
92
93 #define LEDS_AVAILABLE          (AO_LED_BLUE | AO_LED_GREEN)
94
95 #define AO_LCD_STM_SEG_ENABLED_0 (              \
96                 (1 << 0) | /* PA1 */            \
97                 (1 << 1) | /* PA2 */            \
98                 (1 << 2) | /* PA3 */            \
99                 (0 << 3) | /* PA6 */            \
100                 (0 << 4) | /* PA7 */            \
101                 (0 << 5) | /* PB0 */            \
102                 (0 << 6) | /* PB1 */            \
103                 (1 << 7) | /* PB3 */            \
104                 (1 << 8) | /* PB4 */            \
105                 (1 << 9) | /* PB5 */            \
106                 (1 << 10) | /* PB10 */          \
107                 (1 << 11) | /* PB11 */          \
108                 (1 << 12) | /* PB12 */          \
109                 (1 << 13) | /* PB13 */          \
110                 (1 << 14) | /* PB14 */          \
111                 (1 << 15) | /* PB15 */          \
112                 (1 << 16) | /* PB8 */           \
113                 (1 << 17) | /* PA15 */          \
114                 (1 << 18) | /* PC0 */           \
115                 (1 << 19) | /* PC1 */           \
116                 (1 << 20) | /* PC2 */           \
117                 (1 << 21) | /* PC3 */           \
118                 (0 << 22) | /* PC4 */           \
119                 (0 << 23) | /* PC5 */           \
120                 (1 << 24) | /* PC6 */           \
121                 (1 << 25) | /* PC7 */           \
122                 (1 << 26) | /* PC8 */           \
123                 (1 << 27) | /* PC9 */           \
124                 (1 << 28) | /* PC10 or PD8 */   \
125                 (1 << 29) | /* PC11 or PD9 */   \
126                 (0 << 30) | /* PC12 or PD10 */  \
127                 (0 << 31))  /* PD2 or PD11 */
128
129 #define AO_LCD_STM_SEG_ENABLED_1 (              \
130                 (0 << 0) | /* PD12 */           \
131                 (0 << 1) | /* PD13 */           \
132                 (0 << 2) | /* PD14 */           \
133                 (0 << 3) | /* PD15 */           \
134                 (0 << 4) | /* PE0 */            \
135                 (0 << 5) | /* PE1 */            \
136                 (0 << 6) | /* PE2 */            \
137                 (0 << 7))  /* PE3 */
138
139 #define AO_LCD_STM_COM_ENABLED (                \
140                 (1 << 0) | /* PA8 */            \
141                 (1 << 1) | /* PA9 */            \
142                 (1 << 2) | /* PA10 */           \
143                 (1 << 3) | /* PB9 */            \
144                 (0 << 4) | /* PC10 */           \
145                 (0 << 5) | /* PC11 */           \
146                 (0 << 6)) /* PC12 */
147
148 #define AO_LCD_28_ON_C  1
149
150 #define AO_LCD_DUTY     STM_LCD_CR_DUTY_STATIC
151
152 #define HAS_ADC                 1
153
154 #define AO_ADC_RING             32
155
156 struct ao_adc {
157         AO_TICK_TYPE            tick;
158         int16_t                 idd;
159         int16_t                 temp;
160         int16_t                 vref;
161 };
162
163 #define AO_ADC_IDD              4
164 #define AO_ADC_PIN0_PORT        (&stm_gpioa)
165 #define AO_ADC_PIN0_PIN         4
166
167 #define AO_ADC_RCC_AHBENR       ((1 << STM_RCC_AHBENR_GPIOAEN))
168 #define AO_ADC_TEMP             16
169 #define AO_ADC_VREF             17
170
171 #define HAS_ADC_TEMP            1
172
173 #define AO_DATA_RING            32
174 #define AO_NUM_ADC              3
175
176 #define AO_ADC_SQ1              AO_ADC_IDD
177 #define AO_ADC_SQ2              AO_ADC_TEMP
178 #define AO_ADC_SQ3              AO_ADC_VREF
179         
180 #define HAS_I2C_1               1
181 #define I2C_1_PB6_PB7           0
182 #define I2C_1_PB8_PB9           1
183
184 #define HAS_I2C_2               0
185 #define I2C_2_PB10_PB11         0
186
187 #define AO_EVENT                1
188
189 #define AO_QUADRATURE_COUNT     2
190 #define AO_QUADRATURE_MODE      AO_EXTI_MODE_PULL_UP
191
192 #define AO_QUADRATURE_0_PORT    &stm_gpioc
193 #define AO_QUADRATURE_0_A       1
194 #define AO_QUADRATURE_0_B       0
195
196 #define AO_QUADRATURE_1_PORT    &stm_gpioc
197 #define AO_QUADRATURE_1_A       3
198 #define AO_QUADRATURE_1_B       2
199
200 #define AO_BUTTON_COUNT         2
201 #define AO_BUTTON_MODE          AO_EXTI_MODE_PULL_UP
202
203 #define AO_BUTTON_0_PORT        &stm_gpioc
204 #define AO_BUTTON_0             6
205
206 #define AO_BUTTON_1_PORT        &stm_gpioc
207 #define AO_BUTTON_1             7
208
209 #define AO_TICK_TYPE            uint32_t
210 #define AO_TICK_SIGNED          int32_t
211
212 #define AO_PS2_CLOCK_PORT       (&stm_gpioc)
213 #define AO_PS2_CLOCK_BIT        0
214
215 #define AO_PS2_DATA_PORT        (&stm_gpioc)
216 #define AO_PS2_DATA_BIT         1
217
218 #endif /* _AO_PINS_H_ */