amiro-os / modules / DiWheelDrive_1-1 / module.c @ f38aba21
History | View | Annotate | Download (17.783 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 | e545e620 | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | 53710ca3 | Marc Rothmann | /**
|
20 | acc97cbf | Thomas Schöpping | * @file
|
21 | 53710ca3 | Marc Rothmann | * @brief Structures and constant for the DiWheelDrive module.
|
22 | *
|
||
23 | * @addtogroup diwheeldrive_module
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | e545e620 | Thomas Schöpping | #include "module.h" |
28 | |||
29 | /*===========================================================================*/
|
||
30 | /**
|
||
31 | * @name Module specific functions
|
||
32 | * @{
|
||
33 | */
|
||
34 | /*===========================================================================*/
|
||
35 | |||
36 | /** @} */
|
||
37 | |||
38 | /*===========================================================================*/
|
||
39 | /**
|
||
40 | * @name ChibiOS/HAL configuration
|
||
41 | * @{
|
||
42 | */
|
||
43 | /*===========================================================================*/
|
||
44 | |||
45 | CANConfig moduleHalCanConfig = { |
||
46 | /* mcr */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
|
||
47 | /* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1), |
||
48 | }; |
||
49 | |||
50 | I2CConfig moduleHalI2cCompassConfig = { |
||
51 | /* I²C mode */ OPMODE_I2C,
|
||
52 | /* frequency */ 400000, |
||
53 | /* duty cycle */ FAST_DUTY_CYCLE_2,
|
||
54 | }; |
||
55 | |||
56 | I2CConfig moduleHalI2cProxEepromPwrmtrConfig = { |
||
57 | /* I²C mode */ OPMODE_I2C,
|
||
58 | /* frequency */ 400000, |
||
59 | /* duty cycle */ FAST_DUTY_CYCLE_2,
|
||
60 | }; |
||
61 | |||
62 | PWMConfig moduleHalPwmDriveConfig = { |
||
63 | /* frequency */ 7200000, |
||
64 | /* period */ 360, |
||
65 | /* callback */ NULL, |
||
66 | /* channel configurations */ {
|
||
67 | /* channel 0 */ {
|
||
68 | /* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
||
69 | /* callback */ NULL |
||
70 | }, |
||
71 | /* channel 1 */ {
|
||
72 | /* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
||
73 | /* callback */ NULL |
||
74 | }, |
||
75 | /* channel 2 */ {
|
||
76 | /* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
||
77 | /* callback */ NULL |
||
78 | }, |
||
79 | /* channel 3 */ {
|
||
80 | /* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
||
81 | /* callback */ NULL |
||
82 | }, |
||
83 | }, |
||
84 | /* TIM CR2 register */ 0, |
||
85 | 7de0cc90 | Thomas Schöpping | #if (STM32_PWM_USE_ADVANCED == TRUE)
|
86 | e545e620 | Thomas Schöpping | /* TIM BDTR register */ 0, |
87 | 7de0cc90 | Thomas Schöpping | #endif /* (STM32_PWM_USE_ADVANCED == TRUE) */ |
88 | e545e620 | Thomas Schöpping | /* TIM DIER register */ 0 |
89 | }; |
||
90 | |||
91 | QEIConfig moduleHalQeiConfig = { |
||
92 | /* mode */ QEI_COUNT_BOTH,
|
||
93 | /* channel config */ {
|
||
94 | /* channel 0 */ {
|
||
95 | /* input mode */ QEI_INPUT_NONINVERTED,
|
||
96 | }, |
||
97 | /* channel 1 */ {
|
||
98 | /* input mode */ QEI_INPUT_NONINVERTED,
|
||
99 | }, |
||
100 | }, |
||
101 | /* encoder range */ 0x10000u, |
||
102 | }; |
||
103 | |||
104 | SerialConfig moduleHalProgIfConfig = { |
||
105 | /* bit rate */ 115200, |
||
106 | /* CR1 */ 0, |
||
107 | /* CR1 */ 0, |
||
108 | /* CR1 */ 0, |
||
109 | }; |
||
110 | |||
111 | SPIConfig moduleHalSpiAccelerometerConfig = { |
||
112 | 0128be0f | Marc Rothmann | /* circular buffer mode */ false, |
113 | e545e620 | Thomas Schöpping | /* callback function pointer */ NULL, |
114 | 3106e8cc | Thomas Schöpping | /* chip select line port */ PAL_PORT(LINE_ACCEL_SS_N),
|
115 | /* chip select line pad number */ PAL_PAD(LINE_ACCEL_SS_N),
|
||
116 | e545e620 | Thomas Schöpping | /* CR1 */ SPI_CR1_BR_0,
|
117 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
|
||
118 | }; |
||
119 | |||
120 | SPIConfig moduleHalSpiGyroscopeConfig = { |
||
121 | 0128be0f | Marc Rothmann | /* circular buffer mode */ false, |
122 | e545e620 | Thomas Schöpping | /* callback function pointer */ NULL, |
123 | 3106e8cc | Thomas Schöpping | /* chip select line port */ PAL_PORT(LINE_GYRO_SS_N),
|
124 | /* chip select line pad number */ PAL_PAD(LINE_GYRO_SS_N),
|
||
125 | e545e620 | Thomas Schöpping | /* CR1 */ SPI_CR1_BR_0,
|
126 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
|
||
127 | }; |
||
128 | |||
129 | /** @} */
|
||
130 | |||
131 | /*===========================================================================*/
|
||
132 | /**
|
||
133 | * @name GPIO definitions
|
||
134 | * @{
|
||
135 | */
|
||
136 | /*===========================================================================*/
|
||
137 | |||
138 | 1e5f7648 | Thomas Schöpping | /**
|
139 | * @brief LED output signal GPIO.
|
||
140 | */
|
||
141 | static apalGpio_t _gpioLed = {
|
||
142 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LED,
|
143 | e545e620 | Thomas Schöpping | }; |
144 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioLed = { |
145 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioLed,
|
146 | /* meta */ {
|
||
147 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
148 | 4c72a54c | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
149 | 1e5f7648 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
150 | }, |
||
151 | }; |
||
152 | e545e620 | Thomas Schöpping | |
153 | 1e5f7648 | Thomas Schöpping | /**
|
154 | * @brief POWER_EN output signal GPIO.
|
||
155 | */
|
||
156 | static apalGpio_t _gpioPowerEn = {
|
||
157 | 3106e8cc | Thomas Schöpping | /* line */ LINE_POWER_EN,
|
158 | e545e620 | Thomas Schöpping | }; |
159 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
160 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPowerEn,
|
161 | /* meta */ {
|
||
162 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
163 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
164 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
165 | }, |
||
166 | }; |
||
167 | e545e620 | Thomas Schöpping | |
168 | 1e5f7648 | Thomas Schöpping | /**
|
169 | * @brief COMPASS_DRDY output signal GPIO.
|
||
170 | */
|
||
171 | static apalGpio_t _gpioCompassDrdy = {
|
||
172 | 3106e8cc | Thomas Schöpping | /* line */ LINE_COMPASS_DRDY,
|
173 | e545e620 | Thomas Schöpping | }; |
174 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioCompassDrdy = { |
175 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioCompassDrdy,
|
176 | /* meta */ {
|
||
177 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
178 | /* active state */ (L3G4200D_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
179 | /* interrupt edge */ L3G4200D_LLD_INT_EDGE,
|
||
180 | }, |
||
181 | }; |
||
182 | e545e620 | Thomas Schöpping | |
183 | 1e5f7648 | Thomas Schöpping | /**
|
184 | * @brief IR_INT input signal GPIO.
|
||
185 | */
|
||
186 | static apalGpio_t _gpioIrInt = {
|
||
187 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IR_INT,
|
188 | e545e620 | Thomas Schöpping | }; |
189 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioIrInt = { |
190 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioIrInt,
|
191 | /* meta */ {
|
||
192 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
193 | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
194 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
195 | }, |
||
196 | }; |
||
197 | e545e620 | Thomas Schöpping | |
198 | 1e5f7648 | Thomas Schöpping | /**
|
199 | * @brief GYRO_DRDY input signal GPIO.
|
||
200 | */
|
||
201 | static apalGpio_t _gpioGyroDrdy = {
|
||
202 | 3106e8cc | Thomas Schöpping | /* line */ LINE_GYRO_DRDY,
|
203 | e545e620 | Thomas Schöpping | }; |
204 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGyroDrdy = { |
205 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGyroDrdy,
|
206 | /* meta */ {
|
||
207 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
208 | /* active state */ (L3G4200D_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
209 | /* interrupt edge */ L3G4200D_LLD_INT_EDGE,
|
||
210 | }, |
||
211 | }; |
||
212 | e545e620 | Thomas Schöpping | |
213 | 1e5f7648 | Thomas Schöpping | /**
|
214 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
215 | */
|
||
216 | static apalGpio_t _gpioSysUartUp = {
|
||
217 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_UP,
|
218 | e545e620 | Thomas Schöpping | }; |
219 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
220 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysUartUp,
|
221 | /* meta */ {
|
||
222 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
223 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
224 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
225 | }, |
||
226 | }; |
||
227 | e545e620 | Thomas Schöpping | |
228 | 1e5f7648 | Thomas Schöpping | /**
|
229 | * @brief ACCEL_INT input signal GPIO.
|
||
230 | */
|
||
231 | static apalGpio_t _gpioAccelInt = {
|
||
232 | 3106e8cc | Thomas Schöpping | /* line */ LINE_ACCEL_INT_N,
|
233 | e545e620 | Thomas Schöpping | }; |
234 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioAccelInt = { |
235 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioAccelInt,
|
236 | /* meta */ {
|
||
237 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
238 | /* active state */ (LIS331DLH_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
239 | /* interrupt edge */ LIS331DLH_LLD_INT_EDGE,
|
||
240 | }, |
||
241 | }; |
||
242 | e545e620 | Thomas Schöpping | |
243 | 1e5f7648 | Thomas Schöpping | /**
|
244 | * @brief SYS_SNYC bidirectional signal GPIO.
|
||
245 | */
|
||
246 | static apalGpio_t _gpioSysSync = {
|
||
247 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_INT_N,
|
248 | e545e620 | Thomas Schöpping | }; |
249 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
250 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysSync,
|
251 | /* meta */ {
|
||
252 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
253 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
254 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
255 | }, |
||
256 | }; |
||
257 | e545e620 | Thomas Schöpping | |
258 | 1e5f7648 | Thomas Schöpping | /**
|
259 | * @brief PATH_DCSTAT input signal GPIO.
|
||
260 | */
|
||
261 | static apalGpio_t _gpioPathDcStat = {
|
||
262 | 3106e8cc | Thomas Schöpping | /* line */ LINE_PATH_DCSTAT,
|
263 | e545e620 | Thomas Schöpping | }; |
264 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPathDcStat = { |
265 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPathDcStat,
|
266 | /* meta */ {
|
||
267 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
268 | /* active state */ LTC4412_LLD_STAT_ACTIVE_STATE,
|
||
269 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
270 | }, |
||
271 | }; |
||
272 | e545e620 | Thomas Schöpping | |
273 | 1e5f7648 | Thomas Schöpping | /**
|
274 | * @brief PATH_DCEN output signal GPIO.
|
||
275 | */
|
||
276 | static apalGpio_t _gpioPathDcEn = {
|
||
277 | 3106e8cc | Thomas Schöpping | /* line */ LINE_PATH_DCEN,
|
278 | e545e620 | Thomas Schöpping | }; |
279 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPathDcEn = { |
280 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPathDcEn,
|
281 | /* meta */ {
|
||
282 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
283 | /* active state */ LTC4412_LLD_CTRL_ACTIVE_STATE,
|
||
284 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
285 | }, |
||
286 | }; |
||
287 | e545e620 | Thomas Schöpping | |
288 | 1e5f7648 | Thomas Schöpping | /**
|
289 | * @brief SYS_PD bidirectional signal GPIO.
|
||
290 | */
|
||
291 | static apalGpio_t _gpioSysPd = {
|
||
292 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_PD_N,
|
293 | e545e620 | Thomas Schöpping | }; |
294 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
295 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysPd,
|
296 | /* meta */ {
|
||
297 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
298 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
299 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
300 | }, |
||
301 | }; |
||
302 | e545e620 | Thomas Schöpping | |
303 | 1e5f7648 | Thomas Schöpping | /**
|
304 | * @brief SYS_REG_EN input signal GPIO.
|
||
305 | */
|
||
306 | static apalGpio_t _gpioSysRegEn = {
|
||
307 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_REG_EN,
|
308 | e545e620 | Thomas Schöpping | }; |
309 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysRegEn = { |
310 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysRegEn,
|
311 | /* meta */ {
|
||
312 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
313 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
314 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
315 | }, |
||
316 | }; |
||
317 | e545e620 | Thomas Schöpping | |
318 | 1e5f7648 | Thomas Schöpping | /**
|
319 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
320 | */
|
||
321 | static apalGpio_t _gpioSysWarmrst = {
|
||
322 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_WARMRST_N,
|
323 | e545e620 | Thomas Schöpping | }; |
324 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
325 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysWarmrst,
|
326 | /* meta */ {
|
||
327 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
328 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
329 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
330 | }, |
||
331 | }; |
||
332 | e545e620 | Thomas Schöpping | |
333 | /** @} */
|
||
334 | |||
335 | /*===========================================================================*/
|
||
336 | /**
|
||
337 | * @name AMiRo-OS core configurations
|
||
338 | * @{
|
||
339 | */
|
||
340 | /*===========================================================================*/
|
||
341 | |||
342 | 2dd2e257 | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
343 | acc97cbf | Thomas Schöpping | ROMCONST char* moduleShellPrompt = "DiWheelDrive"; |
344 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
345 | 6b53f6bf | Thomas Schöpping | |
346 | /** @} */
|
||
347 | |||
348 | /*===========================================================================*/
|
||
349 | /**
|
||
350 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
351 | * @{
|
||
352 | */
|
||
353 | /*===========================================================================*/
|
||
354 | |||
355 | e545e620 | Thomas Schöpping | /** @} */
|
356 | |||
357 | /*===========================================================================*/
|
||
358 | /**
|
||
359 | * @name Low-level drivers
|
||
360 | * @{
|
||
361 | */
|
||
362 | /*===========================================================================*/
|
||
363 | |||
364 | A3906Driver moduleLldMotors = { |
||
365 | 1e5f7648 | Thomas Schöpping | /* power enable GPIO */ &moduleGpioPowerEn,
|
366 | e545e620 | Thomas Schöpping | }; |
367 | |||
368 | ddf34c3d | Thomas Schöpping | AT24C01BDriver moduleLldEeprom = { |
369 | e545e620 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
370 | ddf34c3d | Thomas Schöpping | /* I²C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
371 | e545e620 | Thomas Schöpping | }; |
372 | |||
373 | HMC5883LDriver moduleLldCompass = { |
||
374 | /* I²C Driver */ &MODULE_HAL_I2C_COMPASS,
|
||
375 | }; |
||
376 | |||
377 | INA219Driver moduleLldPowerMonitorVdd = { |
||
378 | /* I2C Driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
379 | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
||
380 | /* current LSB (uA) */ 0x00u, |
||
381 | /* configuration */ NULL, |
||
382 | }; |
||
383 | |||
384 | L3G4200DDriver moduleLldGyroscope = { |
||
385 | /* SPI Driver */ &MODULE_HAL_SPI_MOTION,
|
||
386 | }; |
||
387 | |||
388 | LEDDriver moduleLldStatusLed = { |
||
389 | 1e5f7648 | Thomas Schöpping | /* LED enable Gpio */ &moduleGpioLed,
|
390 | e545e620 | Thomas Schöpping | }; |
391 | |||
392 | LIS331DLHDriver moduleLldAccelerometer = { |
||
393 | /* SPI Driver */ &MODULE_HAL_SPI_MOTION,
|
||
394 | }; |
||
395 | |||
396 | LTC4412Driver moduleLldPowerPathController = { |
||
397 | 1e5f7648 | Thomas Schöpping | /* Control GPIO */ &moduleGpioPathDcEn,
|
398 | /* Status GPIO */ &moduleGpioPathDcStat,
|
||
399 | e545e620 | Thomas Schöpping | }; |
400 | |||
401 | PCA9544ADriver moduleLldI2cMultiplexer = { |
||
402 | /* I²C driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
403 | /* I²C address */ PCA9544A_LLD_I2C_ADDR_FIXED | PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
||
404 | }; |
||
405 | |||
406 | ddf34c3d | Thomas Schöpping | TPS6211xDriver moduleLldStepDownConverterVdrive = { |
407 | 1e5f7648 | Thomas Schöpping | /* Power enable Gpio */ &moduleGpioPowerEn,
|
408 | e545e620 | Thomas Schöpping | }; |
409 | |||
410 | VCNL4020Driver moduleLldProximity = { |
||
411 | /* I²C Driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
412 | }; |
||
413 | |||
414 | /** @} */
|
||
415 | |||
416 | /*===========================================================================*/
|
||
417 | /**
|
||
418 | 4c72a54c | Thomas Schöpping | * @name Tests
|
419 | e545e620 | Thomas Schöpping | * @{
|
420 | */
|
||
421 | /*===========================================================================*/
|
||
422 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
423 | |||
424 | 8be006e0 | Thomas Schöpping | /*
|
425 | * A3906 (motor driver)
|
||
426 | */
|
||
427 | 4c72a54c | Thomas Schöpping | #include <module_test_A3906.h> |
428 | static int _testA3906ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
429 | e545e620 | Thomas Schöpping | { |
430 | 4c72a54c | Thomas Schöpping | return moduleTestA3906ShellCb(stream, argc, argv, NULL); |
431 | e545e620 | Thomas Schöpping | } |
432 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestA3906ShellCmd, "test:MotorDriver", _testA3906ShellCmdCb);
|
433 | e545e620 | Thomas Schöpping | |
434 | 8be006e0 | Thomas Schöpping | /*
|
435 | 4c72a54c | Thomas Schöpping | * AT24C01BN-SH-B (EEPROM)
|
436 | 8be006e0 | Thomas Schöpping | */
|
437 | 4c72a54c | Thomas Schöpping | #include <module_test_AT24C01B.h> |
438 | static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
439 | e545e620 | Thomas Schöpping | { |
440 | 4c72a54c | Thomas Schöpping | return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
441 | e545e620 | Thomas Schöpping | } |
442 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
|
443 | e545e620 | Thomas Schöpping | |
444 | 8be006e0 | Thomas Schöpping | /*
|
445 | * HMC5883L (compass)
|
||
446 | */
|
||
447 | 4c72a54c | Thomas Schöpping | #include <module_test_HMC5883L.h> |
448 | static int _testHmc5883lShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
449 | e545e620 | Thomas Schöpping | { |
450 | 4c72a54c | Thomas Schöpping | return moduleTestHmc5883lShellCb(stream, argc, argv, NULL); |
451 | e545e620 | Thomas Schöpping | } |
452 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestHmc5883lShellCmd, "test:Compass", _testHmc5883lShellCmdCb);
|
453 | e545e620 | Thomas Schöpping | |
454 | 8be006e0 | Thomas Schöpping | /*
|
455 | * INA219 (power monitor)
|
||
456 | */
|
||
457 | 4c72a54c | Thomas Schöpping | #include <module_test_INA219.h> |
458 | static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
459 | e545e620 | Thomas Schöpping | { |
460 | 4c72a54c | Thomas Schöpping | return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
461 | e545e620 | Thomas Schöpping | } |
462 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
463 | e545e620 | Thomas Schöpping | |
464 | 8be006e0 | Thomas Schöpping | /*
|
465 | * L3G4200D (gyroscope)
|
||
466 | */
|
||
467 | 4c72a54c | Thomas Schöpping | #include <module_test_L3G4200D.h> |
468 | static int _testL3g4200dShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
469 | e545e620 | Thomas Schöpping | { |
470 | 4c72a54c | Thomas Schöpping | return moduleTestL3g4200dShellCb(stream, argc, argv, NULL); |
471 | e545e620 | Thomas Schöpping | } |
472 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestL3g4200dShellCmd, "test:Gyroscope", _testL3g4200dShellCmdCb);
|
473 | e545e620 | Thomas Schöpping | |
474 | 8be006e0 | Thomas Schöpping | /*
|
475 | * Status LED
|
||
476 | */
|
||
477 | 4c72a54c | Thomas Schöpping | #include <module_test_LED.h> |
478 | static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
479 | e545e620 | Thomas Schöpping | { |
480 | 4c72a54c | Thomas Schöpping | return moduleTestLedShellCb(stream, argc, argv, NULL); |
481 | e545e620 | Thomas Schöpping | } |
482 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
483 | e545e620 | Thomas Schöpping | |
484 | 8be006e0 | Thomas Schöpping | /*
|
485 | * LIS331DLH (accelerometer)
|
||
486 | */
|
||
487 | 4c72a54c | Thomas Schöpping | #include <module_test_LIS331DLH.h> |
488 | static int _testLis331dlhShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
489 | e545e620 | Thomas Schöpping | { |
490 | 4c72a54c | Thomas Schöpping | return moduleTestLis331dlhShellCb(stream, argc, argv, NULL); |
491 | e545e620 | Thomas Schöpping | } |
492 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLis331dlhShellCmd, "test:Accelerometer", _testLis331dlhShellCmdCb);
|
493 | e545e620 | Thomas Schöpping | |
494 | 8be006e0 | Thomas Schöpping | /*
|
495 | * LTC4412 (power path controller)
|
||
496 | */
|
||
497 | 4c72a54c | Thomas Schöpping | #include <module_test_LTC4412.h> |
498 | static int _testLtc4412ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
499 | e545e620 | Thomas Schöpping | { |
500 | 4c72a54c | Thomas Schöpping | return moduleTestLtc4412ShellCb(stream, argc, argv, NULL); |
501 | e545e620 | Thomas Schöpping | } |
502 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLtc4412ShellCmd, "test:PowerPathController", _testLtc4412ShellCmdCb);
|
503 | e545e620 | Thomas Schöpping | |
504 | 8be006e0 | Thomas Schöpping | /*
|
505 | * PCA9544A (I2C multiplexer)
|
||
506 | */
|
||
507 | 4c72a54c | Thomas Schöpping | #include <module_test_PCA9544A.h> |
508 | static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
509 | e545e620 | Thomas Schöpping | { |
510 | 4c72a54c | Thomas Schöpping | return moduleTestPca9544aShellCb(stream, argc, argv, NULL); |
511 | e545e620 | Thomas Schöpping | } |
512 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
|
513 | e545e620 | Thomas Schöpping | |
514 | 8be006e0 | Thomas Schöpping | /*
|
515 | * TPS62113 (step-down converter)
|
||
516 | */
|
||
517 | 4c72a54c | Thomas Schöpping | #include <module_test_TPS6211x.h> |
518 | static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
519 | e545e620 | Thomas Schöpping | { |
520 | 4c72a54c | Thomas Schöpping | return moduleTestTps6211xShellCb(stream, argc, argv, NULL); |
521 | e545e620 | Thomas Schöpping | } |
522 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestTps62113ShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
|
523 | e545e620 | Thomas Schöpping | |
524 | 8be006e0 | Thomas Schöpping | /*
|
525 | * VCNL4020 (proximity sensor)
|
||
526 | */
|
||
527 | 4c72a54c | Thomas Schöpping | #include <module_test_VCNL4020.h> |
528 | static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
529 | e545e620 | Thomas Schöpping | { |
530 | 4c72a54c | Thomas Schöpping | return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL); |
531 | e545e620 | Thomas Schöpping | } |
532 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:ProximitySensor", _testVcnl4020ShellCmdCb);
|
533 | |||
534 | /*
|
||
535 | * entire module
|
||
536 | */
|
||
537 | static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
538 | e545e620 | Thomas Schöpping | { |
539 | 4c72a54c | Thomas Schöpping | (void)argc;
|
540 | (void)argv;
|
||
541 | |||
542 | int status = AOS_OK;
|
||
543 | char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
||
544 | aos_testresult_t result_test = {0, 0}; |
||
545 | aos_testresult_t result_total = {0, 0}; |
||
546 | |||
547 | /* A3906 (motor driver) */
|
||
548 | status |= moduleTestA3906ShellCb(stream, 0, targv, &result_test);
|
||
549 | result_total = aosTestResultAdd(result_total, result_test); |
||
550 | |||
551 | /* AT24C01B (EEPROM) */
|
||
552 | status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
||
553 | result_total = aosTestResultAdd(result_total, result_test); |
||
554 | |||
555 | /* HMC5883L (compass) */
|
||
556 | status |= moduleTestHmc5883lShellCb(stream, 0, targv, &result_test);
|
||
557 | result_total = aosTestResultAdd(result_total, result_test); |
||
558 | |||
559 | /* INA219 (power monitor) */
|
||
560 | status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
|
||
561 | result_total = aosTestResultAdd(result_total, result_test); |
||
562 | |||
563 | /* L3G4200D (gyroscope) */
|
||
564 | status |= moduleTestL3g4200dShellCb(stream, 0, targv, &result_test);
|
||
565 | result_total = aosTestResultAdd(result_total, result_test); |
||
566 | |||
567 | /* Status LED */
|
||
568 | status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
||
569 | result_total = aosTestResultAdd(result_total, result_test); |
||
570 | |||
571 | /* LIS331DLH (accelerometer) */
|
||
572 | status |= moduleTestLis331dlhShellCb(stream, 0, targv, &result_test);
|
||
573 | result_total = aosTestResultAdd(result_total, result_test); |
||
574 | |||
575 | /* LTC4412 (power path controller) */
|
||
576 | status |= moduleTestLtc4412ShellCb(stream, 0, targv, &result_test);
|
||
577 | result_total = aosTestResultAdd(result_total, result_test); |
||
578 | |||
579 | /* PCA9544A (I2C multiplexer) */
|
||
580 | status |= moduleTestPca9544aShellCb(stream, 0, targv, &result_test);
|
||
581 | result_total = aosTestResultAdd(result_total, result_test); |
||
582 | |||
583 | /* TPS62113 (step-down converter) */
|
||
584 | status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
|
||
585 | result_total = aosTestResultAdd(result_total, result_test); |
||
586 | |||
587 | /* VCNL4020 (proximity sensor) */
|
||
588 | // wheel left
|
||
589 | targv[1] = "-wl"; |
||
590 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
591 | result_total = aosTestResultAdd(result_total, result_test); |
||
592 | // front left
|
||
593 | targv[1] = "-fl"; |
||
594 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
595 | result_total = aosTestResultAdd(result_total, result_test); |
||
596 | // front right
|
||
597 | targv[1] = "-fr"; |
||
598 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
599 | result_total = aosTestResultAdd(result_total, result_test); |
||
600 | // wheel right
|
||
601 | targv[1] = "-wr"; |
||
602 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
603 | result_total = aosTestResultAdd(result_total, result_test); |
||
604 | targv[1] = ""; |
||
605 | |||
606 | // print total result
|
||
607 | chprintf(stream, "\n");
|
||
608 | aosTestResultPrintSummary(stream, &result_total, "entire module");
|
||
609 | |||
610 | return status;
|
||
611 | e545e620 | Thomas Schöpping | } |
612 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
613 | e545e620 | Thomas Schöpping | |
614 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
615 | e545e620 | Thomas Schöpping | |
616 | /** @} */
|
||
617 | 53710ca3 | Marc Rothmann | /** @} */ |