amiro-os / modules / PowerManagement_1-1 / module.h @ 75d6970a
History | View | Annotate | Download (22.741 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
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 | 8399aeae | Thomas Schöpping | /**
|
142 | * @brief Real-Time Clock driver.
|
||
143 | */
|
||
144 | #define MODULE_HAL_RTC RTCD1
|
||
145 | |||
146 | e545e620 | Thomas Schöpping | /** @} */
|
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 | 6b53f6bf | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
426 | e545e620 | Thomas Schöpping | /**
|
427 | * @brief Shell prompt text.
|
||
428 | */
|
||
429 | extern const char* moduleShellPrompt; |
||
430 | 6b53f6bf | Thomas Schöpping | #endif
|
431 | e545e620 | Thomas Schöpping | |
432 | /**
|
||
433 | * @brief Unit test initialization hook.
|
||
434 | */
|
||
435 | #define MODULE_INIT_TESTS() { \
|
||
436 | /* add unit-test shell commands */ \
|
||
437 | 6b53f6bf | Thomas Schöpping | 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 | e545e620 | Thomas Schöpping | } |
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 | 6b53f6bf | Thomas Schöpping | * @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 Event flags for PD signal events.
|
||
518 | */
|
||
519 | #define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD
|
||
520 | |||
521 | /**
|
||
522 | * @brief Event flags for Sync signal events.
|
||
523 | */
|
||
524 | #define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC
|
||
525 | |||
526 | /**
|
||
527 | * @brief Hook to handle IO events during SSSP startup synchronization.
|
||
528 | */
|
||
529 | #define MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK(mask, flags) { \
|
||
530 | /* ignore all events */ \
|
||
531 | (void)mask; \
|
||
532 | (void)flags; \
|
||
533 | } |
||
534 | |||
535 | /** @} */
|
||
536 | |||
537 | /*===========================================================================*/
|
||
538 | /**
|
||
539 | e545e620 | Thomas Schöpping | * @name Low-level drivers
|
540 | * @{
|
||
541 | */
|
||
542 | /*===========================================================================*/
|
||
543 | #include <alld_at24c01bn-sh-b.h> |
||
544 | #include <alld_bq24103a.h> |
||
545 | #include <alld_bq27500.h> |
||
546 | #include <alld_ina219.h> |
||
547 | #include <alld_led.h> |
||
548 | #include <alld_mpr121.h> |
||
549 | #include <alld_pca9544a.h> |
||
550 | #include <alld_pklcs1212e4001.h> |
||
551 | #include <alld_tps62113.h> |
||
552 | #include <alld_vcnl4020.h> |
||
553 | |||
554 | /**
|
||
555 | * @brief EEPROM driver.
|
||
556 | */
|
||
557 | extern AT24C01BNDriver moduleLldEeprom;
|
||
558 | |||
559 | /**
|
||
560 | * @brief Battery charger (front battery) driver.
|
||
561 | */
|
||
562 | extern BQ24103ADriver moduleLldBatteryChargerFront;
|
||
563 | |||
564 | /**
|
||
565 | * @brief Battery charger (rear battery) driver.
|
||
566 | */
|
||
567 | extern BQ24103ADriver moduleLldBatteryChargerRear;
|
||
568 | |||
569 | /**
|
||
570 | * @brief Fuel gauge (front battery) driver.
|
||
571 | */
|
||
572 | extern BQ27500Driver moduleLldFuelGaugeFront;
|
||
573 | |||
574 | /**
|
||
575 | * @brief Fuel gauge (rear battery) driver.
|
||
576 | */
|
||
577 | extern BQ27500Driver moduleLldFuelGaugeRear;
|
||
578 | |||
579 | /**
|
||
580 | * @brief Power monitor (VDD) driver.
|
||
581 | */
|
||
582 | extern INA219Driver moduleLldPowerMonitorVdd;
|
||
583 | |||
584 | /**
|
||
585 | * @brief Power monitor (VIO 1.8) driver.
|
||
586 | */
|
||
587 | extern INA219Driver moduleLldPowerMonitorVio18;
|
||
588 | |||
589 | /**
|
||
590 | * @brief Power monitor (VIO 3.3) driver.
|
||
591 | */
|
||
592 | extern INA219Driver moduleLldPowerMonitorVio33;
|
||
593 | |||
594 | /**
|
||
595 | * @brief Power monitor (VSYS 4.2) driver.
|
||
596 | */
|
||
597 | extern INA219Driver moduleLldPowerMonitorVsys42;
|
||
598 | |||
599 | /**
|
||
600 | * @brief Power monitor (VIO 5.0) driver.
|
||
601 | */
|
||
602 | extern INA219Driver moduleLldPowerMonitorVio50;
|
||
603 | |||
604 | /**
|
||
605 | * @brief Status LED driver.
|
||
606 | */
|
||
607 | extern LEDDriver moduleLldStatusLed;
|
||
608 | |||
609 | /**
|
||
610 | * @brief Touch sensor driver.
|
||
611 | */
|
||
612 | extern MPR121Driver moduleLldTouch;
|
||
613 | |||
614 | /**
|
||
615 | * @brief I2C multiplexer (I2C 1) driver.
|
||
616 | */
|
||
617 | extern PCA9544ADriver moduleLldI2cMultiplexer1;
|
||
618 | |||
619 | /**
|
||
620 | * @brief I2C multiplexer (I2C 2) driver.
|
||
621 | */
|
||
622 | extern PCA9544ADriver moduleLldI2cMultiplexer2;
|
||
623 | |||
624 | /**
|
||
625 | * @brief Step down converter driver.
|
||
626 | * @note Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
|
||
627 | */
|
||
628 | extern TPS62113Driver moduleLldStepDownConverter;
|
||
629 | |||
630 | /**
|
||
631 | * @brief Proximity sensor (I2C 1) driver.
|
||
632 | */
|
||
633 | extern VCNL4020Driver moduleLldProximity1;
|
||
634 | |||
635 | /**
|
||
636 | * @brief Proximity sensor (I2C 2) driver.
|
||
637 | */
|
||
638 | extern VCNL4020Driver moduleLldProximity2;
|
||
639 | |||
640 | /** @} */
|
||
641 | |||
642 | /*===========================================================================*/
|
||
643 | /**
|
||
644 | * @name Unit tests (UT)
|
||
645 | * @{
|
||
646 | */
|
||
647 | /*===========================================================================*/
|
||
648 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
649 | #include <ut_lld_adc.h> |
||
650 | #include <ut_alld_at24c01bn-sh-b.h> |
||
651 | #include <ut_alld_bq24103a.h> |
||
652 | #include <ut_alld_bq27500.h> |
||
653 | #include <ut_alld_bq27500_bq24103a.h> |
||
654 | #include <ut_alld_ina219.h> |
||
655 | #include <ut_alld_led.h> |
||
656 | #include <ut_alld_mpr121.h> |
||
657 | #include <ut_alld_pca9544a.h> |
||
658 | #include <ut_alld_pklcs1212e4001.h> |
||
659 | #include <ut_alld_tps62113.h> |
||
660 | #include <ut_alld_tps62113_ina219.h> |
||
661 | #include <ut_alld_vcnl4020.h> |
||
662 | |||
663 | /**
|
||
664 | * @brief ADC unit test object.
|
||
665 | */
|
||
666 | extern aos_unittest_t moduleUtAdcVsys;
|
||
667 | |||
668 | /**
|
||
669 | * @brief AT24C01BN-SH-B (EEPROM) unit test object.
|
||
670 | */
|
||
671 | extern aos_unittest_t moduleUtAlldAt24c01bn;
|
||
672 | |||
673 | /**
|
||
674 | * @brief BQ24103A (battery charger) unit test object.
|
||
675 | */
|
||
676 | extern aos_unittest_t moduleUtAlldBq24103a;
|
||
677 | |||
678 | /**
|
||
679 | * @brief BQ27500 (fuel gauge) unit test object.
|
||
680 | */
|
||
681 | extern aos_unittest_t moduleUtAlldBq27500;
|
||
682 | |||
683 | /**
|
||
684 | * @brief BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
|
||
685 | */
|
||
686 | extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
|
||
687 | |||
688 | /**
|
||
689 | * @brief INA219 (power monitor) unit test object.
|
||
690 | */
|
||
691 | extern aos_unittest_t moduleUtAlldIna219;
|
||
692 | |||
693 | /**
|
||
694 | * @brief Status LED unit test object.
|
||
695 | */
|
||
696 | extern aos_unittest_t moduleUtAlldLed;
|
||
697 | |||
698 | /**
|
||
699 | * @brief MPR121 (touch sensor) unit test object.
|
||
700 | */
|
||
701 | extern aos_unittest_t moduleUtAlldMpr121;
|
||
702 | |||
703 | /**
|
||
704 | * @brief PCA9544A (I2C multiplexer) unit test object.
|
||
705 | */
|
||
706 | extern aos_unittest_t moduleUtAlldPca9544a;
|
||
707 | |||
708 | /**
|
||
709 | * @brief PKLCS1212E4001 (buzzer) unit test object.
|
||
710 | */
|
||
711 | extern aos_unittest_t moduleUtAlldPklcs1212e4001;
|
||
712 | |||
713 | /**
|
||
714 | * @brief TPS62113 (step-down converter) unit test object.
|
||
715 | */
|
||
716 | extern aos_unittest_t moduleUtAlldTps62113;
|
||
717 | |||
718 | /**
|
||
719 | * @brief TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
|
||
720 | */
|
||
721 | extern aos_unittest_t moduleUtAlldTps62113Ina219;
|
||
722 | |||
723 | /**
|
||
724 | * @brief VCNL4020 (proximity sensor) unit test object.
|
||
725 | */
|
||
726 | extern aos_unittest_t moduleUtAlldVcnl4020;
|
||
727 | |||
728 | #endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
||
729 | |||
730 | /** @} */
|
||
731 | |||
732 | #endif /* _AMIROOS_MODULE_H_ */ |