Skip to content

Commit d514b78

Browse files
jeromecoutantgpsimenos
authored andcommitted
[STD-PIN] hal-tests-tests-pin_names-arduino_uno
| B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A0 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A1 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A2 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A3 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A4 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | ADC A5 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A0 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A1 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A2 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A3 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A4 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO A5 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D0 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D1 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D10 | 1 | 0 | OK | 0.06 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D11 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D12 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D13 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D14 | 1 | 0 | OK | 0.06 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D15 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D2 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D3 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D4 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D5 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D6 | 1 | 0 | OK | 0.04 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D7 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D8 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | GPIO D9 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | I2C | 1 | 0 | OK | 0.06 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D10 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D11 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D3 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D5 | 1 | 0 | OK | 0.06 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D6 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | PWM D9 | 1 | 0 | OK | 0.05 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | SPI | 1 | 0 | OK | 0.08 | | B_L4S5I_IOT01A-ARMC6 | B_L4S5I_IOT01A | hal-tests-tests-pin_names-arduino_uno | UART | 1 | 0 | OK | 0.06 |
1 parent 5e50e3b commit d514b78

File tree

1 file changed

+300
-0
lines changed
  • hal/tests/TESTS/pin_names/arduino_uno

1 file changed

+300
-0
lines changed
Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
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+
// #if !TARGET_FF_ARDUINO_UNO
24+
#if !(defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO))
25+
#error [NOT_SUPPORTED] Test needs Arduino Uno form factor
26+
#else
27+
28+
#if defined (TARGET_FF_ARDUINO)
29+
#warning ARDUINO form factor should not be used any more => use ARDUINO_UNO
30+
#endif
31+
32+
using namespace utest::v1;
33+
34+
template <PinName TestedPin>
35+
void GPIO_test()
36+
{
37+
printf("Pin 0x%x\n", TestedPin);
38+
39+
TEST_SKIP_UNLESS_MESSAGE(TestedPin != (PinName)NC, "NC pin");
40+
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBTX, "USBTX pin");
41+
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBRX, "USBRX pin");
42+
43+
const PinMap *maps = gpio_pinmap(); // hal/source/mbed_gpio.c
44+
while (maps->pin != (PinName)NC) {
45+
// printf("map pin 0x%x\n", maps->pin);
46+
if (maps->pin == TestedPin) {
47+
{
48+
DigitalOut TEST1(maps->pin);
49+
TEST1 = !TEST1;
50+
}
51+
{
52+
DigitalIn TEST1(maps->pin);
53+
TEST1.read();
54+
}
55+
{
56+
DigitalInOut TEST1(maps->pin);
57+
TEST1.input();
58+
TEST1.output();
59+
}
60+
61+
TEST_ASSERT(true);
62+
return;
63+
}
64+
maps++;
65+
}
66+
TEST_ASSERT(false);
67+
}
68+
69+
70+
template <PinName TestedPin>
71+
void AnalogIn_test()
72+
{
73+
printf("Pin 0x%x\n", TestedPin);
74+
75+
const PinMap *maps = analogin_pinmap();
76+
while (maps->pin != (PinName)NC) {
77+
// printf("map pin 0x%x\n", maps->pin);
78+
if (maps->pin == TestedPin) {
79+
80+
AnalogIn TEST(TestedPin);
81+
TEST.read_u16();
82+
83+
TEST_ASSERT(true);
84+
return;
85+
}
86+
maps++;
87+
}
88+
TEST_ASSERT(false);
89+
}
90+
91+
92+
template <PinName TestedPin>
93+
void PWM_test()
94+
{
95+
printf("Pin 0x%x\n", TestedPin);
96+
97+
const PinMap *maps = pwmout_pinmap();
98+
while (maps->pin != (PinName)NC) {
99+
// printf("map pin 0x%x\n", maps->pin);
100+
if (maps->pin == TestedPin) {
101+
102+
PwmOut pwm(TestedPin);
103+
pwm.period(1.0f);
104+
pwm.write(0.5f);
105+
106+
TEST_ASSERT(true);
107+
return;
108+
}
109+
maps++;
110+
}
111+
112+
// PWM support is not mandatory
113+
TEST_SKIP_UNLESS_MESSAGE(false, "ARDUINO_UNO WARNING: NO PWM ");
114+
}
115+
116+
117+
template <PinName TX_pin, PinName RX_pin>
118+
void UART_test()
119+
{
120+
printf("TX Pin 0x%x RX Pin 0x%x\n", TX_pin, RX_pin);
121+
122+
TEST_SKIP_UNLESS_MESSAGE(TX_pin != USBTX, "USBTX pin");
123+
TEST_SKIP_UNLESS_MESSAGE(RX_pin != USBRX, "USBRX pin");
124+
125+
{
126+
const PinMap *maps = serial_tx_pinmap();
127+
while (maps->pin != (PinName)NC) {
128+
// printf("map pin 0x%x\n", maps->pin);
129+
if (maps->pin == TX_pin) {
130+
break;
131+
}
132+
maps++;
133+
}
134+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
135+
}
136+
{
137+
const PinMap *maps = serial_rx_pinmap();
138+
while (maps->pin != (PinName)NC) {
139+
// printf("map pin 0x%x\n", maps->pin);
140+
if (maps->pin == RX_pin) {
141+
break;
142+
}
143+
maps++;
144+
}
145+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
146+
}
147+
148+
BufferedSerial TEST(TX_pin, RX_pin);
149+
TEST.set_baud(115200);
150+
}
151+
152+
153+
template <PinName SDA_pin, PinName SCL_pin>
154+
void I2C_test()
155+
{
156+
printf("SDA Pin 0x%x SCL Pin 0x%x\n", SDA_pin, SCL_pin);
157+
158+
{
159+
const PinMap *maps = i2c_master_sda_pinmap();
160+
while (maps->pin != (PinName)NC) {
161+
// printf("map pin 0x%x\n", maps->pin);
162+
if (maps->pin == SDA_pin) {
163+
break;
164+
}
165+
maps++;
166+
}
167+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
168+
}
169+
{
170+
const PinMap *maps = i2c_master_scl_pinmap();
171+
while (maps->pin != (PinName)NC) {
172+
// printf("map pin 0x%x\n", maps->pin);
173+
if (maps->pin == SCL_pin) {
174+
break;
175+
}
176+
maps++;
177+
}
178+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
179+
}
180+
181+
I2C i2c(SDA_pin, SCL_pin);
182+
i2c.read(0);
183+
}
184+
185+
186+
template <PinName MOSI_pin, PinName MISO_pin, PinName CLK_pin, PinName CS_pin>
187+
void SPI_test()
188+
{
189+
printf("MOSI Pin 0x%x MISO Pin 0x%x CLOCK Pin 0x%x CS Pin0x%x\n", MOSI_pin, MISO_pin, CLK_pin, CS_pin);
190+
191+
{
192+
const PinMap *maps = spi_master_mosi_pinmap();
193+
while (maps->pin != (PinName)NC) {
194+
// printf("map pin 0x%x\n", maps->pin);
195+
if (maps->pin == MOSI_pin) {
196+
break;
197+
}
198+
maps++;
199+
}
200+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
201+
}
202+
{
203+
const PinMap *maps = spi_master_miso_pinmap();
204+
while (maps->pin != (PinName)NC) {
205+
// printf("map pin 0x%x\n", maps->pin);
206+
if (maps->pin == MISO_pin) {
207+
break;
208+
}
209+
maps++;
210+
}
211+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
212+
}
213+
{
214+
const PinMap *maps = spi_master_clk_pinmap();
215+
while (maps->pin != (PinName)NC) {
216+
// printf("map pin 0x%x\n", maps->pin);
217+
if (maps->pin == CLK_pin) {
218+
break;
219+
}
220+
maps++;
221+
}
222+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
223+
}
224+
{
225+
const PinMap *maps = gpio_pinmap(); // CS pin could be a simple GPIO
226+
while (maps->pin != (PinName)NC) {
227+
// printf("map pin 0x%x\n", maps->pin);
228+
if (maps->pin == CS_pin) {
229+
break;
230+
}
231+
maps++;
232+
}
233+
TEST_ASSERT_NOT_EQUAL(NC, maps->pin);
234+
}
235+
236+
SPI device(MOSI_pin, MISO_pin, CLK_pin);
237+
DigitalOut cs(CS_pin);
238+
device.frequency(10000000);
239+
}
240+
241+
242+
Case cases[] = {
243+
Case("GPIO A0", GPIO_test<ARDUINO_UNO_A0>),
244+
Case("GPIO A1", GPIO_test<ARDUINO_UNO_A1>),
245+
Case("GPIO A2", GPIO_test<ARDUINO_UNO_A2>),
246+
Case("GPIO A3", GPIO_test<ARDUINO_UNO_A3>),
247+
Case("GPIO A4", GPIO_test<ARDUINO_UNO_A4>),
248+
Case("GPIO A5", GPIO_test<ARDUINO_UNO_A5>),
249+
Case("GPIO D0", GPIO_test<ARDUINO_UNO_D0>),
250+
Case("GPIO D1", GPIO_test<ARDUINO_UNO_D1>),
251+
Case("GPIO D2", GPIO_test<ARDUINO_UNO_D2>),
252+
Case("GPIO D3", GPIO_test<ARDUINO_UNO_D3>),
253+
Case("GPIO D4", GPIO_test<ARDUINO_UNO_D4>),
254+
Case("GPIO D5", GPIO_test<ARDUINO_UNO_D5>),
255+
Case("GPIO D6", GPIO_test<ARDUINO_UNO_D6>),
256+
Case("GPIO D7", GPIO_test<ARDUINO_UNO_D7>),
257+
Case("GPIO D8", GPIO_test<ARDUINO_UNO_D8>),
258+
Case("GPIO D9", GPIO_test<ARDUINO_UNO_D9>),
259+
Case("GPIO D10", GPIO_test<ARDUINO_UNO_D10>),
260+
Case("GPIO D11", GPIO_test<ARDUINO_UNO_D11>),
261+
Case("GPIO D12", GPIO_test<ARDUINO_UNO_D12>),
262+
Case("GPIO D13", GPIO_test<ARDUINO_UNO_D13>),
263+
Case("GPIO D14", GPIO_test<ARDUINO_UNO_D14>),
264+
Case("GPIO D15", GPIO_test<ARDUINO_UNO_D15>),
265+
266+
Case("ADC A0", AnalogIn_test<ARDUINO_UNO_A0>),
267+
Case("ADC A1", AnalogIn_test<ARDUINO_UNO_A1>),
268+
Case("ADC A2", AnalogIn_test<ARDUINO_UNO_A2>),
269+
Case("ADC A3", AnalogIn_test<ARDUINO_UNO_A3>),
270+
Case("ADC A4", AnalogIn_test<ARDUINO_UNO_A4>),
271+
Case("ADC A5", AnalogIn_test<ARDUINO_UNO_A5>),
272+
273+
Case("PWM D3", PWM_test<ARDUINO_UNO_D3>),
274+
Case("PWM D5", PWM_test<ARDUINO_UNO_D5>),
275+
Case("PWM D6", PWM_test<ARDUINO_UNO_D6>),
276+
Case("PWM D9", PWM_test<ARDUINO_UNO_D9>),
277+
Case("PWM D10", PWM_test<ARDUINO_UNO_D10>),
278+
Case("PWM D11", PWM_test<ARDUINO_UNO_D11>),
279+
280+
Case("UART", UART_test<ARDUINO_UNO_UART_TX, ARDUINO_UNO_UART_RX>),
281+
282+
Case("I2C", I2C_test<ARDUINO_UNO_I2C_SDA, ARDUINO_UNO_I2C_SCL>),
283+
284+
Case("SPI", SPI_test<ARDUINO_UNO_SPI_MOSI, ARDUINO_UNO_SPI_MISO, ARDUINO_UNO_SPI_SCK, ARDUINO_UNO_SPI_CS>),
285+
};
286+
287+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
288+
{
289+
GREENTEA_SETUP(25, "default_auto");
290+
return greentea_test_setup_handler(number_of_cases);
291+
}
292+
293+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
294+
295+
int main()
296+
{
297+
Harness::run(specification);
298+
}
299+
300+
#endif

0 commit comments

Comments
 (0)