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