BV I2C: warn when reset failed

This commit is contained in:
King Kévin 2019-03-26 19:48:04 +01:00
parent 89e53cb378
commit 7488ebd737
1 changed files with 8 additions and 3 deletions

View File

@ -459,9 +459,14 @@ static bool busvoodoo_i2c_action(const char* action, uint32_t repetition, bool p
static void busvoodoo_i2c_command_reset(void* argument)
{
(void)argument; // we won't use the argument
i2c_master_reset(BUSVOODOO_I2C); // reset the I2C peripheral since it might be stuck
i2c_master_setup(BUSVOODOO_I2C, busvoodoo_i2c_speed); // re-setup I2C
printf("I2C peripheral reset\n");
if (!i2c_master_reset(BUSVOODOO_I2C)) { // reset the I2C peripheral since it might be stuck
busvoodoo_text_style(BUSVOODOO_TEXT_STYLE_WARNING);
printf("reset failed: check the SDA/SCL lines and retry");
busvoodoo_text_style(BUSVOODOO_TEXT_STYLE_RESET);
} else {
i2c_master_setup(BUSVOODOO_I2C, busvoodoo_i2c_speed); // re-setup I2C
printf("I2C peripheral reset\n");
}
}