Skip to content

Commit 8f2c45c

Browse files
committed
Driver: I2C: STM32F4: Fix for every alternate i2c read failure in F2, F4 & L1 families.
This commit fixes the i2c driver issue reported in the below link: #13967 on STM32F4xx platform. The data type of XferOperation has been changed from uint8_t to uint32_t so that it can hold a 32bit value (for example: I2C_OTHER_FRAME or I2C_OTHER_AND_LAST_FRAME). Signed-off-by: Krishna Mohan Dani <[email protected]>
1 parent 14e5d30 commit 8f2c45c

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
@@ -86,6 +86,10 @@ static I2C_HandleTypeDef *i2c_handles[I2C_NUM];
8686
#define FLAG_TIMEOUT ((int)0x1000)
8787
#endif
8888

89+
#ifdef I2C_IP_VERSION_V1
90+
#define I2C_STATE_NONE ((uint32_t)(HAL_I2C_MODE_NONE))
91+
#endif
92+
8993
/* Declare i2c_init_internal to be used in this file */
9094
void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap);
9195

@@ -1057,7 +1061,9 @@ void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
10571061
/* Get object ptr based on handler ptr */
10581062
i2c_t *obj = get_i2c_obj(hi2c);
10591063
struct i2c_s *obj_s = I2C_S(obj);
1060-
1064+
#ifdef I2C_IP_VERSION_V1
1065+
hi2c->PreviousState = I2C_STATE_NONE;
1066+
#endif
10611067
/* Set event flag */
10621068
obj_s->event = I2C_EVENT_TRANSFER_COMPLETE;
10631069
}

0 commit comments

Comments
 (0)