diff --git a/TESTS/Level0/AnalogIn/AnalogIn.cpp b/TESTS/Level0/AnalogIn/AnalogIn.cpp index 82d62cd..22bf210 100644 --- a/TESTS/Level0/AnalogIn/AnalogIn.cpp +++ b/TESTS/Level0/AnalogIn/AnalogIn.cpp @@ -38,22 +38,27 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -utest::v1::control_t test_level0_analogin(const size_t call_count) { + +utest::v1::control_t test_level0_analogin(const size_t call_count) +{ PinMap pin = test_framework.get_increment_pin(TestFramework::AnalogInput); - DEBUG_PRINTF("Running analog input constructor on pin %d\n", pin.pin); - TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); + DEBUG_PRINTF("Running analog input constructor on pin %#x\n", pin.pin); + TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); AnalogIn ain(pin.pin); return test_framework.reset_iterator(TestFramework::AnalogInput); } + Case cases[] = { Case("Level 0 - Analog Input Constructor", test_level0_analogin, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/AnalogOut/AnalogOut.cpp b/TESTS/Level0/AnalogOut/AnalogOut.cpp index ac767c3..e208dc2 100644 --- a/TESTS/Level0/AnalogOut/AnalogOut.cpp +++ b/TESTS/Level0/AnalogOut/AnalogOut.cpp @@ -37,22 +37,27 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -utest::v1::control_t test_level0_analogout(const size_t call_count) { + +utest::v1::control_t test_level0_analogout(const size_t call_count) +{ PinMap pin = test_framework.get_increment_pin(TestFramework::AnalogOutput); - DEBUG_PRINTF("Running analog output constructor on pin %d\n", pin.pin); - TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); + DEBUG_PRINTF("Running analog output constructor on pin %#x\n", pin.pin); + TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); AnalogOut ain(pin.pin); return test_framework.reset_iterator(TestFramework::AnalogOutput); } + Case cases[] = { Case("Level 0 - Analog Output Constructor", test_level0_analogout, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/BusInOut/BusInOut.cpp b/TESTS/Level0/BusInOut/BusInOut.cpp index cf61a5c..cdfc13d 100644 --- a/TESTS/Level0/BusInOut/BusInOut.cpp +++ b/TESTS/Level0/BusInOut/BusInOut.cpp @@ -36,7 +36,9 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -utest::v1::control_t test_level0_businout(const size_t call_count) { + +utest::v1::control_t test_level0_businout(const size_t call_count) +{ DEBUG_PRINTF("Running bus input/output constructor\n"); std::vector pins; // vector of pins that the bus will contain @@ -45,18 +47,18 @@ utest::v1::control_t test_level0_businout(const size_t call_count) { if(TestFramework::check_size(TestFramework::BusIO)) { // fetch new pin pins.push_back(test_framework.get_increment_pin(TestFramework::BusIO).pin); - } + } - // if no more suitable pins are available, then add No-Connects until bus is full - else{ + // if no more suitable pins are available, then add No-Connects until bus is full + else { pins.push_back((PinName)NC); + } } - } - DEBUG_PRINTF("Pins assigned to bus:\n pin[0] = %d\n pin[1] = %d\n pin[2] = %d\n pin[3] = %d\n pin[4] = %d\n pin[5] = %d\n pin[6] = %d\n pin[7] = %d\n pin[8] = %d\n pin[9] = %d\n pin[10] = %d\n pin[11] = %d\n pin[12] = %d\n pin[13] = %d\n pin[14] = %d\n pin[15] = %d\n",pins[0],pins[1],pins[2],pins[3],pins[4],pins[5],pins[6],pins[7],pins[8],pins[9],pins[10],pins[11],pins[12],pins[13],pins[14],pins[15]); + DEBUG_PRINTF("Pins assigned to bus:\n pin[0] = %#x\n pin[1] = %#x\n pin[2] = %#x\n pin[3] = %#x\n pin[4] = %#x\n pin[5] = %#x\n pin[6] = %#x\n pin[7] = %#x\n pin[8] = %#x\n pin[9] = %#x\n pin[10] = %#x\n pin[11] = %#x\n pin[12] = %#x\n pin[13] = %#x\n pin[14] = %#x\n pin[15] = %#x\n",pins[0],pins[1],pins[2],pins[3],pins[4],pins[5],pins[6],pins[7],pins[8],pins[9],pins[10],pins[11],pins[12],pins[13],pins[14],pins[15]); - // construct the bus with assigned pins - BusInOut bio(pins[0],pins[1],pins[2],pins[3],pins[4],pins[5],pins[6],pins[7],pins[8],pins[9],pins[10],pins[11],pins[12],pins[13],pins[14],pins[15]); + // construct the bus with assigned pins + BusInOut bio(pins[0],pins[1],pins[2],pins[3],pins[4],pins[5],pins[6],pins[7],pins[8],pins[9],pins[10],pins[11],pins[12],pins[13],pins[14],pins[15]); return test_framework.reset_iterator(TestFramework::BusIO); } @@ -65,8 +67,9 @@ Case cases[] = { Case("Level 0 - Bus Input/Output Constructor", test_level0_businout, TestFramework::greentea_failure_handler), }; -int main() { +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/DigitalIO/DigitalIO.cpp b/TESTS/Level0/DigitalIO/DigitalIO.cpp index 30c1e58..f037f64 100644 --- a/TESTS/Level0/DigitalIO/DigitalIO.cpp +++ b/TESTS/Level0/DigitalIO/DigitalIO.cpp @@ -34,10 +34,12 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -utest::v1::control_t test_level0_digitalio(const size_t call_count) { + +utest::v1::control_t test_level0_digitalio(const size_t call_count) +{ PinMap pin = test_framework.get_increment_pin(TestFramework::DigitalIO); - DEBUG_PRINTF("Running digital io constructor on pin %d\n", pin.pin); - TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); + DEBUG_PRINTF("Running digital io constructor on pin %#x\n", pin.pin); + TEST_ASSERT_MESSAGE(pin.pin != NC, "Pin is NC"); DigitalOut dout(pin.pin); DigitalIn din(pin.pin); @@ -45,12 +47,15 @@ utest::v1::control_t test_level0_digitalio(const size_t call_count) { return test_framework.reset_iterator(TestFramework::DigitalIO); } + Case cases[] = { Case("Level 0 - DigitalIO Constructor", test_level0_digitalio, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/I2C/I2C.cpp b/TESTS/Level0/I2C/I2C.cpp index 04b351c..237d51d 100644 --- a/TESTS/Level0/I2C/I2C.cpp +++ b/TESTS/Level0/I2C/I2C.cpp @@ -38,24 +38,31 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void construct_i2c(PinName sda, PinName scl) { - DEBUG_PRINTF("Running I2C Constructor on SDA pin %d and SCL pin %d\n", sda, scl); - TEST_ASSERT_MESSAGE(sda != NC, "SDA Pin is NC"); - TEST_ASSERT_MESSAGE(scl != NC, "SCL Pin is NC"); - I2C i2c(sda, scl); +void construct_i2c(PinName sda, PinName scl) +{ + DEBUG_PRINTF("Running I2C Constructor on SDA pin %#x and SCL pin %#x\n", sda, scl); + TEST_ASSERT_MESSAGE(sda != NC, "SDA Pin is NC"); + TEST_ASSERT_MESSAGE(scl != NC, "SCL Pin is NC"); + + I2C i2c(sda, scl); } -utest::v1::control_t test_level0_i2c(const size_t call_count) { + +utest::v1::control_t test_level0_i2c(const size_t call_count) +{ return TestFramework::run_i2c(&construct_i2c); } + Case cases[] = { Case("Level 0 - I2C Constructor", test_level0_i2c, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/Pwm/Pwm.cpp b/TESTS/Level0/Pwm/Pwm.cpp index 4b80a61..9273eb2 100644 --- a/TESTS/Level0/Pwm/Pwm.cpp +++ b/TESTS/Level0/Pwm/Pwm.cpp @@ -38,24 +38,29 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -utest::v1::control_t test_level0_pwm(const size_t call_count) { + +utest::v1::control_t test_level0_pwm(const size_t call_count) +{ PinMap pin = test_framework.get_increment_pin(TestFramework::PWM); - DEBUG_PRINTF("Running pwm constructor on pin %d\n", pin.pin); - TEST_ASSERT_MESSAGE(pin.pin != NC, "pin is NC"); + DEBUG_PRINTF("Running PWM constructor on pin %#x\n", pin.pin); + TEST_ASSERT_MESSAGE(pin.pin != NC, "pin is NC"); PwmOut pwm(pin.pin); - pwm.period(1.0f); - pwm.write(0.5f); + pwm.period(1.0f); + pwm.write(0.5f); return test_framework.reset_iterator(TestFramework::PWM); } + Case cases[] = { Case("Level 0 - PWM Constructor", test_level0_pwm, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level0/SPI/SPI.cpp b/TESTS/Level0/SPI/SPI.cpp index 27d907f..fda5c3b 100644 --- a/TESTS/Level0/SPI/SPI.cpp +++ b/TESTS/Level0/SPI/SPI.cpp @@ -38,27 +38,34 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void construct_spi(PinName pin_clk, PinName pin_miso, PinName pin_mosi, PinName pin_cs) { - DEBUG_PRINTF("Running SPI constructor on CLK pin %d, MISO pin %d, MOSI pin %d, and CS pin %d\n", pin_clk, pin_miso, pin_mosi, pin_cs); - TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); - TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); - TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); - TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); - SPI(pin_mosi, pin_miso, pin_clk); - DigitalOut cs(pin_cs); +void construct_spi(PinName pin_clk, PinName pin_miso, PinName pin_mosi, PinName pin_cs) +{ + DEBUG_PRINTF("Running SPI constructor on CLK pin %#x, MISO pin %#x, MOSI pin %#x, and CS pin %#x\n", pin_clk, pin_miso, pin_mosi, pin_cs); + TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); + TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); + TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); + TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); + + SPI(pin_mosi, pin_miso, pin_clk); + DigitalOut cs(pin_cs); } -utest::v1::control_t test_level0_spi(const size_t call_count) { + +utest::v1::control_t test_level0_spi(const size_t call_count) +{ return test_framework.run_spi(&construct_spi); } + Case cases[] = { Case("Level 0 - SPI Constructor", test_level0_spi, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<60>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level1/AnalogIn/AnalogIn.cpp b/TESTS/Level1/AnalogIn/AnalogIn.cpp index 13718b2..d29bb8f 100644 --- a/TESTS/Level1/AnalogIn/AnalogIn.cpp +++ b/TESTS/Level1/AnalogIn/AnalogIn.cpp @@ -29,6 +29,8 @@ #include "TestFramework.hpp" #include +#define BUS_SIZE 5 + using namespace utest::v1; // Static variables for managing the dynamic list of pins @@ -38,66 +40,69 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void test_analogin_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running analog input range test on pin %d\n", pin); - TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); +void test_analogin_execute(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running analog input range test on pin %#x\n", pin); + TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); - // Find all pins on the resistor ladder that are not the current pin + // Find all pins on the resistor ladder that are not the current pin std::vector resistor_ladder_pins = TestFramework::find_resistor_ladder_pins(pin); - if (resistor_ladder_pins.size() < 5) - TEST_ASSERT_MESSAGE(false, "Error finding the resistor ladder pins"); + if (resistor_ladder_pins.size() < BUS_SIZE){ + TEST_ASSERT_MESSAGE(false, "Error finding the resistor ladder pins"); + } // Create a bus with all of these pins - BusInOut outputs(resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); + BusInOut outputs(resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); outputs.output(); - DEBUG_PRINTF("Creating a resistive ladder bus with the following pins:\n pin[0] = %d\n pin[1] = %d\n pin[2] = %d\n pin[3] = %d\n pin[4] = %d\n", resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); + DEBUG_PRINTF("Creating a resistive ladder bus with the following pins:\n pin[0] = %#x\n pin[1] = %#x\n pin[2] = %#x\n pin[3] = %#x\n pin[4] = %#x\n", resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); - // construct designated analogIn pin + // construct designated analogIn pin AnalogIn ain(pin); - for (unsigned int i=0; i prev_value,"Analog Input did not increment. Check that you have assigned valid pins in mbed_app.json file") - - // Repeat the read multiple times to verify the output is not fluctuating - for (unsigned int j = 0; j prev_value,"Analog Input did not increment. Check that you have assigned valid pins in mbed_app.json file") + + // Repeat the read multiple times to verify the output is not fluctuating + for (unsigned int j = 0; j, cases); - return !Harness::run(specification); +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); + return !Harness::run(specification); } diff --git a/TESTS/Level1/AnalogOut/AnalogOut.cpp b/TESTS/Level1/AnalogOut/AnalogOut.cpp index 36a55dc..47407f2 100644 --- a/TESTS/Level1/AnalogOut/AnalogOut.cpp +++ b/TESTS/Level1/AnalogOut/AnalogOut.cpp @@ -38,25 +38,25 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void test_analogout_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running analog output range test on pin %d\n", pin); +void test_analogout_execute(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running analog output range test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); // Find all pins on the resistor ladder that are not the current pin std::vector resistor_ladder_pins = TestFramework::find_resistor_ladder_pins(pin); - if (resistor_ladder_pins.size() < 5) - TEST_ASSERT_MESSAGE(false, "Error finding the resistor ladder pins"); - - AnalogIn ain(resistor_ladder_pins[0]); + if (resistor_ladder_pins.size() < 5){ + TEST_ASSERT_MESSAGE(false, "Error finding the resistor ladder pins"); + } + AnalogIn ain(resistor_ladder_pins[0]); // Repeat to guarentee consistency - for (unsigned int i=0; i, cases); +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); } diff --git a/TESTS/Level1/BusInOut/BusInOut.cpp b/TESTS/Level1/BusInOut/BusInOut.cpp index c76f8e8..ebfcee3 100644 --- a/TESTS/Level1/BusInOut/BusInOut.cpp +++ b/TESTS/Level1/BusInOut/BusInOut.cpp @@ -34,11 +34,13 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void test_busio_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running analog input range test on pin %d\n", pin); +void test_busio_execute(PinName pin, float tolerance, int iterations) +{ TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); PinName pin_pair = TestFramework::find_pin_pair(pin); + DEBUG_PRINTF("Running BusIO test on pin %#x and its pin-pair %#x", pin, pin_pair); + BusInOut bio1(pin); BusInOut bio2(pin_pair); @@ -50,16 +52,19 @@ void test_busio_execute(PinName pin, float tolerance, int iterations) { TEST_ASSERT_MESSAGE(bio2.read()==1, "Value read on bus does not equal value written."); } -utest::v1::control_t test_level1_busio(const size_t call_count) { - return TestFramework::test_level2_framework(TestFramework::BusIO, TestFramework::CITS_DigitalIO, &test_busio_execute, 0.05, 10); + +utest::v1::control_t test_level1_busio(const size_t call_count) +{ + return TestFramework::test_level1_framework(TestFramework::BusIO, TestFramework::CITS_DigitalIO, &test_busio_execute, 0.05, 10); } Case cases[] = { - Case("Level 1 - Bus Input/Output pair test", test_level1_busio, TestFramework::greentea_failure_handler), + Case("Level 1 - Bus Input/Output pair test", test_level1_busio, TestFramework::greentea_failure_handler), }; -int main() { - // Formulate a specification and run the tests based on the Case array - Specification specification(TestFramework::test_setup<30>, cases); +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); } diff --git a/TESTS/Level1/DigitalIO/DigitalIO.cpp b/TESTS/Level1/DigitalIO/DigitalIO.cpp index 6147694..c9bd3c1 100644 --- a/TESTS/Level1/DigitalIO/DigitalIO.cpp +++ b/TESTS/Level1/DigitalIO/DigitalIO.cpp @@ -31,21 +31,16 @@ using namespace utest::v1; std::vector< vector > TestFramework::pinout(TS_NC); std::vector TestFramework::pin_iterators(TS_NC); -Timer timer; -int clocked_dio_toggle; - // Initialize a test framework object TestFramework test_framework; -void dio_toggled(void) { - clocked_dio_toggle = timer.read_us(); -} - -void test_digitalio_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running digital io test on pin %d\n", pin); +void test_digitalio_execute(PinName pin, float tolerance, int iterations) +{ TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); PinName pinpair = TestFramework::find_pin_pair(pin); + DEBUG_PRINTF("Running digital io test on pin %#x and its pin-pair %#x", pin, pinpair); + DigitalOut dout(pinpair); DigitalIn din(pin); @@ -56,16 +51,21 @@ void test_digitalio_execute(PinName pin, float tolerance, int iterations) { TEST_ASSERT_MESSAGE(1 == din.read(),"Expected value to be 1, read value was not one"); } -utest::v1::control_t test_level1_digitalio(const size_t call_count) { - return TestFramework::test_level1_framework(TestFramework::DigitalIO, TestFramework::CITS_DigitalIO, &test_digitalio_execute, 0.05, 10); + +utest::v1::control_t test_level1_digitalio(const size_t call_count) +{ + return TestFramework::test_level1_framework(TestFramework::DigitalIO, TestFramework::CITS_DigitalIO, &test_digitalio_execute, 0.05, 10); } + Case cases[] = { - Case("Level 1 - Digital In/Out Range test (single pin)", test_level1_digitalio, TestFramework::greentea_failure_handler), + Case("Level 1 - Digital In/Out Range test (single pin)", test_level1_digitalio, TestFramework::greentea_failure_handler), }; -int main() { - // Formulate a specification and run the tests based on the Case array - Specification specification(TestFramework::test_setup<30>, cases); + +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); } diff --git a/TESTS/Level1/I2C/I2C.cpp b/TESTS/Level1/I2C/I2C.cpp index 13b9c2b..5920c90 100644 --- a/TESTS/Level1/I2C/I2C.cpp +++ b/TESTS/Level1/I2C/I2C.cpp @@ -42,55 +42,52 @@ TestFramework test_framework; char* DEADBEEF = "DEADBEEF"; char NULL_STR[128] = {0}; -template -utest::v1::control_t test_level1_i2c(const size_t call_count) { +template +utest::v1::control_t test_level1_i2c(const size_t call_count) +{ // Check to see if the CI test shield I2C pins are connected to the board PinName pin_scl = MBED_CONF_APP_I2C_SCL; PinName pin_sda = MBED_CONF_APP_I2C_SDA; + if (TestFramework::find_pin(pin_scl, TestFramework::I2C_SCL)==-1 || - TestFramework::find_pin(pin_sda, TestFramework::I2C_SDA)==-1) { - return utest::v1::CaseNext; + TestFramework::find_pin(pin_sda, TestFramework::I2C_SDA)==-1) { + TEST_ASSERT_MESSAGE(false,"CI test shield is not properly connected to default I2C pins, or pins are already assigned as greentea's UART pins."); } - DEBUG_PRINTF("Running I2C constructor on SDA pin %d and SCL pin %d\n", pin_sda, pin_scl); - TEST_ASSERT_MESSAGE(pin_sda != NC, "SDA Pin is NC"); - TEST_ASSERT_MESSAGE(pin_scl != NC, "SCL Pin is NC"); - - I2CEeprom memory(pin_sda,pin_scl,MBED_CONF_APP_I2C_EEPROM_ADDR,32,0); - - // Generate a random string - char test_string[128] = {0}; - for (int i=0; i, TestFramework::greentea_failure_handler), Case("Level 1 - I2C test - 10 byte (single pin set)", test_level1_i2c<10>, TestFramework::greentea_failure_handler), Case("Level 1 - I2C test - 100 byte (single pin set)", test_level1_i2c<100>, TestFramework::greentea_failure_handler), }; -int main() { - // Formulate a specification and run the tests based on the Case array - Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); + return !Harness::run(specification); } diff --git a/TESTS/Level1/Pwm/Pwm.cpp b/TESTS/Level1/Pwm/Pwm.cpp index c402623..f2f3c62 100644 --- a/TESTS/Level1/Pwm/Pwm.cpp +++ b/TESTS/Level1/Pwm/Pwm.cpp @@ -45,20 +45,25 @@ int last_rise_time; int duty_count; // Callback for a PWM rising edge -void callback_pwm_rise(void) { +void callback_pwm_rise(void) +{ rise_count++; last_rise_time = timer.read_ms(); } + // Callback for a PWM falling edge -void callback_pwm_fall(void) { +void callback_pwm_fall(void) +{ fall_count++; - if (last_rise_time != 0) + if (last_rise_time != 0){ duty_count = duty_count + (timer.read_ms() - last_rise_time); + } } -void test_pwm_execute(PinName pin, float dutycycle, int period) { - DEBUG_PRINTF("Running pwm test on pin %d\n", pin); +void test_pwm_execute(PinName pin, float dutycycle, int period) +{ + DEBUG_PRINTF("Running pwm test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); // Initialize @@ -107,11 +112,13 @@ void test_pwm_execute(PinName pin, float dutycycle, int period) { // TEST_ASSERT_MESSAGE( std::abs(expectedTime - avgTime) <= calculated_percent,"Greater than a specific variance between expected and measured duty cycle"); } + template utest::v1::control_t test_level1_pwm(const size_t call_count) { - return TestFramework::test_level1_framework(TestFramework::PWM, TestFramework::CITS_PWM, &test_pwm_execute, dutycycle*0.01f, period); + return TestFramework::test_level1_framework(TestFramework::PWM, TestFramework::CITS_PWM, &test_pwm_execute, dutycycle*0.01f, period); } + Case cases[] = { Case("Level 1 - PWM Frequency test (single pin) - 10ms", test_level1_pwm<50, 10>, TestFramework::greentea_failure_handler), Case("Level 1 - PWM Frequency test (single pin) - 30ms", test_level1_pwm<50, 30>, TestFramework::greentea_failure_handler), @@ -121,8 +128,10 @@ Case cases[] = { Case("Level 1 - PWM Duty cycle test (single pin) - 90%", test_level1_pwm<90, 10>, TestFramework::greentea_failure_handler), }; -int main() { - // Formulate a specification and run the tests based on the Case array - Specification specification(TestFramework::test_setup<30>, cases); + +int main() +{ + // Formulate a specification and run the tests based on the Case array + Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); } diff --git a/TESTS/Level1/SPI/SPI.cpp b/TESTS/Level1/SPI/SPI.cpp index 8da1d12..21dae6b 100644 --- a/TESTS/Level1/SPI/SPI.cpp +++ b/TESTS/Level1/SPI/SPI.cpp @@ -40,9 +40,9 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -template -utest::v1::control_t test_level1_spi(const size_t call_count) { - +template +utest::v1::control_t test_level1_spi(const size_t call_count) +{ // Verify that the CI test shield pins are connected to the SPI pins PinName pin_clk = MBED_CONF_APP_SPI_CLK; PinName pin_mosi = MBED_CONF_APP_SPI_MOSI; @@ -51,68 +51,70 @@ utest::v1::control_t test_level1_spi(const size_t call_count) { if (TestFramework::find_pin(pin_mosi, TestFramework::SPI_MOSI)==-1 || TestFramework::find_pin(pin_miso, TestFramework::SPI_MISO)==-1 || TestFramework::find_pin(pin_clk, TestFramework::SPI_CLK)==-1 || - TestFramework::find_pin(pin_cs, TestFramework::SPI_CS)==-1) { - return utest::v1::CaseNext; - } - - DEBUG_PRINTF("Running SPI constructor on CLK pin %d, MISO pin %d, MOSI pin %d, and CS pin %d\n", pin_clk, pin_miso, pin_mosi, pin_cs); - TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); - TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); - TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); - TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); - - // Get a random seed from the Greentea host test - srand(TestFramework::get_seed()); - - // Initialize the SD card and file system residing on the SD card - int error = 0; - SDBlockDevice sd(pin_mosi, pin_miso, pin_clk, pin_cs); - FATFileSystem fs("sd"); - sd.init(); - error = fs.mount(&sd); - TEST_ASSERT_MESSAGE(error==0,"SD file system mount failed."); - - // Iterate twice for consistency - for (int i=0; i<2; i++) { - - // Generate a random string - char test_string[128] = {0}; - for (int i=0; i 0,"Writing File to sd card failed"); // write data - fclose(File_write);// close file on SD - - // Close the old file, open the same file in read only mode, and read the file - FILE *File_read = fopen("/sd/test_card.txt", "r"); // open File_read - char test_string_read[128] = {0}; - fgets(test_string_read, 128, File_read); // read string from the file - DEBUG_PRINTF("Read '%s' in read test\nString comparison returns %d\n",test_string_read,strcmp(test_string_read,test_string)); - TEST_ASSERT_MESSAGE(strcmp(test_string_read,test_string) == 0,"String read does not match string written"); // test that strings match - fclose(File_read);// close file on SD - remove("/sd/test_card.txt"); + TestFramework::find_pin(pin_cs, TestFramework::DigitalIO)==-1) { + TEST_ASSERT_MESSAGE(false,"CI test shield is not properly connected to default SPI pins, or pins are already assigned as greentea's UART pins."); } - - // Unmount and de-initialize the SD card - error = fs.unmount(); - TEST_ASSERT_MESSAGE(error==0,"SD file system unmount failed."); - - sd.deinit(); - - return utest::v1::CaseNext; + TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); + TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); + TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); + TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); + + // Get a random seed from the Greentea host test + //srand(TestFramework::get_seed()); TODO: need to fix, causing test error when calling get_seed + + // Initialize the SD card and file system residing on the SD card + DEBUG_PRINTF("Running SPI constructor on CLK pin %#x, MISO pin %#x, MOSI pin %#x, and CS pin %#x\n", pin_clk, pin_miso, pin_mosi, pin_cs); + SDBlockDevice sd(pin_mosi, pin_miso, pin_clk, pin_cs); + FATFileSystem fs("sd"); + sd.init(); + int error = 0; + error = fs.mount(&sd); + TEST_ASSERT_MESSAGE(error==0,"SD file system mount failed."); + + // Iterate twice for consistency + for (int i=0; i<2; i++) { + + // Generate a random string + char test_string[128] = {0}; + for (int j=0; j 0,"Writing File to sd card failed"); // write data + fclose(File_write);// close file on SD + + // Close the old file, open the same file in read only mode, and read the file + FILE *File_read = fopen("/sd/test_card.txt", "r"); // open File_read + char test_string_read[128] = {0}; + fgets(test_string_read, 128, File_read); // read string from the file + DEBUG_PRINTF("Read '%s' in iteration %d's read test\nString comparison returns %d\n",test_string_read, i,strcmp(test_string_read,test_string)); + TEST_ASSERT_MESSAGE(strcmp(test_string_read,test_string) == 0,"String read does not match string written"); // test that strings match + fclose(File_read);// close file on SD + remove("/sd/test_card.txt"); + } + + // Unmount and de-initialize the SD card + error = fs.unmount(); + TEST_ASSERT_MESSAGE(error==0,"SD file system unmount failed."); + + sd.deinit(); + + return utest::v1::CaseNext; } + Case cases[] = { Case("Level 1 - SPI test - 1 byte (single pin set)", test_level1_spi<1>, TestFramework::greentea_failure_handler), Case("Level 1 - SPI test - 10 byte (single pin set)", test_level1_spi<10>, TestFramework::greentea_failure_handler), Case("Level 1 - SPI test - 100 byte (single pin set)", test_level1_spi<100>, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level2/AnalogIn/AnalogIn.cpp b/TESTS/Level2/AnalogIn/AnalogIn.cpp index 5fcacd3..126aae9 100644 --- a/TESTS/Level2/AnalogIn/AnalogIn.cpp +++ b/TESTS/Level2/AnalogIn/AnalogIn.cpp @@ -29,6 +29,8 @@ #include "TestFramework.hpp" #include +#define BUS_SIZE 5 + using namespace utest::v1; // Static variables for managing the dynamic list of pins @@ -38,22 +40,28 @@ std::vector TestFramework::pin_iterators(TS_NC); // Initialize a test framework object TestFramework test_framework; -void test_analogin_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running analog input range test on pin %d\n", pin); +void test_analogin_execute(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running analog input range test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); - // Find all of the pins in the resistor ladder that are not the current pin, organize them into a bus inout - std::vector resistor_ladder_pins = TestFramework::find_resistor_ladder_pins(pin); - if (resistor_ladder_pins.size() < 5) + // Find all of the pins in the resistor ladder that are not the current pin + std::vector resistor_ladder_pins = TestFramework::find_resistor_ladder_pins(pin); + if (resistor_ladder_pins.size() < BUS_SIZE){ TEST_ASSERT_MESSAGE(false, "Error finding the resistor ladder pins"); + } + + // Create a bus with all of these pins BusInOut outputs(resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); outputs.output(); + DEBUG_PRINTF("Creating a resistive ladder bus with the following pins:\n pin[0] = %#x\n pin[1] = %#x\n pin[2] = %#x\n pin[3] = %#x\n pin[4] = %#x\n", resistor_ladder_pins[0],resistor_ladder_pins[1],resistor_ladder_pins[2],resistor_ladder_pins[3],resistor_ladder_pins[4]); + + // construct designated analogIn pin AnalogIn ain(pin); for (unsigned int i=0; i prev_value,"Analog Input did not increment. Check that you have assigned valid pins in mbed_app.json file") - // Repeat multiple times to verify variability is minimal + + // Repeat multiple times to verify output is not fluctuating for (unsigned int j = 0; j, cases); return !Harness::run(specification); diff --git a/TESTS/Level2/BusInOut/BusInOut.cpp b/TESTS/Level2/BusInOut/BusInOut.cpp index 809a653..0877bce 100644 --- a/TESTS/Level2/BusInOut/BusInOut.cpp +++ b/TESTS/Level2/BusInOut/BusInOut.cpp @@ -35,15 +35,18 @@ std::vector TestFramework::pin_iterators(TS_NC); TestFramework test_framework; // test that all pins can be marked as BusIn -void busin_define_test(){ +void busin_define_test() +{ BusIn bin(MBED_CONF_APP_DIO_2,MBED_CONF_APP_DIO_3,MBED_CONF_APP_DIO_4,MBED_CONF_APP_DIO_5,MBED_CONF_APP_DIO_6,MBED_CONF_APP_DIO_7,MBED_CONF_APP_DIO_8,MBED_CONF_APP_DIO_9,MBED_CONF_APP_SPI_CS,MBED_CONF_APP_SPI_MOSI,MBED_CONF_APP_AIN_0,MBED_CONF_APP_AIN_1,MBED_CONF_APP_AIN_2,MBED_CONF_APP_AIN_3,MBED_CONF_APP_AIN_4,MBED_CONF_APP_AIN_5); int x = 0; x = bin.read(); TEST_ASSERT_MESSAGE(true,"The fact that it hasnt error out proves this passes the sniff test"); } + // test that all pins can be marked as BusOut -void busout_define_test(){ +void busout_define_test() +{ BusOut bout(MBED_CONF_APP_DIO_2,MBED_CONF_APP_DIO_3,MBED_CONF_APP_DIO_4,MBED_CONF_APP_DIO_5,MBED_CONF_APP_DIO_6,MBED_CONF_APP_DIO_7,MBED_CONF_APP_DIO_8,MBED_CONF_APP_DIO_9,MBED_CONF_APP_SPI_CS,MBED_CONF_APP_SPI_MOSI,MBED_CONF_APP_AIN_0,MBED_CONF_APP_AIN_1,MBED_CONF_APP_AIN_2,MBED_CONF_APP_AIN_3,MBED_CONF_APP_AIN_4,MBED_CONF_APP_AIN_5); bout = 0; volatile int x = 0; @@ -55,8 +58,10 @@ void busout_define_test(){ TEST_ASSERT_MESSAGE(true,"The fact that it hasnt error out proves this passes the sniff test"); } + // test that all pins can be marked as BusInOut -void businout_define_test(){ +void businout_define_test() +{ BusInOut bio1(MBED_CONF_APP_DIO_2,MBED_CONF_APP_DIO_4,MBED_CONF_APP_DIO_6,MBED_CONF_APP_DIO_8); BusInOut bio2(MBED_CONF_APP_DIO_3,MBED_CONF_APP_DIO_5,MBED_CONF_APP_DIO_7,MBED_CONF_APP_DIO_9); bio1.output(); @@ -89,7 +94,8 @@ void businout_define_test(){ } // Test writing from one bus to another -void businout_bidirectional_test(){ +void businout_bidirectional_test() +{ BusIn bin(MBED_CONF_APP_DIO_2,MBED_CONF_APP_DIO_4,MBED_CONF_APP_DIO_6,MBED_CONF_APP_DIO_8); BusOut bout(MBED_CONF_APP_DIO_3,MBED_CONF_APP_DIO_5,MBED_CONF_APP_DIO_7,MBED_CONF_APP_DIO_9); bout = 0; @@ -103,6 +109,7 @@ void businout_bidirectional_test(){ TEST_ASSERT_MESSAGE(true,"The fact that it hasnt error out proves this passes the sniff test"); } + Case cases[] = { Case("Level 2 - Bus Input definable", busin_define_test, TestFramework::greentea_failure_handler), Case("Level 2 - Bus Output definable", busout_define_test, TestFramework::greentea_failure_handler), @@ -110,8 +117,10 @@ Case cases[] = { Case("Level 2 - Bus Input/Output range test 2", businout_bidirectional_test, TestFramework::greentea_failure_handler), }; + // Entry point into the tests -int main() { +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); diff --git a/TESTS/Level2/DigitalIO/DigitalIO.cpp b/TESTS/Level2/DigitalIO/DigitalIO.cpp index cda4a58..978c38c 100644 --- a/TESTS/Level2/DigitalIO/DigitalIO.cpp +++ b/TESTS/Level2/DigitalIO/DigitalIO.cpp @@ -37,12 +37,15 @@ int clocked_dio_toggle; // Initialize a test framework object TestFramework test_framework; -void dio_toggled(void) { +void dio_toggled(void) +{ clocked_dio_toggle = timer.read_us(); } -void test_digitalio_execute(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running digital io test on pin %d\n", pin); + +void test_digitalio_execute(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running digital io test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); PinName pinpair = TestFramework::find_pin_pair(pin); @@ -78,15 +81,20 @@ void test_digitalio_execute(PinName pin, float tolerance, int iterations) { } } -utest::v1::control_t test_level2_digitalio(const size_t call_count) { + +utest::v1::control_t test_level2_digitalio(const size_t call_count) +{ return TestFramework::test_level2_framework(TestFramework::DigitalIO, TestFramework::CITS_DigitalIO, &test_digitalio_execute, 0.02, 100); } + Case cases[] = { Case("Level 2 - Digital In/Out Range test (all pins)", test_level2_digitalio, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); return !Harness::run(specification); diff --git a/TESTS/Level2/I2C/I2C.cpp b/TESTS/Level2/I2C/I2C.cpp index 9277fe5..23f3261 100644 --- a/TESTS/Level2/I2C/I2C.cpp +++ b/TESTS/Level2/I2C/I2C.cpp @@ -41,58 +41,58 @@ std::vector TestFramework::pin_iterators(TS_NC); TestFramework test_framework; char NULL_STR[128] = {0}; -template -utest::v1::control_t test_level2_i2c(const size_t call_count) { - - // Check to see if the CI test shield I2C pins are connected to the board +template +utest::v1::control_t test_level2_i2c(const size_t call_count) +{ + // Assign I2C pins PinName pin_scl = MBED_CONF_APP_I2C_SCL; PinName pin_sda = MBED_CONF_APP_I2C_SDA; - if (TestFramework::find_pin(pin_scl, TestFramework::I2C_SCL)==-1 || TestFramework::find_pin(pin_sda, TestFramework::I2C_SDA)==-1) { - return utest::v1::CaseNext; - } - - DEBUG_PRINTF("Running I2C constructor on SDA pin %d and SCL pin %d\n", pin_sda, pin_scl); - TEST_ASSERT_MESSAGE(pin_sda != NC, "SDA Pin is NC"); - TEST_ASSERT_MESSAGE(pin_scl != NC, "SCL Pin is NC"); - - // Get a random seed from the Greentea host test - srand(TestFramework::get_seed()); - - I2CEeprom memory(pin_sda,pin_scl,MBED_CONF_APP_I2C_EEPROM_ADDR,32,0); - - // Generate a random string - char test_string[128] = {0}; - for (int i=0; i, TestFramework::greentea_failure_handler), - Case("Level 2 - I2C test - 10 byte (all pin set)", test_level2_i2c<10>, TestFramework::greentea_failure_handler), - Case("Level 2 - I2C test - 100 byte (all pin set)", test_level2_i2c<100>, TestFramework::greentea_failure_handler), + Case("Level 2 - I2C test - 1 byte to random location", test_level2_i2c<1>, TestFramework::greentea_failure_handler), + Case("Level 2 - I2C test - 10 bytes to random location", test_level2_i2c<10>, TestFramework::greentea_failure_handler), + Case("Level 2 - I2C test - 100 bytes to random location", test_level2_i2c<100>, TestFramework::greentea_failure_handler), }; - -int main() { + + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level2/Pwm/Pwm.cpp b/TESTS/Level2/Pwm/Pwm.cpp index 59ab203..c80904e 100644 --- a/TESTS/Level2/Pwm/Pwm.cpp +++ b/TESTS/Level2/Pwm/Pwm.cpp @@ -45,20 +45,25 @@ int last_rise_time; int duty_count; // Callback for a PWM rising edge -void callback_pwm_rise(void) { +void callback_pwm_rise(void) +{ rise_count++; last_rise_time = timer.read_ms(); } + // Callback for a PWM falling edge -void callback_pwm_fall(void) { +void callback_pwm_fall(void) +{ fall_count++; - if (last_rise_time != 0) + if (last_rise_time != 0) { duty_count = duty_count + (timer.read_ms() - last_rise_time); + } } -void test_pwm_execute(PinName pin, float tolerance, int iterations, float dutycycle, int period) { +void test_pwm_execute(PinName pin, float tolerance, int iterations, float dutycycle, int period) +{ // Initialize float calculated_percent = iterations * tolerance; if (calculated_percent < 1) calculated_percent = 1.0f; @@ -101,23 +106,25 @@ void test_pwm_execute(PinName pin, float tolerance, int iterations, float dutycy TEST_ASSERT_MESSAGE( std::abs(iterations - fc) <= calculated_percent, "There was more than a specific variance in number of fall cycles seen and number expected."); // @TODO The following assert is a good check to have (comparing times) but fails on most platforms. Need to come up with a better way to do this test // TEST_ASSERT_MESSAGE( std::abs(expectedTime - avgTime) <= calculated_percent,"Greater than a specific variance between expected and measured duty cycle"); - } + // Test case to just iterate through duty cycles -void test_pwm_dutycycle(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running pwm test on pin %d\n", pin); +void test_pwm_dutycycle(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running pwm test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); for (float dutycycle=0.05f; dutycycle <= 0.95f; dutycycle+=0.1f) { test_pwm_execute(pin, tolerance, iterations, dutycycle, 10); } - } + // Test case to just iterate through the period -void test_pwm_frequency(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running pwm test on pin %d\n", pin); +void test_pwm_frequency(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running pwm test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); for (int period=10; period<=200; period+=40) { @@ -125,9 +132,11 @@ void test_pwm_frequency(PinName pin, float tolerance, int iterations) { } } + // Test case that combines period and duty cycles -void test_pwm(PinName pin, float tolerance, int iterations) { - DEBUG_PRINTF("Running pwm test on pin %d\n", pin); +void test_pwm(PinName pin, float tolerance, int iterations) +{ + DEBUG_PRINTF("Running pwm test on pin %#x\n", pin); TEST_ASSERT_MESSAGE(pin != NC, "Pin is NC"); for (float dutycycle=0.2f; dutycycle <= 0.8f; dutycycle+=0.2f) { @@ -137,26 +146,34 @@ void test_pwm(PinName pin, float tolerance, int iterations) { } } -utest::v1::control_t test_level2_pwm_frequency(const size_t call_count) { + +utest::v1::control_t test_level2_pwm_frequency(const size_t call_count) +{ return TestFramework::test_level2_framework(TestFramework::PWM, TestFramework::CITS_PWM, &test_pwm_frequency, 0.05f, 20); } -utest::v1::control_t test_level2_pwm_dutycycle(const size_t call_count) { + +utest::v1::control_t test_level2_pwm_dutycycle(const size_t call_count) +{ return TestFramework::test_level2_framework(TestFramework::PWM, TestFramework::CITS_PWM, &test_pwm_dutycycle, 0.05f, 20); } + utest::v1::control_t test_level2_pwm(const size_t call_count) { return TestFramework::test_level2_framework(TestFramework::PWM, TestFramework::CITS_PWM, &test_pwm, 0.05f, 20); } + Case cases[] = { Case("Level 2 - PWM Frequency test (all pins)", test_level2_pwm_frequency, TestFramework::greentea_failure_handler), Case("Level 2 - PWM Dutycycle test (all pins)", test_level2_pwm_dutycycle, TestFramework::greentea_failure_handler), Case("Level 2 - PWM all tests (all pins)", test_level2_pwm, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array - Specification specification(TestFramework::test_setup<300>, cases); + Specification specification(TestFramework::test_setup<360>, cases); return !Harness::run(specification); } diff --git a/TESTS/Level2/SPI/SPI.cpp b/TESTS/Level2/SPI/SPI.cpp index fe08e64..bf0ee7b 100644 --- a/TESTS/Level2/SPI/SPI.cpp +++ b/TESTS/Level2/SPI/SPI.cpp @@ -41,8 +41,8 @@ std::vector TestFramework::pin_iterators(TS_NC); TestFramework test_framework; template -utest::v1::control_t test_level2_spi(const size_t call_count) { - +utest::v1::control_t test_level2_spi(const size_t call_count) +{ // Verify that the CI test shield pins are connected to the SPI pins PinName pin_clk = MBED_CONF_APP_SPI_CLK; PinName pin_mosi = MBED_CONF_APP_SPI_MOSI; @@ -51,74 +51,78 @@ utest::v1::control_t test_level2_spi(const size_t call_count) { if (TestFramework::find_pin(pin_mosi, TestFramework::SPI_MOSI)==-1 || TestFramework::find_pin(pin_miso, TestFramework::SPI_MISO)==-1 || TestFramework::find_pin(pin_clk, TestFramework::SPI_CLK)==-1 || - TestFramework::find_pin(pin_cs, TestFramework::SPI_CS)==-1) { - return utest::v1::CaseNext; + TestFramework::find_pin(pin_cs, TestFramework::DigitalIO)==-1) { + TEST_ASSERT_MESSAGE(false,"CI test shield is not properly connected to default SPI pins, or pins are already assigned as greentea's UART pins."); } - - DEBUG_PRINTF("Running SPI constructor on CLK pin %d, MISO pin %d, MOSI pin %d, and CS pin %d\n", pin_clk, pin_miso, pin_mosi, pin_cs); - TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); - TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); - TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); - TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); - - // Get a random seed from the Greentea host test - srand(TestFramework::get_seed()); - - // Initialize the SD card and file system residing on the SD card - int error = 0; - SDBlockDevice sd(pin_mosi, pin_miso, pin_clk, pin_cs); - FATFileSystem fs("sd"); - sd.init(); - error = fs.mount(&sd); - TEST_ASSERT_MESSAGE(error==0,"SD file system mount failed."); - - // Iterate twice for consistency - for (int i=0; i<2; i++) { - - // Generate a random string - char test_string[128] = {0}; - for (int j=0; j 0,"Writing File to sd card failed"); // write data - fclose(File_write);// close file on SD - - // Close the old file, open the same file in read only mode, and read the file - FILE *File_read = fopen(file_name, "r"); // open File_read - char test_string_read[128] = {0}; - fgets(test_string_read, 128, File_read); // read string from the file - DEBUG_PRINTF("Read '%s' in read test\n",test_string_read); - DEBUG_PRINTF("File name: '%s'\n",file_name); - TEST_ASSERT_MESSAGE(strcmp(test_string_read,test_string) == 0,"String read does not match string written"); // test that strings match - fclose(File_read);// close file on SD - remove(file_name); - } - - // Unmount and de-initialize the SD card - error = fs.unmount(); - TEST_ASSERT_MESSAGE(error==0,"SD file system unmount failed."); - - sd.deinit(); - - return utest::v1::CaseNext; + TEST_ASSERT_MESSAGE(pin_clk != NC, "SPI CLK pin is NC"); + TEST_ASSERT_MESSAGE(pin_mosi != NC, "SPI MOSI Pin is NC"); + TEST_ASSERT_MESSAGE(pin_miso != NC, "SPI MISO Pin is NC"); + TEST_ASSERT_MESSAGE(pin_cs != NC, "SPI CS Pin is NC"); + + // Get a random seed from the Greentea host test + // srand(TestFramework::get_seed()); TODO: not working properly. + + // Initialize the SD card and file system residing on the SD card + DEBUG_PRINTF("Running SPI constructor on CLK pin %#x, MISO pin %#x, MOSI pin %#x, and CS pin %#x\n", pin_clk, pin_miso, pin_mosi, pin_cs); + SDBlockDevice sd(pin_mosi, pin_miso, pin_clk, pin_cs); + int error = 0; + FATFileSystem fs("sd"); + sd.init(); + error = fs.mount(&sd); + TEST_ASSERT_MESSAGE(error==0,"SD file system mount failed."); + + // Iterate twice for consistency + for (int i=0; i<2; i++) { + + // Generate a random string + char test_string[128] = {0}; + for (int j=0; j 0,"Writing File to sd card failed"); // write data + fclose(File_write);// close file on SD + + // Close the old file, open the same file in read only mode, and read the file + FILE *File_read = fopen(file_name, "r"); // open File_read + char test_string_read[128] = {0}; + fgets(test_string_read, 128, File_read); // read string from the file + DEBUG_PRINTF("Read '%s' in read test\n",test_string_read); + DEBUG_PRINTF("File name: '%s'\n",file_name); + TEST_ASSERT_MESSAGE(strcmp(test_string_read,test_string) == 0,"String read does not match string written"); // test that strings match + fclose(File_read);// close file on SD + remove(file_name); + } + + // Unmount and de-initialize the SD card + error = fs.unmount(); + TEST_ASSERT_MESSAGE(error==0,"SD file system unmount failed."); + + sd.deinit(); + + return utest::v1::CaseNext; } + Case cases[] = { - Case("Level 2 - SPI test - 1 byte (all pin sets)", test_level2_spi<1>, TestFramework::greentea_failure_handler), - Case("Level 2 - SPI test - 10 byte (all pin sets)", test_level2_spi<10>, TestFramework::greentea_failure_handler), - Case("Level 2 - SPI test - 100 byte (all pin sets)", test_level2_spi<100>, TestFramework::greentea_failure_handler), + Case("Level 2 - SPI test - 1 byte of random data to random file name", test_level2_spi<1>, TestFramework::greentea_failure_handler), + Case("Level 2 - SPI test - 10 byte of random data to random file name", test_level2_spi<10>, TestFramework::greentea_failure_handler), + Case("Level 2 - SPI test - 100 byte of random data to random file name", test_level2_spi<100>, TestFramework::greentea_failure_handler), }; -int main() { + +int main() +{ // Formulate a specification and run the tests based on the Case array Specification specification(TestFramework::test_setup<30>, cases); - return !Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/Level3/SPI/SPI.cpp b/TESTS/Level3/SPI/SPI.cpp index af1ea3c..1e09013 100644 --- a/TESTS/Level3/SPI/SPI.cpp +++ b/TESTS/Level3/SPI/SPI.cpp @@ -51,7 +51,7 @@ utest::v1::control_t test_level3_spi(const size_t call_count) { if (TestFramework::find_pin(pin_mosi, TestFramework::SPI_MOSI)==-1 || TestFramework::find_pin(pin_miso, TestFramework::SPI_MISO)==-1 || TestFramework::find_pin(pin_clk, TestFramework::SPI_CLK)==-1 || - TestFramework::find_pin(pin_cs, TestFramework::SPI_CS)==-1) { + TestFramework::find_pin(pin_cs, TestFramework::DigitalIO)==-1) { return utest::v1::CaseNext; } diff --git a/TestFramework.cpp b/TestFramework.cpp index 89ebe3e..ca514bf 100644 --- a/TestFramework.cpp +++ b/TestFramework.cpp @@ -18,33 +18,50 @@ #include "TestFramework.hpp" /*///////////////////////////////////////////////////////////////////////////// -// Initialization // +// Initialization // /////////////////////////////////////////////////////////////////////////////*/ -TestFramework::TestFramework() { +TestFramework::TestFramework() +{ + #ifdef DEVICE_ANALOGIN map_pins(PinMap_ADC, AnalogInput); - map_pins(PinMap_DAC, AnalogOutput); - map_pins(PinMap_PWM, DigitalIO); - map_pins(PinMap_ADC, DigitalIO); - // map_pins(PinMap_DAC, DigitalIO); grabbing pin number from PeripheralPins.c, instead of the pin translation from mbed_app.json + map_pins(PinMap_ADC, DigitalIO); + #endif // DEVICE_ANALOGIN + + #ifdef DEVICE_ANALOGOUT + map_pins(PinMap_DAC, AnalogOutput); + // map_pins(PinMap_DAC, DigitalIO); grabbing pin number defined in PinNames.c, instead of the intended pin translation from mbed_app.json + #endif // DEVICE_ANALOGOUT + + #ifdef DEVICE_I2C map_pins(PinMap_I2C_SDA, DigitalIO); map_pins(PinMap_I2C_SCL, DigitalIO); - map_pins(PinMap_SPI_SCLK, DigitalIO); + map_pins(PinMap_I2C_SDA, I2C_SDA); + map_pins(PinMap_I2C_SCL, I2C_SCL); + #endif // DEVICE_I2C + + #ifdef DEVICE_PWMOUT + map_pins(PinMap_PWM, DigitalIO); + map_pins(PinMap_PWM, PWM); + #endif // DEVICE_PWMOUT + + #ifdef DEVICE_SPI + map_pins(PinMap_SPI_SCLK, DigitalIO); map_pins(PinMap_SPI_MOSI, DigitalIO); map_pins(PinMap_SPI_MISO, DigitalIO); map_pins(PinMap_SPI_SSEL, DigitalIO); - pinout[BusIO] = pinout[DigitalIO]; - map_pins(PinMap_PWM, PWM); - map_pins(PinMap_I2C_SDA, I2C_SDA); - map_pins(PinMap_I2C_SCL, I2C_SCL); - map_pins(PinMap_SPI_SCLK, SPI_CLK); + map_pins(PinMap_SPI_SCLK, SPI_CLK); map_pins(PinMap_SPI_MOSI, SPI_MOSI); map_pins(PinMap_SPI_MISO, SPI_MISO); map_pins(PinMap_SPI_SSEL, SPI_CS); + #endif // DEVICE_SPI + + pinout[BusIO] = pinout[DigitalIO]; setup_cits_pins(); } -void TestFramework::setup_cits_pins() { +void TestFramework::setup_cits_pins() +{ pinout[CITS_AnalogInput].push_back(construct_pinmap(MBED_CONF_APP_AIN_0)); pinout[CITS_AnalogInput].push_back(construct_pinmap(MBED_CONF_APP_AIN_1)); pinout[CITS_AnalogInput].push_back(construct_pinmap(MBED_CONF_APP_AIN_2)); @@ -73,42 +90,55 @@ void TestFramework::setup_cits_pins() { } -PinMap TestFramework::construct_pinmap(PinName pin) { - PinMap pinmap = {pin, 0, 0}; - return pinmap; +PinMap TestFramework::construct_pinmap(PinName pin) +{ + PinMap pinmap = {pin, 0, 0}; + return pinmap; } -void TestFramework::map_pins(const PinMap pinmap[], Type pintype) { - int i = 0; - while(pinmap[i].pin != (PinName)NC) { - bool alreadyExists = false; - for (unsigned int j=0; j TestFramework::find_resistor_ladder_pins(PinName pin) { +std::vector TestFramework::find_resistor_ladder_pins(PinName pin) +{ std::vector resistor_ladder_pins; for (unsigned int i = 0; i TestFramework::find_resistor_ladder_pins(PinName pin) { } -unsigned int TestFramework::get_seed() { +unsigned int TestFramework::get_seed() +{ // Send key value pair to greentea host tests greentea_send_kv("return_rand", "seed"); char key[16] = {0}; @@ -167,22 +203,22 @@ unsigned int TestFramework::get_seed() { /*///////////////////////////////////////////////////////////////////////////// -// level0 // -// // +// level0 // +// // // Level 0 tests test the constructor and deconstructor of each pin of a // // specified API. Every pin available for the specified API (ex. Analog in, // // digital io, SPI), gets tested regardless of if it is connected to the CI // -// test shield. // +// test shield. // /////////////////////////////////////////////////////////////////////////////*/ -utest::v1::control_t TestFramework::run_i2c(void (*execution_callback)(PinName, PinName)) { +utest::v1::control_t TestFramework::run_i2c(void (*execution_callback)(PinName, PinName)) +{ PinMap sda_pin = pinout[I2C_SDA][pin_iterators[I2C_SDA]]; - // Tag is used to identify if a test case had been executed (true) or not (false) + // Tag is used to identify if a test case had been executed (true) or not (false) bool tag = false; // Itereate through the SCL pins to find a pin that matches the HW block of the SDA pin while (pin_iterators[I2C_SCL] < pinout[I2C_SCL].size()) { if (pinout[I2C_SCL][pin_iterators[I2C_SCL]].peripheral == sda_pin.peripheral) { - // Execution has already occurred, but another SCL pin was found that matches the SDA pin. Queue up another test case if (tag) {return utest::v1::CaseRepeatAll;} // Matching SCL pin was found. Run the callback with the found pins @@ -202,10 +238,11 @@ utest::v1::control_t TestFramework::run_i2c(void (*execution_callback)(PinName, } -utest::v1::control_t TestFramework::run_spi(void (*execution_callback)(PinName, PinName, PinName, PinName)) { - bool tag = false; // determines if execution_callback() was ran +utest::v1::control_t TestFramework::run_spi(void (*execution_callback)(PinName, PinName, PinName, PinName)) +{ + bool tag = false; // determines if execution_callback() was ran - // Iterate through all CLK pins, finding the remaining SPI pins that have matching HW blocks + // Iterate through all CLK pins, finding the remaining SPI pins that have matching HW blocks while (pin_iterators[SPI_CLK] < pinout[SPI_CLK].size()) { // Iterate through all the MISO pins @@ -214,52 +251,51 @@ utest::v1::control_t TestFramework::run_spi(void (*execution_callback)(PinName, // Iterate through all the MOSI pins while (pin_iterators[SPI_MOSI] < pinout[SPI_MOSI].size()) { - // Iterate through all the CS pins + // Iterate through all the CS pins while (pin_iterators[SPI_CS] < pinout[SPI_CS].size()) { - // create local variables to help make code easier to read - PinMap CLK = pinout[SPI_CLK][pin_iterators[SPI_CLK]]; - PinMap MISO = pinout[SPI_MISO][pin_iterators[SPI_MISO]]; - PinMap MOSI = pinout[SPI_MOSI][pin_iterators[SPI_MOSI]]; - PinMap CS = pinout[SPI_CS][pin_iterators[SPI_CS]]; - - // ensure that chosen MISO, MOSI, and CS pins match the CLK pin's HW block - if ((MISO.peripheral == CLK.peripheral) && (MOSI.peripheral == CLK.peripheral) && (CS.peripheral == CLK.peripheral)){ - - // ensure that chosen SPI_CLK pin is not already assigned to another peripheral - if((CLK.pin != MISO.pin) && (CLK.pin != MOSI.pin) && (CLK.pin != CS.pin)){ - - // ensure that chosen SPI_MISO pin is not already assigned to another peripheral - if((MISO.pin != CLK.pin) && (MISO.pin != MOSI.pin) && (MISO.pin != CS.pin)){ - - // ensure that chosen SPI_MOSI pin is not already assigned to another peripheral - if((MOSI.pin != CLK.pin) && (MOSI.pin != MISO.pin) && (MOSI.pin != CS.pin)){ - - // ensure that chosen SPI_CS pin is not already assigned to another peripheral - if((CS.pin != CLK.pin) && (CS.pin != MOSI.pin) && (CS.pin != MISO.pin)){ - - // Found matching HW block pins. Run execution callback with them. - execution_callback(CLK.pin, MISO.pin, MOSI.pin, CS.pin); - tag = true; - } + // create local variables to help make code easier to read + PinMap CLK = pinout[SPI_CLK][pin_iterators[SPI_CLK]]; + PinMap MISO = pinout[SPI_MISO][pin_iterators[SPI_MISO]]; + PinMap MOSI = pinout[SPI_MOSI][pin_iterators[SPI_MOSI]]; + PinMap CS = pinout[SPI_CS][pin_iterators[SPI_CS]]; + + // ensure that chosen MISO, MOSI, and CS pins match the CLK pin's HW block + if ((MISO.peripheral == CLK.peripheral) && (MOSI.peripheral == CLK.peripheral) && (CS.peripheral == CLK.peripheral)){ + // ensure that chosen SPI_CLK pin is not already assigned to another peripheral + if((CLK.pin != MISO.pin) && (CLK.pin != MOSI.pin) && (CLK.pin != CS.pin)){ + + // ensure that chosen SPI_MISO pin is not already assigned to another peripheral + if((MISO.pin != CLK.pin) && (MISO.pin != MOSI.pin) && (MISO.pin != CS.pin)){ + + // ensure that chosen SPI_MOSI pin is not already assigned to another peripheral + if((MOSI.pin != CLK.pin) && (MOSI.pin != MISO.pin) && (MOSI.pin != CS.pin)){ + + // ensure that chosen SPI_CS pin is not already assigned to another peripheral + if((CS.pin != CLK.pin) && (CS.pin != MOSI.pin) && (CS.pin != MISO.pin)){ + + // Found matching HW block pins. Run execution callback with them. + execution_callback(CLK.pin, MISO.pin, MOSI.pin, CS.pin); + tag = true; + } + } + } + } + } + pin_iterators[SPI_CS]++; // Increment and try next CS pin + if(tag) {return utest::v1::CaseRepeatAll;} } - } - } - } - pin_iterators[SPI_CS]++; // Increment and try next CS pin - if(tag) {return utest::v1::CaseRepeatAll;} + // Cycled through all CS pins. Reset CS iterator and increment MOSI iterator. + pin_iterators[SPI_CS] = 0; + pin_iterators[SPI_MOSI]++; + } + // Cycled through all MOSI pins. Reset MOSI iterator and increment MISO iterator. + pin_iterators[SPI_MOSI] = 0; + pin_iterators[SPI_MISO]++; } - // Cycled through all CS pins. Reset CS iterator and increment MOSI iterator. - pin_iterators[SPI_CS] = 0; - pin_iterators[SPI_MOSI]++; - } - // Cycled through all MOSI pins. Reset MOSI iterator and increment MISO iterator. - pin_iterators[SPI_MOSI] = 0; - pin_iterators[SPI_MISO]++; + // Cycled through all MISO pins. Reset MISO iterator and increment CLK iterator. + pin_iterators[SPI_MISO] = 0; + pin_iterators[SPI_CLK]++; } - // Cycled through all MISO pins. Reset MISO iterator and increment CLK iterator. - pin_iterators[SPI_MISO] = 0; - pin_iterators[SPI_CLK]++; - } // All pins configurations have been iterated through. Reset pin iterators, run the CI test shield pin pair, and then move on to the next test case pin_iterators[SPI_CLK] = 0; @@ -272,50 +308,52 @@ utest::v1::control_t TestFramework::run_spi(void (*execution_callback)(PinName, /*////////////////////////////////////////////////////////////////////////////// -// level1 // -// // +// level1 // +// // // Level 1 tests begin to test the full API for each hardware component. // // The API can only be tested on pins mapped to the CI test shield, so the // // following function iterates through all pins associated with the specified // // hardware component until it finds a pin that is also mapped to the CI test // // shield. Once a pin is found, it runs the callback passed in. Note that // -// only one pin is tested for each hardware component. // +// only one pin is tested for each hardware component. // //////////////////////////////////////////////////////////////////////////////*/ -utest::v1::control_t TestFramework::test_level1_framework(Type pintype, Type testtype, void (*execution_callback)(PinName, float, int), float floatdata, int intdata) { - while(check_size(pintype)) { - // Get current pin specified by the stored iterator - PinName pin = pinout[pintype][pin_iterators[pintype]].pin; - - // Check to see if current pin is available on the CI test shield - int index = find_pin(pin, testtype); - if (index != -1) { - // Current pin is mapped to the CI test shield. Run the callback, reset the iterator, and run the next case - execution_callback(pin, floatdata, intdata); - pin_iterators[pintype] = 0; - return utest::v1::CaseNext; - } - else{ - // Current pin was not mapped to CI test shield, try another pin - pin_iterators[pintype]++; +utest::v1::control_t TestFramework::test_level1_framework(Type pintype, Type testtype, void (*execution_callback)(PinName, float, int), float floatdata, int intdata) +{ + while(check_size(pintype)) { + // Get current pin specified by the stored iterator + PinName pin = pinout[pintype][pin_iterators[pintype]].pin; + + // Check to see if current pin is available on the CI test shield + int index = find_pin(pin, testtype); + if (index != -1) { + // Current pin is mapped to the CI test shield. Run the callback, reset the iterator, and run the next case + execution_callback(pin, floatdata, intdata); + pin_iterators[pintype] = 0; + return utest::v1::CaseNext; + } + else{ + // Current pin was not mapped to CI test shield, try another pin + pin_iterators[pintype]++; + } } - } } /*///////////////////////////////////////////////////////////////////////////// -// level2 // -// // +// level2 // +// // // Level 2 tests test the full API for each hardware similar to level 1 but // // the difference is that the every pin mapped to the CI test shield (not // // just a single pin) is tested. In addition, the tolerance and iterations // -// get a little bit more intense. // +// get a little bit more intense. // /////////////////////////////////////////////////////////////////////////////*/ -utest::v1::control_t TestFramework::test_level2_framework(Type pintype, Type testtype, void (*execution_callback)(PinName, float, int), float floatdata, int intdata) { +utest::v1::control_t TestFramework::test_level2_framework(Type pintype, Type testtype, void (*execution_callback)(PinName, float, int), float floatdata, int intdata) +{ // Get current pin specified by the stored iterator PinName pin = pinout[pintype][pin_iterators[pintype]].pin; - // Check to see if that current pin is available on the CI test shield + // Check to see if that current pin is available on the CI test shield int index = find_pin(pin, testtype); - // Tag is used to identify if a test case had been executed (true) or not (false) + // Tag is used to identify if a test case had been executed (true) or not (false) bool tag = false; // State: Execute if (index != -1) { @@ -328,17 +366,17 @@ utest::v1::control_t TestFramework::test_level2_framework(Type pintype, Type tes // State: Increment iterator pin_iterators[pintype]++; pin = pinout[pintype][pin_iterators[pintype]].pin; - // Check to see if the current pin is available on the CI test shield + // Check to see if the current pin is available on the CI test shield index = find_pin(pin, testtype); - - if (index != -1) { + if (index != -1) { // State: End case // Pin was found, but execution had already occurred so queue up another test case if (tag) { return utest::v1::CaseRepeatAll; // State: Execute // Pin was found and execution has not occurred yet - } else { + } + else { execution_callback(pin, floatdata, intdata); tag = true; } diff --git a/TestFramework.hpp b/TestFramework.hpp index 2166645..6025209 100644 --- a/TestFramework.hpp +++ b/TestFramework.hpp @@ -75,16 +75,20 @@ class TestFramework { template - static utest::v1::status_t test_setup(const size_t number_of_cases) { + static utest::v1::status_t test_setup(const size_t number_of_cases) + { GREENTEA_SETUP(timeout, "rand_provider"); return utest::v1::verbose_test_setup_handler(number_of_cases); } - static utest::v1::status_t greentea_failure_handler(const utest::v1::Case *const source, const utest::v1::failure_t reason) { + + static utest::v1::status_t greentea_failure_handler(const utest::v1::Case *const source, const utest::v1::failure_t reason) + { greentea_case_failure_abort_handler(source, reason); return utest::v1::STATUS_ABORT; } + /** * Find a pin within the array of type pintype * @param PinName pin to search for @@ -93,6 +97,7 @@ class TestFramework { **/ static int find_pin(PinName pin, Type pintype); + /** * Find the pin that is connected to the specified pin via a resistor on the DIO HW bank * @param PinName pin to find the corresponding pin connected by the resistor @@ -100,6 +105,7 @@ class TestFramework { **/ static PinName find_pin_pair(PinName pin); + /** * Check to see if the pin iterator is pointing at a valid pin in the pinout * @param Type pin type to validate @@ -107,6 +113,7 @@ class TestFramework { **/ static bool check_size(Type pintype); + /** * Reset the iterator if all pins of the specified pin type have been looked at,
* or proceed to the next pin of the pin type if there are remaining pins @@ -115,6 +122,7 @@ class TestFramework { **/ static utest::v1::control_t reset_iterator(Type pintype); + /** * Get the current pin for a specific pin type, and incrememnt the iterator for that pin type * @param Type pin type to retrieve and increment @@ -122,6 +130,7 @@ class TestFramework { **/ static PinMap get_increment_pin(Type pintype); + /** * Find the resistor ladder pins that are not the specified pin * @param PinName pin that should not be included in the resistor ladder @@ -129,12 +138,14 @@ class TestFramework { **/ static std::vector find_resistor_ladder_pins(PinName pin); + /** * Get a randomized seed from Greentea's host test * @return unsigned int random seed **/ static unsigned int get_seed(); + /** * Find a matching pin based on HW blocks to the current pin. Iterate the corresponding pin after test case execution * @param Callback to a function to run once a pin pairing has been found @@ -142,6 +153,7 @@ class TestFramework { **/ static utest::v1::control_t run_i2c(void (*execution_callback)(PinName, PinName)); + /** * Find a pin set (CLK, MISO, MOSI, CS) based on HW blocks that matches the current pin. Iterate the corresponding pins after test execution * @param Callback to a function to run once a pin pairing has been found @@ -149,6 +161,7 @@ class TestFramework { **/ static utest::v1::control_t run_spi(void (*execution_callback)(PinName, PinName, PinName, PinName)); + /** * Find a pin of a specified test type and run a test case (passed in as a callback) * @param Type type of pin to find to run the callback @@ -160,6 +173,7 @@ class TestFramework { **/ static utest::v1::control_t test_level1_framework(Type pintype, Type testtype, void (*execution_callback)(PinName, float, int), float floatdata, int intdata); + /** * Find pins of a specified test type and run a test case (passed in as a callback) * Difference from the test_level1_framework function is this runs on ALL pins of a specified test type @@ -180,11 +194,13 @@ class TestFramework { **/ void setup_cits_pins(); + /** * Construct a pinmap from a pin **/ PinMap construct_pinmap(PinName pin); + /** * Put pins from the specified pinmap into the pinout array indexed by pin type * @param PinMap[] Found in the hal, specifies all the pins with a certain type diff --git a/mbed_app.json b/mbed_app.json index 1e456b4..f14bcf3 100644 --- a/mbed_app.json +++ b/mbed_app.json @@ -31,7 +31,7 @@ "PWM_1": "D5", "PWM_2": "D6", "PWM_3": "D9", - "DEBUG_MSG": 1 + "DEBUG_MSG": 0 }, "target_overrides": { "DISCO_L475VG_IOT01A": {