Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / module.c @ 47e89ebf

History | View | Annotate | Download (32.9 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 84f0ce9e Thomas Schöpping
Copyright (C) 2016..2019  Thomas Schöpping et al.
4 e545e620 Thomas Schöpping

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19 53710ca3 Marc Rothmann
/**
20 acc97cbf Thomas Schöpping
 * @file
21 53710ca3 Marc Rothmann
 * @brief   Structures and constant for the PowerManagement module.
22
 *
23
 * @addtogroup powermanagement_module
24
 * @{
25
 */
26
27 e545e620 Thomas Schöpping
#include "module.h"
28
29
/*===========================================================================*/
30
/**
31
 * @name Module specific functions
32
 * @{
33
 */
34
/*===========================================================================*/
35
36
/** @} */
37
38
/*===========================================================================*/
39
/**
40
 * @name ChibiOS/HAL configuration
41
 * @{
42
 */
43
/*===========================================================================*/
44
45
ADCConversionGroup moduleHalAdcVsysConversionGroup = {
46
  /* buffer type        */ true,
47
  /* number of channels */ 1,
48
  /* callback function  */ NULL,
49
  /* error callback     */ NULL,
50
  /* CR1                */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
51
  /* CR2                */ ADC_CR2_SWSTART | ADC_CR2_CONT,
52
  /* SMPR1              */ 0,
53
  /* SMPR2              */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
54
  /* HTR                */ ADC_HTR_HT,
55
  /* LTR                */ 0,
56
  /* SQR1               */ ADC_SQR1_NUM_CH(1),
57
  /* SQR2               */ 0,
58
  /* SQR3               */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
59
};
60
61
CANConfig moduleHalCanConfig = {
62
  /* mcr  */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
63 933df08e Thomas Schöpping
  /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1),
64 e545e620 Thomas Schöpping
};
65
66 8be006e0 Thomas Schöpping
I2CConfig moduleHalI2cSrPm18Pm33GaugeRearConfig = {
67 e545e620 Thomas Schöpping
  /* I²C mode   */ OPMODE_I2C,
68
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
69
  /* duty cycle */ FAST_DUTY_CYCLE_2,
70
};
71
72 8be006e0 Thomas Schöpping
I2CConfig moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig = {
73 e545e620 Thomas Schöpping
  /* I²C mode   */ OPMODE_I2C,
74
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
75
  /* duty cycle */ FAST_DUTY_CYCLE_2,
76
};
77
78
PWMConfig moduleHalPwmBuzzerConfig = {
79
  /* frequency              */ 1000000,
80
  /* period                 */ 0,
81
  /* callback               */ NULL,
82
  /* channel configurations */ {
83
    /* channel 0              */ {
84
      /* mode                   */ PWM_OUTPUT_DISABLED,
85
      /* callback               */ NULL
86
    },
87
    /* channel 1              */ {
88
      /* mode                   */ PWM_OUTPUT_ACTIVE_HIGH,
89
      /* callback               */ NULL
90
    },
91
    /* channel 2              */ {
92
      /* mode                   */ PWM_OUTPUT_DISABLED,
93
      /* callback               */ NULL
94
    },
95
    /* channel 3              */ {
96
      /* mode                   */ PWM_OUTPUT_DISABLED,
97
      /* callback               */ NULL
98
    },
99
  },
100
  /* TIM CR2 register       */ 0,
101 7de0cc90 Thomas Schöpping
#if (STM32_PWM_USE_ADVANCED == TRUE)
102 e545e620 Thomas Schöpping
  /* TIM BDTR register      */ 0,
103 7de0cc90 Thomas Schöpping
#endif /* (STM32_PWM_USE_ADVANCED == TRUE) */
104 e545e620 Thomas Schöpping
  /* TIM DIER register      */ 0,
105
};
106
107
SerialConfig moduleHalProgIfConfig = {
108
  /* bit rate */ 115200,
109
  /* CR1      */ 0,
110
  /* CR1      */ 0,
111
  /* CR1      */ 0,
112
};
113
114
/** @} */
115
116
/*===========================================================================*/
117
/**
118
 * @name GPIO definitions
119
 * @{
120
 */
121
/*===========================================================================*/
122
123 1e5f7648 Thomas Schöpping
/**
124
 * @brief   SYS_REG_EN output signal GPIO.
125
 */
126
static apalGpio_t _gpioSysRegEn = {
127 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_REG_EN,
128 e545e620 Thomas Schöpping
};
129 9af9aaea Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysRegEn = {
130 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysRegEn,
131
  /* meta */ {
132
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
133
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
134
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
135
  },
136
};
137 e545e620 Thomas Schöpping
138 1e5f7648 Thomas Schöpping
/**
139
 * @brief   IR_INT1 input signal GPIO.
140
 */
141
static apalGpio_t _gpioIrInt1 = {
142 3106e8cc Thomas Schöpping
  /* line */ LINE_IR_INT1_N,
143 e545e620 Thomas Schöpping
};
144 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioIrInt1 = {
145 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioIrInt1,
146
  /* meta */ {
147
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
148 8be006e0 Thomas Schöpping
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
149 1e5f7648 Thomas Schöpping
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
150
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
151 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
152 bffb3465 Thomas Schöpping
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
153
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
154 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
155 bffb3465 Thomas Schöpping
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
156
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
157 7de0cc90 Thomas Schöpping
#else /* (BOARD_SENSORRING == ?) */
158 8be006e0 Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
159
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
160 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == ?) */
161 1e5f7648 Thomas Schöpping
  },
162
};
163 e545e620 Thomas Schöpping
164 1e5f7648 Thomas Schöpping
/**
165
 * @brief   POWER_EN output signal GPIO.
166
 */
167
static apalGpio_t _gpioPowerEn = {
168 3106e8cc Thomas Schöpping
  /* line */ LINE_POWER_EN,
169 e545e620 Thomas Schöpping
};
170 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioPowerEn = {
171 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioPowerEn,
172
  /* meta */ {
173
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
174
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
175
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
176
  },
177
};
178 e545e620 Thomas Schöpping
179 1e5f7648 Thomas Schöpping
/**
180
 * @brief   SYS_UART_DN bidirectional signal GPIO.
181
 */
182
static apalGpio_t _gpioSysUartDn = {
183 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_UART_DN,
184 e545e620 Thomas Schöpping
};
185 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
186 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysUartDn,
187
  /* meta */ {
188
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
189
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
190
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
191
  },
192
};
193 e545e620 Thomas Schöpping
194 1e5f7648 Thomas Schöpping
/**
195
 * @brief   CHARGE_STAT2A input signal GPIO.
196
 */
197
static apalGpio_t _gpioChargeStat2A = {
198 3106e8cc Thomas Schöpping
  /* line */ LINE_CHARGE_STAT2A,
199 e545e620 Thomas Schöpping
};
200 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = {
201 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioChargeStat2A,
202
  /* meta */ {
203
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
204 ddf34c3d Thomas Schöpping
    /* active state   */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
205 1e5f7648 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
206
  },
207
};
208 e545e620 Thomas Schöpping
209 1e5f7648 Thomas Schöpping
/**
210
 * @brief   GAUGE_BATLOW2 input signal GPIO.
211
 */
212
static apalGpio_t _gpioGaugeBatLow2 = {
213 3106e8cc Thomas Schöpping
  /* line */ LINE_GAUGE_BATLOW2,
214 e545e620 Thomas Schöpping
};
215 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = {
216 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioGaugeBatLow2,
217
  /* meta */ {
218
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
219
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
220
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
221
  },
222
};
223 e545e620 Thomas Schöpping
224 1e5f7648 Thomas Schöpping
/**
225
 * @brief   GAUGE_BATGD2 input signal GPIO.
226
 */
227
static apalGpio_t _gpioGaugeBatGd2 = {
228 3106e8cc Thomas Schöpping
  /* line */ LINE_GAUGE_BATGD2_N,
229 e545e620 Thomas Schöpping
};
230 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = {
231 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioGaugeBatGd2,
232
  /* meta */ {
233
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
234
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
235
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
236
  },
237
};
238 e545e620 Thomas Schöpping
239 1e5f7648 Thomas Schöpping
/**
240
 * @brief   LED output signal GPIO.
241
 */
242
static apalGpio_t _gpioLed = {
243 3106e8cc Thomas Schöpping
  /* line */ LINE_LED,
244 e545e620 Thomas Schöpping
};
245 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioLed = {
246 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioLed,
247
  /* meta */ {
248
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
249 4c72a54c Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
250 1e5f7648 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
251
  },
252
};
253 e545e620 Thomas Schöpping
254 1e5f7648 Thomas Schöpping
/**
255
 * @brief   SYS_UART_UP bidirectional signal GPIO.
256
 */
257
static apalGpio_t _gpioSysUartUp = {
258 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_UART_UP,
259 e545e620 Thomas Schöpping
};
260 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysUartUp = {
261 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysUartUp,
262
  /* meta */ {
263
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
264
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
265
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
266
  },
267
};
268 e545e620 Thomas Schöpping
269 1e5f7648 Thomas Schöpping
/**
270
 * @brief   CHARGE_STAT1A input signal GPIO.
271
 */
272
static apalGpio_t _gpioChargeStat1A = {
273 3106e8cc Thomas Schöpping
  /* line */ LINE_CHARGE_STAT1A,
274 e545e620 Thomas Schöpping
};
275 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = {
276 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioChargeStat1A,
277
  /* meta */ {
278
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
279 ddf34c3d Thomas Schöpping
    /* active state   */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
280 1e5f7648 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
281
  },
282
};
283 e545e620 Thomas Schöpping
284 1e5f7648 Thomas Schöpping
/**
285
 * @brief   GAUGE_BATLOW1 input signal GPIO.
286
 */
287
static apalGpio_t _gpioGaugeBatLow1 = {
288 3106e8cc Thomas Schöpping
  /* line */ LINE_GAUGE_BATLOW1,
289 e545e620 Thomas Schöpping
};
290 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = {
291 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioGaugeBatLow1,
292
  /* meta */ {
293
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
294
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
295
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
296
  },
297
};
298 e545e620 Thomas Schöpping
299 1e5f7648 Thomas Schöpping
/**
300
 * @brief   GAUGE_BATGD1 input signal GPIO.
301
 */
302
static apalGpio_t _gpioGaugeBatGd1 = {
303 3106e8cc Thomas Schöpping
  /* line */ LINE_GAUGE_BATGD1_N,
304 e545e620 Thomas Schöpping
};
305 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = {
306 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioGaugeBatGd1,
307
  /* meta */ {
308
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
309
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
310
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
311
  },
312
};
313 e545e620 Thomas Schöpping
314 1e5f7648 Thomas Schöpping
/**
315
 * @brief   CHARG_EN1 output signal GPIO.
316
 */
317
static apalGpio_t _gpioChargeEn1 = {
318 3106e8cc Thomas Schöpping
  /* line */ LINE_CHARGE_EN1_N,
319 e545e620 Thomas Schöpping
};
320 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = {
321 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioChargeEn1,
322
  /* meta */ {
323
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
324 ddf34c3d Thomas Schöpping
    /* active state   */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
325 1e5f7648 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
326
  },
327
};
328 e545e620 Thomas Schöpping
329 1e5f7648 Thomas Schöpping
/**
330
 * @brief   IR_INT2 input signal GPIO.
331
 */
332
static apalGpio_t _gpioIrInt2 = {
333 3106e8cc Thomas Schöpping
  /* line */ LINE_IR_INT2_N,
334 e545e620 Thomas Schöpping
};
335 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioIrInt2 = {
336 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioIrInt2,
337
  /* meta */ {
338
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
339 8be006e0 Thomas Schöpping
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
340 1e5f7648 Thomas Schöpping
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
341
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
342 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
343 bffb3465 Thomas Schöpping
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
344
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
345 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
346 bffb3465 Thomas Schöpping
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
347
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
348 7de0cc90 Thomas Schöpping
#else /* (BOARD_SENSORRING == ?) */
349 8be006e0 Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
350
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
351 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == ?) */
352 1e5f7648 Thomas Schöpping
  },
353
};
354 e545e620 Thomas Schöpping
355 1e5f7648 Thomas Schöpping
/**
356
 * @brief   TOUCH_INT input signal GPIO.
357
 */
358
static apalGpio_t _gpioTouchInt = {
359 3106e8cc Thomas Schöpping
  /* line */ LINE_TOUCH_INT_N,
360 e545e620 Thomas Schöpping
};
361 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioTouchInt = {
362 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioTouchInt,
363
  /* meta */ {
364
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
365 8be006e0 Thomas Schöpping
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
366 1e5f7648 Thomas Schöpping
    /* active state   */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
367
    /* interrupt edge */ MPR121_LLD_INT_EDGE,
368 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
369 bffb3465 Thomas Schöpping
    /* active state   */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
370
    /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
371 8be006e0 Thomas Schöpping
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
372 bffb3465 Thomas Schöpping
    /* active state   */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
373
    /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
374 7de0cc90 Thomas Schöpping
#else /* (BOARD_SENSORRING == ?) */
375 8be006e0 Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
376
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
377 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == ?) */
378 1e5f7648 Thomas Schöpping
  },
379
};
380 e545e620 Thomas Schöpping
381 1e5f7648 Thomas Schöpping
/**
382
 * @brief   SYS_DONE input signal GPIO.
383
 */
384
static apalGpio_t _gpioSysDone = {
385 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_DONE,
386 e545e620 Thomas Schöpping
};
387 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysDone = {
388 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysDone,
389
  /* meta */ {
390
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
391
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
392
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
393
  },
394
};
395 e545e620 Thomas Schöpping
396 1e5f7648 Thomas Schöpping
/**
397
 * @brief   SYS_PROG output signal GPIO.
398
 */
399
static apalGpio_t _gpioSysProg = {
400 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_PROG_N,
401 e545e620 Thomas Schöpping
};
402 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysProg = {
403 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysProg,
404
  /* meta */ {
405
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
406
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
407
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
408
  },
409
};
410 e545e620 Thomas Schöpping
411 1e5f7648 Thomas Schöpping
/**
412
 * @brief   PATH_DC input signal GPIO.
413
 */
414
static apalGpio_t _gpioPathDc = {
415 3106e8cc Thomas Schöpping
  /* line */ LINE_PATH_DC,
416 e545e620 Thomas Schöpping
};
417 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioPathDc = {
418 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioPathDc,
419
  /* meta */ {
420
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
421
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
422
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
423
  },
424
};
425 e545e620 Thomas Schöpping
426 1e5f7648 Thomas Schöpping
/**
427
 * @brief   SYS_SPI_DIR bidirectional signal GPIO.
428
 */
429
static apalGpio_t _gpioSysSpiDir = {
430 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_SPI_DIR,
431 e545e620 Thomas Schöpping
};
432 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = {
433 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysSpiDir,
434
  /* meta */ {
435
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
436
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
437
    /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
438
  },
439
};
440 e545e620 Thomas Schöpping
441 1e5f7648 Thomas Schöpping
/**
442
 * @brief   SYS_SYNC bidirectional signal GPIO.
443
 */
444
static apalGpio_t _gpioSysSync = {
445 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_INT_N,
446 e545e620 Thomas Schöpping
};
447 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysSync = {
448 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysSync,
449
  /* meta */ {
450
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
451
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
452
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
453
  },
454
};
455 e545e620 Thomas Schöpping
456 1e5f7648 Thomas Schöpping
/**
457
 * @brief   SYS_PD bidirectional signal GPIO.
458
 */
459
static apalGpio_t _gpioSysPd = {
460 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_PD_N,
461 e545e620 Thomas Schöpping
};
462 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysPd = {
463 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysPd,
464
  /* meta */ {
465
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
466
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
467
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
468
  },
469
};
470 e545e620 Thomas Schöpping
471 1e5f7648 Thomas Schöpping
/**
472
 * @brief   SYS_WARMRST bidirectional signal GPIO.
473
 */
474
static apalGpio_t _gpioSysWarmrst = {
475 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_WARMRST_N,
476 e545e620 Thomas Schöpping
};
477 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = {
478 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioSysWarmrst,
479
  /* meta */ {
480
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
481
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
482
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
483
  },
484
};
485 e545e620 Thomas Schöpping
486 1e5f7648 Thomas Schöpping
/**
487
 * @brief   BT_RST output signal GPIO.
488
 */
489
static apalGpio_t _gpioBtRst = {
490 3106e8cc Thomas Schöpping
  /* line */ LINE_BT_RST,
491 e545e620 Thomas Schöpping
};
492 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioBtRst = {
493 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioBtRst,
494
  /* meta */ {
495
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
496
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
497
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
498
  },
499
};
500 e545e620 Thomas Schöpping
501 1e5f7648 Thomas Schöpping
/**
502
 * @brief   CHARGE_EN2 output signal GPIO.
503
 */
504
static apalGpio_t _gpioChargeEn2 = {
505 3106e8cc Thomas Schöpping
  /* line */ LINE_CHARGE_EN2_N,
506 e545e620 Thomas Schöpping
};
507 acc97cbf Thomas Schöpping
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = {
508 1e5f7648 Thomas Schöpping
  /* GPIO */ &_gpioChargeEn2,
509
  /* meta */ {
510
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
511 ddf34c3d Thomas Schöpping
    /* active state   */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
512 1e5f7648 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
513
  },
514
};
515 e545e620 Thomas Schöpping
516
/** @} */
517
518
/*===========================================================================*/
519
/**
520
 * @name AMiRo-OS core configurations
521
 * @{
522
 */
523
/*===========================================================================*/
524
525 47e89ebf Thomas Schöpping
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
526 acc97cbf Thomas Schöpping
ROMCONST char* moduleShellPrompt = "PowerManagement";
527 47e89ebf Thomas Schöpping
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
528 6b53f6bf Thomas Schöpping
529
/** @} */
530
531
/*===========================================================================*/
532
/**
533
 * @name Startup Shutdown Synchronization Protocol (SSSP)
534
 * @{
535
 */
536
/*===========================================================================*/
537
538 e545e620 Thomas Schöpping
/** @} */
539
540
/*===========================================================================*/
541
/**
542
 * @name Low-level drivers
543
 * @{
544
 */
545
/*===========================================================================*/
546
547 ddf34c3d Thomas Schöpping
AT24C01BDriver moduleLldEeprom = {
548 8be006e0 Thomas Schöpping
  /* I2C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
549 ddf34c3d Thomas Schöpping
  /* I2C address  */ AT24C01B_LLD_I2C_ADDR_FIXED,
550 e545e620 Thomas Schöpping
};
551
552 ddf34c3d Thomas Schöpping
BQ241xxDriver moduleLldBatteryChargerFront = {
553 1e5f7648 Thomas Schöpping
  /* charge enable GPIO */ &moduleGpioChargeEn1,
554
  /* charge status GPIO */ &moduleGpioChargeStat1A,
555 e545e620 Thomas Schöpping
};
556
557 ddf34c3d Thomas Schöpping
BQ241xxDriver moduleLldBatteryChargerRear = {
558 1e5f7648 Thomas Schöpping
  /* charge enable GPIO */ &moduleGpioChargeEn2,
559
  /* charge status GPIO */ &moduleGpioChargeStat2A,
560 e545e620 Thomas Schöpping
};
561
562
BQ27500Driver moduleLldFuelGaugeFront = {
563 8be006e0 Thomas Schöpping
  /* I2C driver         */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
564 1e5f7648 Thomas Schöpping
  /* battery low GPIO   */ &moduleGpioGaugeBatLow1,
565
  /* battery good GPIO  */ &moduleGpioGaugeBatGd1,
566 e545e620 Thomas Schöpping
};
567
568
BQ27500Driver moduleLldFuelGaugeRear = {
569 8be006e0 Thomas Schöpping
  /* I2C driver         */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
570 1e5f7648 Thomas Schöpping
  /* battery low GPIO   */ &moduleGpioGaugeBatLow2,
571
  /* battery good GPIO  */ &moduleGpioGaugeBatGd2,
572 e545e620 Thomas Schöpping
};
573
574
INA219Driver moduleLldPowerMonitorVdd = {
575 8be006e0 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
576 e545e620 Thomas Schöpping
  /* I²C address      */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
577
  /* current LSB (uA) */ 0x00u,
578
  /* configuration    */ NULL,
579
};
580
581
INA219Driver moduleLldPowerMonitorVio18 = {
582 8be006e0 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
583 e545e620 Thomas Schöpping
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
584
  /* current LSB (uA) */ 0x00u,
585
  /* configuration    */ NULL,
586
};
587
588
INA219Driver moduleLldPowerMonitorVio33 = {
589 8be006e0 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
590 e545e620 Thomas Schöpping
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
591
  /* current LSB (uA) */ 0x00u,
592
  /* configuration    */ NULL,
593
};
594
595
INA219Driver moduleLldPowerMonitorVsys42 = {
596 8be006e0 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
597 e545e620 Thomas Schöpping
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
598
  /* current LSB (uA) */ 0x00u,
599
  /* configuration    */ NULL,
600
};
601
602
INA219Driver moduleLldPowerMonitorVio50 = {
603 8be006e0 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
604 e545e620 Thomas Schöpping
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
605
  /* current LSB (uA) */ 0x00u,
606
  /* configuration    */ NULL,
607
};
608
609
LEDDriver moduleLldStatusLed = {
610 1e5f7648 Thomas Schöpping
  /* LED GPIO */ &moduleGpioLed,
611 e545e620 Thomas Schöpping
};
612
613 ddf34c3d Thomas Schöpping
TPS6211xDriver moduleLldStepDownConverter = {
614 8be006e0 Thomas Schöpping
  /* Power enable GPIO */ &moduleGpioPowerEn,
615
};
616
617
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
618
619 e545e620 Thomas Schöpping
MPR121Driver moduleLldTouch = {
620 8be006e0 Thomas Schöpping
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
621 e545e620 Thomas Schöpping
};
622
623
PCA9544ADriver moduleLldI2cMultiplexer1 = {
624 8be006e0 Thomas Schöpping
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
625 e545e620 Thomas Schöpping
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
626
};
627
628
PCA9544ADriver moduleLldI2cMultiplexer2 = {
629 8be006e0 Thomas Schöpping
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
630 e545e620 Thomas Schöpping
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
631
};
632
633
VCNL4020Driver moduleLldProximity1 = {
634 8be006e0 Thomas Schöpping
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
635 e545e620 Thomas Schöpping
};
636
637
VCNL4020Driver moduleLldProximity2 = {
638 8be006e0 Thomas Schöpping
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
639 e545e620 Thomas Schöpping
};
640
641 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */
642 8be006e0 Thomas Schöpping
643
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
644 bffb3465 Thomas Schöpping
645
PCAL6524Driver moduleLldGpioExtender1 = {
646
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
647
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
648
};
649
650
PCAL6524Driver moduleLldGpioExtender2 = {
651
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
652
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
653
};
654
655
AT42QT1050Driver moduleLldTouch = {
656
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
657
  /* I²C address  */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
658
};
659
660 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */
661 8be006e0 Thomas Schöpping
662
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
663 bffb3465 Thomas Schöpping
664
PCAL6524Driver moduleLldGpioExtender1 = {
665
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
666
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
667
};
668
669
PCAL6524Driver moduleLldGpioExtender2 = {
670
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
671
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
672
};
673
674
AT42QT1050Driver moduleLldTouch = {
675
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
676
  /* I²C address  */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
677
};
678
679 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */
680 8be006e0 Thomas Schöpping
681 e545e620 Thomas Schöpping
/** @} */
682
683
/*===========================================================================*/
684
/**
685 4c72a54c Thomas Schöpping
 * @name Tests
686 e545e620 Thomas Schöpping
 * @{
687
 */
688
/*===========================================================================*/
689
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
690
691 8be006e0 Thomas Schöpping
/*
692 4c72a54c Thomas Schöpping
 * ADC (VSYS)
693 8be006e0 Thomas Schöpping
 */
694 4c72a54c Thomas Schöpping
#include <module_test_adc.h>
695
static int _testAdcShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
696 e545e620 Thomas Schöpping
{
697 4c72a54c Thomas Schöpping
  return moduleTestAdcShellCb(stream, argc, argv, NULL);
698 e545e620 Thomas Schöpping
}
699 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestAdcShellCmd, "test:ADC", _testAdcShellCmdCb);
700 e545e620 Thomas Schöpping
701 8be006e0 Thomas Schöpping
/*
702 4c72a54c Thomas Schöpping
 * AT24C01BN-SH-B (EEPROM)
703 8be006e0 Thomas Schöpping
 */
704 4c72a54c Thomas Schöpping
#include <module_test_AT24C01B.h>
705
static int _testAt24c01bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
706 e545e620 Thomas Schöpping
{
707 4c72a54c Thomas Schöpping
  return moduleTestAt24c01bShellCb(stream, argc, argv, NULL);
708 e545e620 Thomas Schöpping
}
709 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24c01bShellCmdCb);
710 e545e620 Thomas Schöpping
711 8be006e0 Thomas Schöpping
/*
712 ddf34c3d Thomas Schöpping
 * bq24103a (battery charger)
713 8be006e0 Thomas Schöpping
 */
714 4c72a54c Thomas Schöpping
#include <module_test_bq241xx.h>
715
static int _testBq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
716 e545e620 Thomas Schöpping
{
717 4c72a54c Thomas Schöpping
  return moduleTestBq241xxShellCb(stream, argc, argv, NULL);
718 e545e620 Thomas Schöpping
}
719 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestBq241xxShellCmd, "test:BatteryCharger", _testBq241xxShellCmdCb);
720 e545e620 Thomas Schöpping
721 8be006e0 Thomas Schöpping
/*
722 ddf34c3d Thomas Schöpping
 * bq27500 (fuel gauge)
723 8be006e0 Thomas Schöpping
 */
724 4c72a54c Thomas Schöpping
#include <module_test_bq27500.h>
725
static int _testBq27500ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
726 e545e620 Thomas Schöpping
{
727 4c72a54c Thomas Schöpping
  return moduleTestBq27500ShellCb(stream, argc, argv, NULL);
728 e545e620 Thomas Schöpping
}
729 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestBq27500ShellCmd, "test:FuelGauge", _testBq27500ShellCmdCb);
730 e545e620 Thomas Schöpping
731 8be006e0 Thomas Schöpping
/*
732 ddf34c3d Thomas Schöpping
 * bq27500 (fuel gauge) in combination with bq24103a (battery charger)
733 8be006e0 Thomas Schöpping
 */
734 4c72a54c Thomas Schöpping
#include <module_test_bq27500_bq241xx.h>
735
static int _testBq27500Bq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
736 e545e620 Thomas Schöpping
{
737 4c72a54c Thomas Schöpping
  return moduleTestBq27500Bq241xxShellCb(stream, argc, argv, NULL);
738 e545e620 Thomas Schöpping
}
739 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestBq27500Bq241xxShellCmd, "test:FuelGauge&BatteryCharger", _testBq27500Bq241xxShellCmdCb);
740 e545e620 Thomas Schöpping
741 8be006e0 Thomas Schöpping
/*
742
 * INA219 (power monitor)
743
 */
744 4c72a54c Thomas Schöpping
#include <module_test_INA219.h>
745
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
746 e545e620 Thomas Schöpping
{
747 4c72a54c Thomas Schöpping
  return moduleTestIna219ShellCb(stream, argc, argv, NULL);
748 e545e620 Thomas Schöpping
}
749 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
750 e545e620 Thomas Schöpping
751 8be006e0 Thomas Schöpping
/*
752
 * Status LED
753
 */
754 4c72a54c Thomas Schöpping
#include <module_test_LED.h>
755
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
756 e545e620 Thomas Schöpping
{
757 4c72a54c Thomas Schöpping
  return moduleTestLedShellCb(stream, argc, argv, NULL);
758 e545e620 Thomas Schöpping
}
759 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
760 e545e620 Thomas Schöpping
761 8be006e0 Thomas Schöpping
/*
762
 * PKLCS1212E4001 (buzzer)
763
 */
764 4c72a54c Thomas Schöpping
#include <module_test_PKxxxExxx.h>
765
static int _testPkxxxexxxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
766 e545e620 Thomas Schöpping
{
767 4c72a54c Thomas Schöpping
  return moduleTestPkxxxexxxShellCb(stream, argc, argv, NULL);
768 e545e620 Thomas Schöpping
}
769 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestPkxxxexxxShellCmd, "test:Buzzer", _testPkxxxexxxShellCmdCb);
770 e545e620 Thomas Schöpping
771 8be006e0 Thomas Schöpping
/*
772 ddf34c3d Thomas Schöpping
 * TPS62113 (step-down converter)
773 8be006e0 Thomas Schöpping
 */
774 4c72a54c Thomas Schöpping
#include <module_test_TPS6211x.h>
775
static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
776 e545e620 Thomas Schöpping
{
777 4c72a54c Thomas Schöpping
  return moduleTestTps6211xShellCb(stream, argc, argv, NULL);
778 e545e620 Thomas Schöpping
}
779 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestTps6211xShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
780 e545e620 Thomas Schöpping
781 8be006e0 Thomas Schöpping
/*
782 4c72a54c Thomas Schöpping
 * TPS62113 (step-sown converter) in combination with INA219 (power monitor)
783 8be006e0 Thomas Schöpping
 */
784 4c72a54c Thomas Schöpping
#include <module_test_TPS6211x_INA219.h>
785
static int _testTps6211xIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
786 e545e620 Thomas Schöpping
{
787 4c72a54c Thomas Schöpping
  return moduleTestTps6211xIna219ShellCb(stream, argc, argv, NULL);
788 e545e620 Thomas Schöpping
}
789 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestTps6211xIna219ShellCmd, "test:StepDownConverter&PowerMonitor", _testTps6211xIna219ShellCmdCb);
790 e545e620 Thomas Schöpping
791 8be006e0 Thomas Schöpping
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
792
793
/*
794
 * MPR121 (touch sensor)
795
 */
796 4c72a54c Thomas Schöpping
#include <module_test_MPR121.h>
797
static int _testMpr121ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
798 8be006e0 Thomas Schöpping
{
799 4c72a54c Thomas Schöpping
  return moduleTestMpr121ShellCb(stream, argc, argv, NULL);
800 8be006e0 Thomas Schöpping
}
801 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestMpr121ShellCmd, "test:Touch", _testMpr121ShellCmdCb);
802 8be006e0 Thomas Schöpping
803
/*
804
 * PCA9544A (I2C multiplexer)
805
 */
806 4c72a54c Thomas Schöpping
#include <module_test_PCA9544A.h>
807
static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
808 8be006e0 Thomas Schöpping
{
809 4c72a54c Thomas Schöpping
  return moduleTestPca9544aShellCb(stream, argc, argv, NULL);
810 8be006e0 Thomas Schöpping
}
811 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
812 8be006e0 Thomas Schöpping
813
/*
814
 * VCNL4020 (proximity sensor)
815
 */
816 4c72a54c Thomas Schöpping
#include <module_test_VCNL4020.h>
817
static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
818 e545e620 Thomas Schöpping
{
819 4c72a54c Thomas Schöpping
  return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL);
820 e545e620 Thomas Schöpping
}
821 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:Proximity", _testVcnl4020ShellCmdCb);
822 e545e620 Thomas Schöpping
823 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */
824 8be006e0 Thomas Schöpping
825
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
826 bffb3465 Thomas Schöpping
827
/*
828
 * PCAL6524 (GPIO extender)
829
 */
830 4c72a54c Thomas Schöpping
#include <module_test_PCAL6524.h>
831
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
832 bffb3465 Thomas Schöpping
{
833 4c72a54c Thomas Schöpping
  return moduleTestPcal6524ShellCb(stream, argc, argv, NULL);
834 bffb3465 Thomas Schöpping
}
835 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
836 bffb3465 Thomas Schöpping
837
/*
838
 * AT42QT1050 (touch sensor)
839
 */
840 4c72a54c Thomas Schöpping
#include <module_test_AT42QT1050.h>
841
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
842 bffb3465 Thomas Schöpping
{
843 4c72a54c Thomas Schöpping
  return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL);
844 bffb3465 Thomas Schöpping
}
845 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
846 bffb3465 Thomas Schöpping
847 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */
848 8be006e0 Thomas Schöpping
849
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
850 bffb3465 Thomas Schöpping
851
/*
852
 * PCAL6524 (GPIO extender)
853
 */
854 4c72a54c Thomas Schöpping
#include <module_test_PCAL6524.h>
855
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
856 bffb3465 Thomas Schöpping
{
857 4c72a54c Thomas Schöpping
  return moduleTestPcal6524ShellCb(stream, argc, argv, NULL);
858 bffb3465 Thomas Schöpping
}
859 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
860 bffb3465 Thomas Schöpping
861
/*
862
 * AT42QT1050 (touch sensor)
863
 */
864 4c72a54c Thomas Schöpping
#include <module_test_AT42QT1050.h>
865
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
866
{
867
  return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL);
868
}
869
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
870
871
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */
872
873
/*
874
 * entire module
875
 */
876
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
877 bffb3465 Thomas Schöpping
{
878
  (void)argc;
879
  (void)argv;
880 4c72a54c Thomas Schöpping
881
  int status = AOS_OK;
882
  char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL};
883
  aos_testresult_t result_test = {0, 0};
884
  aos_testresult_t result_total = {0, 0};
885
886
  /* ADC */
887
  status |= moduleTestAdcShellCb(stream, 0, targv, &result_test);
888
  result_total = aosTestResultAdd(result_total, result_test);
889
890
  /* AT24C01BN-SH-B (EEPROM) */
891
  status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
892
  result_total = aosTestResultAdd(result_total, result_test);
893
894
  /* bq24103a (battery charger) */
895
  // front
896
  targv[1] = "-f";
897
  status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
898
  result_total = aosTestResultAdd(result_total, result_test);
899
  // rear
900
  targv[1] = "-r";
901
  status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
902
  result_total = aosTestResultAdd(result_total, result_test);
903
  targv[1] = "";
904
905
  /* bq27500 (fuel gauge) */
906
  // front
907
  targv[1] = "-f";
908
  status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
909
  result_total = aosTestResultAdd(result_total, result_test);
910
  // rear
911
  targv[1] = "-r";
912
  status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
913
  result_total = aosTestResultAdd(result_total, result_test);
914
  targv[1] = "";
915
916
  /* bq 27500 (fuel gauge) in combination with bq24103a (battery charger) */
917
  // front
918
  targv[1] = "-f";
919
  status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
920
  result_total = aosTestResultAdd(result_total, result_test);
921
  // rear
922
  targv[1] = "-r";
923
  status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
924
  result_total = aosTestResultAdd(result_total, result_test);
925
  targv[1] = "";
926
927
  /* INA219 (power monitor) */
928
  // VDD
929
  targv[1] = "VDD";
930
  status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
931
  result_total = aosTestResultAdd(result_total, result_test);
932
  // VIO 1.8V
933
  targv[1] = "VIO1.8";
934
  status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
935
  result_total = aosTestResultAdd(result_total, result_test);
936
  // VIO 3.3V
937
  targv[1] = "VIO3.3";
938
  status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
939
  result_total = aosTestResultAdd(result_total, result_test);
940
  // VSYS 4.2V
941
  targv[1] = "VSYS4.2";
942
  status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
943
  result_total = aosTestResultAdd(result_total, result_test);
944
  // VIO 5.0V
945
  targv[1] = "VIO5.0";
946
  status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
947
  result_total = aosTestResultAdd(result_total, result_test);
948
  targv[1] = "";
949
950
  /* status LED */
951
  status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
952
  result_total = aosTestResultAdd(result_total, result_test);
953
954
  /* PKLCS1212E4001 (buzzer) */
955
  status |= moduleTestPkxxxexxxShellCb(stream, 0, targv, &result_test);
956
  result_total = aosTestResultAdd(result_total, result_test);
957
958
  /* TPS62113 (step-down converter) */
959
  status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
960
  result_total = aosTestResultAdd(result_total, result_test);
961
962
  /* TPS62113 (step-down converter) in combination with INA219 (power monitor) */
963
  status |= moduleTestTps6211xIna219ShellCb(stream, 0, targv, &result_test);
964
  result_total = aosTestResultAdd(result_total, result_test);
965
966
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
967
968
  /* MPR121 (touch sensor) */
969
  status |= moduleTestMpr121ShellCb(stream, 0, targv, &result_test);
970
  result_total = aosTestResultAdd(result_total, result_test);
971
972
  /* PCA9544A (I2C multiplexer) */
973
  // #1
974
  targv[1] = "#1";
975
  status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
976
  result_total = aosTestResultAdd(result_total, result_test);
977
  // #2
978
  targv[1] = "#2";
979
  status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
980
  result_total = aosTestResultAdd(result_total, result_test);
981
  targv[1] = "";
982
983
  /* VCNL4020 (proximity sensor) */
984
  // north-northeast
985
  targv[1] = "-nne";
986
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
987
  result_total = aosTestResultAdd(result_total, result_test);
988
  // east-northeast
989
  targv[1] = "-ene";
990
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
991
  result_total = aosTestResultAdd(result_total, result_test);
992
  // east-southeast
993
  targv[1] = "-ese";
994
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
995
  result_total = aosTestResultAdd(result_total, result_test);
996
  // south-southeast
997
  targv[1] = "-sse";
998
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
999
  result_total = aosTestResultAdd(result_total, result_test);
1000
  // south-southwest
1001
  targv[1] = "-ssw";
1002
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
1003
  result_total = aosTestResultAdd(result_total, result_test);
1004
  // west-southwest
1005
  targv[1] = "-wsw";
1006
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
1007
  result_total = aosTestResultAdd(result_total, result_test);
1008
  // west-northwest
1009
  targv[1] = "-wnw";
1010
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
1011
  result_total = aosTestResultAdd(result_total, result_test);
1012
  // west-northwest
1013
  targv[1] = "-nnw";
1014
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
1015
  result_total = aosTestResultAdd(result_total, result_test);
1016
  targv[1] = "";
1017
1018
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */
1019
1020
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
1021
1022
  /* PCAL6524 (GPIO extender) */
1023
  // #1
1024
  targv[1] = "#1";
1025
  status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
1026
  result_total = aosTestResultAdd(result_total, result_test);
1027
  // #2
1028
  targv[1] = "#2";
1029
  status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
1030
  result_total = aosTestResultAdd(result_total, result_test);
1031
  targv[1] = "";
1032
1033
  /* AT42QT1050 (touch sensor) */
1034
  status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
1035
  result_total = aosTestResultAdd(result_total, result_test);
1036
1037
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */
1038
1039
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
1040
1041
  /* PCAL6524 (GPIO extender) */
1042
  // #1
1043
  targv[1] = "#1";
1044
  status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
1045
  result_total = aosTestResultAdd(result_total, result_test);
1046
  // #2
1047
  targv[1] = "#2";
1048
  status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
1049
  result_total = aosTestResultAdd(result_total, result_test);
1050
  targv[1] = "";
1051
1052
  /* AT42QT1050 (touch sensor) */
1053
  status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
1054
  result_total = aosTestResultAdd(result_total, result_test);
1055 bffb3465 Thomas Schöpping
1056 7de0cc90 Thomas Schöpping
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */
1057 8be006e0 Thomas Schöpping
1058 4c72a54c Thomas Schöpping
  // print total result
1059
  chprintf(stream, "\n");
1060
  aosTestResultPrintSummary(stream, &result_total, "entire module");
1061
1062
  return status;
1063
}
1064
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
1065
1066 7de0cc90 Thomas Schöpping
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
1067 e545e620 Thomas Schöpping
1068
/** @} */
1069 53710ca3 Marc Rothmann
/** @} */