mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 13:03:33 +08:00
px4_mtd: update eeprom at24c driver to initialize multiple instances
This commit is contained in:
@@ -147,15 +147,19 @@ static int at24xxx_attach(mtd_instance_s &instance)
|
||||
|
||||
/* start the MTD driver, attempt 5 times */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
instance.mtd_dev = px4_at24c_initialize(i2c, PX4_I2C_DEVID_ADDR(instance.devid));
|
||||
int ret_val = px4_at24c_initialize(i2c, PX4_I2C_DEVID_ADDR(instance.devid), &(instance.mtd_dev));
|
||||
|
||||
if (instance.mtd_dev) {
|
||||
if (ret_val == 0) {
|
||||
/* abort on first valid result */
|
||||
if (i > 0) {
|
||||
PX4_WARN("EEPROM needed %d attempts to attach", i + 1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
} else if (ret_val == -ENOMEM) {
|
||||
PX4_ERR("Number of at24c EEPROM instances reached the board limit of %d", BOARD_MTD_NUM_EEPROM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user