2 /*-----------------------------------------------------------------------------
\r
4 *-----------------------------------------------------------------------------
\r
5 * Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
\r
6 * Copyright 2003 Free Software Foundation, Inc.
\r
7 *-----------------------------------------------------------------------------
\r
8 * This code is part of usbjtag. usbjtag is free software; you can redistribute
\r
9 * it and/or modify it under the terms of the GNU General Public License as
\r
10 * published by the Free Software Foundation; either version 2 of the License,
\r
11 * or (at your option) any later version. usbjtag is distributed in the hope
\r
12 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details. You should have received a
\r
15 * copy of the GNU General Public License along with this program in the file
\r
16 * COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
\r
17 * St, Fifth Floor, Boston, MA 02110-1301 USA
\r
18 *-----------------------------------------------------------------------------
\r
22 * Delay approximately 1 microsecond (including overhead in udelay).
\r
25 udelay1 (void) _naked
\r
27 _asm ; lcall that got us here took 4 bus cycles
\r
33 * delay for approximately usecs microseconds
\r
36 udelay (unsigned char usecs)
\r
40 } while (--usecs != 0);
\r
45 * Delay approximately 1 millisecond.
\r
46 * We're running at 48 MHz, so we need 48,000 clock cycles.
\r
48 * Note however, that each bus cycle takes 4 clock cycles (not obvious,
\r
49 * but explains the factor of 4 problem below).
\r
52 mdelay1 (void) _naked
\r
55 mov dptr,#(-1200 & 0xffff)
\r
57 inc dptr ; 3 bus cycles
\r
58 mov a, dpl ; 2 bus cycles
\r
59 orl a, dph ; 2 bus cycles
\r
60 jnz 002$ ; 3 bus cycles
\r
67 mdelay (unsigned int msecs)
\r
71 } while (--msecs != 0);
\r