Statistics
| Branch: | Tag: | Revision:

amiro-os / os / modules / PowerManagement_1-1 / module.h @ e545e620

History | View | Annotate | Download (22.076 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

    
143
/*===========================================================================*/
144
/**
145
 * @name GPIO definitions
146
 * @{
147
 */
148
/*===========================================================================*/
149
#include <amiro-lld.h>
150

    
151
/**
152
 * @brief   Interrupt channel for the IR_INT1 and CHARGE_STAT1A signals.
153
 */
154
#define MODULE_GPIO_EXTCHANNEL_IRINT1           ((expchannel_t)0)
155

    
156
/**
157
 * @brief   Interrupt channel for the GAUGE_BATLOW1 signal.
158
 */
159
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW1     ((expchannel_t)1)
160

    
161
/**
162
 * @brief   Interrupt channel for the GAUGE_BATGD1 signal.
163
 */
164
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATGD1      ((expchannel_t)2)
165

    
166
/**
167
 * @brief   Interrupt channel for the SYS_UART_DN signal.
168
 */
169
#define MODULE_GPIO_EXTCHANNEL_SYSUARTDN        ((expchannel_t)3)
170

    
171
/**
172
 * @brief   Interrupt channel for the IR_INT2 and CHARGE_STAT2A signals.
173
 */
174
#define MODULE_GPIO_EXTCHANNEL_IRINT2           ((expchannel_t)4)
175

    
176
/**
177
 * @brief   Interrupt channel for the TOUCH_INT signal.
178
 */
179
#define MODULE_GPIO_EXTCHANNEL_TOUCHINT         ((expchannel_t)5)
180

    
181
/**
182
 * @brief   Interrupt channel for the GAUGE_BATLOW2 signal.
183
 */
184
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW2     ((expchannel_t)6)
185

    
186
/**
187
 * @brief   Interrupt channel for the GAUGE_BATGD2 signal.
188
 */
189
#define MODULE_GPIO_EXTCHANNEL_GAUGEBATGD2      ((expchannel_t)7)
190

    
191
/**
192
 * @brief   Interrupt channel for the PATH_DC signal.
193
 */
194
#define MODULE_GPIO_EXTCHANNEL_PATHDC           ((expchannel_t)8)
195

    
196
/**
197
 * @brief   Interrupt channel for the SYS_SPI_DIR signal.
198
 */
199
#define MODULE_GPIO_EXTCHANNEL_SYSSPIDIR        ((expchannel_t)9)
200

    
201
/**
202
 * @brief   Interrupt channel for the SYS_SYNC signal.
203
 */
204
#define MODULE_GPIO_EXTCHANNEL_SYSSYNC          ((expchannel_t)12)
205

    
206
/**
207
 * @brief   Interrupt channel for the SYS_PD signal.
208
 */
209
#define MODULE_GPIO_EXTCHANNEL_SYSPD            ((expchannel_t)13)
210

    
211
/**
212
 * @brief   Interrupt channel for the SYS_WARMRST signal.
213
 */
214
#define MODULE_GPIO_EXTCHANNEL_SYSWARMRST       ((expchannel_t)14)
215

    
216
/**
217
 * @brief   Interrupt channel for the SYS_UART_UP signal.
218
 */
219
#define MODULE_GPIO_EXTCHANNEL_SYSUARTUP        ((expchannel_t)15)
220

    
221
/**
222
 * @brief   SYS_REG_EN output signal GPIO.
223
 */
224
extern apalGpio_t moduleGpioSysRegEn;
225

    
226
/**
227
 * @brief   IR_INT1 input signal GPIO.
228
 */
229
extern apalGpio_t moduleGpioIrInt1;
230

    
231
/**
232
 * @brief   POWER_EN output signal GPIO.
233
 */
234
extern apalGpio_t moduleGpioPowerEn;
235

    
236
/**
237
 * @brief   SYS_UART_DN bidirectional signal GPIO.
238
 */
239
extern apalGpio_t moduleGpioSysUartDn;
240

    
241
/**
242
 * @brief   CHARGE_STAT2A input signal GPIO.
243
 */
244
extern apalGpio_t moduleGpioChargeStat2A;
245

    
246
/**
247
 * @brief   GAUGE_BATLOW2 input signal GPIO.
248
 */
249
extern apalGpio_t moduleGpioGaugeBatLow2;
250

    
251
/**
252
 * @brief   GAUGE_BATGD2 input signal GPIO.
253
 */
254
extern apalGpio_t moduleGpioGaugeBatGd2;
255

    
256
/**
257
 * @brief   LED output signal GPIO.
258
 */
259
extern apalGpio_t moduleGpioLed;
260

    
261
/**
262
 * @brief   SYS_UART_UP bidirectional signal GPIO.
263
 */
264
extern apalGpio_t moduleGpioSysUartUp;
265

    
266
/**
267
 * @brief   CHARGE_STAT1A input signal GPIO.
268
 */
269
extern apalGpio_t moduleGpioChargeStat1A;
270

    
271
/**
272
 * @brief   GAUGE_BATLOW1 input signal GPIO.
273
 */
274
extern apalGpio_t moduleGpioGaugeBatLow1;
275

    
276
/**
277
 * @brief   GAUGE_BATGD1 input signal GPIO.
278
 */
279
extern apalGpio_t moduleGpioGaugeBatGd1;
280

    
281
/**
282
 * @brief   CHARG_EN1 output signal GPIO.
283
 */
284
extern apalGpio_t moduleGpioChargeEn1;
285

    
286
/**
287
 * @brief   IR_INT2 input signal GPIO.
288
 */
289
extern apalGpio_t moduleGpioIrInt2;
290

    
291
/**
292
 * @brief   TOUCH_INT input signal GPIO.
293
 */
294
extern apalGpio_t moduleGpioTouchInt;
295

    
296
/**
297
 * @brief   SYS_DONE input signal GPIO.
298
 */
299
extern apalGpio_t moduleGpioSysDone;
300

    
301
/**
302
 * @brief   SYS_PROG output signal GPIO.
303
 */
304
extern apalGpio_t moduleGpioSysProg;
305

    
306
/**
307
 * @brief   PATH_DC input signal GPIO.
308
 */
309
extern apalGpio_t moduleGpioPathDc;
310

    
311
/**
312
 * @brief   SYS_SPI_DIR bidirectional signal GPIO.
313
 */
314
extern apalGpio_t moduleGpioSysSpiDir;
315

    
316
/**
317
 * @brief   SYS_SYNC bidirectional signal GPIO.
318
 */
319
extern apalGpio_t moduleGpioSysSync;
320

    
321
/**
322
 * @brief   SYS_PD bidirectional signal GPIO.
323
 */
324
extern apalGpio_t moduleGpioSysPd;
325

    
326
/**
327
 * @brief   SYS_WARMRST bidirectional signal GPIO.
328
 */
329
extern apalGpio_t moduleGpioSysWarmrst;
330

    
331
/**
332
 * @brief   BT_RST output signal GPIO.
333
 */
334
extern apalGpio_t moduleGpioBtRst;
335

    
336
/**
337
 * @brief   CHARGE_EN2 output signal GPIO.
338
 */
339
extern apalGpio_t moduleGpioChargeEn2;
340

    
341
/** @} */
342

    
343
/*===========================================================================*/
344
/**
345
 * @name AMiRo-OS core configurations
346
 * @{
347
 */
348
/*===========================================================================*/
349

    
350
/**
351
 * @brief   Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
352
 */
353
#define MODULE_OS_IOEVENTFLAGS_IRINT1           ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_IRINT1)
354

    
355
/**
356
 * @brief   Event flag to be set on a GAUGE_BATLOW1 interrupt.
357
 */
358
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1     ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW1)
359

    
360
/**
361
 * @brief   Event flag to be set on a GAUGE_BATGD1 interrupt.
362
 */
363
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1      ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATGD1)
364

    
365
/**
366
 * @brief   Event flag to be set on a SYS_UART_DN interrupt.
367
 */
368
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSUARTDN)
369

    
370
/**
371
 * @brief   Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
372
 */
373
#define MODULE_OS_IOEVENTFLAGS_IRINT2           ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_IRINT2)
374

    
375
/**
376
 * @brief   Event flag to be set on a TOUCH_INT interrupt.
377
 */
378
#define MODULE_OS_IOEVENTFLAGS_TOUCHINT         ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_TOUCHINT)
379

    
380
/**
381
 * @brief   Event flag to be set on a GAUGE_BATLOW2 interrupt.
382
 */
383
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2     ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATLOW2)
384

    
385
/**
386
 * @brief   Event flag to be set on a GAUGE_BATGD2 interrupt.
387
 */
388
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2      ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_GAUGEBATGD2)
389

    
390
/**
391
 * @brief   Event flag to be set on a PATH_DC interrupt.
392
 */
393
#define MODULE_OS_IOEVENTFLAGS_PATHDC           ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_PATHDC)
394

    
395
/**
396
 * @brief   Event flag to be set on a SYS_SPI_DIR interrupt.
397
 */
398
#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR        ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSSPIDIR)
399

    
400
/**
401
 * @brief   Event flag to be set on a SYS_SYNC interrupt.
402
 */
403
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSSYNC)
404

    
405
/**
406
 * @brief   Event flag to be set on a SYS_PD interrupt.
407
 */
408
#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSPD)
409

    
410
/**
411
 * @brief   Event flag to be set on a SYS_WARMRST interrupt.
412
 */
413
#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSWARMRST)
414

    
415
/**
416
 * @brief   Event flag to be set on a SYS_UART_UP interrupt.
417
 */
418
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSUARTUP)
419

    
420
/**
421
 * @brief   PD signal for SSSP.
422
 */
423
extern apalControlGpio_t moduleSsspPd;
424

    
425
/**
426
 * @brief   SYNC signal for SSSP.
427
 */
428
extern apalControlGpio_t moduleSsspSync;
429

    
430
/**
431
 * @brief   Shell prompt text.
432
 */
433
extern const char* moduleShellPrompt;
434

    
435
/**
436
 * @brief   Unit test initialization hook.
437
 */
438
#define MODULE_INIT_TESTS() {                                                 \
439
  /* add unit-test shell commands */                                          \
440
  aosShellAddCommand(aos.shell, &moduleUtAdcVsys.shellcmd);                   \
441
  aosShellAddCommand(aos.shell, &moduleUtAlldAt24c01bn.shellcmd);             \
442
  aosShellAddCommand(aos.shell, &moduleUtAlldBq24103a.shellcmd);              \
443
  aosShellAddCommand(aos.shell, &moduleUtAlldBq27500.shellcmd);               \
444
  aosShellAddCommand(aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd);       \
445
  aosShellAddCommand(aos.shell, &moduleUtAlldIna219.shellcmd);                \
446
  aosShellAddCommand(aos.shell, &moduleUtAlldMpr121.shellcmd);                \
447
  aosShellAddCommand(aos.shell, &moduleUtAlldPca9544a.shellcmd);              \
448
  aosShellAddCommand(aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd);        \
449
  aosShellAddCommand(aos.shell, &moduleUtAlldLed.shellcmd);                   \
450
  aosShellAddCommand(aos.shell, &moduleUtAlldTps62113.shellcmd);              \
451
  aosShellAddCommand(aos.shell, &moduleUtAlldTps62113Ina219.shellcmd);        \
452
  aosShellAddCommand(aos.shell, &moduleUtAlldVcnl4020.shellcmd);              \
453
}
454

    
455
/**
456
 * @brief   Periphery communication interfaces initialization hook.
457
 */
458
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
459
  /* serial driver */                                                         \
460
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
461
  /* I2C */                                                                   \
462
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
463
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
464
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
465
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
466
  moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
467
  i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \
468
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
469
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
470
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
471
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
472
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
473
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
474
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
475
  i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig);  \
476
  /* ADC */                                                                   \
477
  adcStart(&MODULE_HAL_ADC_VSYS, NULL);                                       \
478
  /* PWM */                                                                   \
479
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
480
  moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock;           \
481
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
482
  moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \
483
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
484
}
485

    
486
/**
487
 * @brief   Hook to handle IO events during SSSP startup synchronization.
488
 */
489
#define MODULE_SSP_STARTUP_OUTRO_IO_EVENT(mask, flags) {                      \
490
  /* ignore all events */                                                     \
491
  (void)mask;                                                                 \
492
  (void)flags;                                                                \
493
}
494

    
495
/**
496
 * @brief   Periphery communication interface deinitialization hook.
497
 */
498
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
499
  /* PWM */                                                                   \
500
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
501
  /* ADC */                                                                   \
502
  adcStop(&MODULE_HAL_ADC_VSYS);                                              \
503
  /* I2C */                                                                   \
504
  i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR);                          \
505
  i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT);      \
506
  /* don't stop the serial driver so messages can still be printed */         \
507
}
508

    
509
/** @} */
510

    
511
/*===========================================================================*/
512
/**
513
 * @name Low-level drivers
514
 * @{
515
 */
516
/*===========================================================================*/
517
#include <alld_at24c01bn-sh-b.h>
518
#include <alld_bq24103a.h>
519
#include <alld_bq27500.h>
520
#include <alld_ina219.h>
521
#include <alld_led.h>
522
#include <alld_mpr121.h>
523
#include <alld_pca9544a.h>
524
#include <alld_pklcs1212e4001.h>
525
#include <alld_tps62113.h>
526
#include <alld_vcnl4020.h>
527

    
528
/**
529
 * @brief   EEPROM driver.
530
 */
531
extern AT24C01BNDriver moduleLldEeprom;
532

    
533
/**
534
 * @brief   Battery charger (front battery) driver.
535
 */
536
extern BQ24103ADriver moduleLldBatteryChargerFront;
537

    
538
/**
539
 * @brief   Battery charger (rear battery) driver.
540
 */
541
extern BQ24103ADriver moduleLldBatteryChargerRear;
542

    
543
/**
544
 * @brief   Fuel gauge (front battery) driver.
545
 */
546
extern BQ27500Driver moduleLldFuelGaugeFront;
547

    
548
/**
549
 * @brief   Fuel gauge (rear battery) driver.
550
 */
551
extern BQ27500Driver moduleLldFuelGaugeRear;
552

    
553
/**
554
 * @brief   Power monitor (VDD) driver.
555
 */
556
extern INA219Driver moduleLldPowerMonitorVdd;
557

    
558
/**
559
 * @brief   Power monitor (VIO 1.8) driver.
560
 */
561
extern INA219Driver moduleLldPowerMonitorVio18;
562

    
563
/**
564
 * @brief   Power monitor (VIO 3.3) driver.
565
 */
566
extern INA219Driver moduleLldPowerMonitorVio33;
567

    
568
/**
569
 * @brief   Power monitor (VSYS 4.2) driver.
570
 */
571
extern INA219Driver moduleLldPowerMonitorVsys42;
572

    
573
/**
574
 * @brief   Power monitor (VIO 5.0) driver.
575
 */
576
extern INA219Driver moduleLldPowerMonitorVio50;
577

    
578
/**
579
 * @brief   Status LED driver.
580
 */
581
extern LEDDriver moduleLldStatusLed;
582

    
583
/**
584
 * @brief   Touch sensor driver.
585
 */
586
extern MPR121Driver moduleLldTouch;
587

    
588
/**
589
 * @brief   I2C multiplexer (I2C 1) driver.
590
 */
591
extern PCA9544ADriver moduleLldI2cMultiplexer1;
592

    
593
/**
594
 * @brief   I2C multiplexer (I2C 2) driver.
595
 */
596
extern PCA9544ADriver moduleLldI2cMultiplexer2;
597

    
598
/**
599
 * @brief   Step down converter driver.
600
 * @note    Although there multiple TPS62113, those are completely identical from driver few (share the same signals).
601
 */
602
extern TPS62113Driver moduleLldStepDownConverter;
603

    
604
/**
605
 * @brief   Proximity sensor (I2C 1) driver.
606
 */
607
extern VCNL4020Driver moduleLldProximity1;
608

    
609
/**
610
 * @brief   Proximity sensor (I2C 2) driver.
611
 */
612
extern VCNL4020Driver moduleLldProximity2;
613

    
614
/** @} */
615

    
616
/*===========================================================================*/
617
/**
618
 * @name Unit tests (UT)
619
 * @{
620
 */
621
/*===========================================================================*/
622
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
623
#include <ut_lld_adc.h>
624
#include <ut_alld_at24c01bn-sh-b.h>
625
#include <ut_alld_bq24103a.h>
626
#include <ut_alld_bq27500.h>
627
#include <ut_alld_bq27500_bq24103a.h>
628
#include <ut_alld_ina219.h>
629
#include <ut_alld_led.h>
630
#include <ut_alld_mpr121.h>
631
#include <ut_alld_pca9544a.h>
632
#include <ut_alld_pklcs1212e4001.h>
633
#include <ut_alld_tps62113.h>
634
#include <ut_alld_tps62113_ina219.h>
635
#include <ut_alld_vcnl4020.h>
636

    
637
/**
638
 * @brief   ADC unit test object.
639
 */
640
extern aos_unittest_t moduleUtAdcVsys;
641

    
642
/**
643
 * @brief   AT24C01BN-SH-B (EEPROM) unit test object.
644
 */
645
extern aos_unittest_t moduleUtAlldAt24c01bn;
646

    
647
/**
648
 * @brief   BQ24103A (battery charger) unit test object.
649
 */
650
extern aos_unittest_t moduleUtAlldBq24103a;
651

    
652
/**
653
 * @brief   BQ27500 (fuel gauge) unit test object.
654
 */
655
extern aos_unittest_t moduleUtAlldBq27500;
656

    
657
/**
658
 * @brief   BQ27500 (fuela gauge) in combination with BQ24103A (battery charger) unit test object.
659
 */
660
extern aos_unittest_t moduleUtAlldBq27500Bq24103a;
661

    
662
/**
663
 * @brief   INA219 (power monitor) unit test object.
664
 */
665
extern aos_unittest_t moduleUtAlldIna219;
666

    
667
/**
668
 * @brief   Status LED unit test object.
669
 */
670
extern aos_unittest_t moduleUtAlldLed;
671

    
672
/**
673
 * @brief   MPR121 (touch sensor) unit test object.
674
 */
675
extern aos_unittest_t moduleUtAlldMpr121;
676

    
677
/**
678
 * @brief   PCA9544A (I2C multiplexer) unit test object.
679
 */
680
extern aos_unittest_t moduleUtAlldPca9544a;
681

    
682
/**
683
 * @brief   PKLCS1212E4001 (buzzer) unit test object.
684
 */
685
extern aos_unittest_t moduleUtAlldPklcs1212e4001;
686

    
687
/**
688
 * @brief   TPS62113 (step-down converter) unit test object.
689
 */
690
extern aos_unittest_t moduleUtAlldTps62113;
691

    
692
/**
693
 * @brief   TPS62113 (step-sown converter) in combination with INA219 (power monitor) unit test object.
694
 */
695
extern aos_unittest_t moduleUtAlldTps62113Ina219;
696

    
697
/**
698
 * @brief   VCNL4020 (proximity sensor) unit test object.
699
 */
700
extern aos_unittest_t moduleUtAlldVcnl4020;
701

    
702
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
703

    
704
/** @} */
705

    
706
#endif /* _AMIROOS_MODULE_H_ */