Skip to content

Commit b47e599

Browse files
committed
F1 ST CUBE V1.6.1: add I2C patches
1 parent 8ce35ba commit b47e599

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_i2c.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,34 +4014,37 @@ static HAL_StatusTypeDef I2C_MasterReceive_RXNE(I2C_HandleTypeDef *hi2c)
40144014
}
40154015
else if((tmp == 2U) || (tmp == 3U))
40164016
{
4017-
if(hi2c->XferOptions != I2C_NEXT_FRAME)
4018-
{
4017+
// MBED patch if(hi2c->XferOptions != I2C_NEXT_FRAME)
4018+
// MBED patch {
40194019
/* Disable Acknowledge */
40204020
hi2c->Instance->CR1 &= ~I2C_CR1_ACK;
40214021

40224022
/* Enable Pos */
40234023
hi2c->Instance->CR1 |= I2C_CR1_POS;
4024-
}
4025-
else
4026-
{
4027-
/* Enable Acknowledge */
4028-
hi2c->Instance->CR1 |= I2C_CR1_ACK;
4029-
}
4024+
// MBED patch }
4025+
// MBED patch else
4026+
// MBED patch {
4027+
// MBED patch /* Enable Acknowledge */
4028+
// MBED patch hi2c->Instance->CR1 |= I2C_CR1_ACK;
4029+
// MBED patch }
40304030

40314031
/* Disable BUF interrupt */
40324032
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_BUF);
40334033
}
40344034
else
40354035
{
4036-
if(hi2c->XferOptions != I2C_NEXT_FRAME)
4037-
{
4036+
// MBED patch if(hi2c->XferOptions != I2C_NEXT_FRAME)
4037+
// MBED patch {
40384038
/* Disable Acknowledge */
40394039
hi2c->Instance->CR1 &= ~I2C_CR1_ACK;
4040-
}
4041-
else
4040+
// MBED patch }
4041+
// MBED patch else
4042+
if(hi2c->XferOptions == I2C_NEXT_FRAME) // MBED patch
40424043
{
4043-
/* Enable Acknowledge */
4044-
hi2c->Instance->CR1 |= I2C_CR1_ACK;
4044+
// MBED patch /* Enable Acknowledge */
4045+
// MBED patch hi2c->Instance->CR1 |= I2C_CR1_ACK;
4046+
/* Enable Pos */
4047+
hi2c->Instance->CR1 |= I2C_CR1_POS;
40454048
}
40464049

40474050
/* Disable EVT, BUF and ERR interrupt */
@@ -4097,24 +4100,27 @@ static HAL_StatusTypeDef I2C_MasterReceive_BTF(I2C_HandleTypeDef *hi2c)
40974100
/* Prepare next transfer or stop current transfer */
40984101
if((CurrentXferOptions != I2C_FIRST_AND_LAST_FRAME) && (CurrentXferOptions != I2C_LAST_FRAME) && (CurrentXferOptions != I2C_NO_OPTION_FRAME))
40994102
{
4100-
if(CurrentXferOptions != I2C_NEXT_FRAME)
4101-
{
4103+
// MBED patch if(CurrentXferOptions != I2C_NEXT_FRAME)
4104+
// MBED patch {
41024105
/* Disable Acknowledge */
41034106
hi2c->Instance->CR1 &= ~I2C_CR1_ACK;
4104-
}
4105-
else
4107+
// MBED patch }
4108+
// MBED patch else
4109+
if((CurrentXferOptions == I2C_NEXT_FRAME) || (CurrentXferOptions == I2C_FIRST_FRAME)) // MBED patch
41064110
{
4107-
/* Enable Acknowledge */
4108-
hi2c->Instance->CR1 |= I2C_CR1_ACK;
4111+
// MBED patch /* Enable Acknowledge */
4112+
// MBED patch hi2c->Instance->CR1 |= I2C_CR1_ACK;
4113+
/* Generate ReStart */ // MBED patch
4114+
hi2c->Instance->CR1 |= I2C_CR1_START; // MBED patch
41094115
}
41104116

41114117
/* Disable EVT and ERR interrupt */
4112-
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_ERR);
4118+
// MBED patch __HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_ERR);
41134119
}
41144120
else
41154121
{
41164122
/* Disable EVT and ERR interrupt */
4117-
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_ERR);
4123+
// MBED patch __HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_ERR);
41184124

41194125
/* Generate Stop */
41204126
hi2c->Instance->CR1 |= I2C_CR1_STOP;
@@ -4128,6 +4134,9 @@ static HAL_StatusTypeDef I2C_MasterReceive_BTF(I2C_HandleTypeDef *hi2c)
41284134
(*hi2c->pBuffPtr++) = hi2c->Instance->DR;
41294135
hi2c->XferCount--;
41304136

4137+
/* Disable EVT and ERR interrupt */ // MBED patch
4138+
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_ERR); // MBED patch
4139+
41314140
hi2c->State = HAL_I2C_STATE_READY;
41324141
hi2c->PreviousState = I2C_STATE_NONE;
41334142

0 commit comments

Comments
 (0)