Skip to content

Commit 88281c8

Browse files
committed
Add AnalogIn potentiometer test for A0, A1 as present on the mbed application shield and automate MMA7660 test.
Various flags for platforms and tests.
1 parent 0d4c158 commit 88281c8

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "mbed.h"
2+
#include "test_env.h"
3+
4+
AnalogIn pot1(A0);
5+
AnalogIn pot2(A1);
6+
7+
#define TEST_ITERATIONS 20
8+
#define MEASURE_MIN 0.01
9+
10+
int main(void) {
11+
MBED_HOSTTEST_TIMEOUT(10);
12+
MBED_HOSTTEST_SELECT(default_auto);
13+
MBED_HOSTTEST_DESCRIPTION(AnalogIn potentiometer test);
14+
MBED_HOSTTEST_START("analog_pot");
15+
16+
bool result = false;
17+
float val1, val2;
18+
19+
for (int i = 0; i < TEST_ITERATIONS; i++) {
20+
val1 = pot1.read();
21+
val2 = pot2.read();
22+
23+
const char *succes_str = val1 > MEASURE_MIN || val2 > MEASURE_MIN ? "[OK]" : "[FAIL]";
24+
result = result || (val1 > MEASURE_MIN || val2 > MEASURE_MIN);
25+
printf("Pot values %f, %f\r\n", val1, val2);
26+
wait(0.001);
27+
}
28+
MBED_HOSTTEST_RESULT(result);
29+
}

libraries/tests/mbed/i2c_TMP102/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ TMP102 temperature(p28, p27, 0x90);
2525
defined(TARGET_NUCLEO_F411RE) || \
2626
defined(TARGET_NUCLEO_L053R8) || \
2727
defined(TARGET_NUCLEO_L152RE) || \
28-
defined(TARGET_LPC824)
28+
defined(TARGET_LPC824) || \
29+
defined(TARGET_FF_ARDUINO)
2930
TMP102 temperature(I2C_SDA, I2C_SCL, 0x90);
3031

3132
#else

libraries/tests/mbed/i2c_eeprom_line/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ I2C i2c(I2C_SDA0, I2C_SCL0);
6969
defined(TARGET_NUCLEO_F401RE) || \
7070
defined(TARGET_NUCLEO_F411RE) || \
7171
defined(TARGET_NUCLEO_L053R8) || \
72-
defined(TARGET_NUCLEO_L152RE)
72+
defined(TARGET_NUCLEO_L152RE) || \
73+
defined(TARGET_FF_ARDUINO)
7374
I2C i2c(I2C_SDA, I2C_SCL);
7475

7576
#else

libraries/tests/mbed/i2c_mma7660/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ MMA7660 MMA(p28, p27);
99
#endif
1010

1111
int main() {
12+
MBED_HOSTTEST_TIMEOUT(15);
13+
MBED_HOSTTEST_SELECT(default_auto);
14+
MBED_HOSTTEST_DESCRIPTION(I2C MMA7660 accelerometer);
15+
MBED_HOSTTEST_START("MBED_A13");
16+
1217
if (!MMA.testConnection())
13-
notify_completion(false);
18+
MBED_HOSTTEST_RESULT(false);
1419

1520
for(int i = 0; i < 5; i++) {
1621
printf("x: %f, y: %f, z: %f\r\n", MMA.x(), MMA.y(), MMA.z());
1722
wait(0.2);
1823
}
1924

20-
notify_completion(true);
25+
MBED_HOSTTEST_RESULT(true);
2126
}

workspace_tools/targets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ def __init__(self):
616616
self.core = "Cortex-M4F"
617617
self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG']
618618
self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
619+
self.supported_form_factors = ["ARDUINO"]
619620

620621
def program_cycle_s(self):
621622
return 2

workspace_tools/tests.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
* LPC1*: (p17 <-> p18 )
6060
* KL25Z: (PTE30 <-> PTC2)
6161
62+
* analog_pot (AnalogIn):
63+
* Arduino headers: (A0, A1)
64+
6265
* SD (SPI):
6366
* LPC1*: (mosi=p11 , miso=p12 , sclk=p13 , cs=p14 )
6467
* KL25Z: (mosi=PTD2, miso=PTD3, sclk=PTD1, cs=PTD0)
@@ -72,6 +75,7 @@
7275
* i2c_eeprom:
7376
* LPC1*: (SDA=p28 , SCL=p27)
7477
* KL25Z: (SDA=PTE0, SCL=PTE1)
78+
7579
"""
7680
TESTS = [
7781
# Automated MBED tests
@@ -165,9 +169,10 @@
165169
"peripherals": ["SD"]
166170
},
167171
{
168-
"id": "MBED_A13", "description": "I2C MMA7660",
172+
"id": "MBED_A13", "description": "I2C MMA7660 accelerometer",
169173
"source_dir": join(TEST_DIR, "mbed", "i2c_MMA7660"),
170174
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA7660')],
175+
"automated": True,
171176
"peripherals": ["MMA7660"]
172177
},
173178
{
@@ -251,6 +256,14 @@
251256
"automated": True,
252257
"duration": 10,
253258
},
259+
{
260+
"id": "MBED_A26", "description": "AnalogIn potentiometer test",
261+
"source_dir": join(TEST_DIR, "mbed", "analog_pot"),
262+
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
263+
"peripherals": ["analog_pot"],
264+
"automated": True,
265+
"duration": 10,
266+
},
254267
{
255268
"id": "MBED_BLINKY", "description": "Blinky",
256269
"source_dir": join(TEST_DIR, "mbed", "blinky"),

0 commit comments

Comments
 (0)