mirror of https://github.com/ARMmbed/mbed-os.git
Make use of xxx_free() in FPGA tests
parent
7a6cf2cb51
commit
2ff31126b4
|
|
@ -49,6 +49,7 @@ void fpga_analogin_init_test(PinName pin)
|
|||
analogin_t analogin;
|
||||
|
||||
analogin_init(&analogin, pin);
|
||||
analogin_free(&analogin);
|
||||
}
|
||||
|
||||
void fpga_analogin_test(PinName pin)
|
||||
|
|
@ -72,6 +73,8 @@ void fpga_analogin_test(PinName pin)
|
|||
|
||||
/* Set gpio back to Hi-Z */
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
|
||||
analogin_free(&analogin);
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
// Test gpio_is_connected() returned value.
|
||||
gpio_init(&gpio, NC);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_is_connected(&gpio));
|
||||
gpio_free(&gpio);
|
||||
gpio_init(&gpio, pin);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
||||
|
|
@ -120,6 +121,8 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
TEST_ASSERT_EQUAL_INT(1, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_write(&gpio, 0);
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
|
||||
gpio_free(&gpio);
|
||||
}
|
||||
|
||||
/* Test explicit input initialization.
|
||||
|
|
@ -148,6 +151,7 @@ void fpga_test_explicit_input(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio)); // hi-Z, pulled up
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an input, pull-down mode.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
|
|
@ -156,6 +160,7 @@ void fpga_test_explicit_input(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio)); // hi-Z, pulled down
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an input, pull-up mode.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
|
|
@ -164,6 +169,7 @@ void fpga_test_explicit_input(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio)); // hi-Z, pulled up
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an input, pull-down mode.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
|
|
@ -172,6 +178,7 @@ void fpga_test_explicit_input(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio)); // hi-Z, pulled down
|
||||
gpio_free(&gpio);
|
||||
}
|
||||
|
||||
/* Test explicit output initialization.
|
||||
|
|
@ -198,30 +205,35 @@ void fpga_test_explicit_output(PinName pin)
|
|||
gpio_init_out(&gpio, pin);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 1.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_out_ex(&gpio, pin, 1);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(1, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 0.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_out_ex(&gpio, pin, 0);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 1.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_inout(&gpio, pin, PIN_OUTPUT, PullNone, 1);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(1, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 0.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_inout(&gpio, pin, PIN_OUTPUT, PullNone, 0);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
|
|
|
|||
|
|
@ -50,18 +50,7 @@ void fpga_test_i2c_init_free(PinName sda, PinName scl)
|
|||
i2c_init(&obj, sda, scl);
|
||||
i2c_frequency(&obj, 100000);
|
||||
|
||||
/* Free up I2C pins
|
||||
*
|
||||
* The most suitable place to free up I2C pins is in i2c_free(). Due to
|
||||
* i2c_free() not available in I2C HAL, we free up I2C pins manually by
|
||||
* configuring them back to GPIO.
|
||||
*
|
||||
* Without free-up of I2C pins, SDA/SCL pins of the same I2C peripheral may
|
||||
* share by multiple ports due to 'all ports' tests here, and the following
|
||||
* I2C tests would be subject to interference by shared ports.
|
||||
*/
|
||||
gpio_set(sda);
|
||||
gpio_set(scl);
|
||||
i2c_free(&obj);
|
||||
}
|
||||
|
||||
void fpga_i2c_test_write(PinName sda, PinName scl)
|
||||
|
|
@ -149,6 +138,7 @@ void fpga_i2c_test_write(PinName sda, PinName scl)
|
|||
tester.reset();
|
||||
tester.pin_set_pull(sda, MbedTester::PullNone);
|
||||
tester.pin_set_pull(scl, MbedTester::PullNone);
|
||||
i2c_free(&i2c);
|
||||
}
|
||||
|
||||
void fpga_i2c_test_read(PinName sda, PinName scl)
|
||||
|
|
@ -235,6 +225,7 @@ void fpga_i2c_test_read(PinName sda, PinName scl)
|
|||
tester.reset();
|
||||
tester.pin_set_pull(sda, MbedTester::PullNone);
|
||||
tester.pin_set_pull(scl, MbedTester::PullNone);
|
||||
i2c_free(&i2c);
|
||||
}
|
||||
|
||||
void fpga_i2c_test_byte_write(PinName sda, PinName scl)
|
||||
|
|
@ -332,6 +323,7 @@ void fpga_i2c_test_byte_write(PinName sda, PinName scl)
|
|||
tester.reset();
|
||||
tester.pin_set_pull(sda, MbedTester::PullNone);
|
||||
tester.pin_set_pull(scl, MbedTester::PullNone);
|
||||
i2c_free(&i2c);
|
||||
}
|
||||
|
||||
void fpga_i2c_test_byte_read(PinName sda, PinName scl)
|
||||
|
|
@ -432,6 +424,7 @@ void fpga_i2c_test_byte_read(PinName sda, PinName scl)
|
|||
tester.reset();
|
||||
tester.pin_set_pull(sda, MbedTester::PullNone);
|
||||
tester.pin_set_pull(scl, MbedTester::PullNone);
|
||||
i2c_free(&i2c);
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue