Revision 4c72a54c modules/DiWheelDrive_1-1/module.c

View differences:

modules/DiWheelDrive_1-1/module.c
145 145
  /* GPIO */ &_gpioLed,
146 146
  /* meta */ {
147 147
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
148
    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
148
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
149 149
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
150 150
  },
151 151
};
......
415 415

  
416 416
/*===========================================================================*/
417 417
/**
418
 * @name Unit tests (UT)
418
 * @name Tests
419 419
 * @{
420 420
 */
421 421
/*===========================================================================*/
422 422
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
423
#include <string.h>
424 423

  
425 424
/*
426 425
 * A3906 (motor driver)
427 426
 */
428
static int _utShellCmdCb_AlldA3906(BaseSequentialStream* stream, int argc, char* argv[])
427
#include <module_test_A3906.h>
428
static int _testA3906ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
429 429
{
430
  (void)argc;
431
  (void)argv;
432
  aosUtRun(stream, &moduleUtAlldA3906, NULL);
433
  return AOS_OK;
430
  return moduleTestA3906ShellCb(stream, argc, argv, NULL);
434 431
}
435
static ut_a3906data_t _utA3906Data = {
436
  /* driver           */ &moduleLldMotors,
437
  /* PWM information  */ {
438
    /* driver   */ &MODULE_HAL_PWM_DRIVE,
439
    /* channels */ {
440
      /* left wheel forward   */ MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD,
441
      /* left wheel backward  */ MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD,
442
      /* right wheel forward  */ MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD,
443
      /* right wheel backward */ MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD,
444
    },
445
  },
446
  /* QEI information  */ {
447
    /* left wheel               */ &MODULE_HAL_QEI_LEFT_WHEEL,
448
    /* right wheel              */ &MODULE_HAL_QEI_RIGHT_WHEEL,
449
    /* increment per revolution */ MODULE_HAL_QEI_INCREMENTS_PER_REVOLUTION,
450
  },
451
  /* Wheel diameter   */ {
452
    /* left wheel   */ 0.05571f,
453
    /* right wheel  */ 0.05571f,
454
  },
455
  /* timeout          */ 10 * MICROSECONDS_PER_SECOND,
456
};
457
aos_unittest_t moduleUtAlldA3906  = {
458
  /* name           */ "A3906",
459
  /* info           */ "motor driver",
460
  /* test function  */ utAlldA3906Func,
461
  /* shell command  */ {
462
    /* name     */ "unittest:MotorDriver",
463
    /* callback */ _utShellCmdCb_AlldA3906,
464
    /* next     */ NULL,
465
  },
466
  /* data           */ &_utA3906Data,
467
};
432
AOS_SHELL_COMMAND(moduleTestA3906ShellCmd, "test:MotorDriver", _testA3906ShellCmdCb);
468 433

  
469 434
/*
470
 * AT24C01B (EEPROM)
435
 * AT24C01BN-SH-B (EEPROM)
471 436
 */
472
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[])
437
#include <module_test_AT24C01B.h>
438
static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
473 439
{
474
  (void)argc;
475
  (void)argv;
476
  aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
477
  return AOS_OK;
440
  return moduleTestAt24c01bShellCb(stream, argc, argv, NULL);
478 441
}
479
static ut_at24c01bdata_t _utAlldAt24c01bData = {
480
  /* driver   */ &moduleLldEeprom,
481
  /* timeout  */ MICROSECONDS_PER_SECOND,
482
};
483
aos_unittest_t moduleUtAlldAt24c01b = {
484
  /* name           */ "AT24C01B",
485
  /* info           */ "1kbit EEPROM",
486
  /* test function  */ utAlldAt24c01bFunc,
487
  /* shell command  */ {
488
    /* name     */ "unittest:EEPROM",
489
    /* callback */ _utShellCmdCb_AlldAt24c01b,
490
    /* next     */ NULL,
491
  },
492
  /* data           */ &_utAlldAt24c01bData,
493
};
442
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
494 443

  
495 444
/*
496 445
 * HMC5883L (compass)
497 446
 */
498
static int _utShellCmdCb_AlldHmc5883l(BaseSequentialStream* stream, int argc, char* argv[])
447
#include <module_test_HMC5883L.h>
448
static int _testHmc5883lShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
499 449
{
500
  (void)argc;
501
  (void)argv;
502
  aosUtRun(stream, &moduleUtAlldHmc5883l, NULL);
503
  return AOS_OK;
450
  return moduleTestHmc5883lShellCb(stream, argc, argv, NULL);
504 451
}
505
static ut_hmc5883ldata_t _utHmc5883lData = {
506
  /* HMC driver   */ &moduleLldCompass,
507
  /* event source */ &aos.events.io,
508
  /* event flags  */ MODULE_OS_IOEVENTFLAGS_COMPASSDRDY,
509
  /* timeout      */ MICROSECONDS_PER_SECOND,
510
};
511
aos_unittest_t moduleUtAlldHmc5883l = {
512
  /* name           */ "HMC5883L",
513
  /* info           */ "compass",
514
  /* test function  */ utAlldHmc5883lFunc,
515
  /* shell command  */ {
516
    /* name     */ "unittest:Compass",
517
    /* callback */ _utShellCmdCb_AlldHmc5883l,
518
    /* next     */ NULL,
519
  },
520
  /* data           */ &_utHmc5883lData,
521
};
452
AOS_SHELL_COMMAND(moduleTestHmc5883lShellCmd, "test:Compass", _testHmc5883lShellCmdCb);
522 453

  
523 454
/*
524 455
 * INA219 (power monitor)
525 456
 */
526
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
457
#include <module_test_INA219.h>
458
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
527 459
{
528
  (void)argc;
529
  (void)argv;
530
  aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
531
  return AOS_OK;
460
  return moduleTestIna219ShellCb(stream, argc, argv, NULL);
532 461
}
533
static ut_ina219data_t _utIna219Data = {
534
  /* driver           */ &moduleLldPowerMonitorVdd,
535
  /* expected voltage */ 3.3f,
536
  /* tolerance        */ 0.05f,
537
  /* timeout */ MICROSECONDS_PER_SECOND,
538
};
539
aos_unittest_t moduleUtAlldIna219 = {
540
  /* name           */ "INA219",
541
  /* info           */ "power monitor",
542
  /* test function  */ utAlldIna219Func,
543
  /* shell command  */ {
544
    /* name     */ "unittest:PowerMonitor",
545
    /* callback */ _utShellCmdCb_AlldIna219,
546
    /* next     */ NULL,
547
  },
548
  /* data           */ &_utIna219Data,
549
};
462
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
550 463

  
551 464
/*
552 465
 * L3G4200D (gyroscope)
553 466
 */
554
static int _utShellCmdCb_AlldL3g4200d(BaseSequentialStream* stream, int argc, char* argv[])
467
#include <module_test_L3G4200D.h>
468
static int _testL3g4200dShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
555 469
{
556
  (void)argc;
557
  (void)argv;
558
  spiStart(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid, ((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->spiconf);
559
  aosUtRun(stream, &moduleUtAlldL3g4200d, NULL);
560
  spiStop(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid);
561
  return AOS_OK;
470
  return moduleTestL3g4200dShellCb(stream, argc, argv, NULL);
562 471
}
563
static ut_l3g4200ddata_t _utL3g4200dData = {
564
  /* driver            */ &moduleLldGyroscope,
565
  /* SPI configuration */ &moduleHalSpiGyroscopeConfig,
566
  /* event source */ &aos.events.io,
567
  /* event flags  */ MODULE_OS_IOEVENTFLAGS_GYRODRDY,
568
};
569
aos_unittest_t moduleUtAlldL3g4200d = {
570
  /* name           */ "L3G4200D",
571
  /* info           */ "Gyroscope",
572
  /* test function  */ utAlldL3g4200dFunc,
573
  /* shell command  */ {
574
    /* name     */ "unittest:Gyroscope",
575
    /* callback */ _utShellCmdCb_AlldL3g4200d,
576
    /* next     */ NULL,
577
  },
578
  /* data           */ &_utL3g4200dData,
579
};
472
AOS_SHELL_COMMAND(moduleTestL3g4200dShellCmd, "test:Gyroscope", _testL3g4200dShellCmdCb);
580 473

  
581 474
/*
582 475
 * Status LED
583 476
 */
584
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
477
#include <module_test_LED.h>
478
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
585 479
{
586
  (void)argc;
587
  (void)argv;
588
  aosUtRun(stream, &moduleUtAlldLed, NULL);
589
  return AOS_OK;
480
  return moduleTestLedShellCb(stream, argc, argv, NULL);
590 481
}
591
aos_unittest_t moduleUtAlldLed = {
592
  /* name           */ "LED",
593
  /* info           */ NULL,
594
  /* test function  */ utAlldLedFunc,
595
  /* shell command  */ {
596
    /* name     */ "unittest:StatusLED",
597
    /* callback */ _utShellCmdCb_AlldLed,
598
    /* next     */ NULL,
599
  },
600
  /* data           */ &moduleLldStatusLed,
601
};
482
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
602 483

  
603 484
/*
604 485
 * LIS331DLH (accelerometer)
605 486
 */
606
static int _utShellCmdCb_AlldLis331dlh(BaseSequentialStream* stream, int argc, char* argv[])
487
#include <module_test_LIS331DLH.h>
488
static int _testLis331dlhShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
607 489
{
608
  (void)argc;
609
  (void)argv;
610
  spiStart(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid, ((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->spiconf);
611
  aosUtRun(stream, &moduleUtAlldLis331dlh, NULL);
612
  spiStop(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid);
613
  return AOS_OK;
490
  return moduleTestLis331dlhShellCb(stream, argc, argv, NULL);
614 491
}
615
static ut_lis331dlhdata_t _utLis331dlhData = {
616
  /* driver            */ &moduleLldAccelerometer,
617
  /* SPI configuration */ &moduleHalSpiAccelerometerConfig,
618
  /* event source */ &aos.events.io,
619
  /* event flags  */ MODULE_OS_IOEVENTFLAGS_ACCELINT,
620
};
621
aos_unittest_t moduleUtAlldLis331dlh = {
622
  /* name           */ "LIS331DLH",
623
  /* info           */ "Accelerometer",
624
  /* test function  */ utAlldLis331dlhFunc,
625
  /* shell command  */ {
626
    /* name     */ "unittest:Accelerometer",
627
    /* callback */ _utShellCmdCb_AlldLis331dlh,
628
    /* next     */ NULL,
629
  },
630
  /* data           */ &_utLis331dlhData,
631
};
492
AOS_SHELL_COMMAND(moduleTestLis331dlhShellCmd, "test:Accelerometer", _testLis331dlhShellCmdCb);
632 493

  
633 494
/*
634 495
 * LTC4412 (power path controller)
635 496
 */
636
static int _utShellCmdCb_AlldLtc4412(BaseSequentialStream* stream, int argc, char* argv[])
497
#include <module_test_LTC4412.h>
498
static int _testLtc4412ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
637 499
{
638
  (void)argc;
639
  (void)argv;
640
  aosUtRun(stream, &moduleUtAlldLtc4412, NULL);
641
  return AOS_OK;
500
  return moduleTestLtc4412ShellCb(stream, argc, argv, NULL);
642 501
}
643
aos_unittest_t moduleUtAlldLtc4412 = {
644
  /* name           */ "LTC4412",
645
  /* info           */ "Power path controller",
646
  /* test function  */ utAlldLtc4412Func,
647
  /* shell command  */ {
648
    /* name     */ "unittest:PowerPathController",
649
    /* callback */ _utShellCmdCb_AlldLtc4412,
650
    /* next     */ NULL,
651
  },
652
  /* data           */ &moduleLldPowerPathController,
653
};
502
AOS_SHELL_COMMAND(moduleTestLtc4412ShellCmd, "test:PowerPathController", _testLtc4412ShellCmdCb);
654 503

  
655 504
/*
656 505
 * PCA9544A (I2C multiplexer)
657 506
 */
658
static int _utShellCmdCb_AlldPca9544a(BaseSequentialStream* stream, int argc, char* argv[])
507
#include <module_test_PCA9544A.h>
508
static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
659 509
{
660
  (void)argc;
661
  (void)argv;
662
  aosUtRun(stream, &moduleUtAlldPca9544a, NULL);
663
  return AOS_OK;
510
  return moduleTestPca9544aShellCb(stream, argc, argv, NULL);
664 511
}
665
static ut_pca9544adata_t _utPca9544aData = {
666
  /* driver  */ &moduleLldI2cMultiplexer,
667
  /* timeout */ MICROSECONDS_PER_SECOND,
668
};
669
aos_unittest_t moduleUtAlldPca9544a = {
670
  /* name           */ "PCA9544A",
671
  /* info           */ "I2C multiplexer",
672
  /* test function  */ utAlldPca9544aFunc,
673
  /* shell command  */ {
674
    /* name     */ "unittest:I2CMultiplexer",
675
    /* callback */ _utShellCmdCb_AlldPca9544a,
676
    /* next     */ NULL,
677
  },
678
  /* data           */ &_utPca9544aData,
679
};
512
AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
680 513

  
681 514
/*
682 515
 * TPS62113 (step-down converter)
683 516
 */
684
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[])
517
#include <module_test_TPS6211x.h>
518
static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
685 519
{
686
  (void)argc;
687
  (void)argv;
688
  aosUtRun(stream, &moduleUtAlldTps62113, NULL);
689
  return AOS_OK;
520
  return moduleTestTps6211xShellCb(stream, argc, argv, NULL);
690 521
}
691
aos_unittest_t moduleUtAlldTps62113 = {
692
  /* name           */ "TPS62113",
693
  /* info           */ "Step down converter",
694
  /* test function  */ utAlldTps6211xFunc,
695
  /* shell command  */ {
696
    /* name     */ "unittest:StepDownConverter",
697
    /* callback */ _utShellCmdCb_AlldTps62113,
698
    /* next     */ NULL,
699
  },
700
  /* data           */ &moduleLldStepDownConverterVdrive,
701
};
522
AOS_SHELL_COMMAND(moduleTestTps62113ShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
702 523

  
703 524
/*
704 525
 * VCNL4020 (proximity sensor)
705 526
 */
706
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl)
527
#include <module_test_VCNL4020.h>
528
static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
707 529
{
708
  uint8_t intstatus;
709
  vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
710
  vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
711
  if (intstatus) {
712
    vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
713
  }
714
  return;
530
  return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL);
715 531
}
716
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[])
532
AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:ProximitySensor", _testVcnl4020ShellCmdCb);
533

  
534
/*
535
 * entire module
536
 */
537
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
717 538
{
718
  enum {
719
    UNKNOWN,
720
    FL, FR, WL, WR,
721
  } sensor = UNKNOWN;
722
  // evaluate arguments
723
  if (argc == 2) {
724
    if (strcmp(argv[1], "--frontleft") == 0 || strcmp(argv[1], "-fl") == 0) {
725
      sensor = FL;
726
    } else if (strcmp(argv[1], "--frontright") == 0 || strcmp(argv[1], "-fr") == 0) {
727
      sensor = FR;
728
    } else if (strcmp(argv[1], "--wheelleft") == 0 || strcmp(argv[1], "-wl") == 0) {
729
      sensor = WL;
730
    } else if (strcmp(argv[1], "--wheelright") == 0 || strcmp(argv[1], "-wr") == 0) {
731
      sensor = WR;
732
    }
733
  }
734
  if (sensor != UNKNOWN) {
735
    pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
736
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
737
    pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
738
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
739
    pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
740
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
741
    pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
742
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
743
    switch (sensor) {
744
      case FL:
745
        pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
746
        aosUtRun(stream, &moduleUtAlldVcnl4020, "front left sensor");
747
        break;
748
      case FR:
749
        pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
750
        aosUtRun(stream, &moduleUtAlldVcnl4020, "front right sensor");
751
        break;
752
      case WL:
753
        pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
754
        aosUtRun(stream, &moduleUtAlldVcnl4020, "left wheel sensor");
755
        break;
756
      case WR:
757
        pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
758
        aosUtRun(stream, &moduleUtAlldVcnl4020, "right wheel sensor");
759
        break;
760
      default:
761
        break;
762
    }
763
    return AOS_OK;
764
  }
765
  // print help
766
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
767
  chprintf(stream, "Options:\n");
768
  chprintf(stream, "  --frontleft, -fl\n");
769
  chprintf(stream, "    Test front left proximity sensor.\n");
770
  chprintf(stream, "  --frontrigt, -fr\n");
771
  chprintf(stream, "    Test front right proximity sensor.\n");
772
  chprintf(stream, "  --wheelleft, -wl\n");
773
  chprintf(stream, "    Test left wheel proximity sensor.\n");
774
  chprintf(stream, "  --wheelright, -wr\n");
775
  chprintf(stream, "    Test right wheel proximity sensor.\n");
776
  return AOS_INVALIDARGUMENTS;
539
  (void)argc;
540
  (void)argv;
541

  
542
  int status = AOS_OK;
543
  char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL};
544
  aos_testresult_t result_test = {0, 0};
545
  aos_testresult_t result_total = {0, 0};
546

  
547
  /* A3906 (motor driver) */
548
  status |= moduleTestA3906ShellCb(stream, 0, targv, &result_test);
549
  result_total = aosTestResultAdd(result_total, result_test);
550

  
551
  /* AT24C01B (EEPROM) */
552
  status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
553
  result_total = aosTestResultAdd(result_total, result_test);
554

  
555
  /* HMC5883L (compass) */
556
  status |= moduleTestHmc5883lShellCb(stream, 0, targv, &result_test);
557
  result_total = aosTestResultAdd(result_total, result_test);
558

  
559
  /* INA219 (power monitor) */
560
  status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
561
  result_total = aosTestResultAdd(result_total, result_test);
562

  
563
  /* L3G4200D (gyroscope) */
564
  status |= moduleTestL3g4200dShellCb(stream, 0, targv, &result_test);
565
  result_total = aosTestResultAdd(result_total, result_test);
566

  
567
  /* Status LED */
568
  status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
569
  result_total = aosTestResultAdd(result_total, result_test);
570

  
571
  /* LIS331DLH (accelerometer) */
572
  status |= moduleTestLis331dlhShellCb(stream, 0, targv, &result_test);
573
  result_total = aosTestResultAdd(result_total, result_test);
574

  
575
  /* LTC4412 (power path controller) */
576
  status |= moduleTestLtc4412ShellCb(stream, 0, targv, &result_test);
577
  result_total = aosTestResultAdd(result_total, result_test);
578

  
579
  /* PCA9544A (I2C multiplexer) */
580
  status |= moduleTestPca9544aShellCb(stream, 0, targv, &result_test);
581
  result_total = aosTestResultAdd(result_total, result_test);
582

  
583
  /* TPS62113 (step-down converter) */
584
  status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
585
  result_total = aosTestResultAdd(result_total, result_test);
586

  
587
  /* VCNL4020 (proximity sensor) */
588
  // wheel left
589
  targv[1] = "-wl";
590
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
591
  result_total = aosTestResultAdd(result_total, result_test);
592
  // front left
593
  targv[1] = "-fl";
594
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
595
  result_total = aosTestResultAdd(result_total, result_test);
596
  // front right
597
  targv[1] = "-fr";
598
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
599
  result_total = aosTestResultAdd(result_total, result_test);
600
  // wheel right
601
  targv[1] = "-wr";
602
  status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
603
  result_total = aosTestResultAdd(result_total, result_test);
604
  targv[1] = "";
605

  
606
  // print total result
607
  chprintf(stream, "\n");
608
  aosTestResultPrintSummary(stream, &result_total, "entire module");
609

  
610
  return status;
777 611
}
778
static ut_vcnl4020data_t _utVcnl4020Data = {
779
  /* driver       */ &moduleLldProximity,
780
  /* timeout      */ MICROSECONDS_PER_SECOND,
781
  /* event source */ &aos.events.io,
782
  /* event flags  */ MODULE_OS_IOEVENTFLAGS_IRINT,
783
};
784
aos_unittest_t moduleUtAlldVcnl4020 = {
785
  /* name           */ "VCNL4020",
786
  /* info           */ "proximity sensor",
787
  /* test function  */ utAlldVcnl4020Func,
788
  /* shell command  */ {
789
    /* name     */ "unittest:Proximity",
790
    /* callback */ _utShellCmdCb_AlldVcnl4020,
791
    /* next     */ NULL,
792
  },
793
  /* data           */ &_utVcnl4020Data,
794
};
612
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
795 613

  
796 614
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
797 615

  

Also available in: Unified diff