amiro-os / modules / LightRing_1-2 / module.c @ f38aba21
History | View | Annotate | Download (20.017 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 LightRing v1.2 module.
|
22 |
*
|
23 |
* @addtogroup lightring_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 moduleHalI2cEepromPwrmtrBreakoutConfig = { |
51 |
/* I²C mode */ OPMODE_I2C,
|
52 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
53 |
/* duty cycle */ FAST_DUTY_CYCLE_2,
|
54 |
}; |
55 |
|
56 |
SerialConfig moduleHalProgIfConfig = { |
57 |
/* bit rate */ 115200, |
58 |
/* CR1 */ 0, |
59 |
/* CR1 */ 0, |
60 |
/* CR1 */ 0, |
61 |
}; |
62 |
|
63 |
SPIConfig moduleHalSpiLightConfig = { |
64 |
/* circular buffer mode */ false, |
65 |
/* callback function pointer */ NULL, |
66 |
/* chip select line port */ PAL_PORT(LINE_LIGHT_XLAT),
|
67 |
/* chip select line pad number */ PAL_PAD(LINE_LIGHT_XLAT),
|
68 |
/* CR1 */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
|
69 |
/* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
|
70 |
}; |
71 |
|
72 |
#if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
73 |
|
74 |
SPIConfig moduleHalSpiUwbHsConfig = { |
75 |
/* circular buffer mode */ false, |
76 |
/* callback function pointer */ NULL, |
77 |
/* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
78 |
/* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
79 |
/* CR1 */ 0, // 36/2 Mbps |
80 |
/* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
81 |
}; |
82 |
|
83 |
SPIConfig moduleHalSpiUwbLsConfig = { |
84 |
/* circular buffer mode */ false, |
85 |
/* callback function pointer */ NULL, |
86 |
/* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
87 |
/* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
88 |
/* CR1 */ SPI_CR1_BR_1 | SPI_CR1_BR_0, // 36/16 Mbps |
89 |
/* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
90 |
}; |
91 |
|
92 |
#endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
93 |
|
94 |
/*===========================================================================*/
|
95 |
/**
|
96 |
* @name GPIO definitions
|
97 |
* @{
|
98 |
*/
|
99 |
/*===========================================================================*/
|
100 |
|
101 |
/**
|
102 |
* @brief LIGHT_BANK output signal GPIO.
|
103 |
*/
|
104 |
static apalGpio_t _gpioLightBlank = {
|
105 |
/* line */ LINE_LIGHT_BLANK,
|
106 |
}; |
107 |
ROMCONST apalControlGpio_t moduleGpioLightBlank = { |
108 |
/* GPIO */ &_gpioLightBlank,
|
109 |
/* meta */ {
|
110 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
111 |
/* active state */ TLC5947_LLD_BLANK_ACTIVE_STATE,
|
112 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
113 |
}, |
114 |
}; |
115 |
|
116 |
/**
|
117 |
* @brief RS232_R_EN_N output signal GPIO.
|
118 |
*/
|
119 |
static apalGpio_t _gpioRs232En = {
|
120 |
/* line */ LINE_RS232_R_EN_N,
|
121 |
}; |
122 |
ROMCONST apalControlGpio_t moduleGpioRs232En = { |
123 |
/* GPIO */ &_gpioRs232En,
|
124 |
/* meta */ {
|
125 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
126 |
/* active state */ APAL_GPIO_ACTIVE_LOW, //TODO |
127 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
128 |
}, |
129 |
}; |
130 |
|
131 |
/**
|
132 |
* @brief SW_V33_EN output signal GPIO.
|
133 |
*/
|
134 |
static apalGpio_t _gpioSwV33En = {
|
135 |
/* line */ LINE_SW_V33_EN,
|
136 |
}; |
137 |
ROMCONST apalControlGpio_t moduleGpioSwV33En = { |
138 |
/* GPIO */ &_gpioSwV33En,
|
139 |
/* meta */ {
|
140 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
141 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
142 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
143 |
}, |
144 |
}; |
145 |
|
146 |
// The 4.2V switch is disabled due to a hardware bug.
|
147 |
///**
|
148 |
// * @brief SW_V42_EN output signal GPIO.
|
149 |
// */
|
150 |
//static apalGpio_t _gpioSwV42En = {
|
151 |
// /* line */ LINE_SW_V42_EN,
|
152 |
//};
|
153 |
//ROMCONST apalControlGpio_t moduleGpioSwV42En = {
|
154 |
// /* GPIO */ &_gpioSwV42En,
|
155 |
// /* meta */ {
|
156 |
// /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
157 |
// /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
158 |
// /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
159 |
// },
|
160 |
//};
|
161 |
|
162 |
/**
|
163 |
* @brief SW_V50_EN output signal GPIO.
|
164 |
*/
|
165 |
static apalGpio_t _gpioSwV50En = {
|
166 |
/* line */ LINE_SW_V50_EN,
|
167 |
}; |
168 |
ROMCONST apalControlGpio_t moduleGpioSwV50En = { |
169 |
/* GPIO */ &_gpioSwV50En,
|
170 |
/* meta */ {
|
171 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
172 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
173 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
174 |
}, |
175 |
}; |
176 |
|
177 |
/**
|
178 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
179 |
*/
|
180 |
static apalGpio_t _gpioSysUartDn = {
|
181 |
/* line */ LINE_SYS_UART_DN,
|
182 |
}; |
183 |
ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
184 |
/* GPIO */ &_gpioSysUartDn,
|
185 |
/* meta */ {
|
186 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
187 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
188 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
189 |
}, |
190 |
}; |
191 |
|
192 |
/**
|
193 |
* @brief LED output signal GPIO.
|
194 |
*/
|
195 |
static apalGpio_t _gpioLed = {
|
196 |
/* line */ LINE_LED,
|
197 |
}; |
198 |
ROMCONST apalControlGpio_t moduleGpioLed = { |
199 |
/* GPIO */ &_gpioLed,
|
200 |
/* meta */ {
|
201 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
202 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
203 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
204 |
}, |
205 |
}; |
206 |
|
207 |
/**
|
208 |
* @brief LIGHT_XLAT output signal GPIO.
|
209 |
*/
|
210 |
static apalGpio_t _gpioLightXlat = {
|
211 |
/* line */ LINE_LIGHT_XLAT,
|
212 |
}; |
213 |
ROMCONST apalControlGpio_t moduleGpioLightXlat = { |
214 |
/* GPIO */ &_gpioLightXlat,
|
215 |
/* meta */ {
|
216 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
217 |
/* active state */ (TLC5947_LLD_XLAT_UPDATE_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
218 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
219 |
}, |
220 |
}; |
221 |
|
222 |
/**
|
223 |
* @brief SW_V18_EN output signal GPIO.
|
224 |
*/
|
225 |
static apalGpio_t _gpioSwV18En = {
|
226 |
/* line */ LINE_SW_V18_EN,
|
227 |
}; |
228 |
ROMCONST apalControlGpio_t moduleGpioSwV18En = { |
229 |
/* GPIO */ &_gpioSwV18En,
|
230 |
/* meta */ {
|
231 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
232 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
233 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
234 |
}, |
235 |
}; |
236 |
|
237 |
/**
|
238 |
* @brief SW_VSYS_EN output signal GPIO.
|
239 |
*/
|
240 |
static apalGpio_t _gpioSwVsysEn = {
|
241 |
/* line */ LINE_SW_VSYS_EN,
|
242 |
}; |
243 |
ROMCONST apalControlGpio_t moduleGpioSwVsysEn = { |
244 |
/* GPIO */ &_gpioSwVsysEn,
|
245 |
/* meta */ {
|
246 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
247 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
248 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
249 |
}, |
250 |
}; |
251 |
|
252 |
/**
|
253 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
254 |
*/
|
255 |
static apalGpio_t _gpioSysUartUp = {
|
256 |
/* line */ LINE_SYS_UART_UP,
|
257 |
}; |
258 |
ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
259 |
/* GPIO */ &_gpioSysUartUp,
|
260 |
/* meta */ {
|
261 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
262 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
263 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
264 |
}, |
265 |
}; |
266 |
|
267 |
/**
|
268 |
* @brief SYS_PD bidirectional signal GPIO.
|
269 |
*/
|
270 |
static apalGpio_t _gpioSysPd = {
|
271 |
/* line */ LINE_SYS_PD_N,
|
272 |
}; |
273 |
ROMCONST apalControlGpio_t moduleGpioSysPd = { |
274 |
/* GPIO */ &_gpioSysPd,
|
275 |
/* meta */ {
|
276 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
277 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
278 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
279 |
}, |
280 |
}; |
281 |
|
282 |
/**
|
283 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
284 |
*/
|
285 |
static apalGpio_t _gpioSysSync = {
|
286 |
/* line */ LINE_SYS_INT_N,
|
287 |
}; |
288 |
ROMCONST apalControlGpio_t moduleGpioSysSync = { |
289 |
/* GPIO */ &_gpioSysSync,
|
290 |
/* meta */ {
|
291 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
292 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
293 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
294 |
}, |
295 |
}; |
296 |
|
297 |
/**
|
298 |
* @brief IO_1 breakout signal GPIO.
|
299 |
*/
|
300 |
static apalGpio_t _gpioBreakoutIo1 = {
|
301 |
/* line */ LINE_IO_1,
|
302 |
}; |
303 |
|
304 |
/**
|
305 |
* @brief IO_2 breakout signal GPIO.
|
306 |
*/
|
307 |
static apalGpio_t _gpioBreakoutIo2 = {
|
308 |
/* line */ LINE_IO_2,
|
309 |
}; |
310 |
|
311 |
/**
|
312 |
* @brief IO_3 breakout signal GPIO.
|
313 |
*/
|
314 |
static apalGpio_t _gpioBreakoutIo3 = {
|
315 |
/* line */ LINE_IO_3,
|
316 |
}; |
317 |
|
318 |
/**
|
319 |
* @brief IO_4 breakout signal GPIO.
|
320 |
*/
|
321 |
static apalGpio_t _gpioBreakoutIo4 = {
|
322 |
/* line */ LINE_IO_4,
|
323 |
}; |
324 |
|
325 |
/**
|
326 |
* @brief IO_5 breakout signal GPIO.
|
327 |
*/
|
328 |
static apalGpio_t _gpioBreakoutIo5 = {
|
329 |
/* line */ LINE_IO_5,
|
330 |
}; |
331 |
|
332 |
/**
|
333 |
* @brief IO_6 breakout signal GPIO.
|
334 |
*/
|
335 |
static apalGpio_t _gpioBreakoutIo6 = {
|
336 |
/* line */ LINE_IO_6,
|
337 |
}; |
338 |
|
339 |
/**
|
340 |
* @brief IO_7 breakout signal GPIO.
|
341 |
*/
|
342 |
static apalGpio_t _gpioBreakoutIo7 = {
|
343 |
/* line */ LINE_IO_7,
|
344 |
}; |
345 |
|
346 |
/**
|
347 |
* @brief IO_8 breakout signal GPIO.
|
348 |
*/
|
349 |
static apalGpio_t _gpioBreakoutIo8 = {
|
350 |
/* line */ LINE_IO_8,
|
351 |
}; |
352 |
|
353 |
#if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_NONE)
|
354 |
|
355 |
apalControlGpio_t moduleGpioBreakoutIo1 = { |
356 |
/* GPIO */ &_gpioBreakoutIo1,
|
357 |
/* meta */ {
|
358 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
359 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
360 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
361 |
}, |
362 |
}; |
363 |
|
364 |
apalControlGpio_t moduleGpioBreakoutIo2 = { |
365 |
/* GPIO */ &_gpioBreakoutIo2,
|
366 |
/* meta */ {
|
367 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
368 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
369 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
370 |
}, |
371 |
}; |
372 |
|
373 |
apalControlGpio_t moduleGpioBreakoutIo3 = { |
374 |
/* GPIO */ &_gpioBreakoutIo3,
|
375 |
/* meta */ {
|
376 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
377 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
378 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
379 |
}, |
380 |
}; |
381 |
|
382 |
apalControlGpio_t moduleGpioBreakoutIo4 = { |
383 |
/* GPIO */ &_gpioBreakoutIo4,
|
384 |
/* meta */ {
|
385 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
386 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
387 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
388 |
}, |
389 |
}; |
390 |
|
391 |
apalControlGpio_t moduleGpioBreakoutIo5 = { |
392 |
/* GPIO */ &_gpioBreakoutIo5,
|
393 |
/* meta */ {
|
394 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
395 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
396 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
397 |
}, |
398 |
}; |
399 |
|
400 |
apalControlGpio_t moduleGpioBreakoutIo6 = { |
401 |
/* GPIO */ &_gpioBreakoutIo6,
|
402 |
/* meta */ {
|
403 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
404 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
405 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
406 |
}, |
407 |
}; |
408 |
|
409 |
apalControlGpio_t moduleGpioBreakoutIo7 = { |
410 |
/* GPIO */ &_gpioBreakoutIo7,
|
411 |
/* meta */ {
|
412 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
413 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
414 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
415 |
}, |
416 |
}; |
417 |
|
418 |
apalControlGpio_t moduleGpioBreakoutIo8 = { |
419 |
/* GPIO */ &_gpioBreakoutIo8,
|
420 |
/* meta */ {
|
421 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
422 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
423 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
424 |
}, |
425 |
}; |
426 |
|
427 |
#elif (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
428 |
|
429 |
apalControlGpio_t moduleGpioBreakoutIo1 = { |
430 |
/* GPIO */ &_gpioBreakoutIo1,
|
431 |
/* meta */ {
|
432 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
433 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
434 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
435 |
}, |
436 |
}; |
437 |
|
438 |
apalControlGpio_t moduleGpioBreakoutIo2 = { |
439 |
/* GPIO */ &_gpioBreakoutIo2,
|
440 |
/* meta */ {
|
441 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
442 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
443 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
444 |
}, |
445 |
}; |
446 |
|
447 |
apalControlGpio_t moduleGpioBreakoutIo3 = { |
448 |
/* GPIO */ &_gpioBreakoutIo3,
|
449 |
/* meta */ {
|
450 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
451 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
452 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
453 |
}, |
454 |
}; |
455 |
|
456 |
apalControlGpio_t moduleGpioBreakoutIo4 = { |
457 |
/* GPIO */ &_gpioBreakoutIo4,
|
458 |
/* meta */ {
|
459 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
460 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
461 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
462 |
}, |
463 |
}; |
464 |
|
465 |
apalControlGpio_t moduleGpioBreakoutIo5 = { |
466 |
/* GPIO */ &_gpioBreakoutIo5,
|
467 |
/* meta */ {
|
468 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
469 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
470 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
471 |
}, |
472 |
}; |
473 |
|
474 |
apalControlGpio_t moduleGpioBreakoutIo6 = { |
475 |
/* GPIO */ &_gpioBreakoutIo6,
|
476 |
/* meta */ {
|
477 |
/* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
478 |
/* active state */ APAL_GPIO_ACTIVE_NONE,
|
479 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
480 |
}, |
481 |
}; |
482 |
|
483 |
apalControlGpio_t moduleGpioBreakoutIo7 = { |
484 |
/* GPIO */ &_gpioBreakoutIo7,
|
485 |
/* meta */ {
|
486 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
487 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
488 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
489 |
}, |
490 |
}; |
491 |
|
492 |
apalControlGpio_t moduleGpioBreakoutIo8 = { |
493 |
/* GPIO */ &_gpioBreakoutIo8,
|
494 |
/* meta */ {
|
495 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
496 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
497 |
/* interrupt edge */ APAL_GPIO_EDGE_RISING,
|
498 |
}, |
499 |
}; |
500 |
|
501 |
#endif
|
502 |
|
503 |
/** @} */
|
504 |
|
505 |
/*===========================================================================*/
|
506 |
/**
|
507 |
* @name AMiRo-OS core configurations
|
508 |
* @{
|
509 |
*/
|
510 |
/*===========================================================================*/
|
511 |
|
512 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
513 |
ROMCONST char* moduleShellPrompt = "LightRing"; |
514 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
515 |
|
516 |
/** @} */
|
517 |
|
518 |
/*===========================================================================*/
|
519 |
/**
|
520 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
521 |
* @{
|
522 |
*/
|
523 |
/*===========================================================================*/
|
524 |
|
525 |
/** @} */
|
526 |
|
527 |
/*===========================================================================*/
|
528 |
/**
|
529 |
* @name Low-level drivers
|
530 |
* @{
|
531 |
*/
|
532 |
/*===========================================================================*/
|
533 |
|
534 |
AT24C01BDriver moduleLldEeprom = { |
535 |
/* I2C driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
536 |
/* I2C address */ 0x00u, |
537 |
}; |
538 |
|
539 |
INA219Driver moduleLldPowerMonitorVled = { |
540 |
/* I2C Driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
541 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
542 |
/* current LSB (uA) */ 0x00u, |
543 |
/* configuration */ NULL, |
544 |
}; |
545 |
|
546 |
LEDDriver moduleLldStatusLed = { |
547 |
/* LED enable Gpio */ &moduleGpioLed,
|
548 |
}; |
549 |
|
550 |
MIC9404xDriver moduleLldPowerSwitchV18 = { |
551 |
/* power enable GPIO */ &moduleGpioSwV18En,
|
552 |
}; |
553 |
|
554 |
MIC9404xDriver moduleLldPowerSwitchV33 = { |
555 |
/* power enable GPIO */ &moduleGpioSwV33En,
|
556 |
}; |
557 |
|
558 |
// The 4.2V switch is disabled due to a hardware bug.
|
559 |
//MIC9404xDriver moduleLldPowerSwitchV42 = {
|
560 |
// /* power enable GPIO */ &moduleGpioSwV42En,
|
561 |
//};
|
562 |
|
563 |
MIC9404xDriver moduleLldPowerSwitchV50 = { |
564 |
/* power enable GPIO */ &moduleGpioSwV50En,
|
565 |
}; |
566 |
|
567 |
MIC9404xDriver moduleLldPowerSwitchVsys = { |
568 |
/* power enable GPIO */ &moduleGpioSwVsysEn,
|
569 |
}; |
570 |
|
571 |
// TODO: add SNx5C3221E
|
572 |
|
573 |
TLC5947Driver moduleLldLedPwm = { |
574 |
/* SPI driver */ &MODULE_HAL_SPI_LIGHT,
|
575 |
/* BLANK signal GPIO */ &moduleGpioLightBlank,
|
576 |
/* XLAT signal GPIO */ &moduleGpioLightXlat,
|
577 |
}; |
578 |
|
579 |
#if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
580 |
|
581 |
DW1000Driver moduleLldDw1000 = { |
582 |
/* SPI driver */ &MODULE_HAL_SPI_UWB,
|
583 |
/* interrupt GPIO */ &moduleGpioBreakoutIo8,
|
584 |
/* reset GPIO */ &moduleGpioBreakoutIo7,
|
585 |
}; |
586 |
|
587 |
#endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
588 |
|
589 |
/** @} */
|
590 |
|
591 |
/*===========================================================================*/
|
592 |
/**
|
593 |
* @name Tests
|
594 |
* @{
|
595 |
*/
|
596 |
/*===========================================================================*/
|
597 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
598 |
|
599 |
/*
|
600 |
* AT24C01BN-SH-B (EEPROM)
|
601 |
*/
|
602 |
#include <module_test_AT24C01B.h> |
603 |
static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
604 |
{ |
605 |
return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
606 |
} |
607 |
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
|
608 |
|
609 |
/*
|
610 |
* INA219 (power monitor)
|
611 |
*/
|
612 |
#include <module_test_INA219.h> |
613 |
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
614 |
{ |
615 |
return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
616 |
} |
617 |
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
618 |
|
619 |
/*
|
620 |
* Status LED
|
621 |
*/
|
622 |
#include <module_test_LED.h> |
623 |
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
624 |
{ |
625 |
return moduleTestLedShellCb(stream, argc, argv, NULL); |
626 |
} |
627 |
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
628 |
|
629 |
/*
|
630 |
* MIC9404x (power switch)
|
631 |
*/
|
632 |
#include <module_test_MIC9404x.h> |
633 |
static int _testMic9404xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
634 |
{ |
635 |
return moduleTestMic9404xShellCb(stream, argc, argv, NULL); |
636 |
} |
637 |
AOS_SHELL_COMMAND(moduleTestMic9404xShellCmd, "test:PowerSwitch", _testMic9404xShellCmdCb);
|
638 |
|
639 |
// TODO: add SNx5C3221E
|
640 |
|
641 |
/*
|
642 |
* TLC5947 (24 channel PWM LED driver)
|
643 |
*/
|
644 |
#include <module_test_TLC5947.h> |
645 |
static int _testTlc5947ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
646 |
{ |
647 |
return moduleTestTlc5947ShellCb(stream, argc, argv, NULL); |
648 |
} |
649 |
AOS_SHELL_COMMAND(moduleTestTlc5947ShellCmd, "test:Lights", _testTlc5947ShellCmdCb);
|
650 |
|
651 |
#if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
652 |
|
653 |
/*
|
654 |
* UwB Driver (DW1000)
|
655 |
*/
|
656 |
#include <module_test_DW1000.h> |
657 |
static int _testDw1000ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
658 |
{ |
659 |
return moduleTestDw1000ShellCb(stream, argc, argv, NULL); |
660 |
} |
661 |
AOS_SHELL_COMMAND(moduleTestDw1000ShellCmd, "test:DW1000", _testDw1000ShellCmdCb);
|
662 |
|
663 |
#endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
664 |
|
665 |
/*
|
666 |
* entire module
|
667 |
*/
|
668 |
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
669 |
{ |
670 |
(void)argc;
|
671 |
(void)argv;
|
672 |
|
673 |
int status = AOS_OK;
|
674 |
char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
675 |
aos_testresult_t result_test = {0, 0}; |
676 |
aos_testresult_t result_total = {0, 0}; |
677 |
|
678 |
/* AT24C01B (EEPROM) */
|
679 |
status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
680 |
result_total = aosTestResultAdd(result_total, result_test); |
681 |
|
682 |
/* INA219 (power monitor) */
|
683 |
status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
|
684 |
result_total = aosTestResultAdd(result_total, result_test); |
685 |
|
686 |
/* Status LED */
|
687 |
status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
688 |
result_total = aosTestResultAdd(result_total, result_test); |
689 |
|
690 |
/* MIC9404x (power switch) */
|
691 |
// 1.8V
|
692 |
targv[1] = "1.8V"; |
693 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
694 |
result_total = aosTestResultAdd(result_total, result_test); |
695 |
// 3.3V
|
696 |
targv[1] = "3.3V"; |
697 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
698 |
result_total = aosTestResultAdd(result_total, result_test); |
699 |
// The 4.2V switch is disabled due to a hardware bug.
|
700 |
// // 4.2V
|
701 |
// targv[1] = "4.2V";
|
702 |
// status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
703 |
// result_total = aosTestResultAdd(result_total, result_test);
|
704 |
// 5.0V
|
705 |
targv[1] = "5.0V"; |
706 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
707 |
result_total = aosTestResultAdd(result_total, result_test); |
708 |
//VSYS
|
709 |
targv[1] = "VSYS"; |
710 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
711 |
result_total = aosTestResultAdd(result_total, result_test); |
712 |
targv[1] = ""; |
713 |
|
714 |
// TODO: add SNx5C3221E
|
715 |
|
716 |
/* TLC5947 (24 channel PWM LED driver) */
|
717 |
status |= moduleTestTlc5947ShellCb(stream, 0, targv, &result_test);
|
718 |
result_total = aosTestResultAdd(result_total, result_test); |
719 |
|
720 |
#if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
721 |
/* DW1000 (UWB transceiver) */
|
722 |
status |= moduleTestDw1000ShellCb(stream, 0, targv, &result_test);
|
723 |
result_total = aosTestResultAdd(result_total, result_test); |
724 |
#endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
725 |
|
726 |
// print total result
|
727 |
chprintf(stream, "\n");
|
728 |
aosTestResultPrintSummary(stream, &result_total, "entire module");
|
729 |
|
730 |
return status;
|
731 |
} |
732 |
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
733 |
|
734 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
735 |
|
736 |
/** @} */
|
737 |
/** @} */
|