Skip to content

Commit 69a950c

Browse files
committed
MCUXpresso: Fix SDK LPC driver
Poll the Pending bit after START and STOP operations to ensure operation completion. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent f73415e commit 69a950c

File tree

2 files changed

+18
-0
lines changed
  • targets/TARGET_NXP/TARGET_MCUXpresso_MCUS

2 files changed

+18
-0
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC54114/drivers/fsl_i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ status_t I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direct
163163
/* Start the transfer */
164164
base->MSTCTL = I2C_MSTCTL_MSTSTART_MASK;
165165

166+
I2C_PendingStatusWait(base);
167+
166168
return kStatus_Success;
167169
}
168170

@@ -171,6 +173,9 @@ status_t I2C_MasterStop(I2C_Type *base)
171173
I2C_PendingStatusWait(base);
172174

173175
base->MSTCTL = I2C_MSTCTL_MSTSTOP_MASK;
176+
177+
I2C_PendingStatusWait(base);
178+
174179
return kStatus_Success;
175180
}
176181

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC546XX/drivers/fsl_i2c.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ status_t I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direct
201201
/* Start the transfer */
202202
base->MSTCTL = I2C_MSTCTL_MSTSTART_MASK;
203203

204+
result = I2C_PendingStatusWait(base);
205+
if (result == kStatus_I2C_Timeout)
206+
{
207+
return kStatus_I2C_Timeout;
208+
}
209+
204210
return kStatus_Success;
205211
}
206212

@@ -214,6 +220,13 @@ status_t I2C_MasterStop(I2C_Type *base)
214220
}
215221

216222
base->MSTCTL = I2C_MSTCTL_MSTSTOP_MASK;
223+
224+
result = I2C_PendingStatusWait(base);
225+
if (result == kStatus_I2C_Timeout)
226+
{
227+
return kStatus_I2C_Timeout;
228+
}
229+
217230
return kStatus_Success;
218231
}
219232

0 commit comments

Comments
 (0)