Added timeout for i2c_stop in LPC1114 target.

pull/17/head
Matthew Else 2013-08-01 15:46:05 +01:00
parent a9f0d9a3f7
commit dc68b76d0f
2 changed files with 9 additions and 5 deletions

View File

@ -125,13 +125,17 @@ inline int i2c_start(i2c_t *obj) {
inline int i2c_stop(i2c_t *obj) {
// write the stop bit
int timeout = 0;
i2c_conset(obj, 0, 1, 0, 0);
i2c_clear_SI(obj);
// wait for STO bit to reset
while(I2C_CONSET(obj) & (1 << 4));
return 0;
while(I2C_CONSET(obj) & (1 << 4)) {
timeout++;
if (timeout>100000) return 1;
}
return 0;
}
@ -159,7 +163,7 @@ static inline int i2c_do_read(i2c_t *obj, int last) {
i2c_clear_SI(obj);
// wait for it to arrive
i2c_wait_SI(obj);
//i2c_wait_SI(obj);
// return the data
return (I2C_DAT(obj) & 0xFF);

View File

@ -25,7 +25,7 @@ class ARM(mbedToolchain):
common = [join(ARM_BIN, "armcc"), "-c",
"--cpu=%s" % cpu, "--gnu",
"-Ospace", "--split_sections", "--apcs=interwork",
"-O0", "--split_sections", "--apcs=interwork",
"--brief_diagnostics", "--restrict"
]