Skip to content

Commit 7aea44f

Browse files
committed
Add header files to fpga tests, update test names
1 parent 1bbcc8f commit 7aea44f

File tree

14 files changed

+585
-117
lines changed

14 files changed

+585
-117
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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 basic input & output operations.
29+
*
30+
* Given a GPIO instance initialized with a generic gpio_init() function,
31+
* when basic input and output operations are performed,
32+
* then all operations succeed.
33+
*/
34+
void fpga_test_basic_input_output(PinName pin);
35+
36+
/* Test explicit input initialization.
37+
*
38+
* Given a GPIO instance,
39+
* when additional parameters are passed to the input init function,
40+
* then the GPIO is correctly initialized as an input.
41+
*/
42+
void fpga_test_explicit_input(PinName pin);
43+
44+
/* Test explicit output initialization.
45+
*
46+
* Given a GPIO instance,
47+
* when additional parameters are passed to the output init function,
48+
* then the GPIO is correctly initialized as an output.
49+
*/
50+
void fpga_test_explicit_output(PinName pin);
51+
52+
/**@}*/
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif
59+
60+
61+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include "unity/unity.h"
2626
#include "greentea-client/test_env.h"
2727
#include "mbed.h"
28-
29-
using namespace utest::v1;
30-
3128
#include "MbedTester.h"
3229
#include "pinmap.h"
3330
#include "test_utils.h"
31+
#include "gpio_fpga_test.h"
32+
33+
using namespace utest::v1;
3434

3535
// This delay is used when reading a floating input that has an internal pull-up
3636
// or pull-down resistor. The voltage response is much slower when the input
@@ -45,7 +45,7 @@ MbedTester tester(DefaultFormFactor::pins(), DefaultFormFactor::restricted_pins(
4545
* when basic input and output operations are performed,
4646
* then all operations succeed.
4747
*/
48-
void test_basic_input_output(PinName pin)
48+
void fpga_test_basic_input_output(PinName pin)
4949
{
5050
// Reset everything and set all tester pins to hi-Z.
5151
tester.reset();
@@ -128,7 +128,7 @@ void test_basic_input_output(PinName pin)
128128
* when additional parameters are passed to the input init function,
129129
* then the GPIO is correctly initialized as an input.
130130
*/
131-
void test_explicit_input(PinName pin)
131+
void fpga_test_explicit_input(PinName pin)
132132
{
133133
// Reset everything and set all tester pins to hi-Z.
134134
tester.reset();
@@ -180,7 +180,7 @@ void test_explicit_input(PinName pin)
180180
* when additional parameters are passed to the output init function,
181181
* then the GPIO is correctly initialized as an output.
182182
*/
183-
void test_explicit_output(PinName pin)
183+
void fpga_test_explicit_output(PinName pin)
184184
{
185185
// Reset everything and set all tester pins to hi-Z.
186186
tester.reset();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 IRQ can be initialized/de-initialized using all possible
31+
* GPIO IRQ pins.
32+
*
33+
* Given board provides GPIO IRQ support.
34+
* When GPIO IRQ is initialized (and then de-initialized) using valid GPIO IRQ pin.
35+
* Then the operation is successfull.
36+
*
37+
*/
38+
void fpga_gpio_irq_test(PinName pin);
39+
40+
/** Test that the gpio interrupt is generated correctly.
41+
*
42+
* Given board provides interrupt-in feature.
43+
* When gpio interrupt is configured to fire on rasing/falling/both edge(s).
44+
* Then on rasing/falling/any edge registered interrupt handler is called.
45+
*
46+
*/
47+
void fpga_gpio_irq_init_free_test(PinName pin);
48+
49+
/**@}*/
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
55+
#endif
56+
57+
#endif
58+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
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

@@ -44,7 +47,7 @@ void test_gpio_irq_handler(uint32_t id, gpio_irq_event event)
4447

4548
#define WAIT() wait_us(10)
4649

47-
void gpio_irq_test(PinName pin)
50+
void fpga_gpio_irq_test(PinName pin)
4851
{
4952
// Reset everything and set all tester pins to hi-Z.
5053
tester.reset();
@@ -250,7 +253,7 @@ void gpio_irq_test(PinName pin)
250253
gpio_irq_free(&gpio_irq);
251254
}
252255

253-
void init_free_test(PinName pin)
256+
void fpga_gpio_irq_init_free_test(PinName pin)
254257
{
255258
gpio_t gpio;
256259
gpio_irq_t gpio_irq;
@@ -260,8 +263,8 @@ void init_free_test(PinName pin)
260263
}
261264

262265
Case cases[] = {
263-
Case("init/free", all_ports<GPIOIRQPort, DefaultFormFactor, init_free_test>),
264-
Case("rising & falling edge", all_ports<GPIOIRQPort, DefaultFormFactor, gpio_irq_test>),
266+
Case("init/free", all_ports<GPIOIRQPort, DefaultFormFactor, fpga_gpio_irq_init_free_test>),
267+
Case("rising & falling edge", all_ports<GPIOIRQPort, DefaultFormFactor, fpga_gpio_irq_test>),
265268
};
266269

267270
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)