5c6aee0e302e3615a7b06d53354d17019e37d5f9
[fw/altos] / src / telegps-v2.0 / ao_pins.h
1 /*
2  * Copyright © 2017 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 LED_PORT_ENABLE STM_RCC_AHBENR_IOPBEN
23 #define LED_PORT        (&stm_gpiob)
24 #define LED_PIN_GREEN   5
25 #define AO_LED_GREEN    (1 << LED_PIN_GREEN)
26 #define AO_LED_PANIC    AO_LED_GREEN
27 #define AO_LED_GPS_LOCK AO_LED_GREEN
28
29 #define LEDS_AVAILABLE  (AO_LED_GREEN)
30
31 #define AO_STACK_SIZE           512
32
33 #define IS_FLASH_LOADER         0
34 #define HAS_BEEP               0
35
36 #define AO_HSE                  16000000
37 #define AO_RCC_CFGR_PLLMUL      STM_RCC_CFGR_PLLMUL_3
38 #define AO_RCC_CFGR2_PLLDIV     STM_RCC_CFGR2_PREDIV_1
39 #define AO_PLLMUL               3
40 #define AO_PLLDIV               1
41
42 /* HCLK = 48MHz */
43 #define AO_AHB_PRESCALER        1
44 #define AO_RCC_CFGR_HPRE_DIV    STM_RCC_CFGR_HPRE_DIV_1
45
46 /* APB = 48MHz */
47 #define AO_APB_PRESCALER        1
48 #define AO_RCC_CFGR_PPRE_DIV    STM_RCC_CFGR_PPRE_DIV_1
49
50 #define HAS_USB                         1
51 #define AO_USB_DIRECTIO                 0
52 #define AO_PA11_PA12_RMP                1
53 #define HAS_USB_CONNECT                 1
54 #define AO_USB_CONNECT_PORT             (&stm_gpiob)
55 #define AO_USB_CONNECT_PIN              3
56
57 #define IS_FLASH_LOADER 0
58
59 /* ADC */
60
61 #define HAS_ADC                 1
62 #define AO_ADC_PIN0_PORT        (&stm_gpiob)
63 #define AO_ADC_PIN0_PIN         1
64 #define AO_ADC_PIN0_CH          9
65
66 #define AO_ADC_RCC_AHBENR       ((1 << STM_RCC_AHBENR_IOPBEN))
67
68 #define ao_telemetry_battery_convert(a) ((a) << 3)
69
70 #define AO_NUM_ADC              1
71
72 #define AO_DATA_RING            4
73
74 /*
75  * Voltage divider on ADC battery sampler
76  */
77 #define AO_BATTERY_DIV_PLUS     56      /* 5.6k */
78 #define AO_BATTERY_DIV_MINUS    100     /* 10k */
79
80 /*
81  * ADC reference in decivolts
82  */
83 #define AO_ADC_REFERENCE_DV     33
84
85 struct ao_adc {
86         int16_t                 v_batt;
87 };
88
89 #define AO_ADC_DUMP(p) \
90         printf("tick: %5u batt: %5d\n", \
91                (p)->tick, \
92                (p)->adc.v_batt)
93
94 /* SPI */
95 #define HAS_SPI_1               1
96 #define HAS_SPI_2               0
97 #define SPI_1_PA5_PA6_PA7       1
98 #define SPI_1_PB3_PB4_PB5       0
99 #define SPI_1_OSPEEDR           STM_OSPEEDR_HIGH
100
101 /* Flash */
102
103 #define M25_MAX_CHIPS           1
104 #define AO_M25_SPI_CS_PORT      (&stm_gpiob)
105 #define AO_M25_SPI_CS_MASK      (1 << 0)
106 #define AO_M25_SPI_BUS          AO_SPI_1_PA5_PA6_PA7
107
108 /* Serial */
109 #define HAS_SERIAL_1            0
110 #define SERIAL_1_PB6_PB7        1
111 #define USE_SERIAL_1_STDIN      0
112
113 #define HAS_SERIAL_2            1
114 #define SERIAL_2_PA2_PA3        1
115 #define USE_SERIAL_2_STDIN      0
116 #define USE_SERIAL_2_FLOW       0
117 #define USE_SERIAL_2_SW_FLOW    0
118
119 #define ao_gps_getchar          ao_serial2_getchar
120 #define ao_gps_putchar          ao_serial2_putchar
121 #define ao_gps_set_speed        ao_serial2_set_speed
122
123 #define HAS_EEPROM              1
124 #define USE_INTERNAL_FLASH      0
125 #define HAS_RADIO               1
126 #define HAS_TELEMETRY           1
127 #define HAS_RDF                 1
128 #define HAS_APRS                1
129
130 #define HAS_GPS                 1
131 #define HAS_FLIGHT              0
132 #define HAS_LOG                 1
133 #define FLIGHT_LOG_APPEND       1
134 #define HAS_TRACKER             1
135 #define LOG_ADC                 0
136
137 #define AO_CONFIG_DEFAULT_APRS_INTERVAL         0
138 #define AO_CONFIG_DEFAULT_RADIO_POWER           0xc0
139 #define AO_LOG_FORMAT                           AO_LOG_FORMAT_TELEGPS
140
141 /*
142  * GPS
143  */
144
145 #define AO_SERIAL_SPEED_UBLOX   AO_SERIAL_SPEED_9600
146
147
148 /*
149  * Radio (cc1120)
150  */
151
152 /* gets pretty close to 434.550 */
153
154 #define AO_RADIO_CAL_DEFAULT    5695733
155
156 #define AO_FEC_DEBUG            0
157 #define AO_CC1200_SPI_CS_PORT   (&stm_gpioa)
158 #define AO_CC1200_SPI_CS_PIN    1
159 #define AO_CC1200_SPI_BUS       AO_SPI_1_PA5_PA6_PA7
160 #define AO_CC1200_SPI           stm_spi1
161
162 #define AO_CC1200_INT_PORT              (&stm_gpioa)
163 #define AO_CC1200_INT_PIN               4
164
165 #define AO_CC1200_INT_GPIO      2
166 #define AO_CC1200_INT_GPIO_IOCFG        CC1200_IOCFG2
167
168 #define HAS_BOOT_RADIO          0
169
170 #endif /* _AO_PINS_H_ */