mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
Fix wrong udelay logic that made it be way off.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25770 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a607a6c3c2
commit
3adac47c61
2 changed files with 8 additions and 8 deletions
|
|
@ -233,12 +233,12 @@ int button_read_device(void)
|
||||||
CCU_IO &= ~(1<<12);
|
CCU_IO &= ~(1<<12);
|
||||||
|
|
||||||
GPIOB_PIN(0) = 1<<0;
|
GPIOB_PIN(0) = 1<<0;
|
||||||
udelay(10);
|
udelay(4);
|
||||||
|
|
||||||
gpiod6 = GPIOD_PIN(6);
|
gpiod6 = GPIOD_PIN(6);
|
||||||
|
|
||||||
GPIOB_PIN(0) = 0;
|
GPIOB_PIN(0) = 0;
|
||||||
udelay(5);
|
udelay(2);
|
||||||
|
|
||||||
if (GPIOC_PIN(1) & 1<<1)
|
if (GPIOC_PIN(1) & 1<<1)
|
||||||
btn |= BUTTON_DOWN;
|
btn |= BUTTON_DOWN;
|
||||||
|
|
|
||||||
|
|
@ -66,15 +66,15 @@ static inline void udelay(unsigned usecs)
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* we're limited to 1.5us multiplies due to the odd timer frequency (1.5MHz),
|
* we're limited to 0.666us multiplies due to the odd timer frequency (1.5MHz),
|
||||||
* to avoid calculating which is safer (need to round up for small values)
|
* to avoid calculating which is safer (need to round up for small values)
|
||||||
* and saves spending time in the divider we have a lut for
|
* and saves spending time in the divider we have a lut for
|
||||||
* small us values, it should be roughly us*2/3
|
* small us values, it should be roughly us*3/2
|
||||||
**/
|
**/
|
||||||
static const unsigned char udelay_lut[] =
|
static const unsigned char udelay_lut[] =
|
||||||
{
|
{
|
||||||
0, 1, 2, 2, 3, 4, 4, 5, 6, 6,
|
0, 2, 3, 5, 6, 8, 9, 11, 12, 14,
|
||||||
7, 8, 8, 9, 10, 10, 11, 12, 12, 13,
|
15, 17, 18, 20, 21, 23, 24, 26, 27, 29,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ static inline void udelay(unsigned usecs)
|
||||||
/* we don't want to handle multiple overflows, so limit the numbers
|
/* we don't want to handle multiple overflows, so limit the numbers
|
||||||
* (if you want to wait more than a tick just poll current_tick, or
|
* (if you want to wait more than a tick just poll current_tick, or
|
||||||
* call sleep()) */
|
* call sleep()) */
|
||||||
if (UNLIKELY(usecs >= TIMER_PERIOD))
|
if (UNLIKELY(usecs >= (TIMER_PERIOD*2/3)))
|
||||||
panicf("%s(): %d too high!", __func__, usecs);
|
panicf("%s(): %d too high!", __func__, usecs);
|
||||||
if (UNLIKELY(usecs <= 0))
|
if (UNLIKELY(usecs <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
@ -92,7 +92,7 @@ static inline void udelay(unsigned usecs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* to usecs */
|
{ /* to usecs */
|
||||||
int delay = usecs * 2 / 3; /* us * 1.5 = us*timer_period */
|
int delay = usecs * 3 / 2; /* us * 0.666 = us*timer_period */
|
||||||
end = now - delay;
|
end = now - delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue