Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / test / bq27500 / module_test_bq27500.c @ 96621a83

History | View | Annotate | Download (4.027 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_bq27500.h>
24
#include <aos_test_bq27500.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_bq27500data_t _data = {
44
  /* driver   */ NULL,
45
  /* timeout  */ MICROSECONDS_PER_SECOND,
46
};
47
48
static AOS_TEST(_test, "bq27500", "fuel gauge", moduleTestBq27500ShellCb, aosTestBq27500Func, &_data);
49
50 f3ac1c96 Thomas Schöpping
/******************************************************************************/
51
/* LOCAL FUNCTIONS                                                            */
52
/******************************************************************************/
53
54
/******************************************************************************/
55
/* EXPORTED FUNCTIONS                                                         */
56
/******************************************************************************/
57 e545e620 Thomas Schöpping
58 4c72a54c Thomas Schöpping
int moduleTestBq27500ShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result)
59 e545e620 Thomas Schöpping
{
60 4c72a54c Thomas Schöpping
  enum {
61
    UNKNOWN,
62
    FRONT, REAR,
63
  } charger = UNKNOWN;
64
65
  // evaluate argument
66
  if (argc == 2) {
67
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
68
      charger = FRONT;
69
    } else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
70
      charger = REAR;
71
    }
72 e545e620 Thomas Schöpping
  }
73
74 4c72a54c Thomas Schöpping
  // handle valid charger
75
  if (charger != UNKNOWN) {
76
    aos_testresult_t res = {0, 0};
77
78
    switch (charger) {
79
      case FRONT:
80
        _data.driver = &moduleLldFuelGaugeFront;
81
        res = aosTestRun(stream, &_test, "front battery");
82
        _data.driver = NULL;
83
        break;
84
      case REAR:
85
        _data.driver = &moduleLldFuelGaugeRear;
86
        res = aosTestRun(stream, &_test, "rear battery");
87
        _data.driver = NULL;
88
        break;
89
      default:
90
        break;
91
    }
92
    if (result != NULL) {
93
      *result = res;
94
    }
95
    return AOS_OK;
96 e545e620 Thomas Schöpping
  }
97 4c72a54c Thomas Schöpping
  // handle invalid arguments
98
  else {
99
    // print help
100
    chprintf(stream, "Usage: %s OPTION\n", argv[0]);
101
    chprintf(stream, "Options:\n");
102
    chprintf(stream, "  --front, -f\n");
103
    chprintf(stream, "    Test the front battery fuel gauge.\n");
104
    chprintf(stream, "  --rear, -r\n");
105
    chprintf(stream, "    Test the rear battery fuel gauge.\n");
106
    if (result != NULL) {
107
      result->passed = 0;
108
      result->failed = 0;
109
    }
110
    return AOS_INVALIDARGUMENTS;
111
   }
112 e545e620 Thomas Schöpping
}
113
114 4c72a54c Thomas Schöpping
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */