Skip to content

Commit 23e3bb3

Browse files
jeromecoutantgpsimenos
authored andcommitted
[STD-PIN] hal-tests-tests-pin_names-generic
| B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-generic | BUTTON1 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-generic | LED1 | 1 | 0 | OK | 1.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-generic | LED2 | 1 | 0 | OK | 1.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-generic | LED3 | 1 | 0 | OK | 1.04 |
1 parent a6c213b commit 23e3bb3

File tree

2 files changed

+100
-3
lines changed

2 files changed

+100
-3
lines changed

docs/design-documents/hal/0004-pin-names-general-guidelines.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ This allows for unavailable LEDs or BUTTONs to be caught in Mbed OS allowing the
148148

149149
### Testing compliance
150150

151-
There should be both compile and run time checks to confirm whether a board has valid LEDs and BUTTONS defined. This can be achieved by using Greentea, for example:
151+
A python script could check, during CI process, whether a board has valid LEDs and BUTTONS defined (none equal to NC, and no duplicated pin values).
152152

153-
mbed test -t <toolchain> -m <target> -n *test_generic_pin_names* --compile
154-
mbed test -t <toolchain> -m <target> -n *test_generic_pin_names* --run
153+
A Greentea test could check if LED and BUTTON pins are valid:
154+
155+
mbed test -t <toolchain> -m <target> -n hal-tests-tests-pin_names-generic
155156

156157
Note the testing of UART is implicit when running Greentea tests.
157158

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2020 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "utest/utest.h"
19+
#include "unity/unity.h"
20+
#include "greentea-client/test_env.h"
21+
#include "mbed.h"
22+
23+
#ifndef LED1
24+
// Set test as not supported, could be changed as error later
25+
#error [NOT_SUPPORTED] check docs/design-documents/hal/0004-pin-names-general-guidelines.md
26+
#else
27+
28+
using namespace utest::v1;
29+
30+
template <int LedId, PinName LedPin>
31+
void LED_test()
32+
{
33+
printf("LED %u Pin 0x%x\n", LedId, LedPin);
34+
DigitalOut TEST(LedPin);
35+
TEST = 1;
36+
ThisThread::sleep_for(1s);
37+
TEST = 0;
38+
}
39+
40+
41+
template <int ButtonId, PinName ButtonPin>
42+
void BUTTON_test()
43+
{
44+
printf("BUTTON %u Pin 0x%x\n", ButtonId, ButtonPin);
45+
DigitalIn TEST(ButtonPin);
46+
}
47+
48+
49+
Case cases[] = {
50+
#ifdef LED1
51+
Case("LED1", LED_test<1, LED1>),
52+
#endif
53+
#ifdef LED2
54+
Case("LED2", LED_test<2, LED2>),
55+
#endif
56+
#ifdef LED3
57+
Case("LED3", LED_test<3, LED3>),
58+
#endif
59+
#ifdef LED4
60+
Case("LED4", LED_test<4, LED4>),
61+
#endif
62+
#ifdef LED5
63+
Case("LED5", LED_test<5, LED5>),
64+
#endif
65+
#ifdef LED6
66+
Case("LED6", LED_test<6, LED6>),
67+
#endif
68+
#ifdef LED7
69+
Case("LED7", LED_test<7, LED7>),
70+
#endif
71+
#ifdef LED8
72+
Case("LED8", LED_test<8, LED8>),
73+
#endif
74+
75+
#ifdef BUTTON1
76+
Case("BUTTON1", BUTTON_test<1, BUTTON1>),
77+
#endif
78+
#ifdef BUTTON2
79+
Case("BUTTON2", BUTTON_test<2, BUTTON2>),
80+
#endif
81+
};
82+
83+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
84+
{
85+
GREENTEA_SETUP(20, "default_auto");
86+
return greentea_test_setup_handler(number_of_cases);
87+
}
88+
89+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
90+
91+
int main()
92+
{
93+
Harness::run(specification);
94+
}
95+
96+
#endif

0 commit comments

Comments
 (0)