altos: Add ADC tests to stm-demo
[fw/altos] / src / stm-demo / 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 #define HAS_SERIAL_1            1
22 #define USE_SERIAL_1_STDIN      1
23 #define SERIAL_1_PB6_PB7        1
24 #define SERIAL_1_PA9_PA10       0
25
26 #define HAS_SERIAL_2            0
27 #define USE_SERIAL_2_STDIN      1
28 #define SERIAL_2_PA2_PA3        0
29 #define SERIAL_2_PD5_PD6        1
30
31 #define HAS_SERIAL_3            0
32 #define USE_SERIAL_3_STDIN      1
33 #define SERIAL_3_PB10_PB11      0
34 #define SERIAL_3_PC10_PC11      0
35 #define SERIAL_3_PD8_PD9        1
36
37 #define HAS_SPI_1               1
38 #define SPI_1_PB3_PB4_PB5       1
39
40 #define HAS_SPI_2               0
41
42 #define HAS_USB                 0
43 #define HAS_BEEP                0
44 #define PACKET_HAS_SLAVE        0
45
46 #define LOW_LEVEL_DEBUG         1
47
48 #define LED_PORT_ENABLE         STM_RCC_AHBENR_GPIOBEN
49 #define LED_PORT                stm_gpiob
50 #define LED_PIN_GREEN           7
51 #define LED_PIN_BLUE            6
52 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
53 #define AO_LED_BLUE             (1 << LED_PIN_BLUE)
54
55 #define AO_LED_RED              AO_LED_BLUE     /* a patent lie */
56
57 #define LEDS_AVAILABLE          (AO_LED_BLUE | AO_LED_GREEN)
58
59 #define AO_LCD_STM_SEG_ENABLED_0 (              \
60                 (1 << 0) | /* PA1 */            \
61                 (1 << 1) | /* PA2 */            \
62                 (1 << 2) | /* PA3 */            \
63                 (0 << 3) | /* PA6 */            \
64                 (0 << 4) | /* PA7 */            \
65                 (0 << 5) | /* PB0 */            \
66                 (0 << 6) | /* PB1 */            \
67                 (1 << 7) | /* PB3 */            \
68                 (1 << 8) | /* PB4 */            \
69                 (1 << 9) | /* PB5 */            \
70                 (1 << 10) | /* PB10 */          \
71                 (1 << 11) | /* PB11 */          \
72                 (1 << 12) | /* PB12 */          \
73                 (1 << 13) | /* PB13 */          \
74                 (1 << 14) | /* PB14 */          \
75                 (1 << 15) | /* PB15 */          \
76                 (1 << 16) | /* PB8 */           \
77                 (1 << 17) | /* PA15 */          \
78                 (1 << 18) | /* PC0 */           \
79                 (1 << 19) | /* PC1 */           \
80                 (1 << 20) | /* PC2 */           \
81                 (1 << 21) | /* PC3 */           \
82                 (0 << 22) | /* PC4 */           \
83                 (0 << 23) | /* PC5 */           \
84                 (1 << 24) | /* PC6 */           \
85                 (1 << 25) | /* PC7 */           \
86                 (1 << 26) | /* PC8 */           \
87                 (1 << 27) | /* PC9 */           \
88                 (1 << 28) | /* PC10 or PD8 */   \
89                 (1 << 29) | /* PC11 or PD9 */   \
90                 (0 << 30) | /* PC12 or PD10 */  \
91                 (0 << 31))  /* PD2 or PD11 */
92
93 #define AO_LCD_STM_SEG_ENABLED_1 (              \
94                 (0 << 0) | /* PD12 */           \
95                 (0 << 1) | /* PD13 */           \
96                 (0 << 2) | /* PD14 */           \
97                 (0 << 3) | /* PD15 */           \
98                 (0 << 4) | /* PE0 */            \
99                 (0 << 5) | /* PE1 */            \
100                 (0 << 6) | /* PE2 */            \
101                 (0 << 7))  /* PE3 */
102
103 #define AO_LCD_STM_COM_ENABLED (                \
104                 (1 << 0) | /* PA8 */            \
105                 (1 << 1) | /* PA9 */            \
106                 (1 << 2) | /* PA10 */           \
107                 (1 << 3) | /* PB9 */            \
108                 (0 << 4) | /* PC10 */           \
109                 (0 << 5) | /* PC11 */           \
110                 (0 << 6)) /* PC12 */
111
112 #define AO_LCD_28_ON_C  1
113
114 #define HAS_ADC                 1
115
116 #define AO_ADC_RING             32
117
118 struct ao_adc {
119         uint16_t                tick;
120         int16_t                 idd;
121         int16_t                 temp;
122 };
123
124 #define AO_ADC_IDD              4
125 #define AO_ADC_PIN0_PORT        stm_gpioa
126 #define AO_ADC_PIN0_PIN         4
127
128 #define AO_ADC_RCC_AHBENR       ((1 << STM_RCC_AHBENR_GPIOAEN))
129 #define AO_ADC_TEMP             16
130
131 #define HAS_ADC_TEMP            1
132
133 #define AO_NUM_ADC              2
134
135 #define AO_ADC_SQ1              AO_ADC_IDD
136 #define AO_ADC_SQ2              AO_ADC_TEMP
137         
138
139 #endif /* _AO_PINS_H_ */