From 88281c839e614b5d75993d777db4fa13ac62b4dd Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Fri, 20 Feb 2015 04:15:26 +0200 Subject: [PATCH] Add AnalogIn potentiometer test for A0, A1 as present on the mbed application shield and automate MMA7660 test. Various flags for platforms and tests. --- libraries/tests/mbed/analog_pot/main.cpp | 29 +++++++++++++++++++ libraries/tests/mbed/i2c_TMP102/main.cpp | 3 +- libraries/tests/mbed/i2c_eeprom_line/main.cpp | 3 +- libraries/tests/mbed/i2c_mma7660/main.cpp | 9 ++++-- workspace_tools/targets.py | 1 + workspace_tools/tests.py | 15 +++++++++- 6 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 libraries/tests/mbed/analog_pot/main.cpp diff --git a/libraries/tests/mbed/analog_pot/main.cpp b/libraries/tests/mbed/analog_pot/main.cpp new file mode 100644 index 0000000000..2f64bcbb6e --- /dev/null +++ b/libraries/tests/mbed/analog_pot/main.cpp @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "test_env.h" + +AnalogIn pot1(A0); +AnalogIn pot2(A1); + +#define TEST_ITERATIONS 20 +#define MEASURE_MIN 0.01 + +int main(void) { + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(AnalogIn potentiometer test); + MBED_HOSTTEST_START("analog_pot"); + + bool result = false; + float val1, val2; + + for (int i = 0; i < TEST_ITERATIONS; i++) { + val1 = pot1.read(); + val2 = pot2.read(); + + const char *succes_str = val1 > MEASURE_MIN || val2 > MEASURE_MIN ? "[OK]" : "[FAIL]"; + result = result || (val1 > MEASURE_MIN || val2 > MEASURE_MIN); + printf("Pot values %f, %f\r\n", val1, val2); + wait(0.001); + } + MBED_HOSTTEST_RESULT(result); +} diff --git a/libraries/tests/mbed/i2c_TMP102/main.cpp b/libraries/tests/mbed/i2c_TMP102/main.cpp index 067dfb7473..bab8d3b1da 100644 --- a/libraries/tests/mbed/i2c_TMP102/main.cpp +++ b/libraries/tests/mbed/i2c_TMP102/main.cpp @@ -25,7 +25,8 @@ TMP102 temperature(p28, p27, 0x90); defined(TARGET_NUCLEO_F411RE) || \ defined(TARGET_NUCLEO_L053R8) || \ defined(TARGET_NUCLEO_L152RE) || \ - defined(TARGET_LPC824) + defined(TARGET_LPC824) || \ + defined(TARGET_FF_ARDUINO) TMP102 temperature(I2C_SDA, I2C_SCL, 0x90); #else diff --git a/libraries/tests/mbed/i2c_eeprom_line/main.cpp b/libraries/tests/mbed/i2c_eeprom_line/main.cpp index 9e454c5e3d..2d87d3fa94 100644 --- a/libraries/tests/mbed/i2c_eeprom_line/main.cpp +++ b/libraries/tests/mbed/i2c_eeprom_line/main.cpp @@ -69,7 +69,8 @@ I2C i2c(I2C_SDA0, I2C_SCL0); defined(TARGET_NUCLEO_F401RE) || \ defined(TARGET_NUCLEO_F411RE) || \ defined(TARGET_NUCLEO_L053R8) || \ - defined(TARGET_NUCLEO_L152RE) + defined(TARGET_NUCLEO_L152RE) || \ + defined(TARGET_FF_ARDUINO) I2C i2c(I2C_SDA, I2C_SCL); #else diff --git a/libraries/tests/mbed/i2c_mma7660/main.cpp b/libraries/tests/mbed/i2c_mma7660/main.cpp index f6eb2fbb66..54b1687aa9 100644 --- a/libraries/tests/mbed/i2c_mma7660/main.cpp +++ b/libraries/tests/mbed/i2c_mma7660/main.cpp @@ -9,13 +9,18 @@ MMA7660 MMA(p28, p27); #endif int main() { + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(I2C MMA7660 accelerometer); + MBED_HOSTTEST_START("MBED_A13"); + if (!MMA.testConnection()) - notify_completion(false); + MBED_HOSTTEST_RESULT(false); for(int i = 0; i < 5; i++) { printf("x: %f, y: %f, z: %f\r\n", MMA.x(), MMA.y(), MMA.z()); wait(0.2); } - notify_completion(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/workspace_tools/targets.py b/workspace_tools/targets.py index da1fce138b..c7bdc52517 100644 --- a/workspace_tools/targets.py +++ b/workspace_tools/targets.py @@ -616,6 +616,7 @@ class ARCH_MAX(Target): self.core = "Cortex-M4F" self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG'] self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + self.supported_form_factors = ["ARDUINO"] def program_cycle_s(self): return 2 diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 9acadfa352..69ac530e83 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -59,6 +59,9 @@ Wiring: * LPC1*: (p17 <-> p18 ) * KL25Z: (PTE30 <-> PTC2) + * analog_pot (AnalogIn): + * Arduino headers: (A0, A1) + * SD (SPI): * LPC1*: (mosi=p11 , miso=p12 , sclk=p13 , cs=p14 ) * KL25Z: (mosi=PTD2, miso=PTD3, sclk=PTD1, cs=PTD0) @@ -72,6 +75,7 @@ Wiring: * i2c_eeprom: * LPC1*: (SDA=p28 , SCL=p27) * KL25Z: (SDA=PTE0, SCL=PTE1) + """ TESTS = [ # Automated MBED tests @@ -165,9 +169,10 @@ TESTS = [ "peripherals": ["SD"] }, { - "id": "MBED_A13", "description": "I2C MMA7660", + "id": "MBED_A13", "description": "I2C MMA7660 accelerometer", "source_dir": join(TEST_DIR, "mbed", "i2c_MMA7660"), "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA7660')], + "automated": True, "peripherals": ["MMA7660"] }, { @@ -251,6 +256,14 @@ TESTS = [ "automated": True, "duration": 10, }, + { + "id": "MBED_A26", "description": "AnalogIn potentiometer test", + "source_dir": join(TEST_DIR, "mbed", "analog_pot"), + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], + "peripherals": ["analog_pot"], + "automated": True, + "duration": 10, + }, { "id": "MBED_BLINKY", "description": "Blinky", "source_dir": join(TEST_DIR, "mbed", "blinky"),