Statistics
| Branch: | Tag: | Revision:

amiro-os / test / periphery-lld / switch_v1 / aos_test_switch.c @ 8516dad6

History | View | Annotate | Download (3.426 KB)

1 2347b2ff 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 2347b2ff 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
#include <amiroos.h>
20
#include <aos_test_switch.h>
21
22
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
23
24
/******************************************************************************/
25
/* LOCAL DEFINITIONS                                                          */
26
/******************************************************************************/
27
28
#define INTERRUPT_EVENT_ID            1
29
30
/******************************************************************************/
31
/* EXPORTED VARIABLES                                                         */
32
/******************************************************************************/
33
34
/******************************************************************************/
35
/* LOCAL TYPES                                                                */
36
/******************************************************************************/
37
38
/******************************************************************************/
39
/* LOCAL VARIABLES                                                            */
40
/******************************************************************************/
41
42
/******************************************************************************/
43
/* LOCAL FUNCTIONS                                                            */
44
/******************************************************************************/
45
46
/******************************************************************************/
47
/* EXPORTED FUNCTIONS                                                         */
48
/******************************************************************************/
49
50
/**
51
 * @brief   Switch test function.
52
 *
53
 * @param[in] stream  Stream for input/output.
54
 * @param[in] test    Test object.
55
 *
56
 * @return            Test result value.
57
 */
58
aos_testresult_t aosTestSwitchFunc(BaseSequentialStream* stream, const aos_test_t* test)
59
{
60
  aosDbgCheck(test->data != NULL &&
61
      ((aos_test_switchdata_t*)test->data)->switchd != NULL);
62
63
  // local variables
64
  aos_testresult_t result;
65
  int32_t status;
66
  switch_lld_state_t state;
67
68
  aosTestResultInit(&result);
69
70
  chprintf(stream, "reading switch for ten seconds...\n");
71
  status = APAL_STATUS_OK;
72
  for (unsigned int sec = 0; sec < 10; ++sec) {
73
    status |= switch_lld_get(((aos_test_switchdata_t*)test->data)->switchd, &state);
74
    chprintf(stream, "\t\tswitch is %s\n", (state == SWITCH_LLD_STATE_ON) ? "on" : "off");
75
    aosThdSSleep(1);
76
  }
77
  if (status == APAL_STATUS_OK) {
78
    aosTestPassed(stream, &result);
79
  } else {
80
    aosTestFailedMsg(stream, &result, "0x08X\n", status);
81
  }
82
83
  aosTestInfoMsg(stream,"driver object memory footprint: %u bytes\n", sizeof(SwitchDriver));
84
85
  return result;
86
}
87
88
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */