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.
pull/11152/head
Chun-Chieh Li 2019-07-31 17:19:44 +08:00
parent 0e092603df
commit 1bf6d898b0
1 changed files with 13 additions and 0 deletions

View File

@ -51,6 +51,19 @@ void test_i2c_init_free(PinName sda, PinName scl)
memset(&obj, 0, sizeof(obj));
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);
}
void i2c_test_write(PinName sda, PinName scl)