diff options
| author | Rob Purchase <shotofadds@rockbox.org> | 2010-06-16 21:03:57 +0000 |
|---|---|---|
| committer | Rob Purchase <shotofadds@rockbox.org> | 2010-06-16 21:03:57 +0000 |
| commit | 6c94ce590dadf6e80a029828e65f676bf79e0537 (patch) | |
| tree | bdc56435e7804e0fa983cbe4230cbc2d60fae2a1 | |
| parent | ff8e76e9e534dde1e6a57a84d49b89dad847cafd (diff) | |
| download | rockbox-6c94ce590dadf6e80a029828e65f676bf79e0537.zip rockbox-6c94ce590dadf6e80a029828e65f676bf79e0537.tar.gz rockbox-6c94ce590dadf6e80a029828e65f676bf79e0537.tar.bz2 rockbox-6c94ce590dadf6e80a029828e65f676bf79e0537.tar.xz | |
Re-write the Telechips I2C delay routine in assembler to stop the compiler optimising it away. Tested with EABI and non-EABI compilers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26872 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/target/arm/i2c-telechips.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/firmware/target/arm/i2c-telechips.c b/firmware/target/arm/i2c-telechips.c index 35f4cd4..511bbe8 100644 --- a/firmware/target/arm/i2c-telechips.c +++ b/firmware/target/arm/i2c-telechips.c @@ -27,9 +27,10 @@ /* Delay loop based on CPU frequency (FREQ>>22 is 7..45 for 32MHz..192MHz) */ static inline void delay_loop(void) { - unsigned long x; - for (x = (unsigned)(FREQ>>22); x; x--) - asm volatile("nop"); + asm volatile (" mov %[freq], %[freq], asr#22 \n\t" + "1: subs %[freq], %[freq], #1 \n\t" + " bne 1b" + : : [freq] "r" (cpu_frequency) : "memory"); } #define DELAY delay_loop() |