Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / LightRing_1-2 / test / MIC9404x / module_test_MIC9404x.c @ 96621a83

History | View | Annotate | Download (5.039 KB)

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

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
#include <amiroos.h>
20

    
21
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
22

    
23
#include <module_test_MIC9404x.h>
24
#include <aos_test_MIC9404x.h>
25
#include <string.h>
26

    
27
/******************************************************************************/
28
/* LOCAL DEFINITIONS                                                          */
29
/******************************************************************************/
30

    
31
/******************************************************************************/
32
/* EXPORTED VARIABLES                                                         */
33
/******************************************************************************/
34

    
35
/******************************************************************************/
36
/* LOCAL TYPES                                                                */
37
/******************************************************************************/
38

    
39
/******************************************************************************/
40
/* LOCAL VARIABLES                                                            */
41
/******************************************************************************/
42

    
43
static aos_test_mic9404data_t _data = {
44
  /* driver */ NULL,
45
};
46

    
47
static AOS_TEST(_test, "MIC9404x", "power switch", moduleTestMic9404xShellCb, aosTestMic9404xFunc, &_data);
48

    
49
/******************************************************************************/
50
/* LOCAL FUNCTIONS                                                            */
51
/******************************************************************************/
52

    
53
/******************************************************************************/
54
/* EXPORTED FUNCTIONS                                                         */
55
/******************************************************************************/
56

    
57
int moduleTestMic9404xShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result)
58
{
59
  enum {
60
    UNKNOWN,
61
    V18,
62
    V33,
63
// The 4.2V switch is disabled due to a hardware bug.
64
//  V42,
65
    V50,
66
    VSYS,
67
  } mic = UNKNOWN;
68

    
69
  // evaluate argument
70
  if (argc == 2) {
71
    if (strcmp(argv[1], "1.8V") == 0) {
72
      mic = V18;
73
    } else if (strcmp(argv[1], "3.3V") == 0) {
74
      mic = V33;
75
// The 4.2V switch is disabled due to a hardware bug.
76
//  } else if (strcmp(argv[1], "4.2V") == 0) {
77
//    mic = V42;
78
    } else if (strcmp(argv[1], "5.0V") == 0) {
79
      mic = V50;
80
    } else if (strcmp(argv[1], "VSYS") == 0) {
81
      mic = VSYS;
82
    }
83
  }
84

    
85
  // handle valid power switch
86
  if (mic != UNKNOWN) {
87
    aos_testresult_t res = {0, 0};
88

    
89
    switch (mic) {
90
      case V18:
91
        _data.driver = &moduleLldPowerSwitchV18;
92
        aosTestRun(stream, &_test, "1.8V");
93
        _data.driver = NULL;
94
        break;
95
      case V33:
96
        _data.driver = &moduleLldPowerSwitchV33;
97
        aosTestRun(stream, &_test, "3.3V");
98
        _data.driver = NULL;
99
        break;
100
// The 4.2V switch is disabled due to a hardware bug.
101
//    case V42:
102
//      _data.driver = &moduleLldPowerSwitchV42;
103
//      aosTestRun(stream, &_test, "4.2V");
104
//      _data.driver = NULL;
105
//      break;
106
      case V50:
107
        _data.driver = &moduleLldPowerSwitchV50;
108
        aosTestRun(stream, &_test, "5.0V");
109
        _data.driver = NULL;
110
        break;
111
      case VSYS:
112
        _data.driver = &moduleLldPowerSwitchVsys;
113
        aosTestRun(stream, &_test, "VSYS");
114
        _data.driver = NULL;
115
        break;
116
      default:
117
        break;
118
    }
119
    if (result != NULL) {
120
      *result = res;
121
    }
122
    return AOS_OK;
123
  }
124
  // handle invalid arguments
125
  else {
126
    // print help
127
    chprintf(stream, "Usage: %s OPTION\n", argv[0]);
128
    chprintf(stream, "Options:\n");
129
    chprintf(stream, "  1.8V\n");
130
    chprintf(stream, "    Test power switch for 1.8V supply.\n");
131
    chprintf(stream, "  3.3V\n");
132
    chprintf(stream, "    Test power switch for 3.3V supply.\n");
133
// The 4.2V switch is disabled due to a hardware bug.
134
//  chprintf(stream, "  4.2V\n");
135
//  chprintf(stream, "    Test power switch for 4.2V supply.\n");
136
    chprintf(stream, "  5.0V\n");
137
    chprintf(stream, "    Test power switch for 5.0V supply.\n");
138
    chprintf(stream, "  VSYS\n");
139
    chprintf(stream, "    Test power switch for VSYS supply.\n");
140
    if (result != NULL) {
141
      result->passed = 0;
142
      result->failed = 0;
143
    }
144
    return AOS_INVALIDARGUMENTS;
145
  }
146
}
147

    
148
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */