diff options
Diffstat (limited to 'firmware/target/coldfire')
-rw-r--r-- | firmware/target/coldfire/pcf50606-coldfire.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/firmware/target/coldfire/pcf50606-coldfire.c b/firmware/target/coldfire/pcf50606-coldfire.c index d777b41cb1..d57b249f0d 100644 --- a/firmware/target/coldfire/pcf50606-coldfire.c +++ b/firmware/target/coldfire/pcf50606-coldfire.c | |||
@@ -140,6 +140,11 @@ inline void pcf50606_i2c_stop(void) | |||
140 | asm ( | 140 | asm ( |
141 | "or.l %[sdab],(8,%[sdard]) \n" /* SDA_LO_OUT */ | 141 | "or.l %[sdab],(8,%[sdard]) \n" /* SDA_LO_OUT */ |
142 | 142 | ||
143 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
144 | "1: \n" | ||
145 | "subq.l #1,%%d0 \n" | ||
146 | "bhi.s 1b \n" | ||
147 | |||
143 | "not.l %[sclb] \n" /* SCL_HI_IN */ | 148 | "not.l %[sclb] \n" /* SCL_HI_IN */ |
144 | "and.l %[sclb],(8,%[sclrd]) \n" | 149 | "and.l %[sclb],(8,%[sclrd]) \n" |
145 | "not.l %[sclb] \n" | 150 | "not.l %[sclb] \n" |
@@ -169,6 +174,7 @@ inline void pcf50606_i2c_stop(void) | |||
169 | ); | 174 | ); |
170 | #else | 175 | #else |
171 | SDA_LO_OUT; | 176 | SDA_LO_OUT; |
177 | DELAY; | ||
172 | SCL_HI_IN; | 178 | SCL_HI_IN; |
173 | DELAY; | 179 | DELAY; |
174 | SDA_HI_IN; | 180 | SDA_HI_IN; |
@@ -189,6 +195,11 @@ inline void pcf50606_i2c_ack(bool ack) | |||
189 | "1: \n" | 195 | "1: \n" |
190 | "or.l %[sdab],(8,%[sdard]) \n" /* SDA_LO_OUT */ | 196 | "or.l %[sdab],(8,%[sdard]) \n" /* SDA_LO_OUT */ |
191 | 197 | ||
198 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
199 | "1: \n" | ||
200 | "subq.l #1,%%d0 \n" | ||
201 | "bhi.s 1b \n" | ||
202 | |||
192 | "not.l %[sclb] \n" /* SCL_HI_IN */ | 203 | "not.l %[sclb] \n" /* SCL_HI_IN */ |
193 | "and.l %[sclb],(8,%[sclrd]) \n" | 204 | "and.l %[sclb],(8,%[sclrd]) \n" |
194 | "not.l %[sclb] \n" | 205 | "not.l %[sclb] \n" |
@@ -220,9 +231,8 @@ inline void pcf50606_i2c_ack(bool ack) | |||
220 | SDA_LO_OUT; | 231 | SDA_LO_OUT; |
221 | else | 232 | else |
222 | SDA_HI_IN; | 233 | SDA_HI_IN; |
223 | 234 | DELAY; | |
224 | SCL_HI_IN; | 235 | SCL_HI_IN; |
225 | |||
226 | DELAY; | 236 | DELAY; |
227 | SCL_LO_OUT; | 237 | SCL_LO_OUT; |
228 | #endif | 238 | #endif |
@@ -251,16 +261,16 @@ inline bool pcf50606_i2c_getack(void) | |||
251 | "btst.l %[sclbnum],%%d0 \n" | 261 | "btst.l %[sclbnum],%%d0 \n" |
252 | "beq.s 1b \n" | 262 | "beq.s 1b \n" |
253 | 263 | ||
264 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
265 | "1: \n" | ||
266 | "subq.l #1,%%d0 \n" | ||
267 | "bhi.s 1b \n" | ||
268 | |||
254 | "move.l (%[sdard]),%%d0 \n" /* ret = !SDA */ | 269 | "move.l (%[sdard]),%%d0 \n" /* ret = !SDA */ |
255 | "btst.l %[sdabnum],%%d0 \n" | 270 | "btst.l %[sdabnum],%%d0 \n" |
256 | "seq.b %[ret] \n" | 271 | "seq.b %[ret] \n" |
257 | 272 | ||
258 | "or.l %[sclb],(8,%[sclrd]) \n" /* SCL_LO_OUT */ | 273 | "or.l %[sclb],(8,%[sclrd]) \n" /* SCL_LO_OUT */ |
259 | |||
260 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
261 | "1: \n" | ||
262 | "subq.l #1,%%d0 \n" | ||
263 | "bhi.s 1b \n" | ||
264 | : /* outputs */ | 274 | : /* outputs */ |
265 | [ret] "=&d"(ret) | 275 | [ret] "=&d"(ret) |
266 | : /* inputs */ | 276 | : /* inputs */ |
@@ -278,11 +288,11 @@ inline bool pcf50606_i2c_getack(void) | |||
278 | SDA_HI_IN; | 288 | SDA_HI_IN; |
279 | DELAY; | 289 | DELAY; |
280 | SCL_HI_IN; | 290 | SCL_HI_IN; |
291 | DELAY; | ||
281 | 292 | ||
282 | ret = !SDA; | 293 | ret = !SDA; |
283 | 294 | ||
284 | SCL_LO_OUT; | 295 | SCL_LO_OUT; |
285 | DELAY; | ||
286 | #endif | 296 | #endif |
287 | return ret; | 297 | return ret; |
288 | } | 298 | } |
@@ -372,6 +382,11 @@ unsigned char pcf50606_i2c_inb(bool ack) | |||
372 | "clr.l %[byte] \n" /* byte = 0 */ | 382 | "clr.l %[byte] \n" /* byte = 0 */ |
373 | 383 | ||
374 | "2: \n" /* do */ | 384 | "2: \n" /* do */ |
385 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
386 | "1: \n" | ||
387 | "subq.l #1,%%d0 \n" | ||
388 | "bhi.s 1b \n" | ||
389 | |||
375 | "not.l %[sclb] \n" /* SCL_HI_IN */ | 390 | "not.l %[sclb] \n" /* SCL_HI_IN */ |
376 | "and.l %[sclb],(8,%[sclrd]) \n" | 391 | "and.l %[sclb],(8,%[sclrd]) \n" |
377 | "not.l %[sclb] \n" | 392 | "not.l %[sclb] \n" |
@@ -394,11 +409,6 @@ unsigned char pcf50606_i2c_inb(bool ack) | |||
394 | 409 | ||
395 | "or.l %[sclb],(8,%[sclrd]) \n" /* SCL_LO_OUT */ | 410 | "or.l %[sclb],(8,%[sclrd]) \n" /* SCL_LO_OUT */ |
396 | 411 | ||
397 | "move.l %[dly],%%d0 \n" /* DELAY */ | ||
398 | "1: \n" | ||
399 | "subq.l #1,%%d0 \n" | ||
400 | "bhi.s 1b \n" | ||
401 | |||
402 | "subq.l #1,%%d1 \n" /* i-- */ | 412 | "subq.l #1,%%d1 \n" /* i-- */ |
403 | "bne.s 2b \n" /* while (i != 0) */ | 413 | "bne.s 2b \n" /* while (i != 0) */ |
404 | : /* outputs */ | 414 | : /* outputs */ |
@@ -421,12 +431,12 @@ unsigned char pcf50606_i2c_inb(bool ack) | |||
421 | SDA_HI_IN; | 431 | SDA_HI_IN; |
422 | for ( i=0x80; i; i>>=1 ) | 432 | for ( i=0x80; i; i>>=1 ) |
423 | { | 433 | { |
434 | DELAY; | ||
424 | SCL_HI_IN; | 435 | SCL_HI_IN; |
425 | DELAY; | 436 | DELAY; |
426 | if ( SDA ) | 437 | if ( SDA ) |
427 | byte |= i; | 438 | byte |= i; |
428 | SCL_LO_OUT; | 439 | SCL_LO_OUT; |
429 | DELAY; | ||
430 | } | 440 | } |
431 | #endif | 441 | #endif |
432 | 442 | ||