mirror of https://github.com/ARMmbed/mbed-os.git
Added timeout for i2c_stop in LPC1114 target.
parent
a9f0d9a3f7
commit
dc68b76d0f
|
@ -125,11 +125,15 @@ inline int i2c_start(i2c_t *obj) {
|
||||||
|
|
||||||
inline int i2c_stop(i2c_t *obj) {
|
inline int i2c_stop(i2c_t *obj) {
|
||||||
// write the stop bit
|
// write the stop bit
|
||||||
|
int timeout = 0;
|
||||||
i2c_conset(obj, 0, 1, 0, 0);
|
i2c_conset(obj, 0, 1, 0, 0);
|
||||||
i2c_clear_SI(obj);
|
i2c_clear_SI(obj);
|
||||||
|
|
||||||
// wait for STO bit to reset
|
// wait for STO bit to reset
|
||||||
while(I2C_CONSET(obj) & (1 << 4));
|
while(I2C_CONSET(obj) & (1 << 4)) {
|
||||||
|
timeout++;
|
||||||
|
if (timeout>100000) return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +163,7 @@ static inline int i2c_do_read(i2c_t *obj, int last) {
|
||||||
i2c_clear_SI(obj);
|
i2c_clear_SI(obj);
|
||||||
|
|
||||||
// wait for it to arrive
|
// wait for it to arrive
|
||||||
i2c_wait_SI(obj);
|
//i2c_wait_SI(obj);
|
||||||
|
|
||||||
// return the data
|
// return the data
|
||||||
return (I2C_DAT(obj) & 0xFF);
|
return (I2C_DAT(obj) & 0xFF);
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ARM(mbedToolchain):
|
||||||
|
|
||||||
common = [join(ARM_BIN, "armcc"), "-c",
|
common = [join(ARM_BIN, "armcc"), "-c",
|
||||||
"--cpu=%s" % cpu, "--gnu",
|
"--cpu=%s" % cpu, "--gnu",
|
||||||
"-Ospace", "--split_sections", "--apcs=interwork",
|
"-O0", "--split_sections", "--apcs=interwork",
|
||||||
"--brief_diagnostics", "--restrict"
|
"--brief_diagnostics", "--restrict"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue