amiro-os / modules / PowerManagement_1-1 / module.h @ 9461fadc
History | View | Annotate | Download (22.8 KB)
1 |
/*
|
---|---|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2018 Thomas Schöpping et al.
|
4 |
|
5 |
This program is free software: you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
7 |
the Free Software Foundation, either version 3 of the License, or
|
8 |
(at your option) any later version.
|
9 |
|
10 |
This program is distributed in the hope that it will be useful,
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
GNU General Public License for more details.
|
14 |
|
15 |
You should have received a copy of the GNU General Public License
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
*/
|
18 |
|
19 |
#ifndef _AMIROOS_MODULE_H_
|
20 |
#define _AMIROOS_MODULE_H_
|
21 |
|
22 |
/*===========================================================================*/
|
23 |
/**
|
24 |
* @name Module specific functions
|
25 |
* @{
|
26 |
*/
|
27 |
/*===========================================================================*/
|
28 |
|
29 |
/*
|
30 |
* @brief Makro to store data in the core coupled memory (ccm).
|
31 |
* Example:
|
32 |
* int compute_buffer[128] CCM_RAM;
|
33 |
*
|
34 |
* @note The ccm is not connected to any bus system.
|
35 |
*/
|
36 |
#define CCM_RAM __attribute__((section(".ram4"), aligned(4))) |
37 |
|
38 |
/*
|
39 |
* @brief Makro to store data in the ethernet memory (eth).
|
40 |
* Example:
|
41 |
* int dma_buffer[128] ETH_RAM;
|
42 |
*
|
43 |
* @note The eth is a dedicated memory block with its own DMA controller.
|
44 |
*/
|
45 |
#define ETH_RAM __attribute__((section(".ram2"), aligned(4))) |
46 |
|
47 |
/*
|
48 |
* @brief Makro to store data in the backup memory (bckp).
|
49 |
* Example:
|
50 |
* int backup_buffer[128] BCKP_RAM;
|
51 |
*
|
52 |
* @note The eth is a dedicated memory block with its own DMA controller.
|
53 |
*/
|
54 |
#define BCKP_RAM __attribute__((section(".ram5"), aligned(4))) |
55 |
|
56 |
/** @} */
|
57 |
|
58 |
/*===========================================================================*/
|
59 |
/**
|
60 |
* @name ChibiOS/HAL configuration
|
61 |
* @{
|
62 |
*/
|
63 |
/*===========================================================================*/
|
64 |
#include <hal.h> |
65 |
|
66 |
/**
|
67 |
* @brief ADC driver for reading the system voltage.
|
68 |
*/
|
69 |
#define MODULE_HAL_ADC_VSYS ADCD1
|
70 |
|
71 |
/**
|
72 |
* @brief Configuration for the ADC.
|
73 |
*/
|
74 |
extern ADCConversionGroup moduleHalAdcVsysConversionGroup;
|
75 |
|
76 |
/**
|
77 |
* @brief CAN driver to use.
|
78 |
*/
|
79 |
#define MODULE_HAL_CAN CAND1
|
80 |
|
81 |
/**
|
82 |
* @brief Configuration for the CAN driver.
|
83 |
*/
|
84 |
extern CANConfig moduleHalCanConfig;
|
85 |
|
86 |
/**
|
87 |
* @brief Interrupt driver to use.
|
88 |
*/
|
89 |
#define MODULE_HAL_EXT EXTD1
|
90 |
|
91 |
/**
|
92 |
* @brief Interrupt driver configuration.
|
93 |
*/
|
94 |
extern EXTConfig moduleHalExtConfig;
|
95 |
|
96 |
/**
|
97 |
* @brief I2C driver to access multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery).
|
98 |
*/
|
99 |
#define MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR I2CD1
|
100 |
|
101 |
/**
|
102 |
* @brief Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
|
103 |
*/
|
104 |
extern I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig;
|
105 |
|
106 |
/**
|
107 |
* @brief I2C driver to access multiplexer, proximity sensors 5 to 8, power monitors for VSYS4.2, VIO 5.0 and VDD, EEPROM, touch sensor, and fuel gauge (front battery).
|
108 |
*/
|
109 |
#define MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT I2CD2
|
110 |
|
111 |
/**
|
112 |
* @brief Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
|
113 |
*/
|
114 |
extern I2CConfig moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig;
|
115 |
|
116 |
/**
|
117 |
* @brief PWM driver for the buzzer.
|
118 |
*/
|
119 |
#define MODULE_HAL_PWM_BUZZER PWMD3
|
120 |
|
121 |
/**
|
122 |
* @brief Configuration of the PWM driver.
|
123 |
*/
|
124 |
extern PWMConfig moduleHalPwmBuzzerConfig;
|
125 |
|
126 |
/**
|
127 |
* @brief PWM channeö for the buzzer.
|
128 |
*/
|
129 |
#define MODULE_HAL_PWM_BUZZER_CHANNEL 1 |
130 |
|
131 |
/**
|
132 |
* @brief Serial driver of the programmer interface.
|
133 |
*/
|
134 |
#define MODULE_HAL_PROGIF SD1
|
135 |
|
136 |
/**
|
137 |
* @brief Configuration for the programmer serial interface driver.
|
138 |
*/
|
139 |
extern SerialConfig moduleHalProgIfConfig;
|
140 |
|
141 |
/**
|
142 |
* @brief Real-Time Clock driver.
|
143 |
*/
|
144 |
#define MODULE_HAL_RTC RTCD1
|
145 |
|
146 |
/** @} */
|
147 |
|
148 |
/*===========================================================================*/
|
149 |
/**
|
150 |
* @name GPIO definitions
|
151 |
* @{
|
152 |
*/
|
153 |
/*===========================================================================*/
|
154 |
#include <amiro-lld.h> |
155 |
|
156 |
/**
|
157 |
* @brief Interrupt channel for the IR_INT1 and CHARGE_STAT1A signals.
|
158 |
*/
|
159 |
#define MODULE_GPIO_EXTCHANNEL_IRINT1 ((expchannel_t)0) |
160 |
|
161 |
/**
|
162 |
* @brief Interrupt channel for the GAUGE_BATLOW1 signal.
|
163 |
*/
|
164 |
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW1 ((expchannel_t)1) |
165 |
|
166 |
/**
|
167 |
* @brief Interrupt channel for the GAUGE_BATGD1 signal.
|
168 |
*/
|
169 |
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATGD1 ((expchannel_t)2) |
170 |
|
171 |
/**
|
172 |
* @brief Interrupt channel for the SYS_UART_DN signal.
|
173 |
*/
|
174 |
#define MODULE_GPIO_EXTCHANNEL_SYSUARTDN ((expchannel_t)3) |
175 |
|
176 |
/**
|
177 |
* @brief Interrupt channel for the IR_INT2 and CHARGE_STAT2A signals.
|
178 |
*/
|
179 |
#define MODULE_GPIO_EXTCHANNEL_IRINT2 ((expchannel_t)4) |
180 |
|
181 |
/**
|
182 |
* @brief Interrupt channel for the TOUCH_INT signal.
|
183 |
*/
|
184 |
#define MODULE_GPIO_EXTCHANNEL_TOUCHINT ((expchannel_t)5) |
185 |
|
186 |
/**
|
187 |
* @brief Interrupt channel for the GAUGE_BATLOW2 signal.
|
188 |
*/
|
189 |
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW2 ((expchannel_t)6) |
190 |
|
191 |
/**
|
192 |
* @brief Interrupt channel for the GAUGE_BATGD2 signal.
|
193 |
*/
|
194 |
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATGD2 ((expchannel_t)7) |
195 |
|
196 |
/**
|
197 |
* @brief Interrupt channel for the PATH_DC signal.
|
198 |
*/
|
199 |
#define MODULE_GPIO_EXTCHANNEL_PATHDC ((expchannel_t)8) |
200 |
|
201 |
/**
|
202 |
* @brief Interrupt channel for the SYS_SPI_DIR signal.
|
203 |
*/
|
204 |
#define MODULE_GPIO_EXTCHANNEL_SYSSPIDIR ((expchannel_t)9) |
205 |
|
206 |
/**
|
207 |
* @brief Interrupt channel for the SYS_SYNC signal.
|
208 |
*/
|
209 |
#define MODULE_GPIO_EXTCHANNEL_SYSSYNC ((expchannel_t)12) |
210 |
|
211 |
/**
|
212 |
* @brief Interrupt channel for the SYS_PD signal.
|
213 |
*/
|
214 |
#define MODULE_GPIO_EXTCHANNEL_SYSPD ((expchannel_t)13) |
215 |
|
216 |
/**
|
217 |
* @brief Interrupt channel for the SYS_WARMRST signal.
|
218 |
*/
|
219 |
#define MODULE_GPIO_EXTCHANNEL_SYSWARMRST ((expchannel_t)14) |
220 |
|
221 |
/**
|
222 |
* @brief Interrupt channel for the SYS_UART_UP signal.
|
223 |
*/
|
224 |
#define MODULE_GPIO_EXTCHANNEL_SYSUARTUP ((expchannel_t)15) |
225 |
|
226 |
/**
|
227 |
* @brief SYS_REG_EN output signal GPIO.
|
228 |
*/
|
229 |
extern apalGpio_t moduleGpioSysRegEn;
|
230 |
|
231 |
/**
|
232 |
* @brief IR_INT1 input signal GPIO.
|
233 |
*/
|
234 |
extern apalGpio_t moduleGpioIrInt1;
|
235 |
|
236 |
/**
|
237 |
* @brief POWER_EN output signal GPIO.
|
238 |
*/
|
239 |
extern apalGpio_t moduleGpioPowerEn;
|
240 |
|
241 |
/**
|
242 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
243 |
*/
|
244 |
extern apalGpio_t moduleGpioSysUartDn;
|
245 |
|
246 |
/**
|
247 |
* @brief CHARGE_STAT2A input signal GPIO.
|
248 |
*/
|
249 |
extern apalGpio_t moduleGpioChargeStat2A;
|
250 |
|
251 |
/**
|
252 |
* @brief GAUGE_BATLOW2 input signal GPIO.
|
253 |
*/
|
254 |
extern apalGpio_t moduleGpioGaugeBatLow2;
|
255 |
|
256 |
/**
|
257 |
* @brief GAUGE_BATGD2 input signal GPIO.
|
258 |
*/
|
259 |
extern apalGpio_t moduleGpioGaugeBatGd2;
|
260 |
|
261 |
/**
|
262 |
* @brief LED output signal GPIO.
|
263 |
*/
|
264 |
extern apalGpio_t moduleGpioLed;
|
265 |
|
266 |
/**
|
267 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
268 |
*/
|
269 |
extern apalGpio_t moduleGpioSysUartUp;
|
270 |
|
271 |
/**
|
272 |
* @brief CHARGE_STAT1A input signal GPIO.
|
273 |
*/
|
274 |
extern apalGpio_t moduleGpioChargeStat1A;
|
275 |
|
276 |
/**
|
277 |
* @brief GAUGE_BATLOW1 input signal GPIO.
|
278 |
*/
|
279 |
extern apalGpio_t moduleGpioGaugeBatLow1;
|
280 |
|
281 |
/**
|
282 |
* @brief GAUGE_BATGD1 input signal GPIO.
|
283 |
*/
|
284 |
extern apalGpio_t moduleGpioGaugeBatGd1;
|
285 |
|
286 |
/**
|
287 |
* @brief CHARG_EN1 output signal GPIO.
|
288 |
*/
|
289 |
extern apalGpio_t moduleGpioChargeEn1;
|
290 |
|
291 |
/**
|
292 |
* @brief IR_INT2 input signal GPIO.
|
293 |
*/
|
294 |
extern apalGpio_t moduleGpioIrInt2;
|
295 |
|
296 |
/**
|
297 |
* @brief TOUCH_INT input signal GPIO.
|
298 |
*/
|
299 |
extern apalGpio_t moduleGpioTouchInt;
|
300 |
|
301 |
/**
|
302 |
* @brief SYS_DONE input signal GPIO.
|
303 |
*/
|
304 |
extern apalGpio_t moduleGpioSysDone;
|
305 |
|
306 |
/**
|
307 |
* @brief SYS_PROG output signal GPIO.
|
308 |
*/
|
309 |
extern apalGpio_t moduleGpioSysProg;
|
310 |
|
311 |
/**
|
312 |
* @brief PATH_DC input signal GPIO.
|
313 |
*/
|
314 |
extern apalGpio_t moduleGpioPathDc;
|
315 |
|
316 |
/**
|
317 |
* @brief SYS_SPI_DIR bidirectional signal GPIO.
|
318 |
*/
|
319 |
extern apalGpio_t moduleGpioSysSpiDir;
|
320 |
|
321 |
/**
|
322 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
323 |
*/
|
324 |
extern apalGpio_t moduleGpioSysSync;
|
325 |
|
326 |
/**
|
327 |
* @brief SYS_PD bidirectional signal GPIO.
|
328 |
*/
|
329 |
extern apalGpio_t moduleGpioSysPd;
|
330 |
|
331 |
/**
|
332 |
* @brief SYS_WARMRST bidirectional signal GPIO.
|
333 |
*/
|
334 |
extern apalGpio_t moduleGpioSysWarmrst;
|
335 |
|
336 |
/**
|
337 |
* @brief BT_RST output signal GPIO.
|
338 |
*/
|
339 |
extern apalGpio_t moduleGpioBtRst;
|
340 |
|
341 |
/**
|
342 |
* @brief CHARGE_EN2 output signal GPIO.
|
343 |
*/
|
344 |
extern apalGpio_t moduleGpioChargeEn2;
|
345 |
|
346 |
/** @} */
|
347 |
|
348 |
/*===========================================================================*/
|
349 |
/**
|
350 |
* @name AMiRo-OS core configurations
|
351 |
* @{
|
352 |
*/
|
353 |
/*===========================================================================*/
|
354 |
|
355 |
/**
|
356 |
* @brief Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
|
357 |
*/
|
358 |
#define MODULE_OS_IOEVENTFLAGS_IRINT1 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_IRINT1) |
359 |
|
360 |
/**
|
361 |
* @brief Event flag to be set on a GAUGE_BATLOW1 interrupt.
|
362 |
*/
|
363 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW1) |
364 |
|
365 |
/**
|
366 |
* @brief Event flag to be set on a GAUGE_BATGD1 interrupt.
|
367 |
*/
|
368 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATGD1) |
369 |
|
370 |
/**
|
371 |
* @brief Event flag to be set on a SYS_UART_DN interrupt.
|
372 |
*/
|
373 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSUARTDN) |
374 |
|
375 |
/**
|
376 |
* @brief Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
|
377 |
*/
|
378 |
#define MODULE_OS_IOEVENTFLAGS_IRINT2 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_IRINT2) |
379 |
|
380 |
/**
|
381 |
* @brief Event flag to be set on a TOUCH_INT interrupt.
|
382 |
*/
|
383 |
#define MODULE_OS_IOEVENTFLAGS_TOUCHINT ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_TOUCHINT) |
384 |
|
385 |
/**
|
386 |
* @brief Event flag to be set on a GAUGE_BATLOW2 interrupt.
|
387 |
*/
|
388 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW2) |
389 |
|
390 |
/**
|
391 |
* @brief Event flag to be set on a GAUGE_BATGD2 interrupt.
|
392 |
*/
|
393 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2 ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATGD2) |
394 |
|
395 |
/**
|
396 |
* @brief Event flag to be set on a PATH_DC interrupt.
|
397 |
*/
|
398 |
#define MODULE_OS_IOEVENTFLAGS_PATHDC ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_PATHDC) |
399 |
|
400 |
/**
|
401 |
* @brief Event flag to be set on a SYS_SPI_DIR interrupt.
|
402 |
*/
|
403 |
#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSSPIDIR) |
404 |
|
405 |
/**
|
406 |
* @brief Event flag to be set on a SYS_SYNC interrupt.
|
407 |
*/
|
408 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSSYNC) |
409 |
|
410 |
/**
|
411 |
* @brief Event flag to be set on a SYS_PD interrupt.
|
412 |
*/
|
413 |
#define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSPD) |
414 |
|
415 |
/**
|
416 |
* @brief Event flag to be set on a SYS_WARMRST interrupt.
|
417 |
*/
|
418 |
#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSWARMRST) |
419 |
|
420 |
/**
|
421 |
* @brief Event flag to be set on a SYS_UART_UP interrupt.
|
422 |
*/
|
423 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSUARTUP) |
424 |
|
425 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
426 |
/**
|
427 |
* @brief Shell prompt text.
|
428 |
*/
|
429 |
extern const char* moduleShellPrompt; |
430 |
#endif
|
431 |
|
432 |
/**
|
433 |
* @brief Unit test initialization hook.
|
434 |
*/
|
435 |
#define MODULE_INIT_TESTS() { \
|
436 |
/* add unit-test shell commands */ \
|
437 |
aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd); \ |
438 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \ |
439 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd); \ |
440 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd); \ |
441 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \ |
442 |
aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \ |
443 |
aosShellAddCommand(&aos.shell, &moduleUtAlldMpr121.shellcmd); \ |
444 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \ |
445 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd); \ |
446 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \ |
447 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \ |
448 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113Ina219.shellcmd); \ |
449 |
aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \ |
450 |
} |
451 |
|
452 |
/**
|
453 |
* @brief Periphery communication interfaces initialization hook.
|
454 |
*/
|
455 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
456 |
/* serial driver */ \
|
457 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
458 |
/* I2C */ \
|
459 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
460 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
461 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
462 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
463 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
464 |
i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \ |
465 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
466 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
467 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
468 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
469 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
470 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
471 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
472 |
i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig); \ |
473 |
/* ADC */ \
|
474 |
adcStart(&MODULE_HAL_ADC_VSYS, NULL); \
|
475 |
/* PWM */ \
|
476 |
pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
477 |
moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock; \ |
478 |
pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
479 |
moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \ |
480 |
pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
481 |
} |
482 |
|
483 |
/**
|
484 |
* @brief Periphery communication interface deinitialization hook.
|
485 |
*/
|
486 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
487 |
/* PWM */ \
|
488 |
pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
489 |
/* ADC */ \
|
490 |
adcStop(&MODULE_HAL_ADC_VSYS); \ |
491 |
/* I2C */ \
|
492 |
i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR); \ |
493 |
i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT); \ |
494 |
/* don't stop the serial driver so messages can still be printed */ \
|
495 |
} |
496 |
|
497 |
/** @} */
|
498 |
|
499 |
/*===========================================================================*/
|
500 |
/**
|
501 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
502 |
* @{
|
503 |
*/
|
504 |
/*===========================================================================*/
|
505 |
|
506 |
/**
|
507 |
* @brief PD signal GPIO.
|
508 |
*/
|
509 |
extern apalControlGpio_t moduleSsspGpioPd;
|
510 |
|
511 |
/**
|
512 |
* @brief SYNC signal GPIO.
|
513 |
*/
|
514 |
extern apalControlGpio_t moduleSsspGpioSync;
|
515 |
|
516 |
/**
|
517 |
* @brief DN signal GPIO.
|
518 |
*/
|
519 |
extern apalControlGpio_t moduleSsspGpioDn;
|
520 |
|
521 |
/**
|
522 |
* @brief UP signal GPIO.
|
523 |
*/
|
524 |
extern apalControlGpio_t moduleSsspGpioUp;
|
525 |
|
526 |
/**
|
527 |
* @brief Event flags for PD signal events.
|
528 |
*/
|
529 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
530 |
|
531 |
/**
|
532 |
* @brief Event flags for SYNC signal events.
|
533 |
*/
|
534 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
535 |
|
536 |
/**
|
537 |
* @brief Event flags for UP signal events.
|
538 |
*/
|
539 |
#define MODULE_SSSP_EVENTFLAGS_UP MODULE_OS_IOEVENTFLAGS_SYSUARTUP
|
540 |
|
541 |
/**
|
542 |
* @brief Event flags for DN signal events.
|
543 |
*/
|
544 |
#define MODULE_SSSP_EVENTFLAGS_DN MODULE_OS_IOEVENTFLAGS_SYSUARTDN
|
545 |
|
546 |
/** @} */
|
547 |
|
548 |
/*===========================================================================*/
|
549 |
/**
|
550 |
* @name Low-level drivers
|
551 |
* @{
|
552 |
*/
|
553 |
/*===========================================================================*/
|
554 |
#include <alld_at24c01bn-sh-b.h> |
555 |
#include <alld_bq24103a.h> |
556 |
#include <alld_bq27500.h> |
557 |
#include <alld_ina219.h> |
558 |
#include <alld_led.h> |
559 |
#include <alld_mpr121.h> |
560 |
#include <alld_pca9544a.h> |
561 |
#include <alld_pklcs1212e4001.h> |
562 |
#include <alld_tps62113.h> |
563 |
#include <alld_vcnl4020.h> |
564 |
|
565 |
/**
|
566 |
* @brief EEPROM driver.
|
567 |
*/
|
568 |
extern AT24C01BNDriver moduleLldEeprom;
|
569 |
|
570 |
/**
|
571 |
* @brief Battery charger (front battery) driver.
|
572 |
*/
|
573 |
extern BQ24103ADriver moduleLldBatteryChargerFront;
|
574 |
|
575 |
/**
|
576 |
* @brief Battery charger (rear battery) driver.
|
577 |
*/
|
578 |
extern BQ24103ADriver moduleLldBatteryChargerRear;
|
579 |
|
580 |
/**
|
581 |
* @brief Fuel gauge (front battery) driver.
|
582 |
*/
|
583 |
extern BQ27500Driver moduleLldFuelGaugeFront;
|
584 |
|
585 |
/**
|
586 |
* @brief Fuel gauge (rear battery) driver.
|
587 |
*/
|
588 |
extern BQ27500Driver moduleLldFuelGaugeRear;
|
589 |
|
590 |
/**
|
591 |
* @brief Power monitor (VDD) driver.
|
592 |
*/
|
593 |
extern INA219Driver moduleLldPowerMonitorVdd;
|
594 |
|
595 |
/**
|
596 |
* @brief Power monitor (VIO 1.8) driver.
|
597 |
*/
|
598 |
extern INA219Driver moduleLldPowerMonitorVio18;
|
599 |
|
600 |
/**
|
601 |
* @brief Power monitor (VIO 3.3) driver.
|
602 |
*/
|
603 |
extern INA219Driver moduleLldPowerMonitorVio33;
|
604 |
|
605 |
/**
|
606 |
* @brief Power monitor (VSYS 4.2) driver.
|
607 |
*/
|
608 |
extern INA219Driver moduleLldPowerMonitorVsys42;
|
609 |
|
610 |
/**
|
611 |
* @brief Power monitor (VIO 5.0) driver.
|
612 |
*/
|
613 |
extern INA219Driver moduleLldPowerMonitorVio50;
|
614 |
|
615 |
/**
|
616 |
* @brief Status LED driver.
|
617 |
*/
|
618 |
extern LEDDriver moduleLldStatusLed;
|
619 |
|
620 |
/**
|
621 |
* @brief Touch sensor driver.
|
622 |
*/
|
623 |
extern MPR121Driver moduleLldTouch;
|
624 |
|
625 |
/**
|
626 |
* @brief I2C multiplexer (I2C 1) driver.
|
627 |
*/
|
628 |
extern PCA9544ADriver moduleLldI2cMultiplexer1;
|
629 |
|
630 |
/**
|
631 |
* @brief I2C multiplexer (I2C 2) driver.
|
632 |
*/
|
633 |
extern PCA9544ADriver moduleLldI2cMultiplexer2;
|
634 |
|
635 |
/**
|
636 |
* @brief Step down converter driver.
|
637 |
* @note Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
|
638 |
*/
|
639 |
extern TPS62113Driver moduleLldStepDownConverter;
|
640 |
|
641 |
/**
|
642 |
* @brief Proximity sensor (I2C 1) driver.
|
643 |
*/
|
644 |
extern VCNL4020Driver moduleLldProximity1;
|
645 |
|
646 |
/**
|
647 |
* @brief Proximity sensor (I2C 2) driver.
|
648 |
*/
|
649 |
extern VCNL4020Driver moduleLldProximity2;
|
650 |
|
651 |
/** @} */
|
652 |
|
653 |
/*===========================================================================*/
|
654 |
/**
|
655 |
* @name Unit tests (UT)
|
656 |
* @{
|
657 |
*/
|
658 |
/*===========================================================================*/
|
659 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
660 |
#include <ut_lld_adc.h> |
661 |
#include <ut_alld_at24c01bn-sh-b.h> |
662 |
#include <ut_alld_bq24103a.h> |
663 |
#include <ut_alld_bq27500.h> |
664 |
#include <ut_alld_bq27500_bq24103a.h> |
665 |
#include <ut_alld_ina219.h> |
666 |
#include <ut_alld_led.h> |
667 |
#include <ut_alld_mpr121.h> |
668 |
#include <ut_alld_pca9544a.h> |
669 |
#include <ut_alld_pklcs1212e4001.h> |
670 |
#include <ut_alld_tps62113.h> |
671 |
#include <ut_alld_tps62113_ina219.h> |
672 |
#include <ut_alld_vcnl4020.h> |
673 |
|
674 |
/**
|
675 |
* @brief ADC unit test object.
|
676 |
*/
|
677 |
extern aos_unittest_t moduleUtAdcVsys;
|
678 |
|
679 |
/**
|
680 |
* @brief AT24C01BN-SH-B (EEPROM) unit test object.
|
681 |
*/
|
682 |
extern aos_unittest_t moduleUtAlldAt24c01bn;
|
683 |
|
684 |
/**
|
685 |
* @brief BQ24103A (battery charger) unit test object.
|
686 |
*/
|
687 |
extern aos_unittest_t moduleUtAlldBq24103a;
|
688 |
|
689 |
/**
|
690 |
* @brief BQ27500 (fuel gauge) unit test object.
|
691 |
*/
|
692 |
extern aos_unittest_t moduleUtAlldBq27500;
|
693 |
|
694 |
/**
|
695 |
* @brief BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
|
696 |
*/
|
697 |
extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
|
698 |
|
699 |
/**
|
700 |
* @brief INA219 (power monitor) unit test object.
|
701 |
*/
|
702 |
extern aos_unittest_t moduleUtAlldIna219;
|
703 |
|
704 |
/**
|
705 |
* @brief Status LED unit test object.
|
706 |
*/
|
707 |
extern aos_unittest_t moduleUtAlldLed;
|
708 |
|
709 |
/**
|
710 |
* @brief MPR121 (touch sensor) unit test object.
|
711 |
*/
|
712 |
extern aos_unittest_t moduleUtAlldMpr121;
|
713 |
|
714 |
/**
|
715 |
* @brief PCA9544A (I2C multiplexer) unit test object.
|
716 |
*/
|
717 |
extern aos_unittest_t moduleUtAlldPca9544a;
|
718 |
|
719 |
/**
|
720 |
* @brief PKLCS1212E4001 (buzzer) unit test object.
|
721 |
*/
|
722 |
extern aos_unittest_t moduleUtAlldPklcs1212e4001;
|
723 |
|
724 |
/**
|
725 |
* @brief TPS62113 (step-down converter) unit test object.
|
726 |
*/
|
727 |
extern aos_unittest_t moduleUtAlldTps62113;
|
728 |
|
729 |
/**
|
730 |
* @brief TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
|
731 |
*/
|
732 |
extern aos_unittest_t moduleUtAlldTps62113Ina219;
|
733 |
|
734 |
/**
|
735 |
* @brief VCNL4020 (proximity sensor) unit test object.
|
736 |
*/
|
737 |
extern aos_unittest_t moduleUtAlldVcnl4020;
|
738 |
|
739 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
740 |
|
741 |
/** @} */
|
742 |
|
743 |
#endif /* _AMIROOS_MODULE_H_ */ |