amiro-os / modules / PowerManagement_1-1 / module.c @ 57cbd1cd
History | View | Annotate | Download (46.914 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 | 1e5f7648 | Thomas Schöpping | #include <amiroos.h> |
30 | |||
31 | e545e620 | Thomas Schöpping | /*===========================================================================*/
|
32 | /**
|
||
33 | * @name Module specific functions
|
||
34 | * @{
|
||
35 | */
|
||
36 | /*===========================================================================*/
|
||
37 | |||
38 | /** @} */
|
||
39 | |||
40 | /*===========================================================================*/
|
||
41 | /**
|
||
42 | * @name ChibiOS/HAL configuration
|
||
43 | * @{
|
||
44 | */
|
||
45 | /*===========================================================================*/
|
||
46 | |||
47 | ADCConversionGroup moduleHalAdcVsysConversionGroup = { |
||
48 | /* buffer type */ true, |
||
49 | /* number of channels */ 1, |
||
50 | /* callback function */ NULL, |
||
51 | /* error callback */ NULL, |
||
52 | /* CR1 */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
|
||
53 | /* CR2 */ ADC_CR2_SWSTART | ADC_CR2_CONT,
|
||
54 | /* SMPR1 */ 0, |
||
55 | /* SMPR2 */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
|
||
56 | /* HTR */ ADC_HTR_HT,
|
||
57 | /* LTR */ 0, |
||
58 | /* SQR1 */ ADC_SQR1_NUM_CH(1), |
||
59 | /* SQR2 */ 0, |
||
60 | /* SQR3 */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
|
||
61 | }; |
||
62 | |||
63 | CANConfig moduleHalCanConfig = { |
||
64 | /* mcr */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
|
||
65 | 933df08e | Thomas Schöpping | /* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1), |
66 | e545e620 | Thomas Schöpping | }; |
67 | |||
68 | 8be006e0 | Thomas Schöpping | I2CConfig moduleHalI2cSrPm18Pm33GaugeRearConfig = { |
69 | e545e620 | Thomas Schöpping | /* I²C mode */ OPMODE_I2C,
|
70 | /* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
||
71 | /* duty cycle */ FAST_DUTY_CYCLE_2,
|
||
72 | }; |
||
73 | |||
74 | 8be006e0 | Thomas Schöpping | I2CConfig moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig = { |
75 | e545e620 | Thomas Schöpping | /* I²C mode */ OPMODE_I2C,
|
76 | /* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
||
77 | /* duty cycle */ FAST_DUTY_CYCLE_2,
|
||
78 | }; |
||
79 | |||
80 | PWMConfig moduleHalPwmBuzzerConfig = { |
||
81 | /* frequency */ 1000000, |
||
82 | /* period */ 0, |
||
83 | /* callback */ NULL, |
||
84 | /* channel configurations */ {
|
||
85 | /* channel 0 */ {
|
||
86 | /* mode */ PWM_OUTPUT_DISABLED,
|
||
87 | /* callback */ NULL |
||
88 | }, |
||
89 | /* channel 1 */ {
|
||
90 | /* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
||
91 | /* callback */ NULL |
||
92 | }, |
||
93 | /* channel 2 */ {
|
||
94 | /* mode */ PWM_OUTPUT_DISABLED,
|
||
95 | /* callback */ NULL |
||
96 | }, |
||
97 | /* channel 3 */ {
|
||
98 | /* mode */ PWM_OUTPUT_DISABLED,
|
||
99 | /* callback */ NULL |
||
100 | }, |
||
101 | }, |
||
102 | /* TIM CR2 register */ 0, |
||
103 | #if STM32_PWM_USE_ADVANCED
|
||
104 | /* TIM BDTR register */ 0, |
||
105 | #endif
|
||
106 | /* TIM DIER register */ 0, |
||
107 | }; |
||
108 | |||
109 | SerialConfig moduleHalProgIfConfig = { |
||
110 | /* bit rate */ 115200, |
||
111 | /* CR1 */ 0, |
||
112 | /* CR1 */ 0, |
||
113 | /* CR1 */ 0, |
||
114 | }; |
||
115 | |||
116 | /** @} */
|
||
117 | |||
118 | /*===========================================================================*/
|
||
119 | /**
|
||
120 | * @name GPIO definitions
|
||
121 | * @{
|
||
122 | */
|
||
123 | /*===========================================================================*/
|
||
124 | |||
125 | 1e5f7648 | Thomas Schöpping | /**
|
126 | * @brief SYS_REG_EN output signal GPIO.
|
||
127 | */
|
||
128 | static apalGpio_t _gpioSysRegEn = {
|
||
129 | e545e620 | Thomas Schöpping | /* port */ GPIOA,
|
130 | /* pad */ GPIOA_SYS_REG_EN,
|
||
131 | }; |
||
132 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleSysRegEn = { |
133 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysRegEn,
|
134 | /* meta */ {
|
||
135 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
136 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
137 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
138 | }, |
||
139 | }; |
||
140 | e545e620 | Thomas Schöpping | |
141 | 1e5f7648 | Thomas Schöpping | /**
|
142 | * @brief IR_INT1 input signal GPIO.
|
||
143 | */
|
||
144 | static apalGpio_t _gpioIrInt1 = {
|
||
145 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
146 | /* pad */ GPIOB_IR_INT1_N,
|
||
147 | }; |
||
148 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioIrInt1 = { |
149 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioIrInt1,
|
150 | /* meta */ {
|
||
151 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
152 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
153 | 1e5f7648 | Thomas Schöpping | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
154 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
155 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
156 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
157 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
158 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
159 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
160 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
161 | 8be006e0 | Thomas Schöpping | #else
|
162 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
163 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
164 | #endif
|
||
165 | 1e5f7648 | Thomas Schöpping | }, |
166 | }; |
||
167 | e545e620 | Thomas Schöpping | |
168 | 1e5f7648 | Thomas Schöpping | /**
|
169 | * @brief POWER_EN output signal GPIO.
|
||
170 | */
|
||
171 | static apalGpio_t _gpioPowerEn = {
|
||
172 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
173 | /* pad */ GPIOB_POWER_EN,
|
||
174 | }; |
||
175 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
176 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPowerEn,
|
177 | /* meta */ {
|
||
178 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
179 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
180 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
181 | }, |
||
182 | }; |
||
183 | e545e620 | Thomas Schöpping | |
184 | 1e5f7648 | Thomas Schöpping | /**
|
185 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
186 | */
|
||
187 | static apalGpio_t _gpioSysUartDn = {
|
||
188 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
189 | /* pad */ GPIOB_SYS_UART_DN,
|
||
190 | }; |
||
191 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
192 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysUartDn,
|
193 | /* meta */ {
|
||
194 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
195 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
196 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
197 | }, |
||
198 | }; |
||
199 | e545e620 | Thomas Schöpping | |
200 | 1e5f7648 | Thomas Schöpping | /**
|
201 | * @brief CHARGE_STAT2A input signal GPIO.
|
||
202 | */
|
||
203 | static apalGpio_t _gpioChargeStat2A = {
|
||
204 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
205 | /* pad */ GPIOB_CHARGE_STAT2A,
|
||
206 | }; |
||
207 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeStat2A = { |
208 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeStat2A,
|
209 | /* meta */ {
|
||
210 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
211 | /* active state */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
||
212 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
213 | }, |
||
214 | }; |
||
215 | e545e620 | Thomas Schöpping | |
216 | 1e5f7648 | Thomas Schöpping | /**
|
217 | * @brief GAUGE_BATLOW2 input signal GPIO.
|
||
218 | */
|
||
219 | static apalGpio_t _gpioGaugeBatLow2 = {
|
||
220 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
221 | /* pad */ GPIOB_GAUGE_BATLOW2,
|
||
222 | }; |
||
223 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = { |
224 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatLow2,
|
225 | /* meta */ {
|
||
226 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
227 | /* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
||
228 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
229 | }, |
||
230 | }; |
||
231 | e545e620 | Thomas Schöpping | |
232 | 1e5f7648 | Thomas Schöpping | /**
|
233 | * @brief GAUGE_BATGD2 input signal GPIO.
|
||
234 | */
|
||
235 | static apalGpio_t _gpioGaugeBatGd2 = {
|
||
236 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
237 | /* pad */ GPIOB_GAUGE_BATGD2_N,
|
||
238 | }; |
||
239 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = { |
240 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatGd2,
|
241 | /* meta */ {
|
||
242 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
243 | /* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
||
244 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
245 | }, |
||
246 | }; |
||
247 | e545e620 | Thomas Schöpping | |
248 | 1e5f7648 | Thomas Schöpping | /**
|
249 | * @brief LED output signal GPIO.
|
||
250 | */
|
||
251 | static apalGpio_t _gpioLed = {
|
||
252 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
253 | /* pad */ GPIOB_LED,
|
||
254 | }; |
||
255 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioLed = { |
256 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioLed,
|
257 | /* meta */ {
|
||
258 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
259 | /* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
||
260 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
261 | }, |
||
262 | }; |
||
263 | e545e620 | Thomas Schöpping | |
264 | 1e5f7648 | Thomas Schöpping | /**
|
265 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
266 | */
|
||
267 | static apalGpio_t _gpioSysUartUp = {
|
||
268 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
269 | /* pad */ GPIOB_SYS_UART_UP,
|
||
270 | }; |
||
271 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
272 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysUartUp,
|
273 | /* meta */ {
|
||
274 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
275 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
276 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
277 | }, |
||
278 | }; |
||
279 | e545e620 | Thomas Schöpping | |
280 | 1e5f7648 | Thomas Schöpping | /**
|
281 | * @brief CHARGE_STAT1A input signal GPIO.
|
||
282 | */
|
||
283 | static apalGpio_t _gpioChargeStat1A = {
|
||
284 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
285 | /* pad */ GPIOC_CHARGE_STAT1A,
|
||
286 | }; |
||
287 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeStat1A = { |
288 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeStat1A,
|
289 | /* meta */ {
|
||
290 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
291 | /* active state */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
||
292 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
293 | }, |
||
294 | }; |
||
295 | e545e620 | Thomas Schöpping | |
296 | 1e5f7648 | Thomas Schöpping | /**
|
297 | * @brief GAUGE_BATLOW1 input signal GPIO.
|
||
298 | */
|
||
299 | static apalGpio_t _gpioGaugeBatLow1 = {
|
||
300 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
301 | /* pad */ GPIOC_GAUGE_BATLOW1,
|
||
302 | }; |
||
303 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = { |
304 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatLow1,
|
305 | /* meta */ {
|
||
306 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
307 | /* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
||
308 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
309 | }, |
||
310 | }; |
||
311 | e545e620 | Thomas Schöpping | |
312 | 1e5f7648 | Thomas Schöpping | /**
|
313 | * @brief GAUGE_BATGD1 input signal GPIO.
|
||
314 | */
|
||
315 | static apalGpio_t _gpioGaugeBatGd1 = {
|
||
316 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
317 | /* pad */ GPIOC_GAUGE_BATGD1_N,
|
||
318 | }; |
||
319 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = { |
320 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatGd1,
|
321 | /* meta */ {
|
||
322 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
323 | /* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
||
324 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
325 | }, |
||
326 | }; |
||
327 | e545e620 | Thomas Schöpping | |
328 | 1e5f7648 | Thomas Schöpping | /**
|
329 | * @brief CHARG_EN1 output signal GPIO.
|
||
330 | */
|
||
331 | static apalGpio_t _gpioChargeEn1 = {
|
||
332 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
333 | /* pad */ GPIOC_CHARGE_EN1_N,
|
||
334 | }; |
||
335 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeEn1 = { |
336 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeEn1,
|
337 | /* meta */ {
|
||
338 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
339 | /* active state */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
||
340 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
341 | }, |
||
342 | }; |
||
343 | e545e620 | Thomas Schöpping | |
344 | 1e5f7648 | Thomas Schöpping | /**
|
345 | * @brief IR_INT2 input signal GPIO.
|
||
346 | */
|
||
347 | static apalGpio_t _gpioIrInt2 = {
|
||
348 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
349 | /* pad */ GPIOC_IR_INT2_N,
|
||
350 | }; |
||
351 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioIrInt2 = { |
352 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioIrInt2,
|
353 | /* meta */ {
|
||
354 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
355 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
356 | 1e5f7648 | Thomas Schöpping | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
357 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
358 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
359 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
360 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
361 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
362 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
363 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
364 | 8be006e0 | Thomas Schöpping | #else
|
365 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
366 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
367 | #endif
|
||
368 | 1e5f7648 | Thomas Schöpping | }, |
369 | }; |
||
370 | e545e620 | Thomas Schöpping | |
371 | 1e5f7648 | Thomas Schöpping | /**
|
372 | * @brief TOUCH_INT input signal GPIO.
|
||
373 | */
|
||
374 | static apalGpio_t _gpioTouchInt = {
|
||
375 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
376 | /* pad */ GPIOC_TOUCH_INT_N,
|
||
377 | }; |
||
378 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioTouchInt = { |
379 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioTouchInt,
|
380 | /* meta */ {
|
||
381 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
382 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
383 | 1e5f7648 | Thomas Schöpping | /* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
384 | /* interrupt edge */ MPR121_LLD_INT_EDGE,
|
||
385 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
386 | bffb3465 | Thomas Schöpping | /* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
387 | /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
||
388 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
389 | bffb3465 | Thomas Schöpping | /* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
390 | /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
||
391 | 8be006e0 | Thomas Schöpping | #else
|
392 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
393 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
394 | #endif
|
||
395 | 1e5f7648 | Thomas Schöpping | }, |
396 | }; |
||
397 | e545e620 | Thomas Schöpping | |
398 | 1e5f7648 | Thomas Schöpping | /**
|
399 | * @brief SYS_DONE input signal GPIO.
|
||
400 | */
|
||
401 | static apalGpio_t _gpioSysDone = {
|
||
402 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
403 | /* pad */ GPIOC_SYS_DONE,
|
||
404 | }; |
||
405 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysDone = { |
406 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysDone,
|
407 | /* meta */ {
|
||
408 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
409 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
410 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
411 | }, |
||
412 | }; |
||
413 | e545e620 | Thomas Schöpping | |
414 | 1e5f7648 | Thomas Schöpping | /**
|
415 | * @brief SYS_PROG output signal GPIO.
|
||
416 | */
|
||
417 | static apalGpio_t _gpioSysProg = {
|
||
418 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
419 | /* pad */ GPIOC_SYS_PROG_N,
|
||
420 | }; |
||
421 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysProg = { |
422 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysProg,
|
423 | /* meta */ {
|
||
424 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
425 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
426 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
427 | }, |
||
428 | }; |
||
429 | e545e620 | Thomas Schöpping | |
430 | 1e5f7648 | Thomas Schöpping | /**
|
431 | * @brief PATH_DC input signal GPIO.
|
||
432 | */
|
||
433 | static apalGpio_t _gpioPathDc = {
|
||
434 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
435 | /* pad */ GPIOC_PATH_DC,
|
||
436 | }; |
||
437 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPathDc = { |
438 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPathDc,
|
439 | /* meta */ {
|
||
440 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
441 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
442 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
443 | }, |
||
444 | }; |
||
445 | e545e620 | Thomas Schöpping | |
446 | 1e5f7648 | Thomas Schöpping | /**
|
447 | * @brief SYS_SPI_DIR bidirectional signal GPIO.
|
||
448 | */
|
||
449 | static apalGpio_t _gpioSysSpiDir = {
|
||
450 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
451 | /* pad */ GPIOC_SYS_SPI_DIR,
|
||
452 | }; |
||
453 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSpiDir = { |
454 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysSpiDir,
|
455 | /* meta */ {
|
||
456 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
457 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
458 | /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
|
||
459 | }, |
||
460 | }; |
||
461 | e545e620 | Thomas Schöpping | |
462 | 1e5f7648 | Thomas Schöpping | /**
|
463 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
464 | */
|
||
465 | static apalGpio_t _gpioSysSync = {
|
||
466 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
467 | /* pad */ GPIOC_SYS_INT_N,
|
||
468 | }; |
||
469 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
470 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysSync,
|
471 | /* meta */ {
|
||
472 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
473 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
474 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
475 | }, |
||
476 | }; |
||
477 | e545e620 | Thomas Schöpping | |
478 | 1e5f7648 | Thomas Schöpping | /**
|
479 | * @brief SYS_PD bidirectional signal GPIO.
|
||
480 | */
|
||
481 | static apalGpio_t _gpioSysPd = {
|
||
482 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
483 | /* pad */ GPIOC_SYS_PD_N,
|
||
484 | }; |
||
485 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
486 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysPd,
|
487 | /* meta */ {
|
||
488 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
489 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
490 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
491 | }, |
||
492 | }; |
||
493 | e545e620 | Thomas Schöpping | |
494 | 1e5f7648 | Thomas Schöpping | /**
|
495 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
496 | */
|
||
497 | static apalGpio_t _gpioSysWarmrst = {
|
||
498 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
499 | /* pad */ GPIOC_SYS_WARMRST_N,
|
||
500 | }; |
||
501 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
502 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysWarmrst,
|
503 | /* meta */ {
|
||
504 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
505 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
506 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
507 | }, |
||
508 | }; |
||
509 | e545e620 | Thomas Schöpping | |
510 | 1e5f7648 | Thomas Schöpping | /**
|
511 | * @brief BT_RST output signal GPIO.
|
||
512 | */
|
||
513 | static apalGpio_t _gpioBtRst = {
|
||
514 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
515 | /* pad */ GPIOC_BT_RST,
|
||
516 | }; |
||
517 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioBtRst = { |
518 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioBtRst,
|
519 | /* meta */ {
|
||
520 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
521 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
522 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
523 | }, |
||
524 | }; |
||
525 | e545e620 | Thomas Schöpping | |
526 | 1e5f7648 | Thomas Schöpping | /**
|
527 | * @brief CHARGE_EN2 output signal GPIO.
|
||
528 | */
|
||
529 | static apalGpio_t _gpioChargeEn2 = {
|
||
530 | e545e620 | Thomas Schöpping | /* port */ GPIOD,
|
531 | /* pad */ GPIOD_CHARGE_EN2_N,
|
||
532 | }; |
||
533 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeEn2 = { |
534 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeEn2,
|
535 | /* meta */ {
|
||
536 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
537 | /* active state */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
||
538 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
539 | }, |
||
540 | }; |
||
541 | e545e620 | Thomas Schöpping | |
542 | /** @} */
|
||
543 | |||
544 | /*===========================================================================*/
|
||
545 | /**
|
||
546 | * @name AMiRo-OS core configurations
|
||
547 | * @{
|
||
548 | */
|
||
549 | /*===========================================================================*/
|
||
550 | |||
551 | 6b53f6bf | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
552 | acc97cbf | Thomas Schöpping | ROMCONST char* moduleShellPrompt = "PowerManagement"; |
553 | 6b53f6bf | Thomas Schöpping | #endif
|
554 | |||
555 | /** @} */
|
||
556 | |||
557 | /*===========================================================================*/
|
||
558 | /**
|
||
559 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
560 | * @{
|
||
561 | */
|
||
562 | /*===========================================================================*/
|
||
563 | |||
564 | e545e620 | Thomas Schöpping | /** @} */
|
565 | |||
566 | /*===========================================================================*/
|
||
567 | /**
|
||
568 | * @name Low-level drivers
|
||
569 | * @{
|
||
570 | */
|
||
571 | /*===========================================================================*/
|
||
572 | |||
573 | AT24C01BNDriver moduleLldEeprom = { |
||
574 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
575 | e545e620 | Thomas Schöpping | /* I2C address */ AT24C01BN_LLD_I2C_ADDR_FIXED,
|
576 | }; |
||
577 | |||
578 | BQ24103ADriver moduleLldBatteryChargerFront = { |
||
579 | 1e5f7648 | Thomas Schöpping | /* charge enable GPIO */ &moduleGpioChargeEn1,
|
580 | /* charge status GPIO */ &moduleGpioChargeStat1A,
|
||
581 | e545e620 | Thomas Schöpping | }; |
582 | |||
583 | BQ24103ADriver moduleLldBatteryChargerRear = { |
||
584 | 1e5f7648 | Thomas Schöpping | /* charge enable GPIO */ &moduleGpioChargeEn2,
|
585 | /* charge status GPIO */ &moduleGpioChargeStat2A,
|
||
586 | e545e620 | Thomas Schöpping | }; |
587 | |||
588 | BQ27500Driver moduleLldFuelGaugeFront = { |
||
589 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
590 | 1e5f7648 | Thomas Schöpping | /* battery low GPIO */ &moduleGpioGaugeBatLow1,
|
591 | /* battery good GPIO */ &moduleGpioGaugeBatGd1,
|
||
592 | e545e620 | Thomas Schöpping | }; |
593 | |||
594 | BQ27500Driver moduleLldFuelGaugeRear = { |
||
595 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
596 | 1e5f7648 | Thomas Schöpping | /* battery low GPIO */ &moduleGpioGaugeBatLow2,
|
597 | /* battery good GPIO */ &moduleGpioGaugeBatGd2,
|
||
598 | e545e620 | Thomas Schöpping | }; |
599 | |||
600 | INA219Driver moduleLldPowerMonitorVdd = { |
||
601 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
602 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
|
603 | /* current LSB (uA) */ 0x00u, |
||
604 | /* configuration */ NULL, |
||
605 | }; |
||
606 | |||
607 | INA219Driver moduleLldPowerMonitorVio18 = { |
||
608 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
609 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
610 | /* current LSB (uA) */ 0x00u, |
||
611 | /* configuration */ NULL, |
||
612 | }; |
||
613 | |||
614 | INA219Driver moduleLldPowerMonitorVio33 = { |
||
615 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
616 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
617 | /* current LSB (uA) */ 0x00u, |
||
618 | /* configuration */ NULL, |
||
619 | }; |
||
620 | |||
621 | INA219Driver moduleLldPowerMonitorVsys42 = { |
||
622 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
623 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
624 | /* current LSB (uA) */ 0x00u, |
||
625 | /* configuration */ NULL, |
||
626 | }; |
||
627 | |||
628 | INA219Driver moduleLldPowerMonitorVio50 = { |
||
629 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
630 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
631 | /* current LSB (uA) */ 0x00u, |
||
632 | /* configuration */ NULL, |
||
633 | }; |
||
634 | |||
635 | LEDDriver moduleLldStatusLed = { |
||
636 | 1e5f7648 | Thomas Schöpping | /* LED GPIO */ &moduleGpioLed,
|
637 | e545e620 | Thomas Schöpping | }; |
638 | |||
639 | 8be006e0 | Thomas Schöpping | TPS62113Driver moduleLldStepDownConverter = { |
640 | /* Power enable GPIO */ &moduleGpioPowerEn,
|
||
641 | }; |
||
642 | |||
643 | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
||
644 | |||
645 | e545e620 | Thomas Schöpping | MPR121Driver moduleLldTouch = { |
646 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
647 | e545e620 | Thomas Schöpping | }; |
648 | |||
649 | PCA9544ADriver moduleLldI2cMultiplexer1 = { |
||
650 | 8be006e0 | Thomas Schöpping | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
651 | e545e620 | Thomas Schöpping | /* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
652 | }; |
||
653 | |||
654 | PCA9544ADriver moduleLldI2cMultiplexer2 = { |
||
655 | 8be006e0 | Thomas Schöpping | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
656 | e545e620 | Thomas Schöpping | /* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
657 | }; |
||
658 | |||
659 | VCNL4020Driver moduleLldProximity1 = { |
||
660 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
661 | e545e620 | Thomas Schöpping | }; |
662 | |||
663 | VCNL4020Driver moduleLldProximity2 = { |
||
664 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
665 | e545e620 | Thomas Schöpping | }; |
666 | |||
667 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
668 | |||
669 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
||
670 | bffb3465 | Thomas Schöpping | |
671 | PCAL6524Driver moduleLldGpioExtender1 = { |
||
672 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
||
673 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
674 | }; |
||
675 | |||
676 | PCAL6524Driver moduleLldGpioExtender2 = { |
||
677 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
678 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
679 | }; |
||
680 | |||
681 | AT42QT1050Driver moduleLldTouch = { |
||
682 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
683 | /* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
||
684 | }; |
||
685 | |||
686 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
687 | |||
688 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
||
689 | bffb3465 | Thomas Schöpping | |
690 | PCAL6524Driver moduleLldGpioExtender1 = { |
||
691 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
||
692 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
693 | }; |
||
694 | |||
695 | PCAL6524Driver moduleLldGpioExtender2 = { |
||
696 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
697 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
698 | }; |
||
699 | |||
700 | AT42QT1050Driver moduleLldTouch = { |
||
701 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
702 | /* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
||
703 | }; |
||
704 | |||
705 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
706 | |||
707 | e545e620 | Thomas Schöpping | /** @} */
|
708 | |||
709 | /*===========================================================================*/
|
||
710 | /**
|
||
711 | * @name Unit tests (UT)
|
||
712 | * @{
|
||
713 | */
|
||
714 | /*===========================================================================*/
|
||
715 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
716 | #include <string.h> |
||
717 | |||
718 | 8be006e0 | Thomas Schöpping | /*
|
719 | * ADC
|
||
720 | */
|
||
721 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[]) |
722 | { |
||
723 | (void)argc;
|
||
724 | (void)argv;
|
||
725 | aosUtRun(stream, &moduleUtAdcVsys, NULL);
|
||
726 | return AOS_OK;
|
||
727 | } |
||
728 | static ut_adcdata_t _utAdcVsysData = {
|
||
729 | /* driver */ &MODULE_HAL_ADC_VSYS,
|
||
730 | /* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
|
||
731 | }; |
||
732 | aos_unittest_t moduleUtAdcVsys = { |
||
733 | /* name */ "ADC", |
||
734 | /* info */ "VSYS", |
||
735 | /* test function */ utAdcFunc,
|
||
736 | /* shell command */ {
|
||
737 | /* name */ "unittest:ADC", |
||
738 | /* callback */ _utShellCmdCb_Adc,
|
||
739 | /* next */ NULL, |
||
740 | }, |
||
741 | /* data */ &_utAdcVsysData,
|
||
742 | }; |
||
743 | |||
744 | 8be006e0 | Thomas Schöpping | /*
|
745 | * AT24C01BN-SH-B (EEPROM)
|
||
746 | */
|
||
747 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldAt24c01bn(BaseSequentialStream* stream, int argc, char* argv[]) |
748 | { |
||
749 | (void)argc;
|
||
750 | (void)argv;
|
||
751 | aosUtRun(stream, &moduleUtAlldAt24c01bn, NULL);
|
||
752 | return AOS_OK;
|
||
753 | } |
||
754 | static ut_at24c01bndata_t _utAlldAt24c01bnData = {
|
||
755 | /* driver */ &moduleLldEeprom,
|
||
756 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
757 | }; |
||
758 | aos_unittest_t moduleUtAlldAt24c01bn = { |
||
759 | /* name */ "AT24C01BN-SH-B", |
||
760 | /* info */ "1kbit EEPROM", |
||
761 | /* test function */ utAlldAt24c01bnFunc,
|
||
762 | /* shell command */ {
|
||
763 | /* name */ "unittest:EEPROM", |
||
764 | /* callback */ _utShellCmdCb_AlldAt24c01bn,
|
||
765 | /* next */ NULL, |
||
766 | }, |
||
767 | /* data */ &_utAlldAt24c01bnData,
|
||
768 | }; |
||
769 | |||
770 | 8be006e0 | Thomas Schöpping | /*
|
771 | * BQ24103A (battery charger)
|
||
772 | */
|
||
773 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
774 | { |
||
775 | // local variables
|
||
776 | bool print_help = false; |
||
777 | |||
778 | // evaluate argument
|
||
779 | if (argc == 2) { |
||
780 | if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
||
781 | moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront; |
||
782 | aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
|
||
783 | moduleUtAlldBq24103a.data = NULL;
|
||
784 | } |
||
785 | else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
||
786 | moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear; |
||
787 | aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
|
||
788 | moduleUtAlldBq24103a.data = NULL;
|
||
789 | } |
||
790 | else {
|
||
791 | print_help = true;
|
||
792 | } |
||
793 | } else {
|
||
794 | print_help = true;
|
||
795 | } |
||
796 | |||
797 | // print help or just return
|
||
798 | if (print_help) {
|
||
799 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
800 | chprintf(stream, "Options:\n");
|
||
801 | chprintf(stream, " --front, -f\n");
|
||
802 | chprintf(stream, " Test the front battery charger.\n");
|
||
803 | chprintf(stream, " --rear, -r\n");
|
||
804 | chprintf(stream, " Test the rear battery charger.\n");
|
||
805 | return AOS_INVALID_ARGUMENTS;
|
||
806 | } else {
|
||
807 | return AOS_OK;
|
||
808 | } |
||
809 | } |
||
810 | aos_unittest_t moduleUtAlldBq24103a = { |
||
811 | /* name */ "BQ24103A", |
||
812 | /* info */ "battery charger", |
||
813 | /* test function */ utAlldBq24103aFunc,
|
||
814 | /* shell command */ {
|
||
815 | /* name */ "unittest:BatteryCharger", |
||
816 | /* callback */ _utShellCmdCb_AlldBq24103a,
|
||
817 | /* next */ NULL, |
||
818 | }, |
||
819 | /* data */ NULL, |
||
820 | }; |
||
821 | |||
822 | 8be006e0 | Thomas Schöpping | /*
|
823 | * BQ27500 (fuel gauge)
|
||
824 | */
|
||
825 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[]) |
826 | { |
||
827 | // evaluate arguments
|
||
828 | if (argc == 2) { |
||
829 | if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
||
830 | ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront; |
||
831 | aosUtRun(stream, &moduleUtAlldBq27500, "front battery");
|
||
832 | ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
||
833 | return AOS_OK;
|
||
834 | } |
||
835 | else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
||
836 | ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear; |
||
837 | aosUtRun(stream, &moduleUtAlldBq27500, "rear battery");
|
||
838 | ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
||
839 | return AOS_OK;
|
||
840 | } |
||
841 | } |
||
842 | // print help
|
||
843 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
844 | chprintf(stream, "Options:\n");
|
||
845 | chprintf(stream, " --front, -f\n");
|
||
846 | chprintf(stream, " Test the front battery fuel gauge.\n");
|
||
847 | chprintf(stream, " --rear, -r\n");
|
||
848 | chprintf(stream, " Test the rear battery fuel gauge.\n");
|
||
849 | return AOS_INVALID_ARGUMENTS;
|
||
850 | } |
||
851 | static ut_bq27500data_t _utAlldBq27500Data = {
|
||
852 | /* driver */ NULL, |
||
853 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
854 | }; |
||
855 | aos_unittest_t moduleUtAlldBq27500 = { |
||
856 | /* name */ "BQ27500", |
||
857 | /* info */ "fuel gauge", |
||
858 | /* test function */ utAlldBq27500Func,
|
||
859 | /* shell command */ {
|
||
860 | /* name */ "unittest:FuelGauge", |
||
861 | /* callback */ _utShellCmdCb_AlldBq27500,
|
||
862 | /* next */ NULL, |
||
863 | }, |
||
864 | /* data */ &_utAlldBq27500Data,
|
||
865 | }; |
||
866 | |||
867 | 8be006e0 | Thomas Schöpping | /*
|
868 | * BQ27500 (fuel gauge) in combination with BQ24103A (battery charger)
|
||
869 | */
|
||
870 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
871 | { |
||
872 | // evaluate arguments
|
||
873 | if (argc == 2) { |
||
874 | if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
||
875 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront; |
||
876 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = &moduleLldBatteryChargerFront; |
||
877 | aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery");
|
||
878 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
||
879 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = NULL;
|
||
880 | return AOS_OK;
|
||
881 | } |
||
882 | else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
||
883 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear; |
||
884 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = &moduleLldBatteryChargerRear; |
||
885 | aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery");
|
||
886 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
||
887 | ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = NULL;
|
||
888 | return AOS_OK;
|
||
889 | } |
||
890 | } |
||
891 | // print help
|
||
892 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
893 | chprintf(stream, "Options:\n");
|
||
894 | chprintf(stream, " --front, -f\n");
|
||
895 | chprintf(stream, " Test the front battery fuel gauge and charger.\n");
|
||
896 | chprintf(stream, " --rear, -r\n");
|
||
897 | chprintf(stream, " Test the rear battery fuel gauge and charger.\n");
|
||
898 | return AOS_INVALID_ARGUMENTS;
|
||
899 | } |
||
900 | static ut_bq27500bq24103adata_t _utAlldBq27500Bq24103aData= {
|
||
901 | /* BQ27500 driver */ NULL, |
||
902 | /* BQ23203A driver */ NULL, |
||
903 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
904 | }; |
||
905 | aos_unittest_t moduleUtAlldBq27500Bq24103a = { |
||
906 | /* name */ "BQ27500 & BQ24103A", |
||
907 | /* info */ "fuel gauge & battery charger", |
||
908 | /* test function */ utAlldBq27500Bq24103aFunc,
|
||
909 | /* shell command */ {
|
||
910 | /* name */ "unittest:FuelGauge&BatteryCharger", |
||
911 | /* callback */ _utShellCmdCb_AlldBq27500Bq24103a,
|
||
912 | /* next */ NULL, |
||
913 | }, |
||
914 | /* data */ &_utAlldBq27500Bq24103aData,
|
||
915 | }; |
||
916 | |||
917 | 8be006e0 | Thomas Schöpping | /*
|
918 | * INA219 (power monitor)
|
||
919 | */
|
||
920 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
921 | { |
||
922 | // evaluate arguments
|
||
923 | if (argc == 2) { |
||
924 | if (strcmp(argv[1], "VDD") == 0) { |
||
925 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd; |
||
926 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
||
927 | aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
|
||
928 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
||
929 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
||
930 | return AOS_OK;
|
||
931 | } |
||
932 | else if (strcmp(argv[1], "VIO1.8") == 0) { |
||
933 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18; |
||
934 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f; |
||
935 | aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)");
|
||
936 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
||
937 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
||
938 | return AOS_OK;
|
||
939 | } |
||
940 | else if (strcmp(argv[1], "VIO3.3") == 0) { |
||
941 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33; |
||
942 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
||
943 | aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)");
|
||
944 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
||
945 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
||
946 | return AOS_OK;
|
||
947 | } |
||
948 | else if (strcmp(argv[1], "VSYS4.2") == 0) { |
||
949 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42; |
||
950 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f; |
||
951 | aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)");
|
||
952 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
||
953 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
||
954 | return AOS_OK;
|
||
955 | } |
||
956 | else if (strcmp(argv[1], "VIO5.0") == 0) { |
||
957 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50; |
||
958 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f; |
||
959 | aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)");
|
||
960 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
||
961 | ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
||
962 | return AOS_OK;
|
||
963 | } |
||
964 | } |
||
965 | // print help
|
||
966 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
967 | chprintf(stream, "Options:\n");
|
||
968 | chprintf(stream, " VDD\n");
|
||
969 | chprintf(stream, " Test VDD (3.3V) power monitor.\n");
|
||
970 | chprintf(stream, " VIO1.8\n");
|
||
971 | chprintf(stream, " Test VIO 1.8V power monitor.\n");
|
||
972 | chprintf(stream, " VIO3.3\n");
|
||
973 | chprintf(stream, " Test VIO 3.3V power monitor.\n");
|
||
974 | chprintf(stream, " VSYS4.2\n");
|
||
975 | chprintf(stream, " Test VSYS 4.2V power monitor.\n");
|
||
976 | chprintf(stream, " VIO5.0\n");
|
||
977 | chprintf(stream, " Test VIO 5.0V power monitor.\n");
|
||
978 | return AOS_INVALID_ARGUMENTS;
|
||
979 | } |
||
980 | static ut_ina219data_t _utAlldIna219Data = {
|
||
981 | /* driver */ NULL, |
||
982 | /* expected voltage */ 0.0f, |
||
983 | /* tolerance */ 0.05f, |
||
984 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
985 | }; |
||
986 | aos_unittest_t moduleUtAlldIna219 = { |
||
987 | /* name */ "INA219", |
||
988 | /* info */ "power monitor", |
||
989 | /* test function */ utAlldIna219Func,
|
||
990 | /* shell command */ {
|
||
991 | /* name */ "unittest:PowerMonitor", |
||
992 | /* callback */ _utShellCmdCb_AlldIna219,
|
||
993 | /* next */ NULL, |
||
994 | }, |
||
995 | /* data */ &_utAlldIna219Data,
|
||
996 | }; |
||
997 | |||
998 | 8be006e0 | Thomas Schöpping | /*
|
999 | * Status LED
|
||
1000 | */
|
||
1001 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
1002 | { |
||
1003 | (void)argc;
|
||
1004 | (void)argv;
|
||
1005 | aosUtRun(stream, &moduleUtAlldLed, NULL);
|
||
1006 | return AOS_OK;
|
||
1007 | } |
||
1008 | aos_unittest_t moduleUtAlldLed = { |
||
1009 | /* name */ "LED", |
||
1010 | /* info */ NULL, |
||
1011 | /* test function */ utAlldLedFunc,
|
||
1012 | /* shell command */ {
|
||
1013 | /* name */ "unittest:StatusLED", |
||
1014 | /* callback */ _utShellCmdCb_AlldLed,
|
||
1015 | /* next */ NULL, |
||
1016 | }, |
||
1017 | /* data */ &moduleLldStatusLed,
|
||
1018 | }; |
||
1019 | |||
1020 | 8be006e0 | Thomas Schöpping | /*
|
1021 | * PKLCS1212E4001 (buzzer)
|
||
1022 | */
|
||
1023 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[]) |
1024 | { |
||
1025 | (void)argc;
|
||
1026 | (void)argv;
|
||
1027 | aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL);
|
||
1028 | return AOS_OK;
|
||
1029 | } |
||
1030 | static ut_pklcs1212e4001_t _utAlldPklcs1212e4001Data = {
|
||
1031 | /* PWM driver */ &MODULE_HAL_PWM_BUZZER,
|
||
1032 | /* PWM channel */ MODULE_HAL_PWM_BUZZER_CHANNEL
|
||
1033 | }; |
||
1034 | aos_unittest_t moduleUtAlldPklcs1212e4001 = { |
||
1035 | /* name */ "PKLCS1212E4001", |
||
1036 | /* info */ "buzzer", |
||
1037 | /* test function */ utAlldPklcs1212e4001Func,
|
||
1038 | /* shell command */ {
|
||
1039 | /* name */ "unittest:Buzzer", |
||
1040 | /* callback */ _utShellCmdCb_AlldPklcs1212e4001,
|
||
1041 | /* next */ NULL, |
||
1042 | }, |
||
1043 | /* data */ &_utAlldPklcs1212e4001Data,
|
||
1044 | }; |
||
1045 | |||
1046 | 8be006e0 | Thomas Schöpping | /*
|
1047 | * TPS62113 (stop-down converter)
|
||
1048 | */
|
||
1049 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[]) |
1050 | { |
||
1051 | // Although there are four TPS62113 on the PCB, they all share the same input signal.
|
||
1052 | // A sa result, no additional shell arguments need to be evaluated.
|
||
1053 | (void)argc;
|
||
1054 | (void)argv;
|
||
1055 | aosUtRun(stream, &moduleUtAlldTps62113, NULL);
|
||
1056 | return AOS_OK;
|
||
1057 | } |
||
1058 | aos_unittest_t moduleUtAlldTps62113 = { |
||
1059 | /* name */ "TPS62113", |
||
1060 | /* info */ "step-down converter", |
||
1061 | /* test function */ utAlldTps62113Func,
|
||
1062 | /* shell command */ {
|
||
1063 | /* name */ "unittest:StepDownConverter", |
||
1064 | /* callback */ _utShellCmdCb_AlldTps62113,
|
||
1065 | /* next */ NULL, |
||
1066 | }, |
||
1067 | /* data */ &moduleLldStepDownConverter,
|
||
1068 | }; |
||
1069 | |||
1070 | 8be006e0 | Thomas Schöpping | /*
|
1071 | * TPS62113 (step-donw converter) in combination with INA219 (power monitor)
|
||
1072 | */
|
||
1073 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[]) |
1074 | { |
||
1075 | (void)argc;
|
||
1076 | (void)argv;
|
||
1077 | aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)");
|
||
1078 | return AOS_OK;
|
||
1079 | } |
||
1080 | acc97cbf | Thomas Schöpping | static ut_tps62113ina219data_t _utAlldTps62113Ina219Data = {
|
1081 | e545e620 | Thomas Schöpping | /* TPS62113 */ &moduleLldStepDownConverter,
|
1082 | /* INA219 */ &moduleLldPowerMonitorVsys42,
|
||
1083 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1084 | }; |
||
1085 | aos_unittest_t moduleUtAlldTps62113Ina219 = { |
||
1086 | /* name */ "TPS62113 & INA219", |
||
1087 | /* info */ "step-down converter & power monitor", |
||
1088 | /* test function */ utAlldTps62113Ina219Func,
|
||
1089 | /* shell command */ {
|
||
1090 | /* name */ "unittest:StepDownConverter&PowerMonitor", |
||
1091 | /* callback */ _utShellCmdCb_AlldTps62113Ina219,
|
||
1092 | /* next */ NULL, |
||
1093 | }, |
||
1094 | /* data */ &_utAlldTps62113Ina219Data,
|
||
1095 | }; |
||
1096 | |||
1097 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
1098 | |||
1099 | /*
|
||
1100 | * MPR121 (touch sensor)
|
||
1101 | */
|
||
1102 | static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1103 | { |
||
1104 | (void)argc;
|
||
1105 | (void)argv;
|
||
1106 | aosUtRun(stream, &moduleUtAlldMpr121, NULL);
|
||
1107 | return AOS_OK;
|
||
1108 | } |
||
1109 | static ut_mpr121data_t _utAlldMpr121Data= {
|
||
1110 | /* MPR121 driver */ &moduleLldTouch,
|
||
1111 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1112 | /* event source */ &aos.events.io,
|
||
1113 | /* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
||
1114 | }; |
||
1115 | aos_unittest_t moduleUtAlldMpr121 = { |
||
1116 | /* name */ "MPR121", |
||
1117 | /* info */ "touch sensor", |
||
1118 | /* test function */ utAlldMpr121Func,
|
||
1119 | /* shell command */ {
|
||
1120 | /* name */ "unittest:Touch", |
||
1121 | /* callback */ _utShellCmdCb_AlldMpr121,
|
||
1122 | /* next */ NULL, |
||
1123 | }, |
||
1124 | /* data */ &_utAlldMpr121Data,
|
||
1125 | }; |
||
1126 | |||
1127 | /*
|
||
1128 | * PCA9544A (I2C multiplexer)
|
||
1129 | */
|
||
1130 | static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1131 | { |
||
1132 | // evaluate arguments
|
||
1133 | if (argc == 2) { |
||
1134 | if (strcmp(argv[1], "#1") == 0) { |
||
1135 | ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1; |
||
1136 | aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1");
|
||
1137 | ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
||
1138 | return AOS_OK;
|
||
1139 | } |
||
1140 | else if (strcmp(argv[1], "#2") == 0) { |
||
1141 | ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2; |
||
1142 | aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2");
|
||
1143 | ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
||
1144 | return AOS_OK;
|
||
1145 | } |
||
1146 | } |
||
1147 | // print help
|
||
1148 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
1149 | chprintf(stream, "Options:\n");
|
||
1150 | chprintf(stream, " #1\n");
|
||
1151 | chprintf(stream, " Test the multiplexer on the I2C bus #1.\n");
|
||
1152 | chprintf(stream, " #2\n");
|
||
1153 | chprintf(stream, " Test the multiplexer on the I2C bus #2.\n");
|
||
1154 | return AOS_INVALID_ARGUMENTS;
|
||
1155 | } |
||
1156 | static ut_pca9544adata_t _utAlldPca9544aData = {
|
||
1157 | /* driver */ NULL, |
||
1158 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1159 | }; |
||
1160 | aos_unittest_t moduleUtAlldPca9544a = { |
||
1161 | /* name */ "PCA9544A", |
||
1162 | /* info */ "I2C multiplexer", |
||
1163 | /* test function */ utAlldPca9544aFunc,
|
||
1164 | /* shell command */ {
|
||
1165 | /* name */ "unittest:I2CMultiplexer", |
||
1166 | /* callback */ _utShellCmdCb_AlldPca5944a,
|
||
1167 | /* next */ NULL, |
||
1168 | }, |
||
1169 | /* data */ &_utAlldPca9544aData,
|
||
1170 | }; |
||
1171 | |||
1172 | /*
|
||
1173 | * VCNL4020 (proximity sensor)
|
||
1174 | */
|
||
1175 | e545e620 | Thomas Schöpping | static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl) |
1176 | { |
||
1177 | uint8_t intstatus; |
||
1178 | vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
|
||
1179 | vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1180 | if (intstatus) {
|
||
1181 | vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1182 | } |
||
1183 | return;
|
||
1184 | } |
||
1185 | static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1186 | { |
||
1187 | enum {
|
||
1188 | UNKNOWN, |
||
1189 | NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW, |
||
1190 | } sensor = UNKNOWN; |
||
1191 | // evaluate arguments
|
||
1192 | if (argc == 2) { |
||
1193 | if (strcmp(argv[1], "-nne") == 0) { |
||
1194 | sensor = NNE; |
||
1195 | } else if (strcmp(argv[1], "-ene") == 0) { |
||
1196 | sensor = ENE; |
||
1197 | } else if (strcmp(argv[1], "-ese") == 0) { |
||
1198 | sensor = ESE; |
||
1199 | } else if (strcmp(argv[1], "-sse") == 0) { |
||
1200 | sensor = SSE; |
||
1201 | } else if (strcmp(argv[1], "-ssw") == 0) { |
||
1202 | sensor = SSW; |
||
1203 | } else if (strcmp(argv[1], "-wsw") == 0) { |
||
1204 | sensor = WSW; |
||
1205 | } else if (strcmp(argv[1], "-wnw") == 0) { |
||
1206 | sensor = WNW; |
||
1207 | } else if (strcmp(argv[1], "-nnw") == 0) { |
||
1208 | sensor = NNW; |
||
1209 | } |
||
1210 | } |
||
1211 | if (sensor != UNKNOWN) {
|
||
1212 | PCA9544ADriver* mux = NULL;
|
||
1213 | switch (sensor) {
|
||
1214 | case SSE:
|
||
1215 | case SSW:
|
||
1216 | case WSW:
|
||
1217 | case WNW:
|
||
1218 | mux = &moduleLldI2cMultiplexer1; |
||
1219 | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1; |
||
1220 | 1e5f7648 | Thomas Schöpping | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1221 | e545e620 | Thomas Schöpping | break;
|
1222 | case NNW:
|
||
1223 | case NNE:
|
||
1224 | case ENE:
|
||
1225 | case ESE:
|
||
1226 | mux = &moduleLldI2cMultiplexer2; |
||
1227 | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2; |
||
1228 | 1e5f7648 | Thomas Schöpping | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1229 | e545e620 | Thomas Schöpping | break;
|
1230 | default:
|
||
1231 | break;
|
||
1232 | } |
||
1233 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1234 | _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
||
1235 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1236 | _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
||
1237 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1238 | _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
||
1239 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1240 | _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
||
1241 | switch (sensor) {
|
||
1242 | case NNE:
|
||
1243 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1244 | aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
|
||
1245 | break;
|
||
1246 | case ENE:
|
||
1247 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1248 | aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
|
||
1249 | break;
|
||
1250 | case ESE:
|
||
1251 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1252 | aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
|
||
1253 | break;
|
||
1254 | case SSE:
|
||
1255 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1256 | aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
|
||
1257 | break;
|
||
1258 | case SSW:
|
||
1259 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1260 | aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
|
||
1261 | break;
|
||
1262 | case WSW:
|
||
1263 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1264 | aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
|
||
1265 | break;
|
||
1266 | case WNW:
|
||
1267 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1268 | aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
|
||
1269 | break;
|
||
1270 | case NNW:
|
||
1271 | pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
||
1272 | aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
|
||
1273 | break;
|
||
1274 | default:
|
||
1275 | break;
|
||
1276 | } |
||
1277 | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL;
|
||
1278 | ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0;
|
||
1279 | return AOS_OK;
|
||
1280 | } |
||
1281 | // print help
|
||
1282 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
1283 | chprintf(stream, "Options:\n");
|
||
1284 | chprintf(stream, " -nne\n");
|
||
1285 | chprintf(stream, " Test north-northeast sensor.\n");
|
||
1286 | chprintf(stream, " -ene\n");
|
||
1287 | chprintf(stream, " Test east-northeast sensor.\n");
|
||
1288 | chprintf(stream, " -ese\n");
|
||
1289 | chprintf(stream, " Test east-southeast sensor.\n");
|
||
1290 | chprintf(stream, " -sse\n");
|
||
1291 | chprintf(stream, " Test south-southeast sensor.\n");
|
||
1292 | chprintf(stream, " -ssw\n");
|
||
1293 | chprintf(stream, " Test south-southwest sensor.\n");
|
||
1294 | chprintf(stream, " -wsw\n");
|
||
1295 | chprintf(stream, " Test west-southwest sensor.\n");
|
||
1296 | chprintf(stream, " -wnw\n");
|
||
1297 | chprintf(stream, " Test west-northwest sensor.\n");
|
||
1298 | chprintf(stream, " -nnw\n");
|
||
1299 | chprintf(stream, " Test north-northwest sensor.\n");
|
||
1300 | return AOS_INVALID_ARGUMENTS;
|
||
1301 | } |
||
1302 | static ut_vcnl4020data_t _utAlldVcnl4020Data = {
|
||
1303 | /* driver */ NULL, |
||
1304 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1305 | 6b53f6bf | Thomas Schöpping | /* event source */ &aos.events.io,
|
1306 | e545e620 | Thomas Schöpping | /* event flags */ 0, |
1307 | }; |
||
1308 | aos_unittest_t moduleUtAlldVcnl4020 = { |
||
1309 | /* name */ "VCNL4020", |
||
1310 | /* info */ "proximity sensor", |
||
1311 | /* test function */ utAlldVcnl4020Func,
|
||
1312 | /* shell command */ {
|
||
1313 | /* name */ "unittest:Proximity", |
||
1314 | /* callback */ _utShellCmdCb_AlldVcnl4020,
|
||
1315 | /* next */ NULL, |
||
1316 | }, |
||
1317 | /* data */ &_utAlldVcnl4020Data,
|
||
1318 | }; |
||
1319 | |||
1320 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
1321 | |||
1322 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
||
1323 | bffb3465 | Thomas Schöpping | |
1324 | /*
|
||
1325 | * PCAL6524 (GPIO extender)
|
||
1326 | */
|
||
1327 | static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1328 | { |
||
1329 | // evaluate arguments
|
||
1330 | if (argc == 2) { |
||
1331 | if (strcmp(argv[1], "#1") == 0) { |
||
1332 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
||
1333 | aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
||
1334 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
||
1335 | return AOS_OK;
|
||
1336 | } |
||
1337 | else if (strcmp(argv[1], "#2") == 0) { |
||
1338 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
||
1339 | aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
||
1340 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
||
1341 | return AOS_OK;
|
||
1342 | } |
||
1343 | } |
||
1344 | // print help
|
||
1345 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
1346 | chprintf(stream, "Options:\n");
|
||
1347 | chprintf(stream, " #1\n");
|
||
1348 | chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
||
1349 | chprintf(stream, " #2\n");
|
||
1350 | chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
||
1351 | return AOS_INVALID_ARGUMENTS;
|
||
1352 | } |
||
1353 | static ut_pcal6524data_t _utAlldPcal6524Data = {
|
||
1354 | /* driver */ NULL, |
||
1355 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1356 | }; |
||
1357 | aos_unittest_t moduleUtAlldPcal6524 = { |
||
1358 | /* name */ "PCAL6524", |
||
1359 | /* info */ "GPIO extender", |
||
1360 | /* test function */ utAlldPcal6524Func,
|
||
1361 | /* shell command */ {
|
||
1362 | /* name */ "unittest:GPIOExtender", |
||
1363 | /* callback */ _utShellCmdCb_AlldPcal6524,
|
||
1364 | /* next */ NULL, |
||
1365 | }, |
||
1366 | /* data */ &_utAlldPcal6524Data,
|
||
1367 | }; |
||
1368 | |||
1369 | /*
|
||
1370 | * AT42QT1050 (touch sensor)
|
||
1371 | */
|
||
1372 | static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1373 | { |
||
1374 | (void)argc;
|
||
1375 | (void)argv;
|
||
1376 | aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
||
1377 | return AOS_OK;
|
||
1378 | } |
||
1379 | static ut_at42qt1050data_t _utAlldMpr121Data= {
|
||
1380 | /* AT42QT1050 driver */ &moduleLldTouch,
|
||
1381 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1382 | /* event source */ &aos.events.io,
|
||
1383 | /* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
||
1384 | }; |
||
1385 | aos_unittest_t moduleUtAlldAt42qt1050 = { |
||
1386 | /* name */ "AT42QT1050", |
||
1387 | /* info */ "touch sensor", |
||
1388 | /* test function */ utAlldAt42qt1050Func,
|
||
1389 | /* shell command */ {
|
||
1390 | /* name */ "unittest:Touch", |
||
1391 | /* callback */ _utShellCmdCb_AlldAt42qt1050,
|
||
1392 | /* next */ NULL, |
||
1393 | }, |
||
1394 | /* data */ &_utAlldMpr121Data,
|
||
1395 | }; |
||
1396 | |||
1397 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
1398 | |||
1399 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
||
1400 | bffb3465 | Thomas Schöpping | |
1401 | /*
|
||
1402 | * PCAL6524 (GPIO extender)
|
||
1403 | */
|
||
1404 | static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1405 | { |
||
1406 | // evaluate arguments
|
||
1407 | if (argc == 2) { |
||
1408 | if (strcmp(argv[1], "#1") == 0) { |
||
1409 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
||
1410 | aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
||
1411 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
||
1412 | return AOS_OK;
|
||
1413 | } |
||
1414 | else if (strcmp(argv[1], "#2") == 0) { |
||
1415 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
||
1416 | aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
||
1417 | ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
||
1418 | return AOS_OK;
|
||
1419 | } |
||
1420 | } |
||
1421 | // print help
|
||
1422 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
1423 | chprintf(stream, "Options:\n");
|
||
1424 | chprintf(stream, " #1\n");
|
||
1425 | chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
||
1426 | chprintf(stream, " #2\n");
|
||
1427 | chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
||
1428 | return AOS_INVALID_ARGUMENTS;
|
||
1429 | } |
||
1430 | static ut_pcal6524data_t _utAlldPcal6524Data = {
|
||
1431 | /* driver */ NULL, |
||
1432 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1433 | }; |
||
1434 | aos_unittest_t moduleUtAlldPcal6524 = { |
||
1435 | /* name */ "PCAL6524", |
||
1436 | /* info */ "GPIO extender", |
||
1437 | /* test function */ utAlldPcal6524Func,
|
||
1438 | /* shell command */ {
|
||
1439 | /* name */ "unittest:GPIOExtender", |
||
1440 | /* callback */ _utShellCmdCb_AlldPcal6524,
|
||
1441 | /* next */ NULL, |
||
1442 | }, |
||
1443 | /* data */ &_utAlldPcal6524Data,
|
||
1444 | }; |
||
1445 | |||
1446 | /*
|
||
1447 | * AT42QT1050 (touch sensor)
|
||
1448 | */
|
||
1449 | static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
||
1450 | { |
||
1451 | (void)argc;
|
||
1452 | (void)argv;
|
||
1453 | aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
||
1454 | return AOS_OK;
|
||
1455 | } |
||
1456 | static ut_at42qt1050data_t _utAlldMpr121Data= {
|
||
1457 | /* AT42QT1050 driver */ &moduleLldTouch,
|
||
1458 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
1459 | /* event source */ &aos.events.io,
|
||
1460 | /* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
||
1461 | }; |
||
1462 | aos_unittest_t moduleUtAlldAt42qt1050 = { |
||
1463 | /* name */ "AT42QT1050", |
||
1464 | /* info */ "touch sensor", |
||
1465 | /* test function */ utAlldAt42qt1050Func,
|
||
1466 | /* shell command */ {
|
||
1467 | /* name */ "unittest:Touch", |
||
1468 | /* callback */ _utShellCmdCb_AlldAt42qt1050,
|
||
1469 | /* next */ NULL, |
||
1470 | }, |
||
1471 | /* data */ &_utAlldMpr121Data,
|
||
1472 | }; |
||
1473 | |||
1474 | 8be006e0 | Thomas Schöpping | #endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
1475 | |||
1476 | e545e620 | Thomas Schöpping | #endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
1477 | |||
1478 | /** @} */
|
||
1479 | 53710ca3 | Marc Rothmann | /** @} */ |