diff options
| author | Rob Purchase <shotofadds@rockbox.org> | 2008-12-01 21:02:00 +0000 |
|---|---|---|
| committer | Rob Purchase <shotofadds@rockbox.org> | 2008-12-01 21:02:00 +0000 |
| commit | e70096ea5cafedce01291a40a949bec94fa8b90b (patch) | |
| tree | 3fcad1871ce34dd0d502ed1415f2da1bbabf7492 | |
| parent | 8da8159f74f4c9373b25197e6155c753a00e1f4b (diff) | |
| download | rockbox-e70096ea5cafedce01291a40a949bec94fa8b90b.zip rockbox-e70096ea5cafedce01291a40a949bec94fa8b90b.tar.gz rockbox-e70096ea5cafedce01291a40a949bec94fa8b90b.tar.bz2 rockbox-e70096ea5cafedce01291a40a949bec94fa8b90b.tar.xz | |
Telechips I2C: Scale the busy-wait delay based on FREQ, reducing wasted CPU cycles when unboosted (eg. when reading from the D2 touchscreen).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19293 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/target/arm/i2c-telechips.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/firmware/target/arm/i2c-telechips.c b/firmware/target/arm/i2c-telechips.c index b84fbe4..fb341c7 100644 --- a/firmware/target/arm/i2c-telechips.c +++ b/firmware/target/arm/i2c-telechips.c @@ -24,8 +24,13 @@ #include "i2c.h" #include "i2c-target.h" -/* arbitrary delay loop */ -#define DELAY do { int _x; for(_x=0;_x<40;_x++);} while (0) +/* 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--); +} +#define DELAY delay_loop() static struct mutex i2c_mtx; |