Skip to content

Commit dc68b76

Browse files
committed
Added timeout for i2c_stop in LPC1114 target.
1 parent a9f0d9a commit dc68b76

File tree

2 files changed

+9
-5
lines changed
  • libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX
  • workspace_tools/toolchains

2 files changed

+9
-5
lines changed

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX/i2c_api.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ inline int i2c_start(i2c_t *obj) {
125125

126126
inline int i2c_stop(i2c_t *obj) {
127127
// write the stop bit
128+
int timeout = 0;
128129
i2c_conset(obj, 0, 1, 0, 0);
129130
i2c_clear_SI(obj);
130131

131132
// wait for STO bit to reset
132-
while(I2C_CONSET(obj) & (1 << 4));
133-
134-
return 0;
133+
while(I2C_CONSET(obj) & (1 << 4)) {
134+
timeout++;
135+
if (timeout>100000) return 1;
136+
}
137+
138+
return 0;
135139
}
136140

137141

@@ -159,7 +163,7 @@ static inline int i2c_do_read(i2c_t *obj, int last) {
159163
i2c_clear_SI(obj);
160164

161165
// wait for it to arrive
162-
i2c_wait_SI(obj);
166+
//i2c_wait_SI(obj);
163167

164168
// return the data
165169
return (I2C_DAT(obj) & 0xFF);

workspace_tools/toolchains/arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, target, options=None, notify=None):
2525

2626
common = [join(ARM_BIN, "armcc"), "-c",
2727
"--cpu=%s" % cpu, "--gnu",
28-
"-Ospace", "--split_sections", "--apcs=interwork",
28+
"-O0", "--split_sections", "--apcs=interwork",
2929
"--brief_diagnostics", "--restrict"
3030
]
3131

0 commit comments

Comments
 (0)