Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions drivers/i2c/i2c_ll_stm32_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ void stm32_i2c_event_isr(void *arg)
error:
LL_I2C_DisableIT_TX(i2c);
LL_I2C_DisableIT_RX(i2c);
data->current.is_err = 1;

if (LL_I2C_IsActiveFlag_NACK(i2c)) {
LL_I2C_ClearFlag_NACK(i2c);
data->current.is_nack = 1;
} else {
data->current.is_err = 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be in the right place in the event handler, it should be handled before looking at the message it self.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaussard Here is the Linux implementation of the same IP (STM32F7 uses the same i2c IP) https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-stm32f7.c#L670


k_sem_give(&data->device_sync_sem);
}

Expand All @@ -128,12 +135,7 @@ void stm32_i2c_error_isr(void *arg)
struct i2c_stm32_data *data = DEV_DATA((struct device *)arg);
I2C_TypeDef *i2c = cfg->i2c;

if (LL_I2C_IsActiveFlag_NACK(i2c)) {
LL_I2C_ClearFlag_NACK(i2c);
data->current.is_nack = 1;
} else {
data->current.is_err = 1;
}
data->current.is_err = 1;

k_sem_give(&data->device_sync_sem);
}
Expand Down