add easymotor-v1 initial attempt
[fw/altos] / src / easymotor-v1 / ao_pins.h
1 /*
2  * Copyright © 2018 Bdale Garbee <bdale@gag.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 #define AO_STACK_SIZE           512
23
24 #define AO_HSE                  32000000
25 #define AO_RCC_CFGR_PLLMUL      STM_RCC_CFGR_PLLMUL_3
26 #define AO_RCC_CFGR2_PLLDIV     STM_RCC_CFGR2_PREDIV_2
27 #define AO_PLLMUL               3
28 #define AO_PLLDIV               2
29
30 /* HCLK = 48MHz */
31 #define AO_AHB_PRESCALER        1
32 #define AO_RCC_CFGR_HPRE_DIV    STM_RCC_CFGR_HPRE_DIV_1
33
34 /* APB = 48MHz */
35 #define AO_APB_PRESCALER        1
36 #define AO_RCC_CFGR_PPRE_DIV    STM_RCC_CFGR_PPRE_DIV_1
37
38 #define HAS_USB                 1
39 #define AO_USB_DIRECTIO         0
40 #define AO_PA11_PA12_RMP        0
41
42 #define IS_FLASH_LOADER         0
43 #define HAS_TASK_QUEUE          1
44
45 /*
46  * Serial ports
47  */
48 #define HAS_SERIAL_1            0
49 #define USE_SERIAL_1_STDIN      0
50 #define SERIAL_1_PB6_PB7        0
51 #define SERIAL_1_PA9_PA10       0
52
53 #define HAS_SERIAL_2            0
54 #define USE_SERIAL_2_STDIN      0
55 #define DELAY_SERIAL_2_STDIN    0
56 #define USE_SERIAL_2_FLOW       0
57 #define USE_SERIAL_2_SW_FLOW    0
58 #define SERIAL_2_PA2_PA3        0
59 #define SERIAL_2_PD5_PD6        0
60 #define SERIAL_2_PORT_RTS       (&stm_gpioa)
61 #define SERIAL_2_PIN_RTS        0
62 #define SERIAL_2_PORT_CTS       (&stm_gpioa)
63 #define SERIAL_2_PIN_CTS        0
64
65 #define AO_CONFIG_MAX_SIZE      1024
66
67 #define HAS_EEPROM              0
68 #define USE_INTERNAL_FLASH      0
69 #define USE_EEPROM_CONFIG       0
70 #define USE_STORAGE_CONFIG      0
71 #define HAS_BEEP                1
72 #define HAS_BATTERY_REPORT      1
73 #define HAS_RADIO               0
74 #define HAS_TELEMETRY           0
75 #define HAS_APRS                0
76 #define HAS_ACCEL               1
77 #define HAS_AES                 0
78
79 #define HAS_SPI_1               1
80 #define SPI_1_PA5_PA6_PA7       1       /* sensors */
81 #define SPI_1_PB3_PB4_PB5       0
82 #define SPI_1_PE13_PE14_PE15    0
83 #define SPI_1_OSPEEDR           STM_OSPEEDR_HIGH
84
85 #define HAS_SPI_2               1
86 #define SPI_2_PB13_PB14_PB15    1
87 #define SPI_2_PD1_PD3_PD4       0
88 #define SPI_2_OSPEEDR           STM_OSPEEDR_HIGH
89
90 #define HAS_I2C_1               0
91 #define I2C_1_PB8_PB9           0
92
93 #define HAS_I2C_2               0
94 #define I2C_2_PB10_PB11         0
95
96 #define PACKET_HAS_SLAVE        0
97 #define PACKET_HAS_MASTER       0
98
99 #define LOW_LEVEL_DEBUG         0
100
101 #define LED_PORT_0_ENABLE       STM_RCC_AHBENR_IOPCEN
102 #define LED_PORT_0              (&stm_gpioc)
103 #define LED_PORT_0_SHIFT        13
104 #define LED_PIN_GREEN           (0 + LED_PORT_0_SHIFT)
105 #define AO_LED_GREEN            (1 << LED_PIN_GREEN)
106 #define LED_PORT_0_MASK         (AO_LED_GREEN)
107
108 #define LEDS_AVAILABLE          (AO_LED_GREEN)
109
110 #define HAS_GPS                 0
111 #define HAS_FLIGHT              1
112 #define HAS_ADC                 1
113 #define HAS_ADC_TEMP            0
114 #define HAS_LOG                 0
115
116 /*
117  * ADC
118  */
119 #define AO_DATA_RING            32
120 #define AO_ADC_NUM_SENSE        2
121
122 struct ao_adc {
123         int16_t                 v_batt;
124 };
125
126 #define AO_ADC_DUMP(p) \
127         printf("tick: %5u batt %5d\n", \
128                (p)->tick, \
129                (p)->adc.v_batt);
130
131 #define AO_ADC_V_BATT           0
132 #define AO_ADC_V_BATT_PORT      (&stm_gpiob)
133 #define AO_ADC_V_BATT_PIN       0
134
135 #define AO_ADC_RCC_AHBENR       ((1 << STM_RCC_AHBENR_IOPAEN))
136
137 #define AO_NUM_ADC_PIN          1
138
139 #define AO_ADC_PIN0_PORT        AO_ADC_V_BATT_PORT
140 #define AO_ADC_PIN0_PIN         AO_ADC_V_BATT_PIN
141 #define AO_ADC_PIN0_CH          AO_ADC_V_BATT_PIN
142
143 #define AO_NUM_ADC              (AO_NUM_ADC_PIN)
144
145 #define AO_ADC_SQ1              AO_ADC_V_BATT
146
147 /*
148  * Voltage divider on ADC battery sampler
149  */
150 #define AO_BATTERY_DIV_PLUS     100     /* 100k */
151 #define AO_BATTERY_DIV_MINUS    27      /* 27k */
152
153 /*
154  * ADC reference in decivolts
155  */
156 #define AO_ADC_REFERENCE_DV     33
157
158
159
160 #define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX        (1024 * 1024)
161 #define LOG_ERASE_MARK                         0x55
162 #define LOG_MAX_ERASE                          128
163 #define AO_LOG_FORMAT                           AO_LOG_FORMAT_EASYMOTOR_1
164
165 #define BEEPER_TIMER            2
166 #define BEEPER_CHANNEL          3
167 #define BEEPER_PORT             (&stm_gpioa)
168 #define BEEPER_PIN              2
169
170 /*
171  * SPI Flash memory
172  */
173
174 #define M25_MAX_CHIPS           1
175 #define AO_M25_SPI_CS_PORT      (&stm_gpioa)
176 #define AO_M25_SPI_CS_PIN       0
177 #define AO_M25_SPI_CS_MASK      (1 << AO_M25_SPI_CS_PIN)
178 #define AO_M25_SPI_BUS          AO_SPI_1_PA5_PA6_PA7
179
180 /* ADXL375 */
181
182 #define HAS_ADXL375             1
183 #define AO_ADXL375_SPI_INDEX    (AO_SPI_1_PA5_PA6_PA7 | AO_SPI_MODE_3)
184 #define AO_ADXL375_CS_PORT      (&stm_gpiob)
185 #define AO_ADXL375_CS_PIN       10
186 #define AO_ADXL375_SPI_SPEED    AO_SPI_SPEED_4MHz
187
188 #define AO_ADXL375_INT1_PORT    (&stm_gpiob)
189 #define AO_ADXL375_INT1_PIN     2
190
191 #define AO_ADXL375_INT2_PORT    (&stm_gpiob)
192 #define AO_ADXL375_INT2_PIN     1
193
194 #define AO_ADXL375_AXIS         x
195 #define AO_ADXL375_INVERT       1
196
197 #define NUM_CMDS                16
198
199 /*
200  * Monitor
201  */
202
203 #define HAS_MONITOR             0
204 #define LEGACY_MONITOR          0
205 #define HAS_MONITOR_PUT         0
206 #define AO_MONITOR_LED          0
207 #define HAS_RSSI                0
208
209 #endif /* _AO_PINS_H_ */