-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
lisa_m_2.0.h
193 lines (160 loc) · 4.97 KB
/
lisa_m_2.0.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef CONFIG_LISA_M_2_0_H
#define CONFIG_LISA_M_2_0_H
#define BOARD_LISA_M
/* Lisa/M has a 12MHz external clock and 72MHz internal. */
#define EXT_CLK 12000000
#define AHB_CLK 72000000
/*
* Onboard LEDs
*/
/* red, on PA8 */
#ifndef USE_LED_1
#define USE_LED_1 1
#endif
#define LED_1_GPIO GPIOA
#define LED_1_GPIO_CLK RCC_APB2ENR_IOPAEN
#define LED_1_GPIO_PIN GPIO8
#define LED_1_GPIO_ON GPIO_BRR
#define LED_1_GPIO_OFF GPIO_BSRR
#define LED_1_AFIO_REMAP ((void)0)
/* green, shared with JTAG_TRST */
#ifndef USE_LED_2
#define USE_LED_2 1
#endif
#define LED_2_GPIO GPIOB
#define LED_2_GPIO_CLK RCC_APB2ENR_IOPBEN | RCC_APB2ENR_AFIOEN
#define LED_2_GPIO_PIN GPIO4
#define LED_2_GPIO_ON GPIO_BRR
#define LED_2_GPIO_OFF GPIO_BSRR
#define LED_2_AFIO_REMAP AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_JNTRST
/* green, shared with ADC12 (ADC_6 on connector ANALOG2) */
#ifndef USE_LED_3
#define USE_LED_3 1
#endif
#define LED_3_GPIO GPIOC
#define LED_3_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_3_GPIO_PIN GPIO2
#define LED_3_GPIO_ON GPIO_BRR
#define LED_3_GPIO_OFF GPIO_BSRR
#define LED_3_AFIO_REMAP ((void)0)
/* red, shared with ADC15 (ADC_4 on connector ANALOG2) */
#ifndef USE_LED_4
#define USE_LED_4 1
#endif
#define LED_4_GPIO GPIOC
#define LED_4_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_4_GPIO_PIN GPIO5
#define LED_4_GPIO_ON GPIO_BRR
#define LED_4_GPIO_OFF GPIO_BSRR
#define LED_4_AFIO_REMAP ((void)0)
/* green, on PC15 */
#ifndef USE_LED_5
#define USE_LED_5 1
#endif
#define LED_5_GPIO GPIOC
#define LED_5_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_5_GPIO_PIN GPIO15
#define LED_5_GPIO_ON GPIO_BRR
#define LED_5_GPIO_OFF GPIO_BSRR
#define LED_5_AFIO_REMAP ((void)0)
/*
* LEDs not populated by default
*/
/* PC3, ADC13 on ADC_1 */
#define LED_6_GPIO GPIOC
#define LED_6_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_6_GPIO_PIN GPIO3
#define LED_6_GPIO_ON GPIO_BRR
#define LED_6_GPIO_OFF GPIO_BSRR
#define LED_6_AFIO_REMAP ((void)0)
/* PC0, ADC10 on ADC_2 */
#define LED_7_GPIO GPIOC
#define LED_7_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_7_GPIO_PIN GPIO0
#define LED_7_GPIO_ON GPIO_BRR
#define LED_7_GPIO_OFF GPIO_BSRR
#define LED_7_AFIO_REMAP ((void)0)
/* PC1, ADC11 on ADC_3 */
#define LED_8_GPIO GPIOC
#define LED_8_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_8_GPIO_PIN GPIO1
#define LED_8_GPIO_ON GPIO_BRR
#define LED_8_GPIO_OFF GPIO_BSRR
#define LED_8_AFIO_REMAP ((void)0)
/*
* not actual LEDS, used as GPIOs
*/
/* PB1, DRDY on EXT SPI connector*/
#define LED_BODY_GPIO GPIOB
#define LED_BODY_GPIO_CLK RCC_APB2ENR_IOPBEN
#define LED_BODY_GPIO_PIN GPIO1
#define LED_BODY_GPIO_ON GPIO_BSRR
#define LED_BODY_GPIO_OFF GPIO_BRR
#define LED_BODY_AFIO_REMAP ((void)0)
/* PC12, on GPIO connector*/
#define LED_12_GPIO GPIOC
#define LED_12_GPIO_CLK RCC_APB2ENR_IOPCEN
#define LED_12_GPIO_PIN GPIO12
#define LED_1_GPIO_ON GPIO_BRR
#define LED_1_GPIO_OFF GPIO_BSRR
#define LED_12_AFIO_REMAP ((void)0)
/* configuration for aspirin - and more generaly IMUs */
#define IMU_ACC_DRDY_RCC_GPIO RCC_APB2ENR_IOPBEN
#define IMU_ACC_DRDY_GPIO GPIOB
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOB
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
#define ActuatorsDefaultInit() ActuatorsPwmInit()
#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
#define DefaultVoltageOfAdc(adc) (0.0045*adc)
/* Onboard ADCs */
/*
ADC1 PC3/ADC13
ADC2 PC0/ADC10
ADC3 PC1/ADC11
ADC4 PC5/ADC15
ADC6 PC2/ADC12
BATT PC4/ADC14
*/
#define BOARD_ADC_CHANNEL_1 13
#define BOARD_ADC_CHANNEL_2 10
#define BOARD_ADC_CHANNEL_3 11
// we can only use ADC1,2,3; the last channel is for bat monitoring
#define BOARD_ADC_CHANNEL_4 14
/* provide defines that can be used to access the ADC_x in the code or airframe file
* these directly map to the index number of the 4 adc channels defined above
* 4th (index 3) is used for bat monitoring by default
*/
#define ADC_1 0
#define ADC_2 1
#define ADC_3 2
/* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
#ifndef ADC_CHANNEL_VSUPPLY
#define ADC_CHANNEL_VSUPPLY 3
#endif
/* GPIO mapping for ADC1 pins, overwrites the default in arch/stm32/mcu_periph/adc_arch.c */
// FIXME, this is not very nice, is also stm lib specific
#ifdef USE_AD1
#define ADC1_GPIO_INIT(gpio) { \
gpio_set_mode(GPIOC, GPIO_MODE_INPUT, \
GPIO_CNF_INPUT_ANALOG, \
GPIO3 | GPIO0 | GPIO1 | GPIO4); \
}
#endif // USE_AD1
#define BOARD_HAS_BARO 1
#define USE_OPENCM3 1
// not needed with USE_OPENCM3:
//#define HSE_TYPE_EXT_CLK
//#define STM32_RCC_MODE RCC_HSE_ON
//#define STM32_PLL_MULT RCC_PLLMul_6
#define PWM_5AND6_TIMER TIM5
#define PWM_5AND6_RCC RCC_APB1ENR_TIM5EN
#define PWM5_OC 1
#define PWM6_OC 2
#define PWM_5AND6_GPIO GPIOA
#define PWM5_Pin GPIO0
#define PWM6_Pin GPIO1
// Remap the servos 5 and 6 to TIM5 CH1 and CH2
#define REMAP_SERVOS_5AND6 1
#endif /* CONFIG_LISA_M_2_0_H */