Revision 2347b2ff

View differences:

modules/PowerManagement_1-2/Makefile
155 155
include $(AMIROLLD)/drivers/LED/v1/alld_LED.mk
156 156
include $(AMIROLLD)/drivers/PCA9544A/v1/alld_PCA9544A.mk
157 157
include $(AMIROLLD)/drivers/PKxxxExxx/v1/alld_PKxxxExxx.mk
158
include $(AMIROLLD)/drivers/switch/v1/alld_switch.mk
158 159
include $(AMIROLLD)/drivers/TPS6211x/v1/alld_TPS6211x.mk
159 160
ifeq ($(BOARD_SENSORRING), BOARD_PROXIMITYSENSOR)
160 161
  include $(AMIROLLD)/drivers/MPR121/v1/alld_MPR121.mk
......
189 190
include $(MODULE_DIR)/test/LED/module_test_LED.mk
190 191
include $(MODULE_DIR)/test/PCA9544A/module_test_PCA9544A.mk
191 192
include $(MODULE_DIR)/test/PKxxxExxx/module_test_PKxxxExxx.mk
193
include $(MODULE_DIR)/test/switch/module_test_switch.mk
192 194
include $(MODULE_DIR)/test/TPS6211x/module_test_TPS6211x.mk
193 195
include $(MODULE_DIR)/test/TPS6211x_INA219/module_test_TPS6211x_INA219.mk
194 196
ifeq ($(BOARD_SENSORRING), BOARD_PROXIMITYSENSOR)
modules/PowerManagement_1-2/module.c
688 688
  /* LED GPIO */ &moduleGpioLed,
689 689
};
690 690

  
691
SwitchDriver moduleLldBatterySwitch = {
692
  /* GPIO */ &moduleGpioSwitchStatus,
693
};
694

  
691 695
TPS6211xDriver moduleLldStepDownConverter = {
692 696
  /* Power enable GPIO */ &moduleGpioPowerEn,
693 697
};
......
847 851
AOS_SHELL_COMMAND(moduleTestPkxxxexxxShellCmd, "test:Buzzer", _testPkxxxexxxShellCmdCb);
848 852

  
849 853
/*
854
 * switch
855
 */
856
#include <module_test_switch.h>
857
static int _testSwitchShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
858
{
859
  return moduleTestSwitchShellCb(stream, argc, argv, NULL);
860
}
861
AOS_SHELL_COMMAND(moduleTestSwitchShellCmd, "test:Switch", _testSwitchShellCmdCb);
862

  
863
/*
850 864
 * TPS62113 (step-down converter)
851 865
 */
852 866
#include <module_test_TPS6211x.h>
......
1033 1047
  status |= moduleTestPkxxxexxxShellCb(stream, 0, targv, &result_test);
1034 1048
  result_total = aosTestResultAdd(result_total, result_test);
1035 1049

  
1050
  /* battery switch */
1051
  status |= moduleTestSwitchShellCb(stream, 0, targv, &result_test);
1052
  result_total = aosTestResultAdd(result_total, result_test);
1053

  
1036 1054
  /* TPS62113 (step-down converter) */
1037 1055
  status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
1038 1056
  result_total = aosTestResultAdd(result_total, result_test);
modules/PowerManagement_1-2/module.h
444 444
  aosShellAddCommand(&aos.shell, &moduleTestBq27500Bq241xxShellCmd);          \
445 445
  aosShellAddCommand(&aos.shell, &moduleTestIna219ShellCmd);                  \
446 446
  aosShellAddCommand(&aos.shell, &moduleTestLedShellCmd);                     \
447
  aosShellAddCommand(&aos.shell, &moduleTestPkxxxexxxShellCmd);               \
447
  aosShellAddCommand(&aos.shell, &moduleTestSwitchShellCmd);                  \
448 448
  aosShellAddCommand(&aos.shell, &moduleTestTps6211xShellCmd);                \
449 449
  aosShellAddCommand(&aos.shell, &moduleTestTps6211xIna219ShellCmd);          \
450 450
  MODULE_INIT_TEST_SENSORRING();                                              \
......
573 573
#include <alld_INA219.h>
574 574
#include <alld_LED.h>
575 575
#include <alld_PKxxxExxx.h>
576
#include <alld_switch.h>
576 577
#include <alld_TPS6211x.h>
577 578

  
578 579
/**
......
631 632
extern LEDDriver moduleLldStatusLed;
632 633

  
633 634
/**
635
 * @brief   Battery switch driver.
636
 */
637
extern SwitchDriver moduleLldBatterySwitch;
638

  
639
/**
634 640
 * @brief   Step down converter driver.
635 641
 * @note    Although there multiple TPS6211x, those are completely identical from driver few (share the same signals).
636 642
 */
......
764 770
extern aos_shellcommand_t moduleTestPkxxxexxxShellCmd;
765 771

  
766 772
/**
773
 * @brief   Switch test command.
774
 */
775
extern aos_shellcommand_t moduleTestSwitchShellCmd;
776

  
777
/**
767 778
 * @brief   TPS62113 (step-down converter) test command.
768 779
 */
769 780
extern aos_shellcommand_t moduleTestTps6211xShellCmd;
modules/PowerManagement_1-2/test/switch/module_test_switch.c
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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_switch.h>
24
#include <aos_test_switch.h>
25

  
26
/******************************************************************************/
27
/* LOCAL DEFINITIONS                                                          */
28
/******************************************************************************/
29

  
30
/******************************************************************************/
31
/* EXPORTED VARIABLES                                                         */
32
/******************************************************************************/
33

  
34
/******************************************************************************/
35
/* LOCAL TYPES                                                                */
36
/******************************************************************************/
37

  
38
/******************************************************************************/
39
/* LOCAL VARIABLES                                                            */
40
/******************************************************************************/
41

  
42
static aos_test_switchdata_t _data = {
43
  /* switch */ &moduleLldBatterySwitch,
44
};
45

  
46
static AOS_TEST(_test, "switch", NULL, moduleTestSwitchShellCb, aosTestSwitchFunc, &_data);
47

  
48
/******************************************************************************/
49
/* LOCAL FUNCTIONS                                                            */
50
/******************************************************************************/
51

  
52
/******************************************************************************/
53
/* EXPORTED FUNCTIONS                                                         */
54
/******************************************************************************/
55

  
56
int moduleTestSwitchShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result)
57
{
58
  (void)argc;
59
  (void)argv;
60

  
61
  if (result != NULL) {
62
    *result = aosTestRun(stream, &_test, NULL);
63
  } else {
64
    aosTestRun(stream, &_test, NULL);
65
  }
66

  
67
  return AOS_OK;
68
}
69

  
70
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
modules/PowerManagement_1-2/test/switch/module_test_switch.h
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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

  
20
#ifndef MODULE_TEST_SWITCH_H
21
#define MODULE_TEST_SWITCH_H
22

  
23
#include <amiroos.h>
24

  
25
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
26

  
27
/******************************************************************************/
28
/* CONSTANTS                                                                  */
29
/******************************************************************************/
30

  
31
/******************************************************************************/
32
/* SETTINGS                                                                   */
33
/******************************************************************************/
34

  
35
/******************************************************************************/
36
/* CHECKS                                                                     */
37
/******************************************************************************/
38

  
39
/******************************************************************************/
40
/* DATA STRUCTURES AND TYPES                                                  */
41
/******************************************************************************/
42

  
43
/******************************************************************************/
44
/* MACROS                                                                     */
45
/******************************************************************************/
46

  
47
/******************************************************************************/
48
/* EXTERN DECLARATIONS                                                        */
49
/******************************************************************************/
50

  
51
#if defined(__cplusplus)
52
extern "C" {
53
#endif /* defined(__cplusplus) */
54
  int moduleTestSwitchShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result);
55
#if defined(__cplusplus)
56
}
57
#endif /* defined(__cplusplus) */
58

  
59
/******************************************************************************/
60
/* INLINE FUNCTIONS                                                           */
61
/******************************************************************************/
62

  
63
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
64

  
65
#endif /* MODULE_TEST_SWITCH_H */
66

  
modules/PowerManagement_1-2/test/switch/module_test_switch.mk
1
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2019  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

  
24

  
25

  
26
# path to this directory
27
MODULE_TEST_switch_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
28

  
29
include $(AMIROOS_TEST_DIR)periphery-lld/switch_v1/aos_test_switch.mk
30

  
31
# include paths
32
MODULE_INC += $(MODULE_TEST_switch_DIR:/=)
33

  
34
# C source files
35
MODULE_CSRC += $(MODULE_TEST_switch_DIR)module_test_switch.c
36

  
periphery-lld/AMiRo-LLD
1
Subproject commit 72369edc914c55785d0654e4aa5bee9a3aed9290
1
Subproject commit 96559ab4ee7dcdeb091a72795e821ef27bb72ed8
test/periphery-lld/LED_v1/aos_test_LED.h
16 16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
*/
18 18

  
19
#ifndef AMIROOS_TESTS_LED_H
20
#define AMIROOS_TESTS_LED_H
19
#ifndef AMIROOS_TEST_LED_H
20
#define AMIROOS_TEST_LED_H
21 21

  
22 22
#include <amiroos.h>
23 23

  
......
74 74

  
75 75
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
76 76

  
77
#endif /* AMIROOS_TESTS_LED_H */
77
#endif /* AMIROOS_TEST_LED_H */
test/periphery-lld/button_v1/aos_test_button.h
16 16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
*/
18 18

  
19
#ifndef AMIROOS_TESTS_BUTTON_H
20
#define AMIROOS_TESTS_BUTTON_H
19
#ifndef AMIROOS_TEST_BUTTON_H
20
#define AMIROOS_TEST_BUTTON_H
21 21

  
22 22
#include <amiroos.h>
23 23

  
......
83 83

  
84 84
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
85 85

  
86
#endif /* AMIROOS_TESTS_BUTTON_H */
86
#endif /* AMIROOS_TEST_BUTTON_H */
test/periphery-lld/button_v1/aos_test_button.mk
24 24

  
25 25

  
26 26
# path to this directory
27
AMIROOS_TEST_BUTTON_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
27
AMIROOS_TEST_button_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
28 28

  
29 29
# include path
30
AMIROOS_TEST_INC += $(AMIROOS_TEST_BUTTON_DIR)
30
AMIROOS_TEST_INC += $(AMIROOS_TEST_button_DIR)
31 31

  
32 32
# C sources
33
AMIROOS_TEST_CSRC += $(AMIROOS_TEST_BUTTON_DIR)aos_test_button.c
33
AMIROOS_TEST_CSRC += $(AMIROOS_TEST_button_DIR)aos_test_button.c
34 34

  
test/periphery-lld/switch_v1/aos_test_switch.c
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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
#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) */
test/periphery-lld/switch_v1/aos_test_switch.h
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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
#ifndef AMIROOS_TEST_SWITCH_H
20
#define AMIROOS_TEST_SWITCH_H
21

  
22
#include <amiroos.h>
23

  
24
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
25

  
26
#include <alld_switch.h>
27

  
28
/******************************************************************************/
29
/* CONSTANTS                                                                  */
30
/******************************************************************************/
31

  
32
/******************************************************************************/
33
/* SETTINGS                                                                   */
34
/******************************************************************************/
35

  
36
/******************************************************************************/
37
/* CHECKS                                                                     */
38
/******************************************************************************/
39

  
40
/******************************************************************************/
41
/* DATA STRUCTURES AND TYPES                                                  */
42
/******************************************************************************/
43

  
44
/**
45
 * @brief   Custom data structure for the test.
46
 */
47
typedef struct {
48
  /**
49
   * @brief   Pointer to the driver to use.
50
   */
51
  SwitchDriver* switchd;
52
} aos_test_switchdata_t;
53

  
54
/******************************************************************************/
55
/* MACROS                                                                     */
56
/******************************************************************************/
57

  
58
/******************************************************************************/
59
/* EXTERN DECLARATIONS                                                        */
60
/******************************************************************************/
61

  
62
#if defined(__cplusplus)
63
extern "C" {
64
#endif /* defined(__cplusplus) */
65
  aos_testresult_t aosTestSwitchFunc(BaseSequentialStream* stream, const aos_test_t* test);
66
#if defined(__cplusplus)
67
}
68
#endif /* defined(__cplusplus) */
69

  
70
/******************************************************************************/
71
/* INLINE FUNCTIONS                                                           */
72
/******************************************************************************/
73

  
74
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
75

  
76
#endif /* AMIROOS_TEST_SWITCH_H */
test/periphery-lld/switch_v1/aos_test_switch.mk
1
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2019  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

  
24

  
25

  
26
# path to this directory
27
AMIROOS_TEST_switch_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
28

  
29
# include path
30
AMIROOS_TEST_INC += $(AMIROOS_TEST_switch_DIR)
31

  
32
# C sources
33
AMIROOS_TEST_CSRC += $(AMIROOS_TEST_switch_DIR)aos_test_switch.c
34

  

Also available in: Unified diff