Revision 960338cc

View differences:

modules/RT-STM32L476RG-NUCLEO64/aosconf.h
101 101
 * @brief   Flag to enable SSSP.
102 102
 */
103 103
#if !defined(OS_CFG_SSSP_ENABLE)
104
  #define AMIROOS_CFG_SSSP_ENABLE               true
104
  #define AMIROOS_CFG_SSSP_ENABLE               false
105 105
#else
106 106
  #define AMIROOS_CFG_SSSP_ENABLE               OS_CFG_SSSP_ENABLE
107 107
#endif
modules/RT-STM32L476RG-NUCLEO64/module.c
44 44
 */
45 45
/*===========================================================================*/
46 46

  
47
ADCConversionGroup moduleHalAdcVsysConversionGroup = {
48
  /* buffer type        */ true,
49
  /* number of channels */ 1,
50
  /* callback function  */ NULL,
51
  /* error callback     */ NULL,
52
  /* CR1                */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
53
  /* CR2                */ ADC_CR2_SWSTART | ADC_CR2_CONT,
54
  /* SMPR1              */ 0,
55
  /* SMPR2              */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
56
  /* HTR                */ ADC_HTR_HT,
57
  /* LTR                */ 0,
58
  /* SQR1               */ ADC_SQR1_NUM_CH(1),
59
  /* SQR2               */ 0,
60
  /* SQR3               */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
61
};
62

  
63 47
CANConfig moduleHalCanConfig = {
64 48
  /* mcr  */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
65 49
  /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1),
66 50
};
67 51

  
68
I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig = {
69
  /* I²C mode   */ OPMODE_I2C,
70
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
71
  /* duty cycle */ FAST_DUTY_CYCLE_2,
72
};
73

  
74
I2CConfig moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig = {
75
  /* I²C mode   */ OPMODE_I2C,
76
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
77
  /* duty cycle */ FAST_DUTY_CYCLE_2,
78
};
79

  
80
PWMConfig moduleHalPwmBuzzerConfig = {
81
  /* frequency              */ 1000000,
82
  /* period                 */ 0,
83
  /* callback               */ NULL,
84
  /* channel configurations */ {
85
    /* channel 0              */ {
86
      /* mode                   */ PWM_OUTPUT_DISABLED,
87
      /* callback               */ NULL
88
    },
89
    /* channel 1              */ {
90
      /* mode                   */ PWM_OUTPUT_ACTIVE_HIGH,
91
      /* callback               */ NULL
92
    },
93
    /* channel 2              */ {
94
      /* mode                   */ PWM_OUTPUT_DISABLED,
95
      /* callback               */ NULL
96
    },
97
    /* channel 3              */ {
98
      /* mode                   */ PWM_OUTPUT_DISABLED,
99
      /* callback               */ NULL
100
    },
101
  },
102
  /* TIM CR2 register       */ 0,
103
#if STM32_PWM_USE_ADVANCED
104
  /* TIM BDTR register      */ 0,
105
#endif
106
  /* TIM DIER register      */ 0,
107
};
108

  
109 52
SerialConfig moduleHalProgIfConfig = {
110 53
  /* bit rate */ 115200,
111 54
  /* CR1      */ 0,
......
115 58

  
116 59
/** @} */
117 60

  
118
/*===========================================================================*/
119
/**
120
 * @name GPIO definitions
121
 * @{
122
 */
123
/*===========================================================================*/
124

  
125
/**
126
 * @brief   SYS_REG_EN output signal GPIO.
127
 */
128
static apalGpio_t _gpioSysRegEn = {
129
  /* port */ GPIOA,
130
  /* pad  */ GPIOA_SYS_REG_EN,
131
};
132
ROMCONST apalControlGpio_t moduleSysRegEn = {
133
  /* GPIO */ &_gpioSysRegEn,
134
  /* meta */ {
135
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
136
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
137
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
138
  },
139
};
140

  
141
/**
142
 * @brief   IR_INT1 input signal GPIO.
143
 */
144
static apalGpio_t _gpioIrInt1 = {
145
  /* port */ GPIOB,
146
  /* pad  */ GPIOB_IR_INT1_N,
147
};
148
ROMCONST apalControlGpio_t moduleGpioIrInt1 = {
149
  /* GPIO */ &_gpioIrInt1,
150
  /* meta */ {
151
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
152
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
153
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
154
  },
155
};
156

  
157
/**
158
 * @brief   POWER_EN output signal GPIO.
159
 */
160
static apalGpio_t _gpioPowerEn = {
161
  /* port */ GPIOB,
162
  /* pad  */ GPIOB_POWER_EN,
163
};
164
ROMCONST apalControlGpio_t moduleGpioPowerEn = {
165
  /* GPIO */ &_gpioPowerEn,
166
  /* meta */ {
167
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
168
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
169
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
170
  },
171
};
172

  
173
/**
174
 * @brief   SYS_UART_DN bidirectional signal GPIO.
175
 */
176
static apalGpio_t _gpioSysUartDn = {
177
  /* port */ GPIOB,
178
  /* pad  */ GPIOB_SYS_UART_DN,
179
};
180
ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
181
  /* GPIO */ &_gpioSysUartDn,
182
  /* meta */ {
183
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
184
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
185
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
186
  },
187
};
188

  
189
/**
190
 * @brief   CHARGE_STAT2A input signal GPIO.
191
 */
192
static apalGpio_t _gpioChargeStat2A = {
193
  /* port */ GPIOB,
194
  /* pad  */ GPIOB_CHARGE_STAT2A,
195
};
196
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = {
197
  /* GPIO */ &_gpioChargeStat2A,
198
  /* meta */ {
199
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
200
    /* active state   */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
201
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
202
  },
203
};
204

  
205
/**
206
 * @brief   GAUGE_BATLOW2 input signal GPIO.
207
 */
208
static apalGpio_t _gpioGaugeBatLow2 = {
209
  /* port */ GPIOB,
210
  /* pad  */ GPIOB_GAUGE_BATLOW2,
211
};
212
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = {
213
  /* GPIO */ &_gpioGaugeBatLow2,
214
  /* meta */ {
215
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
216
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
217
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
218
  },
219
};
220

  
221
/**
222
 * @brief   GAUGE_BATGD2 input signal GPIO.
223
 */
224
static apalGpio_t _gpioGaugeBatGd2 = {
225
  /* port */ GPIOB,
226
  /* pad  */ GPIOB_GAUGE_BATGD2_N,
227
};
228
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = {
229
  /* GPIO */ &_gpioGaugeBatGd2,
230
  /* meta */ {
231
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
232
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
233
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
234
  },
235
};
236

  
237
/**
238
 * @brief   LED output signal GPIO.
239
 */
240
static apalGpio_t _gpioLed = {
241
  /* port */ GPIOB,
242
  /* pad  */ GPIOB_LED,
243
};
244
ROMCONST apalControlGpio_t moduleGpioLed = {
245
  /* GPIO */ &_gpioLed,
246
  /* meta */ {
247
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
248
    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
249
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
250
  },
251
};
252

  
253
/**
254
 * @brief   SYS_UART_UP bidirectional signal GPIO.
255
 */
256
static apalGpio_t _gpioSysUartUp = {
257
  /* port */ GPIOB,
258
  /* pad  */ GPIOB_SYS_UART_UP,
259
};
260
ROMCONST apalControlGpio_t moduleGpioSysUartUp = {
261
  /* GPIO */ &_gpioSysUartUp,
262
  /* meta */ {
263
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
264
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
265
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
266
  },
267
};
268

  
269
/**
270
 * @brief   CHARGE_STAT1A input signal GPIO.
271
 */
272
static apalGpio_t _gpioChargeStat1A = {
273
  /* port */ GPIOC,
274
  /* pad  */ GPIOC_CHARGE_STAT1A,
275
};
276
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = {
277
  /* GPIO */ &_gpioChargeStat1A,
278
  /* meta */ {
279
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
280
    /* active state   */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
281
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
282
  },
283
};
284

  
285
/**
286
 * @brief   GAUGE_BATLOW1 input signal GPIO.
287
 */
288
static apalGpio_t _gpioGaugeBatLow1 = {
289
  /* port */ GPIOC,
290
  /* pad  */ GPIOC_GAUGE_BATLOW1,
291
};
292
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = {
293
  /* GPIO */ &_gpioGaugeBatLow1,
294
  /* meta */ {
295
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
296
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
297
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
298
  },
299
};
300

  
301
/**
302
 * @brief   GAUGE_BATGD1 input signal GPIO.
303
 */
304
static apalGpio_t _gpioGaugeBatGd1 = {
305
  /* port */ GPIOC,
306
  /* pad  */ GPIOC_GAUGE_BATGD1_N,
307
};
308
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = {
309
  /* GPIO */ &_gpioGaugeBatGd1,
310
  /* meta */ {
311
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
312
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
313
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
314
  },
315
};
316

  
317
/**
318
 * @brief   CHARG_EN1 output signal GPIO.
319
 */
320
static apalGpio_t _gpioChargeEn1 = {
321
  /* port */ GPIOC,
322
  /* pad  */ GPIOC_CHARGE_EN1_N,
323
};
324
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = {
325
  /* GPIO */ &_gpioChargeEn1,
326
  /* meta */ {
327
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
328
    /* active state   */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
329
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
330
  },
331
};
332

  
333
/**
334
 * @brief   IR_INT2 input signal GPIO.
335
 */
336
static apalGpio_t _gpioIrInt2 = {
337
  /* port */ GPIOC,
338
  /* pad  */ GPIOC_IR_INT2_N,
339
};
340
ROMCONST apalControlGpio_t moduleGpioIrInt2 = {
341
  /* GPIO */ &_gpioIrInt2,
342
  /* meta */ {
343
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
344
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
345
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
346
  },
347
};
348

  
349
/**
350
 * @brief   TOUCH_INT input signal GPIO.
351
 */
352
static apalGpio_t _gpioTouchInt = {
353
  /* port */ GPIOC,
354
  /* pad  */ GPIOC_TOUCH_INT_N,
355
};
356
ROMCONST apalControlGpio_t moduleGpioTouchInt = {
357
  /* GPIO */ &_gpioTouchInt,
358
  /* meta */ {
359
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
360
    /* active state   */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
361
    /* interrupt edge */ MPR121_LLD_INT_EDGE,
362
  },
363
};
364

  
365
/**
366
 * @brief   SYS_DONE input signal GPIO.
367
 */
368
static apalGpio_t _gpioSysDone = {
369
  /* port */ GPIOC,
370
  /* pad  */ GPIOC_SYS_DONE,
371
};
372
ROMCONST apalControlGpio_t moduleGpioSysDone = {
373
  /* GPIO */ &_gpioSysDone,
374
  /* meta */ {
375
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
376
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
377
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
378
  },
379
};
380

  
381
/**
382
 * @brief   SYS_PROG output signal GPIO.
383
 */
384
static apalGpio_t _gpioSysProg = {
385
  /* port */ GPIOC,
386
  /* pad  */ GPIOC_SYS_PROG_N,
387
};
388
ROMCONST apalControlGpio_t moduleGpioSysProg = {
389
  /* GPIO */ &_gpioSysProg,
390
  /* meta */ {
391
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
392
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
393
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
394
  },
395
};
396

  
397
/**
398
 * @brief   PATH_DC input signal GPIO.
399
 */
400
static apalGpio_t _gpioPathDc = {
401
  /* port */ GPIOC,
402
  /* pad  */ GPIOC_PATH_DC,
403
};
404
ROMCONST apalControlGpio_t moduleGpioPathDc = {
405
  /* GPIO */ &_gpioPathDc,
406
  /* meta */ {
407
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
408
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
409
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
410
  },
411
};
412

  
413
/**
414
 * @brief   SYS_SPI_DIR bidirectional signal GPIO.
415
 */
416
static apalGpio_t _gpioSysSpiDir = {
417
  /* port */ GPIOC,
418
  /* pad  */ GPIOC_SYS_SPI_DIR,
419
};
420
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = {
421
  /* GPIO */ &_gpioSysSpiDir,
422
  /* meta */ {
423
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
424
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
425
    /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
426
  },
427
};
428

  
429
/**
430
 * @brief   SYS_SYNC bidirectional signal GPIO.
431
 */
432
static apalGpio_t _gpioSysSync = {
433
  /* port */ GPIOC,
434
  /* pad  */ GPIOC_SYS_INT_N,
435
};
436
ROMCONST apalControlGpio_t moduleGpioSysSync = {
437
  /* GPIO */ &_gpioSysSync,
438
  /* meta */ {
439
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
440
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
441
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
442
  },
443
};
444

  
445
/**
446
 * @brief   SYS_PD bidirectional signal GPIO.
447
 */
448
static apalGpio_t _gpioSysPd = {
449
  /* port */ GPIOC,
450
  /* pad  */ GPIOC_SYS_PD_N,
451
};
452
ROMCONST apalControlGpio_t moduleGpioSysPd = {
453
  /* GPIO */ &_gpioSysPd,
454
  /* meta */ {
455
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
456
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
457
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
458
  },
459
};
460

  
461
/**
462
 * @brief   SYS_WARMRST bidirectional signal GPIO.
463
 */
464
static apalGpio_t _gpioSysWarmrst = {
465
  /* port */ GPIOC,
466
  /* pad  */ GPIOC_SYS_WARMRST_N,
467
};
468
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = {
469
  /* GPIO */ &_gpioSysWarmrst,
470
  /* meta */ {
471
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
472
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
473
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
474
  },
475
};
476

  
477
/**
478
 * @brief   BT_RST output signal GPIO.
479
 */
480
static apalGpio_t _gpioBtRst = {
481
  /* port */ GPIOC,
482
  /* pad  */ GPIOC_BT_RST,
483
};
484
ROMCONST apalControlGpio_t moduleGpioBtRst = {
485
  /* GPIO */ &_gpioBtRst,
486
  /* meta */ {
487
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
488
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
489
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
490
  },
491
};
492

  
493
/**
494
 * @brief   CHARGE_EN2 output signal GPIO.
495
 */
496
static apalGpio_t _gpioChargeEn2 = {
497
  /* port */ GPIOD,
498
  /* pad  */ GPIOD_CHARGE_EN2_N,
499
};
500
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = {
501
  /* GPIO */ &_gpioChargeEn2,
502
  /* meta */ {
503
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
504
    /* active state   */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
505
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
506
  },
507
};
508

  
509
/** @} */
510 61

  
511 62
/*===========================================================================*/
512 63
/**
......
519 70
ROMCONST char* moduleShellPrompt = "PowerManagement";
520 71
#endif
521 72

  
522
/** @} */
523

  
524
#if (AMIROOS_CFG_SSSP_ENABLE == true)
525
/*===========================================================================*/
526
/**
527
 * @name Startup Shutdown Synchronization Protocol (SSSP)
528
 * @{
529
 */
530
/*===========================================================================*/
531

  
532
/** @} */
533
#endif
534

  
535
/*===========================================================================*/
536
/**
537
 * @name Low-level drivers
538
 * @{
539
 */
540
/*===========================================================================*/
541

  
542
AT24C01BNDriver moduleLldEeprom = {
543
  /* I2C driver   */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
544
  /* I2C address  */ AT24C01BN_LLD_I2C_ADDR_FIXED,
545
};
546

  
547
BQ24103ADriver moduleLldBatteryChargerFront = {
548
  /* charge enable GPIO */ &moduleGpioChargeEn1,
549
  /* charge status GPIO */ &moduleGpioChargeStat1A,
550
};
551

  
552
BQ24103ADriver moduleLldBatteryChargerRear = {
553
  /* charge enable GPIO */ &moduleGpioChargeEn2,
554
  /* charge status GPIO */ &moduleGpioChargeStat2A,
555
};
556

  
557
BQ27500Driver moduleLldFuelGaugeFront = {
558
  /* I2C driver         */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
559
  /* battery low GPIO   */ &moduleGpioGaugeBatLow1,
560
  /* battery good GPIO  */ &moduleGpioGaugeBatGd1,
561
};
562

  
563
BQ27500Driver moduleLldFuelGaugeRear = {
564
  /* I2C driver         */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
565
  /* battery low GPIO   */ &moduleGpioGaugeBatLow2,
566
  /* battery good GPIO  */ &moduleGpioGaugeBatGd2,
567
};
568

  
569
INA219Driver moduleLldPowerMonitorVdd = {
570
  /* I2C Driver       */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
571
  /* I²C address      */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
572
  /* current LSB (uA) */ 0x00u,
573
  /* configuration    */ NULL,
574
};
575

  
576
INA219Driver moduleLldPowerMonitorVio18 = {
577
  /* I2C Driver       */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
578
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
579
  /* current LSB (uA) */ 0x00u,
580
  /* configuration    */ NULL,
581
};
582

  
583
INA219Driver moduleLldPowerMonitorVio33 = {
584
  /* I2C Driver       */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
585
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
586
  /* current LSB (uA) */ 0x00u,
587
  /* configuration    */ NULL,
588
};
589

  
590
INA219Driver moduleLldPowerMonitorVsys42 = {
591
  /* I2C Driver       */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
592
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
593
  /* current LSB (uA) */ 0x00u,
594
  /* configuration    */ NULL,
595
};
596

  
597
INA219Driver moduleLldPowerMonitorVio50 = {
598
  /* I2C Driver       */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
599
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
600
  /* current LSB (uA) */ 0x00u,
601
  /* configuration    */ NULL,
602
};
603

  
604
LEDDriver moduleLldStatusLed = {
605
  /* LED GPIO */ &moduleGpioLed,
606
};
607

  
608
MPR121Driver moduleLldTouch = {
609
  /* I²C Driver */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
610
};
611 73

  
612
PCA9544ADriver moduleLldI2cMultiplexer1 = {
613
  /* I²C driver   */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
614
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
615
};
616

  
617
PCA9544ADriver moduleLldI2cMultiplexer2 = {
618
  /* I²C driver   */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
619
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
620
};
621

  
622
TPS62113Driver moduleLldStepDownConverter = {
623
  /* Power enable GPIO */ &moduleGpioPowerEn,
624
};
625

  
626
VCNL4020Driver moduleLldProximity1 = {
627
  /* I²C Driver */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
628
};
629

  
630
VCNL4020Driver moduleLldProximity2 = {
631
  /* I²C Driver */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
632
};
633

  
634
/** @} */
635

  
636
/*===========================================================================*/
637
/**
638
 * @name Unit tests (UT)
639
 * @{
640
 */
641
/*===========================================================================*/
642
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
643
#include <string.h>
644

  
645
/* ADC  */
646
static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[])
647
{
648
  (void)argc;
649
  (void)argv;
650
  aosUtRun(stream, &moduleUtAdcVsys, NULL);
651
  return AOS_OK;
652
}
653
static ut_adcdata_t _utAdcVsysData = {
654
  /* driver               */ &MODULE_HAL_ADC_VSYS,
655
  /* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
656
};
657
aos_unittest_t moduleUtAdcVsys = {
658
  /* name           */ "ADC",
659
  /* info           */ "VSYS",
660
  /* test function  */ utAdcFunc,
661
  /* shell command  */ {
662
    /* name     */ "unittest:ADC",
663
    /* callback */ _utShellCmdCb_Adc,
664
    /* next     */ NULL,
665
  },
666
  /* data           */ &_utAdcVsysData,
667
};
668

  
669
/* AT24C01BN-SH-B (EEPROM) */
670
static int _utShellCmdCb_AlldAt24c01bn(BaseSequentialStream* stream, int argc, char* argv[])
671
{
672
  (void)argc;
673
  (void)argv;
674
  aosUtRun(stream, &moduleUtAlldAt24c01bn, NULL);
675
  return AOS_OK;
676
}
677
static ut_at24c01bndata_t _utAlldAt24c01bnData = {
678
  /* driver   */ &moduleLldEeprom,
679
  /* timeout  */ MICROSECONDS_PER_SECOND,
680
};
681
aos_unittest_t moduleUtAlldAt24c01bn = {
682
  /* name           */ "AT24C01BN-SH-B",
683
  /* info           */ "1kbit EEPROM",
684
  /* test function  */ utAlldAt24c01bnFunc,
685
  /* shell command  */ {
686
    /* name     */ "unittest:EEPROM",
687
    /* callback */ _utShellCmdCb_AlldAt24c01bn,
688
    /* next     */ NULL,
689
  },
690
  /* data           */ &_utAlldAt24c01bnData,
691
};
692

  
693
/* BQ24103A (battery charger) */
694
static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[])
695
{
696
  // local variables
697
  bool print_help = false;
698

  
699
  // evaluate argument
700
  if (argc == 2) {
701
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
702
      moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront;
703
      aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
704
      moduleUtAlldBq24103a.data = NULL;
705
    }
706
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
707
      moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear;
708
      aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
709
      moduleUtAlldBq24103a.data = NULL;
710
    }
711
    else {
712
      print_help = true;
713
    }
714
  } else {
715
    print_help = true;
716
  }
717

  
718
  // print help or just return
719
  if (print_help) {
720
    chprintf(stream, "Usage: %s OPTION\n", argv[0]);
721
    chprintf(stream, "Options:\n");
722
    chprintf(stream, "  --front, -f\n");
723
    chprintf(stream, "    Test the front battery charger.\n");
724
    chprintf(stream, "  --rear, -r\n");
725
    chprintf(stream, "    Test the rear battery charger.\n");
726
    return AOS_INVALID_ARGUMENTS;
727
  } else {
728
    return AOS_OK;
729
  }
730
}
731
aos_unittest_t moduleUtAlldBq24103a = {
732
  /* name           */ "BQ24103A",
733
  /* info           */ "battery charger",
734
  /* test function  */ utAlldBq24103aFunc,
735
  /* shell command  */ {
736
    /* name     */ "unittest:BatteryCharger",
737
    /* callback */ _utShellCmdCb_AlldBq24103a,
738
    /* next     */ NULL,
739
  },
740
  /* data           */ NULL,
741
};
742

  
743
/* BQ27500 (fuel gauge) */
744
static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[])
745
{
746
  // evaluate arguments
747
  if (argc == 2) {
748
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
749
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront;
750
      aosUtRun(stream, &moduleUtAlldBq27500, "front battery");
751
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
752
      return AOS_OK;
753
    }
754
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
755
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear;
756
      aosUtRun(stream, &moduleUtAlldBq27500, "rear battery");
757
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
758
      return AOS_OK;
759
    }
760
  }
761
  // print help
762
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
763
  chprintf(stream, "Options:\n");
764
  chprintf(stream, "  --front, -f\n");
765
  chprintf(stream, "    Test the front battery fuel gauge.\n");
766
  chprintf(stream, "  --rear, -r\n");
767
  chprintf(stream, "    Test the rear battery fuel gauge.\n");
768
  return AOS_INVALID_ARGUMENTS;
769
}
770
static ut_bq27500data_t _utAlldBq27500Data = {
771
  /* driver   */ NULL,
772
  /* timeout  */ MICROSECONDS_PER_SECOND,
773
};
774
aos_unittest_t moduleUtAlldBq27500 = {
775
  /* name           */ "BQ27500",
776
  /* info           */ "fuel gauge",
777
  /* test function  */ utAlldBq27500Func,
778
  /* shell command  */ {
779
    /* name     */ "unittest:FuelGauge",
780
    /* callback */ _utShellCmdCb_AlldBq27500,
781
    /* next     */ NULL,
782
  },
783
  /* data           */ &_utAlldBq27500Data,
784
};
785

  
786
/* BQ27500 (fuel gauge) in combination with BQ24103A (battery charger) */
787
static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[])
788
{
789
  // evaluate arguments
790
  if (argc == 2) {
791
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
792
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront;
793
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = &moduleLldBatteryChargerFront;
794
      aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery");
795
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
796
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = NULL;
797
      return AOS_OK;
798
    }
799
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
800
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear;
801
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = &moduleLldBatteryChargerRear;
802
      aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery");
803
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
804
      ((ut_bq27500bq24103adata_t*)moduleUtAlldBq27500Bq24103a.data)->bq24103a = NULL;
805
      return AOS_OK;
806
    }
807
  }
808
  // print help
809
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
810
  chprintf(stream, "Options:\n");
811
  chprintf(stream, "  --front, -f\n");
812
  chprintf(stream, "    Test the front battery fuel gauge and charger.\n");
813
  chprintf(stream, "  --rear, -r\n");
814
  chprintf(stream, "    Test the rear battery fuel gauge and charger.\n");
815
  return AOS_INVALID_ARGUMENTS;
816
}
817
static ut_bq27500bq24103adata_t _utAlldBq27500Bq24103aData= {
818
  /* BQ27500 driver   */ NULL,
819
  /* BQ23203A driver  */ NULL,
820
  /* timeout          */ MICROSECONDS_PER_SECOND,
821
};
822
aos_unittest_t moduleUtAlldBq27500Bq24103a = {
823
  /* name           */ "BQ27500 & BQ24103A",
824
  /* info           */ "fuel gauge & battery charger",
825
  /* test function  */ utAlldBq27500Bq24103aFunc,
826
  /* shell command  */ {
827
    /* name     */ "unittest:FuelGauge&BatteryCharger",
828
    /* callback */ _utShellCmdCb_AlldBq27500Bq24103a,
829
    /* next     */ NULL,
830
  },
831
  /* data           */ &_utAlldBq27500Bq24103aData,
832
};
833

  
834
/* INA219 (power monitor) */
835
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
836
{
837
  // evaluate arguments
838
  if (argc == 2) {
839
    if (strcmp(argv[1], "VDD") == 0) {
840
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd;
841
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f;
842
      aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
843
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
844
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
845
      return AOS_OK;
846
    }
847
    else if (strcmp(argv[1], "VIO1.8") == 0) {
848
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18;
849
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f;
850
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)");
851
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
852
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
853
      return AOS_OK;
854
    }
855
    else if (strcmp(argv[1], "VIO3.3") == 0) {
856
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33;
857
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f;
858
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)");
859
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
860
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
861
      return AOS_OK;
862
    }
863
    else if (strcmp(argv[1], "VSYS4.2") == 0) {
864
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42;
865
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f;
866
      aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)");
867
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
868
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
869
      return AOS_OK;
870
    }
871
    else if (strcmp(argv[1], "VIO5.0") == 0) {
872
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50;
873
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f;
874
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)");
875
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
876
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
877
      return AOS_OK;
878
    }
879
  }
880
  // print help
881
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
882
  chprintf(stream, "Options:\n");
883
  chprintf(stream, "  VDD\n");
884
  chprintf(stream, "    Test VDD (3.3V) power monitor.\n");
885
  chprintf(stream, "  VIO1.8\n");
886
  chprintf(stream, "    Test VIO 1.8V power monitor.\n");
887
  chprintf(stream, "  VIO3.3\n");
888
  chprintf(stream, "    Test VIO 3.3V power monitor.\n");
889
  chprintf(stream, "  VSYS4.2\n");
890
  chprintf(stream, "    Test VSYS 4.2V power monitor.\n");
891
  chprintf(stream, "  VIO5.0\n");
892
  chprintf(stream, "    Test VIO 5.0V power monitor.\n");
893
  return AOS_INVALID_ARGUMENTS;
894
}
895
static ut_ina219data_t _utAlldIna219Data = {
896
  /* driver           */ NULL,
897
  /* expected voltage */ 0.0f,
898
  /* tolerance        */ 0.05f,
899
  /* timeout          */ MICROSECONDS_PER_SECOND,
900
};
901
aos_unittest_t moduleUtAlldIna219 = {
902
  /* name           */ "INA219",
903
  /* info           */ "power monitor",
904
  /* test function  */ utAlldIna219Func,
905
  /* shell command  */ {
906
    /* name     */ "unittest:PowerMonitor",
907
    /* callback */ _utShellCmdCb_AlldIna219,
908
    /* next     */ NULL,
909
  },
910
  /* data           */ &_utAlldIna219Data,
911
};
912

  
913
/* Status LED */
914
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
915
{
916
  (void)argc;
917
  (void)argv;
918
  aosUtRun(stream, &moduleUtAlldLed, NULL);
919
  return AOS_OK;
920
}
921
aos_unittest_t moduleUtAlldLed = {
922
  /* name           */ "LED",
923
  /* info           */ NULL,
924
  /* test function  */ utAlldLedFunc,
925
  /* shell command  */ {
926
    /* name     */ "unittest:StatusLED",
927
    /* callback */ _utShellCmdCb_AlldLed,
928
    /* next     */ NULL,
929
  },
930
  /* data           */ &moduleLldStatusLed,
931
};
932

  
933
/* MPR121 (touch sensor) */
934
static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[])
935
{
936
  (void)argc;
937
  (void)argv;
938
  aosUtRun(stream, &moduleUtAlldMpr121, NULL);
939
  return AOS_OK;
940
}
941
static ut_mpr121data_t _utAlldMpr121Data= {
942
  /* MPR121 driver  */ &moduleLldTouch,
943
  /* timeout        */ MICROSECONDS_PER_SECOND,
944
  /* event source   */ &aos.events.io,
945
  /* event flags    */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
946
};
947
aos_unittest_t moduleUtAlldMpr121 = {
948
  /* name           */ "MPR121",
949
  /* info           */ "touch sensor",
950
  /* test function  */ utAlldMpr121Func,
951
  /* shell command  */ {
952
    /* name     */ "unittest:Touch",
953
    /* callback */ _utShellCmdCb_AlldMpr121,
954
    /* next     */ NULL,
955
  },
956
  /* data           */ &_utAlldMpr121Data,
957
};
958

  
959
/* PCA9544A (I2C multiplexer) */
960
static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[])
961
{
962
  // evaluate arguments
963
  if (argc == 2) {
964
    if (strcmp(argv[1], "#1") == 0) {
965
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1;
966
      aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1");
967
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
968
      return AOS_OK;
969
    }
970
    else if (strcmp(argv[1], "#2") == 0) {
971
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2;
972
      aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2");
973
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
974
      return AOS_OK;
975
    }
976
  }
977
  // print help
978
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
979
  chprintf(stream, "Options:\n");
980
  chprintf(stream, "  #1\n");
981
  chprintf(stream, "    Test the multiplexer on the I2C bus #1.\n");
982
  chprintf(stream, "  #2\n");
983
  chprintf(stream, "    Test the multiplexer on the I2C bus #2.\n");
984
  return AOS_INVALID_ARGUMENTS;
985
}
986
static ut_pca9544adata_t _utAlldPca9544aData = {
987
  /* driver   */ NULL,
988
  /* timeout  */ MICROSECONDS_PER_SECOND,
989
};
990
aos_unittest_t moduleUtAlldPca9544a = {
991
  /* name           */ "PCA9544A",
992
  /* info           */ "I2C multiplexer",
993
  /* test function  */ utAlldPca9544aFunc,
994
  /* shell command  */ {
995
    /* name     */ "unittest:I2CMultiplexer",
996
    /* callback */ _utShellCmdCb_AlldPca5944a,
997
    /* next     */ NULL,
998
  },
999
  /* data           */ &_utAlldPca9544aData,
1000
};
1001

  
1002
/* PKLCS1212E4001 (buzzer) */
1003
static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[])
1004
{
1005
  (void)argc;
1006
  (void)argv;
1007
  aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL);
1008
  return AOS_OK;
1009
}
1010
static ut_pklcs1212e4001_t _utAlldPklcs1212e4001Data = {
1011
  /* PWM driver   */ &MODULE_HAL_PWM_BUZZER,
1012
  /* PWM channel  */ MODULE_HAL_PWM_BUZZER_CHANNEL
1013
};
1014
aos_unittest_t moduleUtAlldPklcs1212e4001 = {
1015
  /* name           */ "PKLCS1212E4001",
1016
  /* info           */ "buzzer",
1017
  /* test function  */ utAlldPklcs1212e4001Func,
1018
  /* shell command  */ {
1019
    /* name     */ "unittest:Buzzer",
1020
    /* callback */ _utShellCmdCb_AlldPklcs1212e4001,
1021
    /* next     */ NULL,
1022
  },
1023
  /* data           */ &_utAlldPklcs1212e4001Data,
1024
};
1025

  
1026
/* TPS62113 (stop-down converter) */
1027
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[])
1028
{
1029
  // Although there are four TPS62113 on the PCB, they all share the same input signal.
1030
  // A sa result, no additional shell arguments need to be evaluated.
1031
  (void)argc;
1032
  (void)argv;
1033
  aosUtRun(stream, &moduleUtAlldTps62113, NULL);
1034
  return AOS_OK;
1035
}
1036
aos_unittest_t moduleUtAlldTps62113 = {
1037
  /* name           */ "TPS62113",
1038
  /* info           */ "step-down converter",
1039
  /* test function  */ utAlldTps62113Func,
1040
  /* shell command  */ {
1041
    /* name     */ "unittest:StepDownConverter",
1042
    /* callback */ _utShellCmdCb_AlldTps62113,
1043
    /* next     */ NULL,
1044
  },
1045
  /* data           */ &moduleLldStepDownConverter,
1046
};
1047

  
1048
/* TPS62113 (step-donw converter) in combination with INA219 (power monitor) */
1049
static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[])
1050
{
1051
  (void)argc;
1052
  (void)argv;
1053
  aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)");
1054
  return AOS_OK;
1055
}
1056
static ut_tps62113ina219data_t _utAlldTps62113Ina219Data = {
1057
  /* TPS62113 */ &moduleLldStepDownConverter,
1058
  /* INA219   */ &moduleLldPowerMonitorVsys42,
1059
  /* timeout  */ MICROSECONDS_PER_SECOND,
1060
};
1061
aos_unittest_t moduleUtAlldTps62113Ina219 = {
1062
  /* name           */ "TPS62113 & INA219",
1063
  /* info           */ "step-down converter & power monitor",
1064
  /* test function  */ utAlldTps62113Ina219Func,
1065
  /* shell command  */ {
1066
    /* name     */ "unittest:StepDownConverter&PowerMonitor",
1067
    /* callback */ _utShellCmdCb_AlldTps62113Ina219,
1068
    /* next     */ NULL,
1069
  },
1070
  /* data           */ &_utAlldTps62113Ina219Data,
1071
};
1072

  
1073
/* VCNL4020 (proximity sensor) */
1074
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl)
1075
{
1076
  uint8_t intstatus;
1077
  vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1078
  vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1079
  if (intstatus) {
1080
    vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1081
  }
1082
  return;
1083
}
1084
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[])
1085
{
1086
  enum {
1087
    UNKNOWN,
1088
    NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW,
1089
  } sensor = UNKNOWN;
1090
  // evaluate arguments
1091
  if (argc == 2) {
1092
    if (strcmp(argv[1], "-nne") == 0) {
1093
      sensor = NNE;
1094
    } else if (strcmp(argv[1], "-ene") == 0) {
1095
      sensor = ENE;
1096
    } else if (strcmp(argv[1], "-ese") == 0) {
1097
      sensor = ESE;
1098
    } else if (strcmp(argv[1], "-sse") == 0) {
1099
      sensor = SSE;
1100
    } else if (strcmp(argv[1], "-ssw") == 0) {
1101
      sensor = SSW;
1102
    } else if (strcmp(argv[1], "-wsw") == 0) {
1103
      sensor = WSW;
1104
    } else if (strcmp(argv[1], "-wnw") == 0) {
1105
      sensor = WNW;
1106
    } else if (strcmp(argv[1], "-nnw") == 0) {
1107
      sensor = NNW;
1108
    }
1109
  }
1110
  if (sensor != UNKNOWN) {
1111
    PCA9544ADriver* mux = NULL;
1112
    switch (sensor) {
1113
      case SSE:
1114
      case SSW:
1115
      case WSW:
1116
      case WNW:
1117
        mux = &moduleLldI2cMultiplexer1;
1118
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1;
1119
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2;
1120
        break;
1121
      case NNW:
1122
      case NNE:
1123
      case ENE:
1124
      case ESE:
1125
        mux = &moduleLldI2cMultiplexer2;
1126
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2;
1127
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1;
1128
        break;
1129
      default:
1130
        break;
1131
    }
1132
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1133
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1134
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1135
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1136
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1137
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1138
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1139
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1140
    switch (sensor) {
1141
      case NNE:
1142
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1143
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
1144
        break;
1145
      case ENE:
1146
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1147
        aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
1148
        break;
1149
      case ESE:
1150
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1151
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
1152
        break;
1153
      case SSE:
1154
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1155
        aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
1156
        break;
1157
      case SSW:
1158
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1159
        aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
1160
        break;
1161
      case WSW:
1162
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1163
        aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
1164
        break;
1165
      case WNW:
1166
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1167
        aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
1168
        break;
1169
      case NNW:
1170
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1171
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
1172
        break;
1173
      default:
1174
        break;
1175
    }
1176
    ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL;
1177
    ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0;
1178
    return AOS_OK;
1179
  }
1180
  // print help
1181
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
1182
  chprintf(stream, "Options:\n");
1183
  chprintf(stream, "  -nne\n");
1184
  chprintf(stream, "    Test north-northeast sensor.\n");
1185
  chprintf(stream, "  -ene\n");
1186
  chprintf(stream, "    Test east-northeast sensor.\n");
1187
  chprintf(stream, "  -ese\n");
1188
  chprintf(stream, "    Test east-southeast sensor.\n");
1189
  chprintf(stream, "  -sse\n");
1190
  chprintf(stream, "    Test south-southeast sensor.\n");
1191
  chprintf(stream, "  -ssw\n");
1192
  chprintf(stream, "    Test south-southwest sensor.\n");
1193
  chprintf(stream, "  -wsw\n");
1194
  chprintf(stream, "    Test west-southwest sensor.\n");
1195
  chprintf(stream, "  -wnw\n");
1196
  chprintf(stream, "    Test west-northwest sensor.\n");
1197
  chprintf(stream, "  -nnw\n");
1198
  chprintf(stream, "    Test north-northwest sensor.\n");
1199
  return AOS_INVALID_ARGUMENTS;
1200
}
1201
static ut_vcnl4020data_t _utAlldVcnl4020Data = {
1202
  /* driver       */ NULL,
1203
  /* timeout      */ MICROSECONDS_PER_SECOND,
1204
  /* event source */ &aos.events.io,
1205
  /* event flags  */ 0,
1206
};
1207
aos_unittest_t moduleUtAlldVcnl4020 = {
1208
  /* name           */ "VCNL4020",
1209
  /* info           */ "proximity sensor",
1210
  /* test function  */ utAlldVcnl4020Func,
1211
  /* shell command  */ {
1212
    /* name     */ "unittest:Proximity",
1213
    /* callback */ _utShellCmdCb_AlldVcnl4020,
1214
    /* next     */ NULL,
1215
  },
1216
  /* data           */ &_utAlldVcnl4020Data,
1217
};
1218

  
1219
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
1220

  
1221
/** @} */
1222 74
/** @} */
modules/RT-STM32L476RG-NUCLEO64/module.h
72 72
#include <hal.h>
73 73

  
74 74
/**
75
 * @brief   ADC driver for reading the system voltage.
76
 */
77
#define MODULE_HAL_ADC_VSYS                     ADCD1
78

  
79
/**
80
 * @brief   Configuration for the ADC.
81
 */
82
//extern ADCConversionGroup moduleHalAdcVsysConversionGroup;
83

  
84
/**
85 75
 * @brief   CAN driver to use.
86 76
 */
87 77
#define MODULE_HAL_CAN                          CAND1
......
92 82
extern CANConfig moduleHalCanConfig;
93 83

  
94 84
/**
95
 * @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).
96
 */
97
//#define MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR I2CD1
98

  
99
/**
100
 * @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.
101
 */
102
//extern I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig;
103

  
104
/**
105
 * @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).
106
 */
107
#define MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT I2CD2
108

  
109
/**
110
 * @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.
111
 */
112
//extern I2CConfig moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig;
113

  
114
/**
115
 * @brief   PWM driver for the buzzer.
116
 */
117
//#define MODULE_HAL_PWM_BUZZER                   PWMD3
118

  
119
/**
120
 * @brief   Configuration of the PWM driver.
121
 */
122
//extern PWMConfig moduleHalPwmBuzzerConfig;
123

  
124
/**
125
 * @brief   PWM channeö for the buzzer.
126
 */
127
//#define MODULE_HAL_PWM_BUZZER_CHANNEL           1
128

  
129
/**
130 85
 * @brief   Serial driver of the programmer interface.
131 86
 */
132 87
#define MODULE_HAL_PROGIF                       SD2
......
172 127
extern ROMCONST apalControlGpio_t moduleGpioSysUartDn;
173 128

  
174 129
/**
175
 * @brief   CHARGE_STAT2A input signal GPIO.
176
 */
177
extern ROMCONST apalControlGpio_t moduleGpioChargeStat2A;
178

  
179
/**
180
 * @brief   GAUGE_BATLOW2 input signal GPIO.
181
 */
182
extern ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2;
183

  
184
/**
185
 * @brief   GAUGE_BATGD2 input signal GPIO.
186
 */
187
extern ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2;
188

  
189
/**
190 130
 * @brief   LED output signal GPIO.
191 131
 */
192 132
extern ROMCONST apalControlGpio_t moduleGpioLed;
......
197 137
extern ROMCONST apalControlGpio_t moduleGpioSysUartUp;
198 138

  
199 139
/**
200
 * @brief   CHARGE_STAT1A input signal GPIO.
201
 */
202
extern ROMCONST apalControlGpio_t moduleGpioChargeStat1A;
203

  
204
/**
205
 * @brief   GAUGE_BATLOW1 input signal GPIO.
206
 */
207
extern ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1;
208

  
209
/**
210
 * @brief   GAUGE_BATGD1 input signal GPIO.
211
 */
212
extern ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1;
213

  
214
/**
215
 * @brief   CHARG_EN1 output signal GPIO.
216
 */
217
extern ROMCONST apalControlGpio_t moduleGpioChargeEn1;
218

  
219
/**
220 140
 * @brief   IR_INT2 input signal GPIO.
221 141
 */
222 142
extern ROMCONST apalControlGpio_t moduleGpioIrInt2;
......
266 186
 */
267 187
extern ROMCONST apalControlGpio_t moduleGpioBtRst;
268 188

  
269
/**
270
 * @brief   CHARGE_EN2 output signal GPIO.
271
 */
272
extern ROMCONST apalControlGpio_t moduleGpioChargeEn2;
273 189

  
274 190
/** @} */
275 191

  
......
285 201
 */
286 202
#define MODULE_OS_IOEVENTFLAGS_IRINT1           ((eventflags_t)1 << GPIOB_IR_INT1_N)
287 203

  
288
/**
289
 * @brief   Event flag to be set on a GAUGE_BATLOW1 interrupt.
290
 */
291
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1     ((eventflags_t)1 << GPIOC_GAUGE_BATLOW1)
292

  
293
/**
294
 * @brief   Event flag to be set on a GAUGE_BATGD1 interrupt.
295
 */
296
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1      ((eventflags_t)1 << GPIOC_GAUGE_BATGD1_N)
297 204

  
298 205
/**
299 206
 * @brief   Event flag to be set on a SYS_UART_DN interrupt.
300 207
 */
301 208
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << GPIOB_SYS_UART_DN)
302 209

  
303
/**
304
 * @brief   Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
305
 */
306
#define MODULE_OS_IOEVENTFLAGS_IRINT2           ((eventflags_t)1 << GPIOC_IR_INT2_N)
307 210

  
308 211
/**
309 212
 * @brief   Event flag to be set on a TOUCH_INT interrupt.
310 213
 */
311 214
#define MODULE_OS_IOEVENTFLAGS_TOUCHINT         ((eventflags_t)1 << GPIOC_TOUCH_INT_N)
312 215

  
313
/**
314
 * @brief   Event flag to be set on a GAUGE_BATLOW2 interrupt.
315
 */
316
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2     ((eventflags_t)1 << GPIOB_GAUGE_BATLOW2)
317

  
318
/**
319
 * @brief   Event flag to be set on a GAUGE_BATGD2 interrupt.
320
 */
321
#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2      ((eventflags_t)1 << GPIOB_GAUGE_BATGD2_N)
322 216

  
323 217
/**
324 218
 * @brief   Event flag to be set on a PATH_DC interrupt.
......
357 251
extern ROMCONST char* moduleShellPrompt;
358 252
#endif
359 253

  
360
/**
361
 * @brief   Interrupt initialization macro.
362
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
363
 */
364
#define MODULE_INIT_INTERRUPTS() {                                            \
365
  /* IR_INT1 */                                                               \
366
  palSetPadCallback(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \
367
  palEnablePadEvent(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge));  \
368
  /* GAUGE_BATLOW2 */                                                         \
369
  palSetPadCallback(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, _intCallback, &moduleGpioGaugeBatLow2.gpio->pad);  \
370
  palEnablePadEvent(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow2.meta.edge));   \
371
  /* GAUGE_BATGD2 */                                                          \
372
  palSetPadCallback(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, _intCallback, &moduleGpioGaugeBatGd2.gpio->pad); \
373
  palEnablePadEvent(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd2.meta.edge));  \
374
  /* GAUGE_BATLOW1 */                                                         \
375
  palSetPadCallback(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, _intCallback, &moduleGpioGaugeBatLow1.gpio->pad);  \
376
  palEnablePadEvent(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow1.meta.edge));   \
377
  /* GAUGE_BATGD1 */                                                          \
378
  palSetPadCallback(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, _intCallback, &moduleGpioGaugeBatGd1.gpio->pad); \
379
  palEnablePadEvent(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd1.meta.edge));  \
380
  /* IR_INT1 */                                                               \
381
  palSetPadCallback(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \
382
  palEnablePadEvent(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge));  \
383
  /* TOUCH_INT */                                                             \
384
  palSetPadCallback(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, _intCallback, &moduleGpioTouchInt.gpio->pad); \
385
  palEnablePadEvent(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, APAL2CH_EDGE(moduleGpioTouchInt.meta.edge));  \
386
  /* PATH_DC */                                                               \
387
  palSetPadCallback(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, _intCallback, &moduleGpioPathDc.gpio->pad);  \
388
  palEnablePadEvent(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, APAL2CH_EDGE(moduleGpioPathDc.meta.edge));   \
389
  /* SYS_SPI_DIR */                                                           \
390
  palSetPadCallback(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, _intCallback, &moduleGpioSysSpiDir.gpio->pad); \
391
  palEnablePadEvent(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, APAL2CH_EDGE(moduleGpioSysSpiDir.meta.edge));  \
392
  /* SYS_WARMRST */                                                           \
393
  palSetPadCallback(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, _intCallback, &moduleGpioSysWarmrst.gpio->pad);  \
394
  palEnablePadEvent(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge));   \
395
}
396

  
397
/**
398
 * @brief   Unit test initialization hook.
399
 */
400
#define MODULE_INIT_TESTS() {                                                 \
401
  /* add unit-test shell commands */                                          \
402
  aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd);                  \
403
  aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd);            \
404
  aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd);             \
405
  aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd);              \
406
  aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd);      \
407
  aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd);               \
408
  aosShellAddCommand(&aos.shell, &moduleUtAlldMpr121.shellcmd);               \
409
  aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd);             \
410
  aosShellAddCommand(&aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd);       \
411
  aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd);                  \
412
  aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd);             \
413
  aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113Ina219.shellcmd);       \
414
  aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd);             \
415
}
416

  
417
/**
418
 * @brief   Periphery communication interfaces initialization hook.
419
 */
420
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
421
  /* serial driver */                                                         \
422
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
423
  /* I2C */                                                                   \
424
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
425
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
426
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
427
  moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed;  \
428
  moduleHalI2cProxPm18Pm33GaugeRearConfig.duty_cycle = (moduleHalI2cProxPm18Pm33GaugeRearConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
429
  i2cStart(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR, &moduleHalI2cProxPm18Pm33GaugeRearConfig); \
430
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (PCA9544A_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? PCA9544A_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
431
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (VCNL4020_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? VCNL4020_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
432
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (INA219_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? INA219_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
433
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
434
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (MPR121_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? MPR121_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
435
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed = (BQ27500_LLD_I2C_MAXFREQUENCY < moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed) ? BQ27500_LLD_I2C_MAXFREQUENCY : moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed; \
436
  moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.duty_cycle = (moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
437
  i2cStart(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT, &moduleHalI2cProxPm42Pm50PmVddEepromTouchGaugeFrontConfig);  \
438
  /* ADC */                                                                   \
439
  adcStart(&MODULE_HAL_ADC_VSYS, NULL);                                       \
440
  /* PWM */                                                                   \
441
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
442
  moduleHalPwmBuzzerConfig.frequency = MODULE_HAL_PWM_BUZZER.clock;           \
443
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
444
  moduleHalPwmBuzzerConfig.period = moduleHalPwmBuzzerConfig.frequency / PKLCS1212E4001_LLD_FREQUENCY_SPEC; \
445
  pwmStart(&MODULE_HAL_PWM_BUZZER, &moduleHalPwmBuzzerConfig);                \
446
}
447

  
448
/**
449
 * @brief   Periphery communication interface deinitialization hook.
450
 */
451
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
452
  /* PWM */                                                                   \
453
  pwmStop(&MODULE_HAL_PWM_BUZZER);                                            \
454
  /* ADC */                                                                   \
455
  adcStop(&MODULE_HAL_ADC_VSYS);                                              \
456
  /* I2C */                                                                   \
457
  i2cStop(&MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR);                          \
458
  i2cStop(&MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT);      \
459
  /* don't stop the serial driver so messages can still be printed */         \
460
}
461

  
462
/** @} */
463

  
464
#if (AMIROOS_CFG_SSSP_ENABLE == true)
465
/*===========================================================================*/
466
/**
467
 * @name Startup Shutdown Synchronization Protocol (SSSP)
468
 * @{
469
 */
470
/*===========================================================================*/
471

  
472
/**
473
 * @brief   PD signal GPIO.
474
 */
475
#define moduleSsspGpioPd                        moduleGpioSysPd
476

  
477
/**
478
 * @brief   SYNC signal GPIO.
479
 */
480
#define moduleSsspGpioSync                       moduleGpioSysSync
481

  
482
/**
483
 * @brief   DN signal GPIO.
484
 */
485
#define moduleSsspGpioDn                        moduleGpioSysUartDn
486

  
487
/**
488
 * @brief   UP signal GPIO.
489
 */
490
#define moduleSsspGpioUp                        moduleGpioSysUartUp
491

  
492
/**
493
 * @brief   Event flags for PD signal events.
494
 */
495
#define MODULE_SSSP_EVENTFLAGS_PD               MODULE_OS_IOEVENTFLAGS_SYSPD
496

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff