amiro-os / modules / PowerManagement_1-1 / module.c @ 3f716772
History | View | Annotate | Download (47.208 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 | e545e620 | Thomas Schöpping | /* port */ GPIOA,
|
128 | /* pad */ GPIOA_SYS_REG_EN,
|
||
129 | }; |
||
130 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleSysRegEn = { |
131 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysRegEn,
|
132 | /* meta */ {
|
||
133 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
134 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
135 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
136 | }, |
||
137 | }; |
||
138 | e545e620 | Thomas Schöpping | |
139 | 1e5f7648 | Thomas Schöpping | /**
|
140 | * @brief IR_INT1 input signal GPIO.
|
||
141 | */
|
||
142 | static apalGpio_t _gpioIrInt1 = {
|
||
143 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
144 | /* pad */ GPIOB_IR_INT1_N,
|
||
145 | }; |
||
146 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioIrInt1 = { |
147 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioIrInt1,
|
148 | /* meta */ {
|
||
149 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
150 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
151 | 1e5f7648 | Thomas Schöpping | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
152 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
153 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
154 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
155 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
156 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
157 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
158 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
159 | 7de0cc90 | Thomas Schöpping | #else /* (BOARD_SENSORRING == ?) */ |
160 | 8be006e0 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
161 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
162 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == ?) */ |
163 | 1e5f7648 | Thomas Schöpping | }, |
164 | }; |
||
165 | e545e620 | Thomas Schöpping | |
166 | 1e5f7648 | Thomas Schöpping | /**
|
167 | * @brief POWER_EN output signal GPIO.
|
||
168 | */
|
||
169 | static apalGpio_t _gpioPowerEn = {
|
||
170 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
171 | /* pad */ GPIOB_POWER_EN,
|
||
172 | }; |
||
173 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
174 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPowerEn,
|
175 | /* meta */ {
|
||
176 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
177 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
178 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
179 | }, |
||
180 | }; |
||
181 | e545e620 | Thomas Schöpping | |
182 | 1e5f7648 | Thomas Schöpping | /**
|
183 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
184 | */
|
||
185 | static apalGpio_t _gpioSysUartDn = {
|
||
186 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
187 | /* pad */ GPIOB_SYS_UART_DN,
|
||
188 | }; |
||
189 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
190 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysUartDn,
|
191 | /* meta */ {
|
||
192 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
193 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
194 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
195 | }, |
||
196 | }; |
||
197 | e545e620 | Thomas Schöpping | |
198 | 1e5f7648 | Thomas Schöpping | /**
|
199 | * @brief CHARGE_STAT2A input signal GPIO.
|
||
200 | */
|
||
201 | static apalGpio_t _gpioChargeStat2A = {
|
||
202 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
203 | /* pad */ GPIOB_CHARGE_STAT2A,
|
||
204 | }; |
||
205 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeStat2A = { |
206 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeStat2A,
|
207 | /* meta */ {
|
||
208 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
209 | ddf34c3d | Thomas Schöpping | /* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
210 | 1e5f7648 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
211 | }, |
||
212 | }; |
||
213 | e545e620 | Thomas Schöpping | |
214 | 1e5f7648 | Thomas Schöpping | /**
|
215 | * @brief GAUGE_BATLOW2 input signal GPIO.
|
||
216 | */
|
||
217 | static apalGpio_t _gpioGaugeBatLow2 = {
|
||
218 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
219 | /* pad */ GPIOB_GAUGE_BATLOW2,
|
||
220 | }; |
||
221 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = { |
222 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatLow2,
|
223 | /* meta */ {
|
||
224 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
225 | /* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
||
226 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
227 | }, |
||
228 | }; |
||
229 | e545e620 | Thomas Schöpping | |
230 | 1e5f7648 | Thomas Schöpping | /**
|
231 | * @brief GAUGE_BATGD2 input signal GPIO.
|
||
232 | */
|
||
233 | static apalGpio_t _gpioGaugeBatGd2 = {
|
||
234 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
235 | /* pad */ GPIOB_GAUGE_BATGD2_N,
|
||
236 | }; |
||
237 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = { |
238 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatGd2,
|
239 | /* meta */ {
|
||
240 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
241 | /* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
||
242 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
243 | }, |
||
244 | }; |
||
245 | e545e620 | Thomas Schöpping | |
246 | 1e5f7648 | Thomas Schöpping | /**
|
247 | * @brief LED output signal GPIO.
|
||
248 | */
|
||
249 | static apalGpio_t _gpioLed = {
|
||
250 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
251 | /* pad */ GPIOB_LED,
|
||
252 | }; |
||
253 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioLed = { |
254 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioLed,
|
255 | /* meta */ {
|
||
256 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
257 | /* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
||
258 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
259 | }, |
||
260 | }; |
||
261 | e545e620 | Thomas Schöpping | |
262 | 1e5f7648 | Thomas Schöpping | /**
|
263 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
264 | */
|
||
265 | static apalGpio_t _gpioSysUartUp = {
|
||
266 | e545e620 | Thomas Schöpping | /* port */ GPIOB,
|
267 | /* pad */ GPIOB_SYS_UART_UP,
|
||
268 | }; |
||
269 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
270 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysUartUp,
|
271 | /* meta */ {
|
||
272 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
273 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
274 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
275 | }, |
||
276 | }; |
||
277 | e545e620 | Thomas Schöpping | |
278 | 1e5f7648 | Thomas Schöpping | /**
|
279 | * @brief CHARGE_STAT1A input signal GPIO.
|
||
280 | */
|
||
281 | static apalGpio_t _gpioChargeStat1A = {
|
||
282 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
283 | /* pad */ GPIOC_CHARGE_STAT1A,
|
||
284 | }; |
||
285 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeStat1A = { |
286 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeStat1A,
|
287 | /* meta */ {
|
||
288 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
289 | ddf34c3d | Thomas Schöpping | /* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
290 | 1e5f7648 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
291 | }, |
||
292 | }; |
||
293 | e545e620 | Thomas Schöpping | |
294 | 1e5f7648 | Thomas Schöpping | /**
|
295 | * @brief GAUGE_BATLOW1 input signal GPIO.
|
||
296 | */
|
||
297 | static apalGpio_t _gpioGaugeBatLow1 = {
|
||
298 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
299 | /* pad */ GPIOC_GAUGE_BATLOW1,
|
||
300 | }; |
||
301 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = { |
302 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatLow1,
|
303 | /* meta */ {
|
||
304 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
305 | /* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
||
306 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
307 | }, |
||
308 | }; |
||
309 | e545e620 | Thomas Schöpping | |
310 | 1e5f7648 | Thomas Schöpping | /**
|
311 | * @brief GAUGE_BATGD1 input signal GPIO.
|
||
312 | */
|
||
313 | static apalGpio_t _gpioGaugeBatGd1 = {
|
||
314 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
315 | /* pad */ GPIOC_GAUGE_BATGD1_N,
|
||
316 | }; |
||
317 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = { |
318 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioGaugeBatGd1,
|
319 | /* meta */ {
|
||
320 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
321 | /* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
||
322 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
323 | }, |
||
324 | }; |
||
325 | e545e620 | Thomas Schöpping | |
326 | 1e5f7648 | Thomas Schöpping | /**
|
327 | * @brief CHARG_EN1 output signal GPIO.
|
||
328 | */
|
||
329 | static apalGpio_t _gpioChargeEn1 = {
|
||
330 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
331 | /* pad */ GPIOC_CHARGE_EN1_N,
|
||
332 | }; |
||
333 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeEn1 = { |
334 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeEn1,
|
335 | /* meta */ {
|
||
336 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
337 | ddf34c3d | Thomas Schöpping | /* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
338 | 1e5f7648 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
339 | }, |
||
340 | }; |
||
341 | e545e620 | Thomas Schöpping | |
342 | 1e5f7648 | Thomas Schöpping | /**
|
343 | * @brief IR_INT2 input signal GPIO.
|
||
344 | */
|
||
345 | static apalGpio_t _gpioIrInt2 = {
|
||
346 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
347 | /* pad */ GPIOC_IR_INT2_N,
|
||
348 | }; |
||
349 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioIrInt2 = { |
350 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioIrInt2,
|
351 | /* meta */ {
|
||
352 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
353 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
354 | 1e5f7648 | Thomas Schöpping | /* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
355 | /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
||
356 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
357 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
358 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
359 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
360 | bffb3465 | Thomas Schöpping | /* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
361 | /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
||
362 | 7de0cc90 | Thomas Schöpping | #else /* (BOARD_SENSORRING == ?) */ |
363 | 8be006e0 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
364 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
365 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == ?) */ |
366 | 1e5f7648 | Thomas Schöpping | }, |
367 | }; |
||
368 | e545e620 | Thomas Schöpping | |
369 | 1e5f7648 | Thomas Schöpping | /**
|
370 | * @brief TOUCH_INT input signal GPIO.
|
||
371 | */
|
||
372 | static apalGpio_t _gpioTouchInt = {
|
||
373 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
374 | /* pad */ GPIOC_TOUCH_INT_N,
|
||
375 | }; |
||
376 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioTouchInt = { |
377 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioTouchInt,
|
378 | /* meta */ {
|
||
379 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
380 | 8be006e0 | Thomas Schöpping | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
381 | 1e5f7648 | Thomas Schöpping | /* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
382 | /* interrupt edge */ MPR121_LLD_INT_EDGE,
|
||
383 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
384 | bffb3465 | Thomas Schöpping | /* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
385 | /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
||
386 | 8be006e0 | Thomas Schöpping | #elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
387 | bffb3465 | Thomas Schöpping | /* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
388 | /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
||
389 | 7de0cc90 | Thomas Schöpping | #else /* (BOARD_SENSORRING == ?) */ |
390 | 8be006e0 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
391 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
392 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == ?) */ |
393 | 1e5f7648 | Thomas Schöpping | }, |
394 | }; |
||
395 | e545e620 | Thomas Schöpping | |
396 | 1e5f7648 | Thomas Schöpping | /**
|
397 | * @brief SYS_DONE input signal GPIO.
|
||
398 | */
|
||
399 | static apalGpio_t _gpioSysDone = {
|
||
400 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
401 | /* pad */ GPIOC_SYS_DONE,
|
||
402 | }; |
||
403 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysDone = { |
404 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysDone,
|
405 | /* meta */ {
|
||
406 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
407 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
408 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
409 | }, |
||
410 | }; |
||
411 | e545e620 | Thomas Schöpping | |
412 | 1e5f7648 | Thomas Schöpping | /**
|
413 | * @brief SYS_PROG output signal GPIO.
|
||
414 | */
|
||
415 | static apalGpio_t _gpioSysProg = {
|
||
416 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
417 | /* pad */ GPIOC_SYS_PROG_N,
|
||
418 | }; |
||
419 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysProg = { |
420 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysProg,
|
421 | /* meta */ {
|
||
422 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
423 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
424 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
425 | }, |
||
426 | }; |
||
427 | e545e620 | Thomas Schöpping | |
428 | 1e5f7648 | Thomas Schöpping | /**
|
429 | * @brief PATH_DC input signal GPIO.
|
||
430 | */
|
||
431 | static apalGpio_t _gpioPathDc = {
|
||
432 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
433 | /* pad */ GPIOC_PATH_DC,
|
||
434 | }; |
||
435 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioPathDc = { |
436 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioPathDc,
|
437 | /* meta */ {
|
||
438 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
439 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
440 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
441 | }, |
||
442 | }; |
||
443 | e545e620 | Thomas Schöpping | |
444 | 1e5f7648 | Thomas Schöpping | /**
|
445 | * @brief SYS_SPI_DIR bidirectional signal GPIO.
|
||
446 | */
|
||
447 | static apalGpio_t _gpioSysSpiDir = {
|
||
448 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
449 | /* pad */ GPIOC_SYS_SPI_DIR,
|
||
450 | }; |
||
451 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSpiDir = { |
452 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysSpiDir,
|
453 | /* meta */ {
|
||
454 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
455 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
456 | /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
|
||
457 | }, |
||
458 | }; |
||
459 | e545e620 | Thomas Schöpping | |
460 | 1e5f7648 | Thomas Schöpping | /**
|
461 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
462 | */
|
||
463 | static apalGpio_t _gpioSysSync = {
|
||
464 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
465 | /* pad */ GPIOC_SYS_INT_N,
|
||
466 | }; |
||
467 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
468 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysSync,
|
469 | /* meta */ {
|
||
470 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
471 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
472 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
473 | }, |
||
474 | }; |
||
475 | e545e620 | Thomas Schöpping | |
476 | 1e5f7648 | Thomas Schöpping | /**
|
477 | * @brief SYS_PD bidirectional signal GPIO.
|
||
478 | */
|
||
479 | static apalGpio_t _gpioSysPd = {
|
||
480 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
481 | /* pad */ GPIOC_SYS_PD_N,
|
||
482 | }; |
||
483 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
484 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysPd,
|
485 | /* meta */ {
|
||
486 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
487 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
488 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
489 | }, |
||
490 | }; |
||
491 | e545e620 | Thomas Schöpping | |
492 | 1e5f7648 | Thomas Schöpping | /**
|
493 | * @brief SYS_WARMRST bidirectional signal GPIO.
|
||
494 | */
|
||
495 | static apalGpio_t _gpioSysWarmrst = {
|
||
496 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
497 | /* pad */ GPIOC_SYS_WARMRST_N,
|
||
498 | }; |
||
499 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
500 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioSysWarmrst,
|
501 | /* meta */ {
|
||
502 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
503 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
504 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
505 | }, |
||
506 | }; |
||
507 | e545e620 | Thomas Schöpping | |
508 | 1e5f7648 | Thomas Schöpping | /**
|
509 | * @brief BT_RST output signal GPIO.
|
||
510 | */
|
||
511 | static apalGpio_t _gpioBtRst = {
|
||
512 | e545e620 | Thomas Schöpping | /* port */ GPIOC,
|
513 | /* pad */ GPIOC_BT_RST,
|
||
514 | }; |
||
515 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioBtRst = { |
516 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioBtRst,
|
517 | /* meta */ {
|
||
518 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
519 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
520 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
521 | }, |
||
522 | }; |
||
523 | e545e620 | Thomas Schöpping | |
524 | 1e5f7648 | Thomas Schöpping | /**
|
525 | * @brief CHARGE_EN2 output signal GPIO.
|
||
526 | */
|
||
527 | static apalGpio_t _gpioChargeEn2 = {
|
||
528 | e545e620 | Thomas Schöpping | /* port */ GPIOD,
|
529 | /* pad */ GPIOD_CHARGE_EN2_N,
|
||
530 | }; |
||
531 | acc97cbf | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioChargeEn2 = { |
532 | 1e5f7648 | Thomas Schöpping | /* GPIO */ &_gpioChargeEn2,
|
533 | /* meta */ {
|
||
534 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
535 | ddf34c3d | Thomas Schöpping | /* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
536 | 1e5f7648 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
537 | }, |
||
538 | }; |
||
539 | e545e620 | Thomas Schöpping | |
540 | /** @} */
|
||
541 | |||
542 | /*===========================================================================*/
|
||
543 | /**
|
||
544 | * @name AMiRo-OS core configurations
|
||
545 | * @{
|
||
546 | */
|
||
547 | /*===========================================================================*/
|
||
548 | |||
549 | 2dd2e257 | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
550 | acc97cbf | Thomas Schöpping | ROMCONST char* moduleShellPrompt = "PowerManagement"; |
551 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
552 | 6b53f6bf | Thomas Schöpping | |
553 | /** @} */
|
||
554 | |||
555 | /*===========================================================================*/
|
||
556 | /**
|
||
557 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
558 | * @{
|
||
559 | */
|
||
560 | /*===========================================================================*/
|
||
561 | |||
562 | e545e620 | Thomas Schöpping | /** @} */
|
563 | |||
564 | /*===========================================================================*/
|
||
565 | /**
|
||
566 | * @name Low-level drivers
|
||
567 | * @{
|
||
568 | */
|
||
569 | /*===========================================================================*/
|
||
570 | |||
571 | ddf34c3d | Thomas Schöpping | AT24C01BDriver moduleLldEeprom = { |
572 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
573 | ddf34c3d | Thomas Schöpping | /* I2C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
574 | e545e620 | Thomas Schöpping | }; |
575 | |||
576 | ddf34c3d | Thomas Schöpping | BQ241xxDriver moduleLldBatteryChargerFront = { |
577 | 1e5f7648 | Thomas Schöpping | /* charge enable GPIO */ &moduleGpioChargeEn1,
|
578 | /* charge status GPIO */ &moduleGpioChargeStat1A,
|
||
579 | e545e620 | Thomas Schöpping | }; |
580 | |||
581 | ddf34c3d | Thomas Schöpping | BQ241xxDriver moduleLldBatteryChargerRear = { |
582 | 1e5f7648 | Thomas Schöpping | /* charge enable GPIO */ &moduleGpioChargeEn2,
|
583 | /* charge status GPIO */ &moduleGpioChargeStat2A,
|
||
584 | e545e620 | Thomas Schöpping | }; |
585 | |||
586 | BQ27500Driver moduleLldFuelGaugeFront = { |
||
587 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
588 | 1e5f7648 | Thomas Schöpping | /* battery low GPIO */ &moduleGpioGaugeBatLow1,
|
589 | /* battery good GPIO */ &moduleGpioGaugeBatGd1,
|
||
590 | e545e620 | Thomas Schöpping | }; |
591 | |||
592 | BQ27500Driver moduleLldFuelGaugeRear = { |
||
593 | 8be006e0 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
594 | 1e5f7648 | Thomas Schöpping | /* battery low GPIO */ &moduleGpioGaugeBatLow2,
|
595 | /* battery good GPIO */ &moduleGpioGaugeBatGd2,
|
||
596 | e545e620 | Thomas Schöpping | }; |
597 | |||
598 | INA219Driver moduleLldPowerMonitorVdd = { |
||
599 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
600 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
|
601 | /* current LSB (uA) */ 0x00u, |
||
602 | /* configuration */ NULL, |
||
603 | }; |
||
604 | |||
605 | INA219Driver moduleLldPowerMonitorVio18 = { |
||
606 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
607 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
608 | /* current LSB (uA) */ 0x00u, |
||
609 | /* configuration */ NULL, |
||
610 | }; |
||
611 | |||
612 | INA219Driver moduleLldPowerMonitorVio33 = { |
||
613 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
614 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
615 | /* current LSB (uA) */ 0x00u, |
||
616 | /* configuration */ NULL, |
||
617 | }; |
||
618 | |||
619 | INA219Driver moduleLldPowerMonitorVsys42 = { |
||
620 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
621 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
622 | /* current LSB (uA) */ 0x00u, |
||
623 | /* configuration */ NULL, |
||
624 | }; |
||
625 | |||
626 | INA219Driver moduleLldPowerMonitorVio50 = { |
||
627 | 8be006e0 | Thomas Schöpping | /* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
628 | e545e620 | Thomas Schöpping | /* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
629 | /* current LSB (uA) */ 0x00u, |
||
630 | /* configuration */ NULL, |
||
631 | }; |
||
632 | |||
633 | LEDDriver moduleLldStatusLed = { |
||
634 | 1e5f7648 | Thomas Schöpping | /* LED GPIO */ &moduleGpioLed,
|
635 | e545e620 | Thomas Schöpping | }; |
636 | |||
637 | ddf34c3d | Thomas Schöpping | TPS6211xDriver moduleLldStepDownConverter = { |
638 | 8be006e0 | Thomas Schöpping | /* Power enable GPIO */ &moduleGpioPowerEn,
|
639 | }; |
||
640 | |||
641 | #if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
||
642 | |||
643 | e545e620 | Thomas Schöpping | MPR121Driver moduleLldTouch = { |
644 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
645 | e545e620 | Thomas Schöpping | }; |
646 | |||
647 | PCA9544ADriver moduleLldI2cMultiplexer1 = { |
||
648 | 8be006e0 | Thomas Schöpping | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
649 | e545e620 | Thomas Schöpping | /* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
650 | }; |
||
651 | |||
652 | PCA9544ADriver moduleLldI2cMultiplexer2 = { |
||
653 | 8be006e0 | Thomas Schöpping | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
654 | e545e620 | Thomas Schöpping | /* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
655 | }; |
||
656 | |||
657 | VCNL4020Driver moduleLldProximity1 = { |
||
658 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
659 | e545e620 | Thomas Schöpping | }; |
660 | |||
661 | VCNL4020Driver moduleLldProximity2 = { |
||
662 | 8be006e0 | Thomas Schöpping | /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
663 | e545e620 | Thomas Schöpping | }; |
664 | |||
665 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
666 | 8be006e0 | Thomas Schöpping | |
667 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
||
668 | bffb3465 | Thomas Schöpping | |
669 | PCAL6524Driver moduleLldGpioExtender1 = { |
||
670 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
||
671 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
672 | }; |
||
673 | |||
674 | PCAL6524Driver moduleLldGpioExtender2 = { |
||
675 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
676 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
677 | }; |
||
678 | |||
679 | AT42QT1050Driver moduleLldTouch = { |
||
680 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
681 | /* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
||
682 | }; |
||
683 | |||
684 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
685 | 8be006e0 | Thomas Schöpping | |
686 | #if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
||
687 | bffb3465 | Thomas Schöpping | |
688 | PCAL6524Driver moduleLldGpioExtender1 = { |
||
689 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
||
690 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
691 | }; |
||
692 | |||
693 | PCAL6524Driver moduleLldGpioExtender2 = { |
||
694 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
695 | /* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
||
696 | }; |
||
697 | |||
698 | AT42QT1050Driver moduleLldTouch = { |
||
699 | /* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
||
700 | /* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
||
701 | }; |
||
702 | |||
703 | 7de0cc90 | Thomas Schöpping | #endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
704 | 8be006e0 | Thomas Schöpping | |
705 | e545e620 | Thomas Schöpping | /** @} */
|
706 | |||
707 | /*===========================================================================*/
|
||
708 | /**
|
||
709 | * @name Unit tests (UT)
|
||
710 | * @{
|
||
711 | */
|
||
712 | /*===========================================================================*/
|
||
713 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
714 | #include <string.h> |
||
715 | |||
716 | 8be006e0 | Thomas Schöpping | /*
|
717 | * ADC
|
||
718 | */
|
||
719 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[]) |
720 | { |
||
721 | (void)argc;
|
||
722 | (void)argv;
|
||
723 | aosUtRun(stream, &moduleUtAdcVsys, NULL);
|
||
724 | return AOS_OK;
|
||
725 | } |
||
726 | static ut_adcdata_t _utAdcVsysData = {
|
||
727 | /* driver */ &MODULE_HAL_ADC_VSYS,
|
||
728 | /* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
|
||
729 | }; |
||
730 | aos_unittest_t moduleUtAdcVsys = { |
||
731 | /* name */ "ADC", |
||
732 | /* info */ "VSYS", |
||
733 | /* test function */ utAdcFunc,
|
||
734 | /* shell command */ {
|
||
735 | /* name */ "unittest:ADC", |
||
736 | /* callback */ _utShellCmdCb_Adc,
|
||
737 | /* next */ NULL, |
||
738 | }, |
||
739 | /* data */ &_utAdcVsysData,
|
||
740 | }; |
||
741 | |||
742 | 8be006e0 | Thomas Schöpping | /*
|
743 | ddf34c3d | Thomas Schöpping | * AT24C01B (EEPROM)
|
744 | 8be006e0 | Thomas Schöpping | */
|
745 | ddf34c3d | Thomas Schöpping | static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
746 | e545e620 | Thomas Schöpping | { |
747 | (void)argc;
|
||
748 | (void)argv;
|
||
749 | ddf34c3d | Thomas Schöpping | aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
750 | e545e620 | Thomas Schöpping | return AOS_OK;
|
751 | } |
||
752 | ddf34c3d | Thomas Schöpping | static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
753 | e545e620 | Thomas Schöpping | /* driver */ &moduleLldEeprom,
|
754 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
755 | }; |
||
756 | ddf34c3d | Thomas Schöpping | aos_unittest_t moduleUtAlldAt24c01b = { |
757 | /* name */ "AT24C01B", |
||
758 | e545e620 | Thomas Schöpping | /* info */ "1kbit EEPROM", |
759 | ddf34c3d | Thomas Schöpping | /* test function */ utAlldAt24c01bFunc,
|
760 | e545e620 | Thomas Schöpping | /* shell command */ {
|
761 | /* name */ "unittest:EEPROM", |
||
762 | ddf34c3d | Thomas Schöpping | /* callback */ _utShellCmdCb_AlldAt24c01b,
|
763 | e545e620 | Thomas Schöpping | /* next */ NULL, |
764 | }, |
||
765 | ddf34c3d | Thomas Schöpping | /* data */ &_utAlldAt24c01bData,
|
766 | e545e620 | Thomas Schöpping | }; |
767 | |||
768 | 8be006e0 | Thomas Schöpping | /*
|
769 | ddf34c3d | Thomas Schöpping | * bq24103a (battery charger)
|
770 | 8be006e0 | Thomas Schöpping | */
|
771 | e545e620 | Thomas Schöpping | static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
772 | { |
||
773 | // local variables
|
||
774 | bool print_help = false; |
||
775 | |||
776 | // evaluate argument
|
||
777 | if (argc == 2) { |
||
778 | if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
||
779 | moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront; |
||
780 | aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
|
||
781 | moduleUtAlldBq24103a.data = NULL;
|
||
782 | } |
||
783 | else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
||
784 | moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear; |
||
785 | aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
|
||
786 | moduleUtAlldBq24103a.data = NULL;
|
||
787 | } |
||
788 | else {
|
||
789 | print_help = true;
|
||
790 | } |
||
791 | } else {
|
||
792 | print_help = true;
|
||
793 | } |
||
794 | |||
795 | // print help or just return
|
||
796 | if (print_help) {
|
||
797 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
798 | chprintf(stream, "Options:\n");
|
||
799 | chprintf(stream, " --front, -f\n");
|
||
800 | chprintf(stream, " Test the front battery charger.\n");
|
||
801 | chprintf(stream, " --rear, -r\n");
|
||
802 | chprintf(stream, " Test the rear battery charger.\n");
|
||
803 | return AOS_INVALID_ARGUMENTS;
|
||
804 | } else {
|
||
805 | return AOS_OK;
|
||
806 | } |
||
807 | } |
||
808 | aos_unittest_t moduleUtAlldBq24103a = { |
||
809 | ddf34c3d | Thomas Schöpping | /* name */ "bq24103a", |
810 | e545e620 | Thomas Schöpping | /* info */ "battery charger", |
811 | ddf34c3d | Thomas Schöpping | /* test function */ utAlldBq241xxFunc,
|
812 | e545e620 | Thomas Schöpping | /* shell command */ {
|