Skip to content

Commit e95ef36

Browse files
committed
Add header files to fpga tests, update test names
1 parent ed029d0 commit e95ef36

File tree

14 files changed

+543
-120
lines changed

14 files changed

+543
-120
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 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+
/** \addtogroup hal_analogin_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_ANALOG_IN_TEST_H
22+
#define MBED_FPGA_ANALOG_IN_TEST_H
23+
24+
#if DEVICE_ANALOGIN
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/** Test that the alalogin can be initialized using all possible analogin pins.
31+
*
32+
* Given board provides analogin support.
33+
* When analogin is initialized using valid analogin pin.
34+
* Then the operation is successfull.
35+
*
36+
*/
37+
void fpga_analogin_init_test(PinName pin);
38+
39+
/** Test that analogin correctly interprets given input voltage.
40+
*
41+
* Given board provides analogin support.
42+
* When 0.0/3.3 V is provided to analogin pin.
43+
* Then analogin_read returns 0.0/1.0,
44+
* analogin_read_u16 returns 0/65535.
45+
*
46+
*/
47+
void fpga_analogin_test(PinName pin);
48+
49+
50+
/**@}*/
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
56+
#endif
57+
58+
#endif
59+
60+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/analogin/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
#include "utest/utest.h"
2727
#include "unity/unity.h"
2828
#include "greentea-client/test_env.h"
29-
3029
#include "mbed.h"
3130
#include "pinmap.h"
3231
#include "test_utils.h"
3332
#include "MbedTester.h"
33+
#include "analogin_fpga_test.h"
3434

3535
using namespace utest::v1;
3636

@@ -44,14 +44,14 @@ const PinList *restricted = pinmap_restricted_pins();
4444

4545
MbedTester tester(form_factor, restricted);
4646

47-
void analogin_init(PinName pin)
47+
void fpga_analogin_init_test(PinName pin)
4848
{
4949
analogin_t analogin;
5050

5151
analogin_init(&analogin, pin);
5252
}
5353

54-
void analogin_test(PinName pin)
54+
void fpga_analogin_test(PinName pin)
5555
{
5656
tester.reset();
5757
tester.pin_map_set(pin, MbedTester::LogicalPinGPIO0);
@@ -76,9 +76,9 @@ void analogin_test(PinName pin)
7676

7777
Case cases[] = {
7878
// This will be run for all pins
79-
Case("AnalogIn - init test", all_ports<AnaloginPort, DefaultFormFactor, analogin_init>),
79+
Case("AnalogIn - init test", all_ports<AnaloginPort, DefaultFormFactor, fpga_analogin_init_test>),
8080
// This will be run for single pin
81-
Case("AnalogIn - read test", all_ports<AnaloginPort, DefaultFormFactor, analogin_test>),
81+
Case("AnalogIn - read test", all_ports<AnaloginPort, DefaultFormFactor, fpga_analogin_test>),
8282
};
8383

8484
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 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+
/** \addtogroup hal_gpio_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_GPIO_TEST_H
22+
#define MBED_FPGA_GPIO_TEST_H
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/** Test that the gpio works correctly.
29+
*
30+
* Given board provides gpio.
31+
* When gpio port is set as input port and logic 0/1 is provided on this port.
32+
* Then gpio_read returns 0/1.
33+
* When gpio port is set as output port and the output value is set to logic 0/1 by means of gpio_write.
34+
* Then we have logic 0/1 on output.
35+
*
36+
*/
37+
void fpga_gpio_inout_test();
38+
39+
/**@}*/
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
45+
#endif
46+
47+
48+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio/main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
#include "unity/unity.h"
2626
#include "greentea-client/test_env.h"
2727
#include "mbed.h"
28+
#include "MbedTester.h"
29+
#include "pinmap.h"
30+
#include "gpio_fpga_test.h"
2831

2932
using namespace utest::v1;
3033

31-
#include "MbedTester.h"
32-
#include "pinmap.h"
3334

3435
const PinList *form_factor = pinmap_ff_default_pins();
3536
const PinList *restricted = pinmap_restricted_pins();
@@ -64,7 +65,7 @@ void gpio_inout_test(PinName pin)
6465
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
6566
}
6667

67-
void gpio_inout_test()
68+
void fpga_gpio_inout_test()
6869
{
6970
for (int i = 0; i < form_factor->count; i++) {
7071
const PinName test_pin = form_factor->pins[i];
@@ -98,7 +99,7 @@ utest::v1::status_t teardown(const Case *const source, const size_t passed, cons
9899
}
99100

100101
Case cases[] = {
101-
Case("GPIO - inout", setup, gpio_inout_test, teardown),
102+
Case("GPIO - inout", setup, fpga_gpio_inout_test, teardown),
102103
};
103104

104105
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 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+
/** \addtogroup hal_gpioirq_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_GPIO_IRQ_TEST_H
22+
#define MBED_FPGA_GPIO_IRQ_TEST_H
23+
24+
#if DEVICE_INTERRUPTIN
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/** Test that the gpio interrupt is generated correctly.
31+
*
32+
* Given board provides interrupt-in feature.
33+
* When gpio interrupt is configured to fire on rasing/falling/both edge(s).
34+
* Then on rasing/falling/any edge registered interrupt handler is called.
35+
*
36+
*/
37+
void fpga_gpio_irq_test(PinName pin);
38+
39+
/**@}*/
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
45+
#endif
46+
47+
#endif
48+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
#include "unity/unity.h"
2828
#include "greentea-client/test_env.h"
2929
#include "mbed.h"
30+
#include "MbedTester.h"
31+
#include "pinmap.h"
32+
#include "gpio_irq_fpga_test.h"
3033

3134
using namespace utest::v1;
3235

33-
#include "mbed.h"
34-
#include "MbedTester.h"
35-
#include "pinmap.h"
3636

3737
static uint32_t call_counter;
3838
void test_gpio_irq_handler(uint32_t id, gpio_irq_event event)
@@ -47,7 +47,7 @@ MbedTester tester(form_factor, restricted);
4747
#define WAIT() wait_us(10)
4848

4949

50-
void gpio_irq_test(PinName pin)
50+
void fpga_gpio_irq_test(PinName pin)
5151
{
5252
gpio_t gpio;
5353
// configure pin as input
@@ -246,7 +246,7 @@ void gpio_irq_test(PinName pin)
246246
}
247247

248248

249-
void gpio_irq_test()
249+
void fpga_gpio_irq_test()
250250
{
251251
for (uint32_t i = 0; i < form_factor->count; i++) {
252252
const PinName test_pin = form_factor->pins[i];
@@ -261,7 +261,7 @@ void gpio_irq_test()
261261
tester.pin_map_set(test_pin, MbedTester::LogicalPinGPIO0);
262262

263263
printf("GPIO irq test on pin %3s (%3i)\r\n", pinmap_ff_default_pin_to_string(test_pin), test_pin);
264-
gpio_irq_test(test_pin);
264+
fpga_gpio_irq_test(test_pin);
265265
}
266266
}
267267

@@ -280,7 +280,7 @@ utest::v1::status_t teardown(const Case *const source, const size_t passed, cons
280280
}
281281

282282
Case cases[] = {
283-
Case("GPIO - irq test", setup, gpio_irq_test, teardown)
283+
Case("GPIO - irq test", setup, fpga_gpio_irq_test, teardown)
284284
};
285285

286286
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 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+
/** \addtogroup hal_GeneralI2C_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_I2C_TEST_H
22+
#define MBED_FPGA_I2C_TEST_H
23+
24+
#if DEVICE_I2C
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/** Test that the i2c-master can be initialized/de-initialized using all possible
31+
* i2c pins.
32+
*
33+
* Given board provides i2c-master support.
34+
* When i2c-master is initialized (and then de-initialized) using valid set of i2c pins.
35+
* Then the operation is successfull.
36+
*
37+
*/
38+
void fpga_test_i2c_init_free(PinName sda, PinName scl);
39+
40+
/** Test that I2C master is able to read data from I2C bus using i2c_byte_read.
41+
*
42+
* Given board provides I2C master support.
43+
* When I2C master reads data from I2C bus using i2c_byte_read.
44+
* Then data is successfully read.
45+
*
46+
*/
47+
void fpga_i2c_test_byte_read(PinName sda, PinName scl);
48+
49+
/** Test that I2C master is able to write data to I2C bus using i2c_byte_write.
50+
*
51+
* Given board provides I2C master support.
52+
* When I2C master writes data to the I2C bus using i2c_byte_write.
53+
* Then data is successfully transmitted.
54+
*
55+
*/
56+
void fpga_i2c_test_byte_write(PinName sda, PinName scl);
57+
58+
/** Test that I2C master is able to read data from I2C bus using i2c_read.
59+
*
60+
* Given board provides I2C master support.
61+
* When I2C master reads data from I2C bus using i2c_read.
62+
* Then data is successfully read.
63+
*
64+
*/
65+
void fpga_i2c_test_read(PinName sda, PinName scl);
66+
67+
/** Test that I2C master is able to write data to I2C bus using i2c_write.
68+
*
69+
* Given board provides I2C master support.
70+
* When I2C master writes data to the I2C bus using i2c_write.
71+
* Then data is successfully transmitted.
72+
*
73+
*/
74+
void fpga_i2c_test_write(PinName sda, PinName scl);
75+
76+
/**@}*/
77+
78+
#ifdef __cplusplus
79+
}
80+
#endif
81+
82+
#endif
83+
84+
#endif
85+
86+
/**@}*/

0 commit comments

Comments
 (0)