amiro-os / modules / PowerManagement_1-1 / module.h @ 1e5f7648
History | View | Annotate | Download (24.4 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 I2C driver to access multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery).
|
88 |
*/
|
89 |
#define MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR I2CD1
|
90 |
|
91 |
/**
|
92 |
* @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.
|
93 |
*/
|
94 |
extern I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig;
|
95 |
|
96 |
/**
|
97 |
* @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).
|
98 |
*/
|
99 |
#define MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT I2CD2
|
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 moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig;
|
105 |
|
106 |
/**
|
107 |
* @brief PWM driver for the buzzer.
|
108 |
*/
|
109 |
#define MODULE_HAL_PWM_BUZZER PWMD3
|
110 |
|
111 |
/**
|
112 |
* @brief Configuration of the PWM driver.
|
113 |
*/
|
114 |
extern PWMConfig moduleHalPwmBuzzerConfig;
|
115 |
|
116 |
/**
|
117 |
* @brief PWM channeö for the buzzer.
|
118 |
*/
|
119 |
#define MODULE_HAL_PWM_BUZZER_CHANNEL 1 |
120 |
|
121 |
/**
|
122 |
* @brief Serial driver of the programmer interface.
|
123 |
*/
|
124 |
#define MODULE_HAL_PROGIF SD1
|
125 |
|
126 |
/**
|
127 |
* @brief Configuration for the programmer serial interface driver.
|
128 |
*/
|
129 |
extern SerialConfig moduleHalProgIfConfig;
|
130 |
|
131 |
/**
|
132 |
* @brief Real-Time Clock driver.
|
133 |
*/
|
134 |
#define MODULE_HAL_RTC RTCD1
|
135 |
|
136 |
/** @} */
|
137 |
|
138 |
/*===========================================================================*/
|
139 |
/**
|
140 |
* @name GPIO definitions
|
141 |
* @{
|
142 |
*/
|
143 |
/*===========================================================================*/
|
144 |
#include <amiro-lld.h> |
145 |
|
146 |
/**
|
147 |
* @brief SYS_REG_EN output signal GPIO.
|
148 |
*/
|
149 |
extern apalControlGpio_t moduleGpioSysRegEn;
|
150 |
|
151 |
/**
|
152 |
* @brief IR_INT1 input signal GPIO.
|
153 |
*/
|
154 |
extern apalControlGpio_t moduleGpioIrInt1;
|
155 |
|
156 |
/**
|
157 |
* @brief POWER_EN output signal GPIO.
|
158 |
*/
|
159 |
extern apalControlGpio_t moduleGpioPowerEn;
|
160 |
|
161 |
/**
|
162 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
163 |
*/
|
164 |
extern apalControlGpio_t moduleGpioSysUartDn;
|
165 |
|
166 |
/**
|
167 |
* @brief CHARGE_STAT2A input signal GPIO.
|
168 |
*/
|
169 |
extern apalControlGpio_t moduleGpioChargeStat2A;
|
170 |
|
171 |
/**
|
172 |
* @brief GAUGE_BATLOW2 input signal GPIO.
|
173 |
*/
|
174 |
extern apalControlGpio_t moduleGpioGaugeBatLow2;
|
175 |
|
176 |
/**
|
177 |
* @brief GAUGE_BATGD2 input signal GPIO.
|
178 |
*/
|
179 |
extern apalControlGpio_t moduleGpioGaugeBatGd2;
|
180 |
|
181 |
/**
|
182 |
* @brief LED output signal GPIO.
|
183 |
*/
|
184 |
extern apalControlGpio_t moduleGpioLed;
|
185 |
|
186 |
/**
|
187 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
188 |
*/
|
189 |
extern apalControlGpio_t moduleGpioSysUartUp;
|
190 |
|
191 |
/**
|
192 |
* @brief CHARGE_STAT1A input signal GPIO.
|
193 |
*/
|
194 |
extern apalControlGpio_t moduleGpioChargeStat1A;
|
195 |
|
196 |
/**
|
197 |
* @brief GAUGE_BATLOW1 input signal GPIO.
|
198 |
*/
|
199 |
extern apalControlGpio_t moduleGpioGaugeBatLow1;
|
200 |
|
201 |
/**
|
202 |
* @brief GAUGE_BATGD1 input signal GPIO.
|
203 |
*/
|
204 |
extern apalControlGpio_t moduleGpioGaugeBatGd1;
|
205 |
|
206 |
/**
|
207 |
* @brief CHARG_EN1 output signal GPIO.
|
208 |
*/
|
209 |
extern apalControlGpio_t moduleGpioChargeEn1;
|
210 |
|
211 |
/**
|
212 |
* @brief IR_INT2 input signal GPIO.
|
213 |
*/
|
214 |
extern apalControlGpio_t moduleGpioIrInt2;
|
215 |
|
216 |
/**
|
217 |
* @brief TOUCH_INT input signal GPIO.
|
218 |
*/
|
219 |
extern apalControlGpio_t moduleGpioTouchInt;
|
220 |
|
221 |
/**
|
222 |
* @brief SYS_DONE input signal GPIO.
|
223 |
*/
|
224 |
extern apalControlGpio_t moduleGpioSysDone;
|
225 |
|
226 |
/**
|
227 |
* @brief SYS_PROG output signal GPIO.
|
228 |
*/
|
229 |
extern apalControlGpio_t moduleGpioSysProg;
|
230 |
|
231 |
/**
|
232 |
* @brief PATH_DC input signal GPIO.
|
233 |
*/
|
234 |
extern apalControlGpio_t moduleGpioPathDc;
|
235 |
|
236 |
/**
|
237 |
* @brief SYS_SPI_DIR bidirectional signal GPIO.
|
238 |
*/
|
239 |
extern apalControlGpio_t moduleGpioSysSpiDir;
|
240 |
|
241 |
/**
|
242 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
243 |
*/
|
244 |
extern apalControlGpio_t moduleGpioSysSync;
|
245 |
|
246 |
/**
|
247 |
* @brief SYS_PD bidirectional signal GPIO.
|
248 |
*/
|
249 |
extern apalControlGpio_t moduleGpioSysPd;
|
250 |
|
251 |
/**
|
252 |
* @brief SYS_WARMRST bidirectional signal GPIO.
|
253 |
*/
|
254 |
extern apalControlGpio_t moduleGpioSysWarmrst;
|
255 |
|
256 |
/**
|
257 |
* @brief BT_RST output signal GPIO.
|
258 |
*/
|
259 |
extern apalControlGpio_t moduleGpioBtRst;
|
260 |
|
261 |
/**
|
262 |
* @brief CHARGE_EN2 output signal GPIO.
|
263 |
*/
|
264 |
extern apalControlGpio_t moduleGpioChargeEn2;
|
265 |
|
266 |
/** @} */
|
267 |
|
268 |
/*===========================================================================*/
|
269 |
/**
|
270 |
* @name AMiRo-OS core configurations
|
271 |
* @{
|
272 |
*/
|
273 |
/*===========================================================================*/
|
274 |
|
275 |
/**
|
276 |
* @brief Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
|
277 |
*/
|
278 |
#define MODULE_OS_IOEVENTFLAGS_IRINT1 ((eventflags_t)1 << GPIOB_IR_INT1_N) |
279 |
|
280 |
/**
|
281 |
* @brief Event flag to be set on a GAUGE_BATLOW1 interrupt.
|
282 |
*/
|
283 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1 ((eventflags_t)1 << GPIOC_GAUGE_BATLOW1) |
284 |
|
285 |
/**
|
286 |
* @brief Event flag to be set on a GAUGE_BATGD1 interrupt.
|
287 |
*/
|
288 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1 ((eventflags_t)1 << GPIOC_GAUGE_BATGD1_N) |
289 |
|
290 |
/**
|
291 |
* @brief Event flag to be set on a SYS_UART_DN interrupt.
|
292 |
*/
|
293 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN ((eventflags_t)1 << GPIOB_SYS_UART_DN) |
294 |
|
295 |
/**
|
296 |
* @brief Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
|
297 |
*/
|
298 |
#define MODULE_OS_IOEVENTFLAGS_IRINT2 ((eventflags_t)1 << GPIOC_IR_INT2_N) |
299 |
|
300 |
/**
|
301 |
* @brief Event flag to be set on a TOUCH_INT interrupt.
|
302 |
*/
|
303 |
#define MODULE_OS_IOEVENTFLAGS_TOUCHINT ((eventflags_t)1 << GPIOC_TOUCH_INT_N) |
304 |
|
305 |
/**
|
306 |
* @brief Event flag to be set on a GAUGE_BATLOW2 interrupt.
|
307 |
*/
|
308 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2 ((eventflags_t)1 << GPIOB_GAUGE_BATLOW2) |
309 |
|
310 |
/**
|
311 |
* @brief Event flag to be set on a GAUGE_BATGD2 interrupt.
|
312 |
*/
|
313 |
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2 ((eventflags_t)1 << GPIOB_GAUGE_BATGD2_N) |
314 |
|
315 |
/**
|
316 |
* @brief Event flag to be set on a PATH_DC interrupt.
|
317 |
*/
|
318 |
#define MODULE_OS_IOEVENTFLAGS_PATHDC ((eventflags_t)1 << GPIOC_PATH_DC) |
319 |
|
320 |
/**
|
321 |
* @brief Event flag to be set on a SYS_SPI_DIR interrupt.
|
322 |
*/
|
323 |
#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR ((eventflags_t)1 << GPIOC_SYS_SPI_DIR) |
324 |
|
325 |
/**
|
326 |
* @brief Event flag to be set on a SYS_SYNC interrupt.
|
327 |
*/
|
328 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)1 << GPIOC_SYS_INT_N) |
329 |
|
330 |
/**
|
331 |
* @brief Event flag to be set on a SYS_PD interrupt.
|
332 |
*/
|
333 |
#define MODULE_OS_IOEVENTFLAGS_SYSPD ((eventflags_t)1 << GPIOC_SYS_PD_N) |
334 |
|
335 |
/**
|
336 |
* @brief Event flag to be set on a SYS_WARMRST interrupt.
|
337 |
*/
|
338 |
#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST ((eventflags_t)1 << GPIOC_SYS_WARMRST_N) |
339 |
|
340 |
/**
|
341 |
* @brief Event flag to be set on a SYS_UART_UP interrupt.
|
342 |
*/
|
343 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << GPIOB_SYS_UART_UP) |
344 |
|
345 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
346 |
/**
|
347 |
* @brief Shell prompt text.
|
348 |
*/
|
349 |
extern const char* moduleShellPrompt; |
350 |
#endif
|
351 |
|
352 |
/**
|
353 |
* @brief Interrupt initialization macro.
|
354 |
* @note SSSP related interrupt signals are already initialized in 'aos_system.c'.
|
355 |
*/
|
356 |
#define MODULE_INIT_INTERRUPTS() { \
|
357 |
/* IR_INT1 */ \
|
358 |
palSetPadCallback(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \ |
359 |
palEnablePadEvent(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge)); \ |
360 |
/* GAUGE_BATLOW2 */ \
|
361 |
palSetPadCallback(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, _intCallback, &moduleGpioGaugeBatLow2.gpio->pad); \ |
362 |
palEnablePadEvent(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow2.meta.edge)); \ |
363 |
/* GAUGE_BATGD2 */ \
|
364 |
palSetPadCallback(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, _intCallback, &moduleGpioGaugeBatGd2.gpio->pad); \ |
365 |
palEnablePadEvent(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd2.meta.edge)); \ |
366 |
/* GAUGE_BATLOW1 */ \
|
367 |
palSetPadCallback(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, _intCallback, &moduleGpioGaugeBatLow1.gpio->pad); \ |
368 |
palEnablePadEvent(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow1.meta.edge)); \ |
369 |
/* GAUGE_BATGD1 */ \
|
370 |
palSetPadCallback(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, _intCallback, &moduleGpioGaugeBatGd1.gpio->pad); \ |
371 |
palEnablePadEvent(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd1.meta.edge)); \ |
372 |
/* IR_INT1 */ \
|
373 |
palSetPadCallback(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \ |
374 |
palEnablePadEvent(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge)); \ |
375 |
/* TOUCH_INT */ \
|
376 |
palSetPadCallback(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, _intCallback, &moduleGpioTouchInt.gpio->pad); \ |
377 |
palEnablePadEvent(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, APAL2CH_EDGE(moduleGpioTouchInt.meta.edge)); \ |
378 |
/* PATH_DC */ \
|
379 |
palSetPadCallback(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, _intCallback, &moduleGpioPathDc.gpio->pad); \ |
380 |
palEnablePadEvent(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, APAL2CH_EDGE(moduleGpioPathDc.meta.edge)); \ |
381 |
/* SYS_SPI_DIR */ \
|
382 |
palSetPadCallback(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, _intCallback, &moduleGpioSysSpiDir.gpio->pad); \ |
383 |
palEnablePadEvent(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, APAL2CH_EDGE(moduleGpioSysSpiDir.meta.edge)); \ |
384 |
/* SYS_WARMRST */ \
|
385 |
palSetPadCallback(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, _intCallback, &moduleGpioSysWarmrst.gpio->pad); \ |
386 |
palEnablePadEvent(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge)); \ |
387 |
} |
388 |
|
389 |
/**
|
390 |
* @brief Unit test initialization hook.
|
391 |
*/
|
392 |
#define MODULE_INIT_TESTS() { \
|
393 |
/* add unit-test shell commands */ \
|
394 |
aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd); \ |
395 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \ |
396 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd); \ |
397 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd); \ |
398 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \ |
399 |
aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \ |
400 |
aosShellAddCommand(&aos.shell, &moduleUtAlldMpr121.shellcmd); \ |
401 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \ |
402 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd); \ |
403 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \ |
404 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \ |
405 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113Ina219.shellcmd); \ |
406 |
aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \ |
407 |
} |
408 |
|
409 |
/**
|
410 |
* @brief Periphery communication interfaces initialization hook.
|
411 |
*/
|
412 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
413 |
/* serial driver */ \
|
414 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
415 |
/* I2C */ \
|
416 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
417 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
418 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
419 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed; \ |
420 |
moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
421 |
i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \ |
422 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
423 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
424 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
425 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
426 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
427 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \ |
428 |
moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2; \
|
429 |
i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig); \ |
430 |
/* ADC */ \
|
431 |
adcStart(&MODULE_HAL_ADC_VSYS, NULL); \
|
432 |
/* PWM */ \
|
433 |
pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
434 |
moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock; \ |
435 |
pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
436 |
moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \ |
437 |
pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig); \ |
438 |
} |
439 |
|
440 |
/**
|
441 |
* @brief Periphery communication interface deinitialization hook.
|
442 |
*/
|
443 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \
|
444 |
/* PWM */ \
|
445 |
pwmStop(&MODULE_HAL_PWM_BUZZER); \ |
446 |
/* ADC */ \
|
447 |
adcStop(&MODULE_HAL_ADC_VSYS); \ |
448 |
/* I2C */ \
|
449 |
i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR); \ |
450 |
i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT); \ |
451 |
/* don't stop the serial driver so messages can still be printed */ \
|
452 |
} |
453 |
|
454 |
/** @} */
|
455 |
|
456 |
/*===========================================================================*/
|
457 |
/**
|
458 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
459 |
* @{
|
460 |
*/
|
461 |
/*===========================================================================*/
|
462 |
|
463 |
/**
|
464 |
* @brief PD signal GPIO.
|
465 |
*/
|
466 |
#define moduleSsspGpioPd moduleGpioSysPd
|
467 |
|
468 |
/**
|
469 |
* @brief SYNC signal GPIO.
|
470 |
*/
|
471 |
#define moduleSsspGpioSync moduleGpioSysSync
|
472 |
|
473 |
/**
|
474 |
* @brief DN signal GPIO.
|
475 |
*/
|
476 |
#define moduleSsspGpioDn moduleGpioSysUartDn
|
477 |
|
478 |
/**
|
479 |
* @brief UP signal GPIO.
|
480 |
*/
|
481 |
#define moduleSsspGpioUp moduleGpioSysUartUp
|
482 |
|
483 |
/**
|
484 |
* @brief Event flags for PD signal events.
|
485 |
*/
|
486 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
487 |
|
488 |
/**
|
489 |
* @brief Event flags for SYNC signal events.
|
490 |
*/
|
491 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
492 |
|
493 |
/**
|
494 |
* @brief Event flags for UP signal events.
|
495 |
*/
|
496 |
#define MODULE_SSSP_EVENTFLAGS_UP MODULE_OS_IOEVENTFLAGS_SYSUARTUP
|
497 |
|
498 |
/**
|
499 |
* @brief Event flags for DN signal events.
|
500 |
*/
|
501 |
#define MODULE_SSSP_EVENTFLAGS_DN MODULE_OS_IOEVENTFLAGS_SYSUARTDN
|
502 |
|
503 |
/** @} */
|
504 |
|
505 |
/*===========================================================================*/
|
506 |
/**
|
507 |
* @name Low-level drivers
|
508 |
* @{
|
509 |
*/
|
510 |
/*===========================================================================*/
|
511 |
#include <alld_at24c01bn-sh-b.h> |
512 |
#include <alld_bq24103a.h> |
513 |
#include <alld_bq27500.h> |
514 |
#include <alld_ina219.h> |
515 |
#include <alld_led.h> |
516 |
#include <alld_mpr121.h> |
517 |
#include <alld_pca9544a.h> |
518 |
#include <alld_pklcs1212e4001.h> |
519 |
#include <alld_tps62113.h> |
520 |
#include <alld_vcnl4020.h> |
521 |
|
522 |
/**
|
523 |
* @brief EEPROM driver.
|
524 |
*/
|
525 |
extern AT24C01BNDriver moduleLldEeprom;
|
526 |
|
527 |
/**
|
528 |
* @brief Battery charger (front battery) driver.
|
529 |
*/
|
530 |
extern BQ24103ADriver moduleLldBatteryChargerFront;
|
531 |
|
532 |
/**
|
533 |
* @brief Battery charger (rear battery) driver.
|
534 |
*/
|
535 |
extern BQ24103ADriver moduleLldBatteryChargerRear;
|
536 |
|
537 |
/**
|
538 |
* @brief Fuel gauge (front battery) driver.
|
539 |
*/
|
540 |
extern BQ27500Driver moduleLldFuelGaugeFront;
|
541 |
|
542 |
/**
|
543 |
* @brief Fuel gauge (rear battery) driver.
|
544 |
*/
|
545 |
extern BQ27500Driver moduleLldFuelGaugeRear;
|
546 |
|
547 |
/**
|
548 |
* @brief Power monitor (VDD) driver.
|
549 |
*/
|
550 |
extern INA219Driver moduleLldPowerMonitorVdd;
|
551 |
|
552 |
/**
|
553 |
* @brief Power monitor (VIO 1.8) driver.
|
554 |
*/
|
555 |
extern INA219Driver moduleLldPowerMonitorVio18;
|
556 |
|
557 |
/**
|
558 |
* @brief Power monitor (VIO 3.3) driver.
|
559 |
*/
|
560 |
extern INA219Driver moduleLldPowerMonitorVio33;
|
561 |
|
562 |
/**
|
563 |
* @brief Power monitor (VSYS 4.2) driver.
|
564 |
*/
|
565 |
extern INA219Driver moduleLldPowerMonitorVsys42;
|
566 |
|
567 |
/**
|
568 |
* @brief Power monitor (VIO 5.0) driver.
|
569 |
*/
|
570 |
extern INA219Driver moduleLldPowerMonitorVio50;
|
571 |
|
572 |
/**
|
573 |
* @brief Status LED driver.
|
574 |
*/
|
575 |
extern LEDDriver moduleLldStatusLed;
|
576 |
|
577 |
/**
|
578 |
* @brief Touch sensor driver.
|
579 |
*/
|
580 |
extern MPR121Driver moduleLldTouch;
|
581 |
|
582 |
/**
|
583 |
* @brief I2C multiplexer (I2C 1) driver.
|
584 |
*/
|
585 |
extern PCA9544ADriver moduleLldI2cMultiplexer1;
|
586 |
|
587 |
/**
|
588 |
* @brief I2C multiplexer (I2C 2) driver.
|
589 |
*/
|
590 |
extern PCA9544ADriver moduleLldI2cMultiplexer2;
|
591 |
|
592 |
/**
|
593 |
* @brief Step down converter driver.
|
594 |
* @note Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
|
595 |
*/
|
596 |
extern TPS62113Driver moduleLldStepDownConverter;
|
597 |
|
598 |
/**
|
599 |
* @brief Proximity sensor (I2C 1) driver.
|
600 |
*/
|
601 |
extern VCNL4020Driver moduleLldProximity1;
|
602 |
|
603 |
/**
|
604 |
* @brief Proximity sensor (I2C 2) driver.
|
605 |
*/
|
606 |
extern VCNL4020Driver moduleLldProximity2;
|
607 |
|
608 |
/** @} */
|
609 |
|
610 |
/*===========================================================================*/
|
611 |
/**
|
612 |
* @name Unit tests (UT)
|
613 |
* @{
|
614 |
*/
|
615 |
/*===========================================================================*/
|
616 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
617 |
#include <ut_lld_adc.h> |
618 |
#include <ut_alld_at24c01bn-sh-b.h> |
619 |
#include <ut_alld_bq24103a.h> |
620 |
#include <ut_alld_bq27500.h> |
621 |
#include <ut_alld_bq27500_bq24103a.h> |
622 |
#include <ut_alld_ina219.h> |
623 |
#include <ut_alld_led.h> |
624 |
#include <ut_alld_mpr121.h> |
625 |
#include <ut_alld_pca9544a.h> |
626 |
#include <ut_alld_pklcs1212e4001.h> |
627 |
#include <ut_alld_tps62113.h> |
628 |
#include <ut_alld_tps62113_ina219.h> |
629 |
#include <ut_alld_vcnl4020.h> |
630 |
|
631 |
/**
|
632 |
* @brief ADC unit test object.
|
633 |
*/
|
634 |
extern aos_unittest_t moduleUtAdcVsys;
|
635 |
|
636 |
/**
|
637 |
* @brief AT24C01BN-SH-B (EEPROM) unit test object.
|
638 |
*/
|
639 |
extern aos_unittest_t moduleUtAlldAt24c01bn;
|
640 |
|
641 |
/**
|
642 |
* @brief BQ24103A (battery charger) unit test object.
|
643 |
*/
|
644 |
extern aos_unittest_t moduleUtAlldBq24103a;
|
645 |
|
646 |
/**
|
647 |
* @brief BQ27500 (fuel gauge) unit test object.
|
648 |
*/
|
649 |
extern aos_unittest_t moduleUtAlldBq27500;
|
650 |
|
651 |
/**
|
652 |
* @brief BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
|
653 |
*/
|
654 |
extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
|
655 |
|
656 |
/**
|
657 |
* @brief INA219 (power monitor) unit test object.
|
658 |
*/
|
659 |
extern aos_unittest_t moduleUtAlldIna219;
|
660 |
|
661 |
/**
|
662 |
* @brief Status LED unit test object.
|
663 |
*/
|
664 |
extern aos_unittest_t moduleUtAlldLed;
|
665 |
|
666 |
/**
|
667 |
* @brief MPR121 (touch sensor) unit test object.
|
668 |
*/
|
669 |
extern aos_unittest_t moduleUtAlldMpr121;
|
670 |
|
671 |
/**
|
672 |
* @brief PCA9544A (I2C multiplexer) unit test object.
|
673 |
*/
|
674 |
extern aos_unittest_t moduleUtAlldPca9544a;
|
675 |
|
676 |
/**
|
677 |
* @brief PKLCS1212E4001 (buzzer) unit test object.
|
678 |
*/
|
679 |
extern aos_unittest_t moduleUtAlldPklcs1212e4001;
|
680 |
|
681 |
/**
|
682 |
* @brief TPS62113 (step-down converter) unit test object.
|
683 |
*/
|
684 |
extern aos_unittest_t moduleUtAlldTps62113;
|
685 |
|
686 |
/**
|
687 |
* @brief TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
|
688 |
*/
|
689 |
extern aos_unittest_t moduleUtAlldTps62113Ina219;
|
690 |
|
691 |
/**
|
692 |
* @brief VCNL4020 (proximity sensor) unit test object.
|
693 |
*/
|
694 |
extern aos_unittest_t moduleUtAlldVcnl4020;
|
695 |
|
696 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
697 |
|
698 |
/** @} */
|
699 |
|
700 |
#endif /* _AMIROOS_MODULE_H_ */ |