Skip to content

Commit 10a2da9

Browse files
authored
Merge pull request #14668 from ikmdani/fix_i2c_read_13967
Driver: I2C: STM32F2/STM32F4/STM32L1: Fix alternate i2c read.
2 parents 95dadc6 + 8f2c45c commit 10a2da9

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

targets/TARGET_STM/TARGET_STM32F2/objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct i2c_s {
122122
PinName scl;
123123
IRQn_Type event_i2cIRQ;
124124
IRQn_Type error_i2cIRQ;
125-
uint8_t XferOperation;
125+
uint32_t XferOperation;
126126
volatile uint8_t event;
127127
#if DEVICE_I2CSLAVE
128128
uint8_t slave;

targets/TARGET_STM/TARGET_STM32F4/objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct i2c_s {
106106
int scl_func;
107107
IRQn_Type event_i2cIRQ;
108108
IRQn_Type error_i2cIRQ;
109-
uint8_t XferOperation;
109+
uint32_t XferOperation;
110110
volatile uint8_t event;
111111
#if DEVICE_I2CSLAVE
112112
uint8_t slave;

targets/TARGET_STM/i2c_api.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ static I2C_HandleTypeDef *i2c_handles[I2C_NUM];
195195
#define FLAG_TIMEOUT ((int)0x1000)
196196
#endif
197197

198+
#ifdef I2C_IP_VERSION_V1
199+
#define I2C_STATE_NONE ((uint32_t)(HAL_I2C_MODE_NONE))
200+
#endif
201+
198202
/* Declare i2c_init_internal to be used in this file */
199203
void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap);
200204

@@ -1159,7 +1163,9 @@ void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
11591163
/* Get object ptr based on handler ptr */
11601164
i2c_t *obj = get_i2c_obj(hi2c);
11611165
struct i2c_s *obj_s = I2C_S(obj);
1162-
1166+
#ifdef I2C_IP_VERSION_V1
1167+
hi2c->PreviousState = I2C_STATE_NONE;
1168+
#endif
11631169
/* Set event flag */
11641170
obj_s->event = I2C_EVENT_TRANSFER_COMPLETE;
11651171
}

0 commit comments

Comments
 (0)