amiro-os / modules / LightRing_1-2 / module.c @ 080149cf
History | View | Annotate | Download (16.571 KB)
1 | 9ae7c4f3 | 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 | 034cb15a | Thomas Schöpping | * @brief Structures and constant for the LightRing v1.2 module.
|
22 | 9ae7c4f3 | Thomas Schöpping | *
|
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 | ee884101 | Thomas Schöpping | I2CConfig moduleHalI2cEepromPwrmtrBreakoutConfig = { |
51 | 9ae7c4f3 | Thomas Schöpping | /* 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 | 3106e8cc | Thomas Schöpping | /* chip select line port */ PAL_PORT(LINE_LIGHT_XLAT),
|
67 | /* chip select line pad number */ PAL_PAD(LINE_LIGHT_XLAT),
|
||
68 | 9ae7c4f3 | Thomas Schöpping | /* CR1 */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
|
69 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
|
||
70 | }; |
||
71 | |||
72 | |||
73 | /*===========================================================================*/
|
||
74 | /**
|
||
75 | * @name GPIO definitions
|
||
76 | * @{
|
||
77 | */
|
||
78 | /*===========================================================================*/
|
||
79 | |||
80 | /**
|
||
81 | * @brief LIGHT_BANK output signal GPIO.
|
||
82 | */
|
||
83 | static apalGpio_t _gpioLightBlank = {
|
||
84 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LIGHT_BLANK,
|
85 | 9ae7c4f3 | Thomas Schöpping | }; |
86 | ROMCONST apalControlGpio_t moduleGpioLightBlank = { |
||
87 | /* GPIO */ &_gpioLightBlank,
|
||
88 | /* meta */ {
|
||
89 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
90 | /* active state */ TLC5947_LLD_BLANK_ACTIVE_STATE,
|
||
91 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
92 | }, |
||
93 | }; |
||
94 | |||
95 | /**
|
||
96 | * @brief RS232_R_EN_N output signal GPIO.
|
||
97 | */
|
||
98 | static apalGpio_t _gpioRs232En = {
|
||
99 | 3106e8cc | Thomas Schöpping | /* line */ LINE_RS232_R_EN_N,
|
100 | 9ae7c4f3 | Thomas Schöpping | }; |
101 | ROMCONST apalControlGpio_t moduleGpioRs232En = { |
||
102 | /* GPIO */ &_gpioRs232En,
|
||
103 | /* meta */ {
|
||
104 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
105 | /* active state */ APAL_GPIO_ACTIVE_LOW, //TODO |
||
106 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
107 | }, |
||
108 | }; |
||
109 | |||
110 | /**
|
||
111 | * @brief SW_V33_EN output signal GPIO.
|
||
112 | */
|
||
113 | static apalGpio_t _gpioSwV33En = {
|
||
114 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V33_EN,
|
115 | 9ae7c4f3 | Thomas Schöpping | }; |
116 | ROMCONST apalControlGpio_t moduleGpioSwV33En = { |
||
117 | /* GPIO */ &_gpioSwV33En,
|
||
118 | /* meta */ {
|
||
119 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
120 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
121 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
122 | }, |
||
123 | }; |
||
124 | |||
125 | /**
|
||
126 | * @brief SW_V42_EN output signal GPIO.
|
||
127 | */
|
||
128 | static apalGpio_t _gpioSwV42En = {
|
||
129 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V42_EN,
|
130 | 9ae7c4f3 | Thomas Schöpping | }; |
131 | ROMCONST apalControlGpio_t moduleGpioSwV42En = { |
||
132 | /* GPIO */ &_gpioSwV42En,
|
||
133 | /* meta */ {
|
||
134 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
135 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
136 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
137 | }, |
||
138 | }; |
||
139 | |||
140 | /**
|
||
141 | * @brief SW_V50_EN output signal GPIO.
|
||
142 | */
|
||
143 | static apalGpio_t _gpioSwV50En = {
|
||
144 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V50_EN,
|
145 | 9ae7c4f3 | Thomas Schöpping | }; |
146 | ROMCONST apalControlGpio_t moduleGpioSwV50En = { |
||
147 | /* GPIO */ &_gpioSwV50En,
|
||
148 | /* meta */ {
|
||
149 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
150 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
151 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
152 | }, |
||
153 | }; |
||
154 | |||
155 | /**
|
||
156 | * @brief IO_3 breakout signal GPIO.
|
||
157 | */
|
||
158 | static apalGpio_t _gpioBreakoutIo3 = {
|
||
159 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_3,
|
160 | 9ae7c4f3 | Thomas Schöpping | }; |
161 | apalControlGpio_t moduleGpioBreakoutIo3 = { |
||
162 | /* GPIO */ &_gpioBreakoutIo3,
|
||
163 | /* meta */ {
|
||
164 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
165 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
166 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
167 | }, |
||
168 | }; |
||
169 | |||
170 | /**
|
||
171 | * @brief IO_5 breakout signal GPIO.
|
||
172 | */
|
||
173 | static apalGpio_t _gpioBreakoutIo5 = {
|
||
174 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_5,
|
175 | 9ae7c4f3 | Thomas Schöpping | }; |
176 | apalControlGpio_t moduleGpioBreakoutIo5 = { |
||
177 | /* GPIO */ &_gpioBreakoutIo5,
|
||
178 | /* meta */ {
|
||
179 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
180 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
181 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
182 | }, |
||
183 | }; |
||
184 | |||
185 | /**
|
||
186 | * @brief IO_6 breakout signal GPIO.
|
||
187 | */
|
||
188 | static apalGpio_t _gpioBreakoutIo6 = {
|
||
189 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_6,
|
190 | 9ae7c4f3 | Thomas Schöpping | }; |
191 | apalControlGpio_t moduleGpioBreakoutIo6 = { |
||
192 | /* GPIO */ &_gpioBreakoutIo6,
|
||
193 | /* meta */ {
|
||
194 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
195 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
196 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
197 | }, |
||
198 | }; |
||
199 | |||
200 | /**
|
||
201 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
202 | */
|
||
203 | static apalGpio_t _gpioSysUartDn = {
|
||
204 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_DN,
|
205 | 9ae7c4f3 | Thomas Schöpping | }; |
206 | ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
||
207 | /* GPIO */ &_gpioSysUartDn,
|
||
208 | /* meta */ {
|
||
209 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
210 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
211 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
212 | }, |
||
213 | }; |
||
214 | |||
215 | /**
|
||
216 | * @brief IO_7 breakout signal GPIO.
|
||
217 | */
|
||
218 | static apalGpio_t _gpioBreakoutIo7 = {
|
||
219 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_7,
|
220 | 9ae7c4f3 | Thomas Schöpping | }; |
221 | apalControlGpio_t moduleGpioBreakoutIo7 = { |
||
222 | /* GPIO */ &_gpioBreakoutIo7,
|
||
223 | /* meta */ {
|
||
224 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
225 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
226 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
227 | }, |
||
228 | }; |
||
229 | |||
230 | /**
|
||
231 | * @brief IO_8 breakout signal GPIO.
|
||
232 | */
|
||
233 | static apalGpio_t _gpioBreakoutIo8 = {
|
||
234 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_8,
|
235 | 9ae7c4f3 | Thomas Schöpping | }; |
236 | apalControlGpio_t moduleGpioBreakoutIo8 = { |
||
237 | /* GPIO */ &_gpioBreakoutIo8,
|
||
238 | /* meta */ {
|
||
239 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
240 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
241 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
242 | }, |
||
243 | }; |
||
244 | |||
245 | /**
|
||
246 | * @brief IO_4 breakout signal GPIO.
|
||
247 | */
|
||
248 | static apalGpio_t _gpioBreakoutIo4 = {
|
||
249 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_4,
|
250 | 9ae7c4f3 | Thomas Schöpping | }; |
251 | apalControlGpio_t moduleGpioBreakoutIo4 = { |
||
252 | /* GPIO */ &_gpioBreakoutIo4,
|
||
253 | /* meta */ {
|
||
254 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
255 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
256 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
257 | }, |
||
258 | }; |
||
259 | |||
260 | /**
|
||
261 | * @brief IO_1 breakout signal GPIO.
|
||
262 | */
|
||
263 | static apalGpio_t _gpioBreakoutIo1 = {
|
||
264 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_1,
|
265 | 9ae7c4f3 | Thomas Schöpping | }; |
266 | apalControlGpio_t moduleGpioBreakoutIo1 = { |
||
267 | /* GPIO */ &_gpioBreakoutIo1,
|
||
268 | /* meta */ {
|
||
269 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
270 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
271 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
272 | }, |
||
273 | }; |
||
274 | |||
275 | /**
|
||
276 | * @brief IO_2 breakout signal GPIO.
|
||
277 | */
|
||
278 | static apalGpio_t _gpioBreakoutIo2 = {
|
||
279 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_2,
|
280 | 9ae7c4f3 | Thomas Schöpping | }; |
281 | apalControlGpio_t moduleGpioBreakoutIo2 = { |
||
282 | /* GPIO */ &_gpioBreakoutIo2,
|
||
283 | /* meta */ {
|
||
284 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
285 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
286 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
287 | }, |
||
288 | }; |
||
289 | |||
290 | /**
|
||
291 | * @brief LED output signal GPIO.
|
||
292 | */
|
||
293 | static apalGpio_t _gpioLed = {
|
||
294 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LED,
|
295 | 9ae7c4f3 | Thomas Schöpping | }; |
296 | ROMCONST apalControlGpio_t moduleGpioLed = { |
||
297 | /* GPIO */ &_gpioLed,
|
||
298 | /* meta */ {
|
||
299 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
300 | /* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
||
301 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
302 | }, |
||
303 | }; |
||
304 | |||
305 | /**
|
||
306 | * @brief SW_V18_EN output signal GPIO.
|
||
307 | */
|
||
308 | static apalGpio_t _gpioSwV18En = {
|
||
309 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V18_EN,
|
310 | 9ae7c4f3 | Thomas Schöpping | }; |
311 | ROMCONST apalControlGpio_t moduleGpioSwV18En = { |
||
312 | /* GPIO */ &_gpioSwV18En,
|
||
313 | /* meta */ {
|
||
314 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
315 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
316 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
317 | }, |
||
318 | }; |
||
319 | |||
320 | /**
|
||
321 | * @brief SW_VSYS_EN output signal GPIO.
|
||
322 | */
|
||
323 | static apalGpio_t _gpioSwVsysEn = {
|
||
324 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_VSYS_EN,
|
325 | 9ae7c4f3 | Thomas Schöpping | }; |
326 | ROMCONST apalControlGpio_t moduleGpioSwVsysEn = { |
||
327 | /* GPIO */ &_gpioSwVsysEn,
|
||
328 | /* meta */ {
|
||
329 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
330 | ee884101 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
331 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
332 | }, |
||
333 | }; |
||
334 | |||
335 | /**
|
||
336 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
337 | */
|
||
338 | static apalGpio_t _gpioSysUartUp = {
|
||
339 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_UP,
|
340 | 9ae7c4f3 | Thomas Schöpping | }; |
341 | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
||
342 | /* GPIO */ &_gpioSysUartUp,
|
||
343 | /* meta */ {
|
||
344 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
345 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
346 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
347 | }, |
||
348 | }; |
||
349 | |||
350 | /**
|
||
351 | * @brief SYS_PD bidirectional signal GPIO.
|
||
352 | */
|
||
353 | static apalGpio_t _gpioSysPd = {
|
||
354 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_PD_N,
|
355 | 9ae7c4f3 | Thomas Schöpping | }; |
356 | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
||
357 | /* GPIO */ &_gpioSysPd,
|
||
358 | /* meta */ {
|
||
359 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
360 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
361 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
362 | }, |
||
363 | }; |
||
364 | |||
365 | /**
|
||
366 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
367 | */
|
||
368 | static apalGpio_t _gpioSysSync = {
|
||
369 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_INT_N,
|
370 | 9ae7c4f3 | Thomas Schöpping | }; |
371 | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
||
372 | /* GPIO */ &_gpioSysSync,
|
||
373 | /* meta */ {
|
||
374 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
375 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
376 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
377 | }, |
||
378 | }; |
||
379 | |||
380 | /** @} */
|
||
381 | |||
382 | /*===========================================================================*/
|
||
383 | /**
|
||
384 | * @name AMiRo-OS core configurations
|
||
385 | * @{
|
||
386 | */
|
||
387 | /*===========================================================================*/
|
||
388 | |||
389 | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
390 | ROMCONST char* moduleShellPrompt = "LightRing"; |
||
391 | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
||
392 | |||
393 | /** @} */
|
||
394 | |||
395 | /*===========================================================================*/
|
||
396 | /**
|
||
397 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
398 | * @{
|
||
399 | */
|
||
400 | /*===========================================================================*/
|
||
401 | |||
402 | /** @} */
|
||
403 | |||
404 | /*===========================================================================*/
|
||
405 | /**
|
||
406 | * @name Low-level drivers
|
||
407 | * @{
|
||
408 | */
|
||
409 | /*===========================================================================*/
|
||
410 | |||
411 | AT24C01BDriver moduleLldEeprom = { |
||
412 | ee884101 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
413 | 9ae7c4f3 | Thomas Schöpping | /* I2C address */ 0x00u, |
414 | }; |
||
415 | |||
416 | ee884101 | Thomas Schöpping | INA219Driver moduleLldPowerMonitorVled = { |
417 | /* I2C Driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
||
418 | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
||
419 | /* current LSB (uA) */ 0x00u, |
||
420 | /* configuration */ NULL, |
||
421 | }; |
||
422 | |||
423 | LEDDriver moduleLldStatusLed = { |
||
424 | /* LED enable Gpio */ &moduleGpioLed,
|
||
425 | }; |
||
426 | |||
427 | MIC9404xDriver moduleLldPowerSwitchV18 = { |
||
428 | /* power enable GPIO */ &moduleGpioSwV18En,
|
||
429 | }; |
||
430 | |||
431 | MIC9404xDriver moduleLldPowerSwitchV33 = { |
||
432 | /* power enable GPIO */ &moduleGpioSwV33En,
|
||
433 | }; |
||
434 | |||
435 | MIC9404xDriver moduleLldPowerSwitchV42 = { |
||
436 | /* power enable GPIO */ &moduleGpioSwV42En,
|
||
437 | }; |
||
438 | |||
439 | MIC9404xDriver moduleLldPowerSwitchV50 = { |
||
440 | /* power enable GPIO */ &moduleGpioSwV50En,
|
||
441 | }; |
||
442 | |||
443 | MIC9404xDriver moduleLldPowerSwitchVsys = { |
||
444 | /* power enable GPIO */ &moduleGpioSwVsysEn,
|
||
445 | }; |
||
446 | |||
447 | 9ae7c4f3 | Thomas Schöpping | TLC5947Driver moduleLldLedPwm = { |
448 | /* SPI driver */ &MODULE_HAL_SPI_LIGHT,
|
||
449 | /* BLANK signal GPIO */ &moduleGpioLightBlank,
|
||
450 | 3106e8cc | Thomas Schöpping | /* XLAT signal GPIO */ NULL, |
451 | 9ae7c4f3 | Thomas Schöpping | }; |
452 | |||
453 | /** @} */
|
||
454 | |||
455 | /*===========================================================================*/
|
||
456 | /**
|
||
457 | * @name Unit tests (UT)
|
||
458 | * @{
|
||
459 | */
|
||
460 | /*===========================================================================*/
|
||
461 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
462 | ee884101 | Thomas Schöpping | #include <string.h> |
463 | 9ae7c4f3 | Thomas Schöpping | |
464 | /*
|
||
465 | * EEPROM (AT24C01B)
|
||
466 | */
|
||
467 | static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
||
468 | { |
||
469 | (void)argc;
|
||
470 | (void)argv;
|
||
471 | aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
||
472 | return AOS_OK;
|
||
473 | } |
||
474 | static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
||
475 | /* driver */ &moduleLldEeprom,
|
||
476 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
477 | }; |
||
478 | aos_unittest_t moduleUtAlldAt24c01b = { |
||
479 | /* name */ "AT24C01B", |
||
480 | /* info */ "1kbit EEPROM", |
||
481 | /* test function */ utAlldAt24c01bFunc,
|
||
482 | /* shell command */ {
|
||
483 | /* name */ "unittest:EEPROM", |
||
484 | /* callback */ _utShellCmdCb_AlldAt24c01b,
|
||
485 | /* next */ NULL, |
||
486 | }, |
||
487 | /* data */ &_utAlldAt24c01bData,
|
||
488 | }; |
||
489 | |||
490 | /*
|
||
491 | ee884101 | Thomas Schöpping | * INA219 (power monitor)
|
492 | */
|
||
493 | static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
||
494 | { |
||
495 | (void)argc;
|
||
496 | (void)argv;
|
||
497 | aosUtRun(stream, &moduleUtAlldIna219, "VLED (4.2V)");
|
||
498 | return AOS_OK;
|
||
499 | } |
||
500 | static ut_ina219data_t _utIna219Data = {
|
||
501 | /* driver */ &moduleLldPowerMonitorVled,
|
||
502 | /* expected voltage */ 4.2f, |
||
503 | /* tolerance */ 0.2f, |
||
504 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
505 | }; |
||
506 | aos_unittest_t moduleUtAlldIna219 = { |
||
507 | /* name */ "INA219", |
||
508 | /* info */ "power monitor", |
||
509 | /* test function */ utAlldIna219Func,
|
||
510 | /* shell command */ {
|
||
511 | /* name */ "unittest:PowerMonitor", |
||
512 | /* callback */ _utShellCmdCb_AlldIna219,
|
||
513 | /* next */ NULL, |
||
514 | }, |
||
515 | /* data */ &_utIna219Data,
|
||
516 | }; |
||
517 | |||
518 | /*
|
||
519 | * Status LED
|
||
520 | */
|
||
521 | static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
||
522 | { |
||
523 | (void)argc;
|
||
524 | (void)argv;
|
||
525 | aosUtRun(stream, &moduleUtAlldLed, NULL);
|
||
526 | return AOS_OK;
|
||
527 | } |
||
528 | aos_unittest_t moduleUtAlldLed = { |
||
529 | /* name */ "LED", |
||
530 | /* info */ NULL, |
||
531 | /* test function */ utAlldLedFunc,
|
||
532 | /* shell command */ {
|
||
533 | /* name */ "unittest:StatusLED", |
||
534 | /* callback */ _utShellCmdCb_AlldLed,
|
||
535 | /* next */ NULL, |
||
536 | }, |
||
537 | /* data */ &moduleLldStatusLed,
|
||
538 | }; |
||
539 | |||
540 | /*
|
||
541 | * Power switch driver (MIC9404x)
|
||
542 | */
|
||
543 | static int _utShellCmdCb_Mic9404x(BaseSequentialStream* stream, int argc, char* argv[]) |
||
544 | { |
||
545 | // evaluate arguments
|
||
546 | if (argc == 2) { |
||
547 | if (strcmp(argv[1], "1.8V") == 0) { |
||
548 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV18; |
||
549 | aosUtRun(stream, &moduleUtAlldMic9404x, "1.8V");
|
||
550 | moduleUtAlldMic9404x.data = NULL;
|
||
551 | return AOS_OK;
|
||
552 | } |
||
553 | else if (strcmp(argv[1], "3.3V") == 0) { |
||
554 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV33; |
||
555 | aosUtRun(stream, &moduleUtAlldMic9404x, "3.3V");
|
||
556 | moduleUtAlldMic9404x.data = NULL;
|
||
557 | return AOS_OK;
|
||
558 | } |
||
559 | else if (strcmp(argv[1], "4.2V") == 0) { |
||
560 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV42; |
||
561 | aosUtRun(stream, &moduleUtAlldMic9404x, "4.2V");
|
||
562 | moduleUtAlldMic9404x.data = NULL;
|
||
563 | return AOS_OK;
|
||
564 | } |
||
565 | else if (strcmp(argv[1], "5.0V") == 0) { |
||
566 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV50; |
||
567 | aosUtRun(stream, &moduleUtAlldMic9404x, "5.0V");
|
||
568 | moduleUtAlldMic9404x.data = NULL;
|
||
569 | return AOS_OK;
|
||
570 | } |
||
571 | else if (strcmp(argv[1], "VSYS") == 0) { |
||
572 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchVsys; |
||
573 | aosUtRun(stream, &moduleUtAlldMic9404x, "VSYS");
|
||
574 | moduleUtAlldMic9404x.data = NULL;
|
||
575 | return AOS_OK;
|
||
576 | } |
||
577 | } |
||
578 | // print help
|
||
579 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
580 | chprintf(stream, "Options:\n");
|
||
581 | chprintf(stream, " 1.8V\n");
|
||
582 | chprintf(stream, " Test power switch for 1.8V supply.\n");
|
||
583 | chprintf(stream, " 3.3V\n");
|
||
584 | chprintf(stream, " Test power switch for 3.3V supply.\n");
|
||
585 | chprintf(stream, " 4.2V\n");
|
||
586 | chprintf(stream, " Test power switch for 4.2V supply.\n");
|
||
587 | chprintf(stream, " 5.0V\n");
|
||
588 | chprintf(stream, " Test power switch for 5.0V supply.\n");
|
||
589 | chprintf(stream, " VSYS\n");
|
||
590 | chprintf(stream, " Test power switch for VSYS supply.\n");
|
||
591 | 916f8d28 | Thomas Schöpping | return AOS_INVALIDARGUMENTS;
|
592 | ee884101 | Thomas Schöpping | } |
593 | aos_unittest_t moduleUtAlldMic9404x = { |
||
594 | /* info */ "MIC9404x", |
||
595 | /* name */ "power swicth driver", |
||
596 | /* test function */ utAlldMic9404xFunc,
|
||
597 | /* shell command */ {
|
||
598 | /* name */ "unittest:PowerSwitch", |
||
599 | /* callback */ _utShellCmdCb_Mic9404x,
|
||
600 | /* next */ NULL, |
||
601 | }, |
||
602 | /* data */ NULL, |
||
603 | }; |
||
604 | |||
605 | /*
|
||
606 | 9ae7c4f3 | Thomas Schöpping | * LED PWM driver (TLC5947)
|
607 | */
|
||
608 | static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[]) |
||
609 | { |
||
610 | (void)argc;
|
||
611 | (void)argv;
|
||
612 | aosUtRun(stream, &moduleUtAlldTlc5947, NULL);
|
||
613 | return AOS_OK;
|
||
614 | } |
||
615 | aos_unittest_t moduleUtAlldTlc5947 = { |
||
616 | /* info */ "TLC5947", |
||
617 | /* name */ "LED PWM driver", |
||
618 | /* test function */ utAlldTlc5947Func,
|
||
619 | /* shell command */ {
|
||
620 | /* name */ "unittest:Lights", |
||
621 | /* callback */ _utShellCmdCb_Tlc5947,
|
||
622 | /* next */ NULL, |
||
623 | }, |
||
624 | /* data */ &moduleLldLedPwm,
|
||
625 | }; |
||
626 | |||
627 | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
||
628 | |||
629 | /** @} */
|
||
630 | /** @} */ |