Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / test / bq241xx / module_test_bq241xx.c @ 96621a83

History | View | Annotate | Download (3.996 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 96621a83 Thomas Schöpping
Copyright (C) 2016..2020  Thomas Schöpping et al.
4 e545e620 Thomas Schöpping

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 ddf34c3d Thomas Schöpping
#include <amiroos.h>
20 e545e620 Thomas Schöpping
21 4c72a54c Thomas Schöpping
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
22
23
#include <module_test_bq241xx.h>
24
#include <aos_test_bq241xx.h>
25
#include <string.h>
26 ddf34c3d Thomas Schöpping
27 f3ac1c96 Thomas Schöpping
/******************************************************************************/
28
/* LOCAL DEFINITIONS                                                          */
29
/******************************************************************************/
30
31
/******************************************************************************/
32
/* EXPORTED VARIABLES                                                         */
33
/******************************************************************************/
34
35
/******************************************************************************/
36
/* LOCAL TYPES                                                                */
37
/******************************************************************************/
38
39
/******************************************************************************/
40
/* LOCAL VARIABLES                                                            */
41
/******************************************************************************/
42
43 4c72a54c Thomas Schöpping
static aos_test_bq241xxdata_t _data = {
44
  /* driver   */ NULL,
45
};
46
47
static AOS_TEST(_test, "bq24103a", "battery charger", moduleTestBq241xxShellCb, aosTestBq241xxFunc, &_data);
48
49 f3ac1c96 Thomas Schöpping
/******************************************************************************/
50
/* LOCAL FUNCTIONS                                                            */
51
/******************************************************************************/
52
53
/******************************************************************************/
54
/* EXPORTED FUNCTIONS                                                         */
55
/******************************************************************************/
56 e545e620 Thomas Schöpping
57 4c72a54c Thomas Schöpping
int moduleTestBq241xxShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result)
58 e545e620 Thomas Schöpping
{
59 4c72a54c Thomas Schöpping
  enum {
60
    UNKNOWN,
61
    FRONT, REAR,
62
  } charger = UNKNOWN;
63
64
  // evaluate argument
65
  if (argc == 2) {
66
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
67
      charger = FRONT;
68
    } else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
69
      charger = REAR;
70
    }
71 e545e620 Thomas Schöpping
  }
72
73 4c72a54c Thomas Schöpping
  // handle valid charger
74
  if (charger != UNKNOWN) {
75
    aos_testresult_t res = {0, 0};
76
77
    switch (charger) {
78
      case FRONT:
79
        _data.driver = &moduleLldBatteryChargerFront;
80
        res = aosTestRun(stream, &_test, "front battery");
81
        _data.driver = NULL;
82
        break;
83
      case REAR:
84
        _data.driver = &moduleLldBatteryChargerRear;
85
        res = aosTestRun(stream, &_test, "rear battery");
86
        _data.driver = NULL;
87
        break;
88
      default:
89
        break;
90
    }
91
    if (result != NULL) {
92
      *result = res;
93
    }
94
    return AOS_OK;
95 e545e620 Thomas Schöpping
  }
96 4c72a54c Thomas Schöpping
  // handle invalid arguments
97
  else {
98
    // print help
99
    chprintf(stream, "Usage: %s OPTION\n", argv[0]);
100
    chprintf(stream, "Options:\n");
101
    chprintf(stream, "  --front, -f\n");
102
    chprintf(stream, "    Test the front battery charger.\n");
103
    chprintf(stream, "  --rear, -r\n");
104
    chprintf(stream, "    Test the rear battery charger.\n");
105
    if (result != NULL) {
106
      result->passed = 0;
107
      result->failed = 0;
108
    }
109
    return AOS_INVALIDARGUMENTS;
110
   }
111 e545e620 Thomas Schöpping
}
112
113 4c72a54c Thomas Schöpping
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */