summaryrefslogtreecommitdiff
path: root/cpu/at32ap/interrupts.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-06-05 01:12:30 +0200
committerWolfgang Denk <wd@denx.de>2008-06-05 01:12:30 +0200
commit8155efbd7ae9c65564ca98affe94631d612ae088 (patch)
tree23f89ba651f48bf88c653796cb64f2c58d2f0515 /cpu/at32ap/interrupts.c
parent5e1882df6a3efc7de5524d28cea4ecde7d163d54 (diff)
parent9ef1cbef1a649e3779298b0e663be4865cbbbfbc (diff)
downloadolio-uboot-2014.01-8155efbd7ae9c65564ca98affe94631d612ae088.tar.xz
olio-uboot-2014.01-8155efbd7ae9c65564ca98affe94631d612ae088.zip
Merge branch 'master' of ssh://mercury/home/wd/git/u-boot/master
Diffstat (limited to 'cpu/at32ap/interrupts.c')
-rw-r--r--cpu/at32ap/interrupts.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/cpu/at32ap/interrupts.c b/cpu/at32ap/interrupts.c
index bef1f30d7..160838eee 100644
--- a/cpu/at32ap/interrupts.c
+++ b/cpu/at32ap/interrupts.c
@@ -98,18 +98,16 @@ void set_timer(unsigned long t)
*/
void udelay(unsigned long usec)
{
- unsigned long now, end;
+ unsigned long cycles;
+ unsigned long base;
+ unsigned long now;
- now = sysreg_read(COUNT);
+ base = sysreg_read(COUNT);
+ cycles = ((usec * (get_tbclk() / 10000)) + 50) / 100;
- end = ((usec * (get_tbclk() / 10000)) + 50) / 100;
- end += now;
-
- while (now > end)
- now = sysreg_read(COUNT);
-
- while (now < end)
+ do {
now = sysreg_read(COUNT);
+ } while ((now - base) < cycles);
}
static int set_interrupt_handler(unsigned int nr, void (*handler)(void),