amiro-os / modules / DiWheelDrive_1-2 / module.c @ 57a5d1df
History | View | Annotate | Download (15.62 KB)
1 | abb8b3f4 | Thomas Schöpping | /*
|
---|---|---|---|
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 "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 moduleHalI2cImuConfig = { |
||
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 | #if (STM32_PWM_USE_ADVANCED == TRUE)
|
||
86 | /* TIM BDTR register */ 0, |
||
87 | #endif /* (STM32_PWM_USE_ADVANCED == TRUE) */ |
||
88 | /* 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 | /** @} */
|
||
112 | |||
113 | /*===========================================================================*/
|
||
114 | /**
|
||
115 | * @name GPIO definitions
|
||
116 | * @{
|
||
117 | */
|
||
118 | /*===========================================================================*/
|
||
119 | |||
120 | /**
|
||
121 | * @brief LED output signal GPIO.
|
||
122 | */
|
||
123 | static apalGpio_t _gpioLed = {
|
||
124 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LED,
|
125 | abb8b3f4 | Thomas Schöpping | }; |
126 | ROMCONST apalControlGpio_t moduleGpioLed = { |
||
127 | /* GPIO */ &_gpioLed,
|
||
128 | /* meta */ {
|
||
129 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
130 | 4c72a54c | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
131 | abb8b3f4 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
132 | }, |
||
133 | }; |
||
134 | |||
135 | /**
|
||
136 | * @brief POWER_EN output signal GPIO.
|
||
137 | */
|
||
138 | static apalGpio_t _gpioPowerEn = {
|
||
139 | 3106e8cc | Thomas Schöpping | /* line */ LINE_POWER_EN,
|
140 | abb8b3f4 | Thomas Schöpping | }; |
141 | ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
||
142 | /* GPIO */ &_gpioPowerEn,
|
||
143 | /* meta */ {
|
||
144 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
145 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
146 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
147 | }, |
||
148 | }; |
||
149 | |||
150 | /**
|
||
151 | * @brief IR_INT input signal GPIO.
|
||
152 | */
|
||
153 | static apalGpio_t _gpioIrInt = {
|
||
154 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IR_INT,
|
155 | abb8b3f4 | Thomas Schöpping | }; |
156 | ROMCONST apalControlGpio_t moduleGpioIrInt = { |
||
157 | /* GPIO */ &_gpioIrInt,
|
||
158 | /* meta */ {
|
||
159 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
160 | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
161 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
162 | }, |
||
163 | }; |
||
164 | |||
165 | /**
|
||
166 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
167 | */
|
||
168 | static apalGpio_t _gpioSysUartUp = {
|
||
169 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_UP,
|
170 | abb8b3f4 | Thomas Schöpping | }; |
171 | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
||
172 | /* GPIO */ &_gpioSysUartUp,
|
||
173 | /* meta */ {
|
||
174 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
175 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
176 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
177 | }, |
||
178 | }; |
||
179 | |||
180 | /**
|
||
181 | * @brief IMU_INT input signal GPIO.
|
||
182 | */
|
||
183 | static apalGpio_t _gpioImuInt = {
|
||
184 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IMU_INT,
|
185 | abb8b3f4 | Thomas Schöpping | }; |
186 | ROMCONST apalControlGpio_t moduleGpioImuInt = { |
||
187 | /* GPIO */ &_gpioImuInt,
|
||
188 | /* meta */ {
|
||
189 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
190 | /* active state */ APAL_GPIO_ACTIVE_HIGH, // TODO |
||
191 | /* interrupt edge */ APAL_GPIO_EDGE_RISING, // TODO |
||
192 | }, |
||
193 | }; |
||
194 | |||
195 | /**
|
||
196 | * @brief SYS_SNYC bidirectional signal GPIO.
|
||
197 | */
|
||
198 | static apalGpio_t _gpioSysSync = {
|
||
199 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_INT_N,
|
200 | abb8b3f4 | Thomas Schöpping | }; |
201 | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
||
202 | /* GPIO */ &_gpioSysSync,
|
||
203 | /* meta */ {
|
||
204 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
205 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
206 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
207 | }, |
||
208 | }; |
||
209 | |||
210 | /**
|
||
211 | * @brief IMU_RESET output signal GPIO.
|
||
212 | */
|
||
213 | static apalGpio_t _gpioImuReset = {
|
||
214 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IMU_RESET_N,
|
215 | abb8b3f4 | Thomas Schöpping | }; |
216 | ROMCONST apalControlGpio_t moduleGpioImuReset = { |
||
217 | /* GPIO */ &_gpioImuReset,
|
||
218 | /* meta */ {
|
||
219 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
220 | /* active state */ APAL_GPIO_ACTIVE_LOW, // TODO |
||
221 | /* interrupt edge */ APAL_GPIO_EDGE_NONE, // TODO |
||
222 | }, |
||
223 | }; |
||
224 | |||
225 | /**
|
||
226 | * @brief PATH_DCSTAT input signal GPIO.
|
||
227 | */
|
||
228 | static apalGpio_t _gpioPathDcStat = {
|
||
229 | 3106e8cc | Thomas Schöpping | /* line */ LINE_PATH_DCSTAT,
|
230 | abb8b3f4 | Thomas Schöpping | }; |
231 | ROMCONST apalControlGpio_t moduleGpioPathDcStat = { |
||
232 | /* GPIO */ &_gpioPathDcStat,
|
||
233 | /* meta */ {
|
||
234 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
235 | /* active state */ LTC4412_LLD_STAT_ACTIVE_STATE,
|
||
236 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
237 | }, |
||
238 | }; |
||
239 | |||
240 | /**
|
||
241 | * @brief PATH_DCEN output signal GPIO.
|
||
242 | */
|
||
243 | static apalGpio_t _gpioPathDcEn = {
|
||
244 | 3106e8cc | Thomas Schöpping | /* line */ LINE_PATH_DCEN,
|
245 | abb8b3f4 | Thomas Schöpping | }; |
246 | ROMCONST apalControlGpio_t moduleGpioPathDcEn = { |
||
247 | /* GPIO */ &_gpioPathDcEn,
|
||
248 | /* meta */ {
|
||
249 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
250 | /* active state */ LTC4412_LLD_CTRL_ACTIVE_STATE,
|
||
251 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
252 | }, |
||
253 | }; |
||
254 | |||
255 | /**
|
||
256 | * @brief SYS_PD bidirectional signal GPIO.
|
||
257 | */
|
||
258 | static apalGpio_t _gpioSysPd = {
|
||
259 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_PD_N,
|
260 | abb8b3f4 | Thomas Schöpping | }; |
261 | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
||
262 | /* GPIO */ &_gpioSysPd,
|
||
263 | /* meta */ {
|
||
264 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
265 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
266 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
267 | }, |
||
268 | }; |
||
269 | |||
270 | /**
|
||
271 | * @brief SYS_REG_EN input signal GPIO.
|
||
272 | */
|
||
273 | static apalGpio_t _gpioSysRegEn = {
|
||
274 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_REG_EN,
|
275 | abb8b3f4 | Thomas Schöpping | }; |
276 | ROMCONST apalControlGpio_t moduleGpioSysRegEn = { |
||
277 | /* GPIO */ &_gpioSysRegEn,
|
||
278 | /* meta */ {
|
||
279 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
280 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
281 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
282 | }, |
||
283 | }; |
||
284 | |||
285 | /**
|
||
286 | * @brief IMU_BOOT_LOAD output signal GPIO.
|
||
287 | */
|
||
288 | static apalGpio_t _gpioImuBootLoad = {
|
||
289 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IMU_BOOT_LOAD_N,
|
290 | abb8b3f4 | Thomas Schöpping | }; |
291 | ROMCONST apalControlGpio_t moduleGpioImuBootLoad = { |
||
292 | /* GPIO */ &_gpioImuBootLoad,
|
||
293 | /* meta */ {
|
||
294 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
295 | /* active state */ APAL_GPIO_ACTIVE_LOW, // TODO |
||
296 | /* interrupt edge */ APAL_GPIO_EDGE_NONE, // TODO |
||
297 | }, |
||
298 | }; |
||
299 | |||
300 | /**
|
||
301 | * @brief IMU_BL_IND input signal GPIO.
|
||
302 | */
|
||
303 | static apalGpio_t _gpioImuBlInd = {
|
||
304 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IMU_BL_IND,
|
305 | abb8b3f4 | Thomas Schöpping | }; |
306 | ROMCONST apalControlGpio_t moduleGpioImuBlInd = { |
||
307 | /* GPIO */ &_gpioImuBlInd,
|
||
308 | /* meta */ {
|
||
309 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
310 | /* active state */ APAL_GPIO_ACTIVE_HIGH, // TODO |
||
311 | /* interrupt edge */ APAL_GPIO_EDGE_NONE, // TODO |
||
312 | }, |
||
313 | }; |
||
314 | |||
315 | /**
|
||
316 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
317 | */
|
||
318 | static apalGpio_t _gpioSysWarmrst = {
|
||
319 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_WARMRST_N,
|
320 | abb8b3f4 | Thomas Schöpping | }; |
321 | ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
||
322 | /* GPIO */ &_gpioSysWarmrst,
|
||
323 | /* meta */ {
|
||
324 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
325 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
326 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
327 | }, |
||
328 | }; |
||
329 | |||
330 | /** @} */
|
||
331 | |||
332 | /*===========================================================================*/
|
||
333 | /**
|
||
334 | * @name AMiRo-OS core configurations
|
||
335 | * @{
|
||
336 | */
|
||
337 | /*===========================================================================*/
|
||
338 | |||
339 | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
340 | ROMCONST char* moduleShellPrompt = "DiWheelDrive"; |
||
341 | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
||
342 | |||
343 | /** @} */
|
||
344 | |||
345 | /*===========================================================================*/
|
||
346 | /**
|
||
347 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
348 | * @{
|
||
349 | */
|
||
350 | /*===========================================================================*/
|
||
351 | |||
352 | /** @} */
|
||
353 | |||
354 | /*===========================================================================*/
|
||
355 | /**
|
||
356 | * @name Low-level drivers
|
||
357 | * @{
|
||
358 | */
|
||
359 | /*===========================================================================*/
|
||
360 | |||
361 | A3906Driver moduleLldMotors = { |
||
362 | /* power enable GPIO */ &moduleGpioPowerEn,
|
||
363 | }; |
||
364 | |||
365 | AT24C01BDriver moduleLldEeprom = { |
||
366 | /* I2C driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
367 | /* I²C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
||
368 | }; |
||
369 | |||
370 | 4c72a54c | Thomas Schöpping | // TODO: BNO055
|
371 | |||
372 | abb8b3f4 | Thomas Schöpping | INA219Driver moduleLldPowerMonitorVdd = { |
373 | /* I2C Driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
374 | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
||
375 | /* current LSB (uA) */ 0x00u, |
||
376 | /* configuration */ NULL, |
||
377 | }; |
||
378 | |||
379 | LEDDriver moduleLldStatusLed = { |
||
380 | /* LED enable Gpio */ &moduleGpioLed,
|
||
381 | }; |
||
382 | |||
383 | LTC4412Driver moduleLldPowerPathController = { |
||
384 | /* Control GPIO */ &moduleGpioPathDcEn,
|
||
385 | /* Status GPIO */ &moduleGpioPathDcStat,
|
||
386 | }; |
||
387 | |||
388 | PCA9544ADriver moduleLldI2cMultiplexer = { |
||
389 | /* I²C driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
390 | /* I²C address */ PCA9544A_LLD_I2C_ADDR_FIXED | PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
||
391 | }; |
||
392 | |||
393 | TPS6211xDriver moduleLldStepDownConverterVdrive = { |
||
394 | /* Power enable Gpio */ &moduleGpioPowerEn,
|
||
395 | }; |
||
396 | |||
397 | VCNL4020Driver moduleLldProximity = { |
||
398 | /* I²C Driver */ &MODULE_HAL_I2C_PROX_EEPROM_PWRMTR,
|
||
399 | }; |
||
400 | |||
401 | /** @} */
|
||
402 | |||
403 | /*===========================================================================*/
|
||
404 | /**
|
||
405 | 4c72a54c | Thomas Schöpping | * @name Tests
|
406 | abb8b3f4 | Thomas Schöpping | * @{
|
407 | */
|
||
408 | /*===========================================================================*/
|
||
409 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
410 | |||
411 | /*
|
||
412 | * A3906 (motor driver)
|
||
413 | */
|
||
414 | 4c72a54c | Thomas Schöpping | #include <module_test_A3906.h> |
415 | static int _testA3906ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
416 | abb8b3f4 | Thomas Schöpping | { |
417 | 4c72a54c | Thomas Schöpping | return moduleTestA3906ShellCb(stream, argc, argv, NULL); |
418 | abb8b3f4 | Thomas Schöpping | } |
419 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestA3906ShellCmd, "test:MotorDriver", _testA3906ShellCmdCb);
|
420 | abb8b3f4 | Thomas Schöpping | |
421 | /*
|
||
422 | 4c72a54c | Thomas Schöpping | * AT24C01BN-SH-B (EEPROM)
|
423 | abb8b3f4 | Thomas Schöpping | */
|
424 | 4c72a54c | Thomas Schöpping | #include <module_test_AT24C01B.h> |
425 | static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
426 | abb8b3f4 | Thomas Schöpping | { |
427 | 4c72a54c | Thomas Schöpping | return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
428 | abb8b3f4 | Thomas Schöpping | } |
429 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
|
430 | |||
431 | // TODO: BNO055
|
||
432 | abb8b3f4 | Thomas Schöpping | |
433 | /*
|
||
434 | * INA219 (power monitor)
|
||
435 | */
|
||
436 | 4c72a54c | Thomas Schöpping | #include <module_test_INA219.h> |
437 | static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
438 | abb8b3f4 | Thomas Schöpping | { |
439 | 4c72a54c | Thomas Schöpping | return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
440 | abb8b3f4 | Thomas Schöpping | } |
441 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
442 | abb8b3f4 | Thomas Schöpping | |
443 | /*
|
||
444 | * Status LED
|
||
445 | */
|
||
446 | 4c72a54c | Thomas Schöpping | #include <module_test_LED.h> |
447 | static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
448 | abb8b3f4 | Thomas Schöpping | { |
449 | 4c72a54c | Thomas Schöpping | return moduleTestLedShellCb(stream, argc, argv, NULL); |
450 | abb8b3f4 | Thomas Schöpping | } |
451 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
452 | abb8b3f4 | Thomas Schöpping | |
453 | /*
|
||
454 | * LTC4412 (power path controller)
|
||
455 | */
|
||
456 | 4c72a54c | Thomas Schöpping | #include <module_test_LTC4412.h> |
457 | static int _testLtc4412ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
458 | abb8b3f4 | Thomas Schöpping | { |
459 | 4c72a54c | Thomas Schöpping | return moduleTestLtc4412ShellCb(stream, argc, argv, NULL); |
460 | abb8b3f4 | Thomas Schöpping | } |
461 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLtc4412ShellCmd, "test:PowerPathController", _testLtc4412ShellCmdCb);
|
462 | abb8b3f4 | Thomas Schöpping | |
463 | /*
|
||
464 | * PCA9544A (I2C multiplexer)
|
||
465 | */
|
||
466 | 4c72a54c | Thomas Schöpping | #include <module_test_PCA9544A.h> |
467 | static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
468 | abb8b3f4 | Thomas Schöpping | { |
469 | 4c72a54c | Thomas Schöpping | return moduleTestPca9544aShellCb(stream, argc, argv, NULL); |
470 | abb8b3f4 | Thomas Schöpping | } |
471 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
|
472 | abb8b3f4 | Thomas Schöpping | |
473 | /*
|
||
474 | * TPS62113 (step-down converter)
|
||
475 | */
|
||
476 | 4c72a54c | Thomas Schöpping | #include <module_test_TPS6211x.h> |
477 | static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
478 | abb8b3f4 | Thomas Schöpping | { |
479 | 4c72a54c | Thomas Schöpping | return moduleTestTps6211xShellCb(stream, argc, argv, NULL); |
480 | abb8b3f4 | Thomas Schöpping | } |
481 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestTps62113ShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
|
482 | abb8b3f4 | Thomas Schöpping | |
483 | /*
|
||
484 | * VCNL4020 (proximity sensor)
|
||
485 | */
|
||
486 | 4c72a54c | Thomas Schöpping | #include <module_test_VCNL4020.h> |
487 | static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
488 | abb8b3f4 | Thomas Schöpping | { |
489 | 4c72a54c | Thomas Schöpping | return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL); |
490 | abb8b3f4 | Thomas Schöpping | } |
491 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:ProximitySensor", _testVcnl4020ShellCmdCb);
|
492 | |||
493 | /*
|
||
494 | * entire module
|
||
495 | */
|
||
496 | static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
497 | abb8b3f4 | Thomas Schöpping | { |
498 | 4c72a54c | Thomas Schöpping | (void)argc;
|
499 | (void)argv;
|
||
500 | |||
501 | int status = AOS_OK;
|
||
502 | char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
||
503 | aos_testresult_t result_test = {0, 0}; |
||
504 | aos_testresult_t result_total = {0, 0}; |
||
505 | |||
506 | /* A3906 (motor driver) */
|
||
507 | status |= moduleTestA3906ShellCb(stream, 0, targv, &result_test);
|
||
508 | result_total = aosTestResultAdd(result_total, result_test); |
||
509 | |||
510 | /* AT24C01B (EEPROM) */
|
||
511 | status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
||
512 | result_total = aosTestResultAdd(result_total, result_test); |
||
513 | |||
514 | // TODO: BNO055
|
||
515 | |||
516 | /* INA219 (power monitor) */
|
||
517 | status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
|
||
518 | result_total = aosTestResultAdd(result_total, result_test); |
||
519 | |||
520 | /* Status LED */
|
||
521 | status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
||
522 | result_total = aosTestResultAdd(result_total, result_test); |
||
523 | |||
524 | /* LTC4412 (power path controller) */
|
||
525 | status |= moduleTestLtc4412ShellCb(stream, 0, targv, &result_test);
|
||
526 | result_total = aosTestResultAdd(result_total, result_test); |
||
527 | |||
528 | /* PCA9544A (I2C multiplexer) */
|
||
529 | status |= moduleTestPca9544aShellCb(stream, 0, targv, &result_test);
|
||
530 | result_total = aosTestResultAdd(result_total, result_test); |
||
531 | |||
532 | /* TPS62113 (step-down converter) */
|
||
533 | status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
|
||
534 | result_total = aosTestResultAdd(result_total, result_test); |
||
535 | |||
536 | /* VCNL4020 (proximity sensor) */
|
||
537 | // wheel left
|
||
538 | targv[1] = "-wl"; |
||
539 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
540 | result_total = aosTestResultAdd(result_total, result_test); |
||
541 | // front left
|
||
542 | targv[1] = "-fl"; |
||
543 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
544 | result_total = aosTestResultAdd(result_total, result_test); |
||
545 | // front right
|
||
546 | targv[1] = "-fr"; |
||
547 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
548 | result_total = aosTestResultAdd(result_total, result_test); |
||
549 | // wheel right
|
||
550 | targv[1] = "-wr"; |
||
551 | status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
||
552 | result_total = aosTestResultAdd(result_total, result_test); |
||
553 | targv[1] = ""; |
||
554 | |||
555 | // print total result
|
||
556 | chprintf(stream, "\n");
|
||
557 | aosTestResultPrintSummary(stream, &result_total, "entire module");
|
||
558 | |||
559 | return status;
|
||
560 | abb8b3f4 | Thomas Schöpping | } |
561 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
562 | abb8b3f4 | Thomas Schöpping | |
563 | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
||
564 | |||
565 | /** @} */
|
||
566 | /** @} */ |