-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperiphstruct.h
More file actions
344 lines (304 loc) · 6.76 KB
/
Copy pathperiphstruct.h
File metadata and controls
344 lines (304 loc) · 6.76 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/**
* @file periphstruct.h
* @brief common definition for STM32 peripherals and board devices
*/
#include "mcudef.h"
/**
* @brief I/O pin
*/
struct pconf_pin {
GPIO_TypeDef *inst; /*!< GPIO port */
uint16_t idx; /*!< pin number */
};
/**
* @brief I2C interface
*/
struct pconf_i2c {
I2C_TypeDef *inst; /*!< I2C HAL instance */
/**
* @brief interface usage
*/
enum PCONF_I2CUSAGE {
PCONF_I2CUSAGE_DEVS, /*!< used for board devices */
} usage;
struct pconf_pin sda; /*!< SDA pin */
struct pconf_pin scl; /*!< clock pin */
DMA_Stream_TypeDef *rxdma; /*!< DMA stream instance
used for receiving */
DMA_Stream_TypeDef *txdma; /*!< DMA stream instance used
for transmiting */
};
/**
* @brief Spi interface
*/
struct pconf_spi {
SPI_TypeDef *inst; /*!< SPI HAL instance */
/**
* @brief interface usage
*/
enum PCONF_SPIUSAGE {
PCONF_SPIUSAGE_DEVS, /*!< used for board devices */
PCONF_SPIUSAGE_FLASH, /*!< used for log flash */
PCONF_SPIUSAGE_WIFI /*!< used for wifi chip */
} usage;
struct pconf_pin miso; /*!< MISO pin */
struct pconf_pin mosi; /*!< MOSI pin */
struct pconf_pin sck; /*!< clock pin */
union {
DMA_Stream_TypeDef *txdma;
BDMA_Channel_TypeDef *txbdma;
}; /*!< DMA stream instance used
to transmiting */
};
/**
* @brief External interrupt interface
*/
struct pconf_exti {
struct pconf_pin pin; /*!< pin used for interrupt */
};
/**
* @brief Timer interface
*/
struct pconf_tim {
TIM_TypeDef *inst; /*!< timer HAL instance */
/**
* @brief timer usage
*/
enum PCONF_TIMUSAGE {
PCONF_TIMUSAGE_PWM, /*!< used for PWM
generation */
PCONF_TIMUSAGE_PWMBURST, /*!< used for PWM
generation in
tim burst
mode */
PCONF_TIMUSAGE_SCHED, /*!< used for
scheduling */
PCONF_TIMUSAGE_DELAY /*!< used for delays */
} usage;
/**
* @brief PWM channels
*/
struct {
int chan; /*!< timer's channel
number */
struct pconf_pin pin; /*!< pin used for
PWM output */
DMA_Stream_TypeDef *dma; /*!< DMA stream instance
used for PWM
output */
} pwm[4];
DMA_Stream_TypeDef *updma; /*!< DMA stream instance
used for PWM
output in PWM
burst mode */
int chcnt; /*!< PWM channels
count */
};
/**
* @brief ADC interface
*/
struct pconf_adc {
ADC_TypeDef *inst; /*!< SPI HAL instance */
/**
* @brief ADC usage
*/
enum PCONF_ADCUSAGE {
PCONF_ADCUSAGE_MEASURE, /*!< used for battery
or current sensor */
} usage;
struct pconf_pin pin; /*!< pin used for ADC input */
uint32_t chan; /*!< ADC channel's number */
DMA_Stream_TypeDef *dma; /*!< DMA stream instance used
for ADC sampling */
};
/**
* @brief UART interface
*/
struct pconf_uart {
USART_TypeDef *inst; /*!< UART HAL instance */
/**
* @brief interface usage
*/
enum PCONF_UARTUSAGE {
PCONF_UARTUSAGE_CRSF, /*!< used for CRSF eLRS
device */
PCONF_UARTUSAGE_GNSS, /*!< used for GNSS device */
PCONF_UARTUSAGE_DEBUG, /*!< used as debug channel */
PCONF_UARTUSAGE_IRC, /*!< used for IRC VTX device */
PCONF_UARTUSAGE_MSP /*!< used for MSP VTX device */
} usage;
struct pconf_pin rx; /*!< RX pin */
struct pconf_pin tx; /*!< TX pin */
DMA_Stream_TypeDef *rxdma; /*!< DMA stream instance
used for receiving */
DMA_Stream_TypeDef *txdma; /*!< DMA stream instance
used for transmiting */
};
/**
* @brief Board device interface
*/
struct pconf_iface {
/**
* @brief interface type
*/
enum PCONF_IFACETYPE {
PCONF_IFACETYPE_I2C, /*!< I2C interface */
PCONF_IFACETYPE_SPI, /*!< SPI interface */
PCONF_IFACETYPE_UART /*!< UART interface */
} type;
/**
* @brief interface
*/
union {
USART_TypeDef *huart; /*!< I2C interface */
I2C_TypeDef *hi2c; /*!< I2C interface */
/**
* @brief SPI interface with chip select pin
*/
struct {
SPI_TypeDef *hspi; /*!< SPI interface */
struct pconf_pin cs; /*!< chip select pin */
};
};
};
/**
* @brief Debug connection device
*/
struct pconf_debug {
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief IMU device
*/
struct pconf_imu {
/**
* @brief IMU device type
*/
enum PCONF_IMUTYPE {
PCONF_IMUTYPE_ICM42688P, /*!< ICM-42688-P */
PCONF_IMUTYPE_MPU6500 /*!< MPU-6500/6050 */
} type;
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief Barometer device
*/
struct pconf_bar {
/**
* @brief barometer device type
*/
enum PCONF_BARTYPE {
PCONF_BARTYPE_HP206C, /*!< HP206C */
PCONF_BARTYPE_BMP280, /*!< BMP280 */
PCONF_BARTYPE_DPS368 /*!< DPS368 */
} type;
struct pconf_iface iface;; /*!< used interface */
};
/**
* @brief Magmetometer device
*/
struct pconf_mag {
/**
* @brief magnetometer device type
*/
enum PCONF_MAGTYPE {
PCONF_MAGTYPE_QMC5883L, /*!< QMC5883L */
PCONF_MAGTYPE_HMC5883L, /*!< HMC5883L */
PCONF_MAGTYPE_LIS3MDL, /*!< LIS3MDL */
PCONF_MAGTYPE_MMC5983MA /*!< MMC5983MA */
} type;
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief Flash device
*/
struct pconf_flash {
/**
* @brief flash device type
*/
enum PCONF_FLASHTYPE {
PCONF_FLASHTYPE_W25Q /*!< HMC5883L */
} type;
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief CRSF device
*/
struct pconf_crsf {
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief GNSS device
*/
struct pconf_gnss {
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief Wireless configuration device
*/
struct pconf_wireless {
struct pconf_iface iface; /*!< used interface */
struct pconf_pin interrupt; /*!< pin used to interrupt
when new config
data arrived */
struct pconf_pin busy; /*!< pin used to indicate
device's busy state */
struct pconf_pin boot; /*!< device's boot pin */
struct pconf_pin reset; /*!< device's reset pin */
};
/**
* @brief VTX device
*/
struct pconf_vtx {
/**
* @brief VTX device type
*/
enum PCONF_VTXTYPE {
PCONF_VTXTYPE_IRC, /*!< VTX that uses IRC
tramp protocol */
PCONF_VTXTYPE_MSP /*!< VTX that uses MSP
protocol */
} type;
struct pconf_iface iface; /*!< used interface */
};
/**
* @brief PWM throttle signal device
*/
struct pconf_pwm {
/**
* used DMA mode
*/
enum PCONF_TIMDMATYPE {
PCONF_TIMDMATYPE_BURST, /*!< DMA in tim burst mode */
PCONF_TIMDMATYPE_CCR, /*!< separate DMA stream for
each PWM channel */
} dmatype;
/**
* PWM protocol
*/
enum PCONF_PROTO {
PCONF_PROTO_DSHOT300, /*!< DShot-300 */
PCONF_PROTO_DSHOT600 /*!< DShot-600 */
} proto;
/**
* PWM channel
*/
struct {
TIM_TypeDef *inst; /*!< timer used for this
PWM channel */
int chan; /*!< timer's channel used for
this PWM channel */
} pwm[4];
};
/**
* @brief Battery sensor
*/
struct pconf_battery {
ADC_TypeDef *adc; /*!< ADC used for battery sensor */
};
/**
* @brief Current sensor
*/
struct pconf_current {
ADC_TypeDef *adc; /*!< ADC used for current sensor */
};