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