Skip to content

Commit 1bf6d89

Browse files
committed
FPGA: Free up I2C pins to avoid interference with following I2C tests
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.
1 parent 0e09260 commit 1bf6d89

File tree

1 file changed

+13
-0
lines changed
  • TESTS/mbed_hal_fpga_ci_test_shield/i2c

1 file changed

+13
-0
lines changed

TESTS/mbed_hal_fpga_ci_test_shield/i2c/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ void test_i2c_init_free(PinName sda, PinName scl)
5151
memset(&obj, 0, sizeof(obj));
5252
i2c_init(&obj, sda, scl);
5353
i2c_frequency(&obj, 100000);
54+
55+
/* Free up I2C pins
56+
*
57+
* The most suitable place to free up I2C pins is in i2c_free(). Due to
58+
* i2c_free() not available in I2C HAL, we free up I2C pins manually by
59+
* configuring them back to GPIO.
60+
*
61+
* Without free-up of I2C pins, SDA/SCL pins of the same I2C peripheral may
62+
* share by multiple ports due to 'all ports' tests here, and the following
63+
* I2C tests would be subject to interference by shared ports.
64+
*/
65+
gpio_set(sda);
66+
gpio_set(scl);
5467
}
5568

5669
void i2c_test_write(PinName sda, PinName scl)

0 commit comments

Comments
 (0)