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
This commit is contained in:
Rob Purchase 2008-12-01 21:02:00 +00:00
parent 8da8159f74
commit e70096ea5c

View file

@ -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;