Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h
index d2cf994..fe122e5 100644
--- a/firmware/target/arm/as3525/system-target.h
+++ b/firmware/target/arm/as3525/system-target.h
@@ -65,15 +65,15 @@ static inline void udelay(unsigned usecs)
     int now, 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)
      * 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[] =
     {
-        0, 1, 2, 2,  3,  4,  4,  5,  6,  6,
-        7, 8, 8, 9, 10, 10, 11, 12, 12, 13,
+         0,  2,  3,  5,  6,  8,  9, 11, 12, 14,
+        15, 17, 18, 20, 21, 23, 24, 26, 27, 29,
     };


@@ -81,7 +81,7 @@ static inline void udelay(unsigned usecs)
     /* 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
      * call sleep()) */
-    if (UNLIKELY(usecs >= TIMER_PERIOD))
+    if (UNLIKELY(usecs >= (TIMER_PERIOD*2/3)))
         panicf("%s(): %d too high!", __func__, usecs);
     if (UNLIKELY(usecs <= 0))
         return;
@@ -91,7 +91,7 @@ static inline void udelay(unsigned usecs)
     }
     else
     {   /* 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;
     }
     /* underrun ? */