Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver: I2C: STM32F2/STM32F4/STM32L1: Fix alternate i2c read. #14668

Merged
merged 1 commit into from May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F2/objects.h
Expand Up @@ -122,7 +122,7 @@ struct i2c_s {
PinName scl;
IRQn_Type event_i2cIRQ;
IRQn_Type error_i2cIRQ;
uint8_t XferOperation;
uint32_t XferOperation;
volatile uint8_t event;
#if DEVICE_I2CSLAVE
uint8_t slave;
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F4/objects.h
Expand Up @@ -106,7 +106,7 @@ struct i2c_s {
int scl_func;
IRQn_Type event_i2cIRQ;
IRQn_Type error_i2cIRQ;
uint8_t XferOperation;
uint32_t XferOperation;
volatile uint8_t event;
#if DEVICE_I2CSLAVE
uint8_t slave;
Expand Down
8 changes: 7 additions & 1 deletion targets/TARGET_STM/i2c_api.c
Expand Up @@ -86,6 +86,10 @@ static I2C_HandleTypeDef *i2c_handles[I2C_NUM];
#define FLAG_TIMEOUT ((int)0x1000)
#endif

#ifdef I2C_IP_VERSION_V1
#define I2C_STATE_NONE ((uint32_t)(HAL_I2C_MODE_NONE))
#endif

/* Declare i2c_init_internal to be used in this file */
void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap);

Expand Down Expand Up @@ -1057,7 +1061,9 @@ void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
/* Get object ptr based on handler ptr */
i2c_t *obj = get_i2c_obj(hi2c);
struct i2c_s *obj_s = I2C_S(obj);

#ifdef I2C_IP_VERSION_V1
hi2c->PreviousState = I2C_STATE_NONE;
#endif
/* Set event flag */
obj_s->event = I2C_EVENT_TRANSFER_COMPLETE;
}
Expand Down