Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / module.h @ 4f3a1f5e

History | View | Annotate | Download (22.173 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
/**
426
 * @brief   PD signal for SSSP.
427
 */
428
extern apalControlGpio_t moduleSsspPd;
429
430
/**
431
 * @brief   SYNC signal for SSSP.
432
 */
433
extern apalControlGpio_t moduleSsspSync;
434
435
/**
436
 * @brief   Shell prompt text.
437
 */
438
extern const char* moduleShellPrompt;
439
440
/**
441
 * @brief   Unit test initialization hook.
442
 */
443
#define MODULE_INIT_TESTS() {                                                 \
444
  /* add unit-test shell commands */                                          \
445
  aosShellAddCommand(aos.shell, &moduleUtAdcVsys.shellcmd);                   \
446
  aosShellAddCommand(aos.shell, &moduleUtAlldAt24c01bn.shellcmd);             \
447
  aosShellAddCommand(aos.shell, &moduleUtAlldBq24103a.shellcmd);              \
448
  aosShellAddCommand(aos.shell, &moduleUtAlldBq27500.shellcmd);               \
449
  aosShellAddCommand(aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd);       \
450
  aosShellAddCommand(aos.shell, &moduleUtAlldIna219.shellcmd);                \
451
  aosShellAddCommand(aos.shell, &moduleUtAlldMpr121.shellcmd);                \
452
  aosShellAddCommand(aos.shell, &moduleUtAlldPca9544a.shellcmd);              \
453
  aosShellAddCommand(aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd);        \
454
  aosShellAddCommand(aos.shell, &moduleUtAlldLed.shellcmd);                   \
455
  aosShellAddCommand(aos.shell, &moduleUtAlldTps62113.shellcmd);              \
456
  aosShellAddCommand(aos.shell, &moduleUtAlldTps62113Ina219.shellcmd);        \
457
  aosShellAddCommand(aos.shell, &moduleUtAlldVcnl4020.shellcmd);              \
458
}
459
460
/**
461
 * @brief   Periphery communication interfaces initialization hook.
462
 */
463
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
464
  /* serial driver */                                                         \
465
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
466
  /* I2C */                                                                   \
467
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
468
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
469
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
470
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
471
  moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
472
  i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \
473
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
474
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
475
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
476
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
477
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
478
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
479
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
480
  i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig);  \
481
  /* ADC */                                                                   \
482
  adcStart(&MODULE_HAL_ADC_VSYS, NULL);                                       \
483
  /* PWM */                                                                   \
484
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
485
  moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock;           \
486
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
487
  moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \
488
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
489
}
490
491
/**
492
 * @brief   Hook to handle IO events during SSSP startup synchronization.
493
 */
494
#define MODULE_SSP_STARTUP_OUTRO_IO_EVENT(mask, flags) {                      \
495
  /* ignore all events */                                                     \
496
  (void)mask;                                                                 \
497
  (void)flags;                                                                \
498
}
499
500
/**
501
 * @brief   Periphery communication interface deinitialization hook.
502
 */
503
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
504
  /* PWM */                                                                   \
505
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
506
  /* ADC */                                                                   \
507
  adcStop(&MODULE_HAL_ADC_VSYS);                                              \
508
  /* I2C */                                                                   \
509
  i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR);                          \
510
  i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT);      \
511
  /* don't stop the serial driver so messages can still be printed */         \
512
}
513
514
/** @} */
515
516
/*===========================================================================*/
517
/**
518
 * @name Low-level drivers
519
 * @{
520
 */
521
/*===========================================================================*/
522
#include <alld_at24c01bn-sh-b.h>
523
#include <alld_bq24103a.h>
524
#include <alld_bq27500.h>
525
#include <alld_ina219.h>
526
#include <alld_led.h>
527
#include <alld_mpr121.h>
528
#include <alld_pca9544a.h>
529
#include <alld_pklcs1212e4001.h>
530
#include <alld_tps62113.h>
531
#include <alld_vcnl4020.h>
532
533
/**
534
 * @brief   EEPROM driver.
535
 */
536
extern AT24C01BNDriver moduleLldEeprom;
537
538
/**
539
 * @brief   Battery charger (front battery) driver.
540
 */
541
extern BQ24103ADriver moduleLldBatteryChargerFront;
542
543
/**
544
 * @brief   Battery charger (rear battery) driver.
545
 */
546
extern BQ24103ADriver moduleLldBatteryChargerRear;
547
548
/**
549
 * @brief   Fuel gauge (front battery) driver.
550
 */
551
extern BQ27500Driver moduleLldFuelGaugeFront;
552
553
/**
554
 * @brief   Fuel gauge (rear battery) driver.
555
 */
556
extern BQ27500Driver moduleLldFuelGaugeRear;
557
558
/**
559
 * @brief   Power monitor (VDD) driver.
560
 */
561
extern INA219Driver moduleLldPowerMonitorVdd;
562
563
/**
564
 * @brief   Power monitor (VIO 1.8) driver.
565
 */
566
extern INA219Driver moduleLldPowerMonitorVio18;
567
568
/**
569
 * @brief   Power monitor (VIO 3.3) driver.
570
 */
571
extern INA219Driver moduleLldPowerMonitorVio33;
572
573
/**
574
 * @brief   Power monitor (VSYS 4.2) driver.
575
 */
576
extern INA219Driver moduleLldPowerMonitorVsys42;
577
578
/**
579
 * @brief   Power monitor (VIO 5.0) driver.
580
 */
581
extern INA219Driver moduleLldPowerMonitorVio50;
582
583
/**
584
 * @brief   Status LED driver.
585
 */
586
extern LEDDriver moduleLldStatusLed;
587
588
/**
589
 * @brief   Touch sensor driver.
590
 */
591
extern MPR121Driver moduleLldTouch;
592
593
/**
594
 * @brief   I2C multiplexer (I2C 1) driver.
595
 */
596
extern PCA9544ADriver moduleLldI2cMultiplexer1;
597
598
/**
599
 * @brief   I2C multiplexer (I2C 2) driver.
600
 */
601
extern PCA9544ADriver moduleLldI2cMultiplexer2;
602
603
/**
604
 * @brief   Step down converter driver.
605
 * @note    Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
606
 */
607
extern TPS62113Driver moduleLldStepDownConverter;
608
609
/**
610
 * @brief   Proximity sensor (I2C 1) driver.
611
 */
612
extern VCNL4020Driver moduleLldProximity1;
613
614
/**
615
 * @brief   Proximity sensor (I2C 2) driver.
616
 */
617
extern VCNL4020Driver moduleLldProximity2;
618
619
/** @} */
620
621
/*===========================================================================*/
622
/**
623
 * @name Unit tests (UT)
624
 * @{
625
 */
626
/*===========================================================================*/
627
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
628
#include <ut_lld_adc.h>
629
#include <ut_alld_at24c01bn-sh-b.h>
630
#include <ut_alld_bq24103a.h>
631
#include <ut_alld_bq27500.h>
632
#include <ut_alld_bq27500_bq24103a.h>
633
#include <ut_alld_ina219.h>
634
#include <ut_alld_led.h>
635
#include <ut_alld_mpr121.h>
636
#include <ut_alld_pca9544a.h>
637
#include <ut_alld_pklcs1212e4001.h>
638
#include <ut_alld_tps62113.h>
639
#include <ut_alld_tps62113_ina219.h>
640
#include <ut_alld_vcnl4020.h>
641
642
/**
643
 * @brief   ADC unit test object.
644
 */
645
extern aos_unittest_t moduleUtAdcVsys;
646
647
/**
648
 * @brief   AT24C01BN-SH-B (EEPROM) unit test object.
649
 */
650
extern aos_unittest_t moduleUtAlldAt24c01bn;
651
652
/**
653
 * @brief   BQ24103A (battery charger) unit test object.
654
 */
655
extern aos_unittest_t moduleUtAlldBq24103a;
656
657
/**
658
 * @brief   BQ27500 (fuel gauge) unit test object.
659
 */
660
extern aos_unittest_t moduleUtAlldBq27500;
661
662
/**
663
 * @brief   BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
664
 */
665
extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
666
667
/**
668
 * @brief   INA219 (power monitor) unit test object.
669
 */
670
extern aos_unittest_t moduleUtAlldIna219;
671
672
/**
673
 * @brief   Status LED unit test object.
674
 */
675
extern aos_unittest_t moduleUtAlldLed;
676
677
/**
678
 * @brief   MPR121 (touch sensor) unit test object.
679
 */
680
extern aos_unittest_t moduleUtAlldMpr121;
681
682
/**
683
 * @brief   PCA9544A (I2C multiplexer) unit test object.
684
 */
685
extern aos_unittest_t moduleUtAlldPca9544a;
686
687
/**
688
 * @brief   PKLCS1212E4001 (buzzer) unit test object.
689
 */
690
extern aos_unittest_t moduleUtAlldPklcs1212e4001;
691
692
/**
693
 * @brief   TPS62113 (step-down converter) unit test object.
694
 */
695
extern aos_unittest_t moduleUtAlldTps62113;
696
697
/**
698
 * @brief   TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
699
 */
700
extern aos_unittest_t moduleUtAlldTps62113Ina219;
701
702
/**
703
 * @brief   VCNL4020 (proximity sensor) unit test object.
704
 */
705
extern aos_unittest_t moduleUtAlldVcnl4020;
706
707
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
708
709
/** @} */
710
711
#endif /* _AMIROOS_MODULE_H_ */