source: rtems/c/src/lib/libcpu/sh/sh7032/delay/delay.c @ fc0ac39c

4.104.114.84.95
Last change on this file since fc0ac39c was 875fbdbb, checked in by Joel Sherrill <joel.sherrill@…>, on 11/22/99 at 13:48:10

Added files missed by previous merger of SH-2 port.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/* 
2 *  This routine is a simple spin delay
3 *
4 *  Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de)
5 *
6 *  COPYRIGHT (c) 1999, Ralf Corsepius, Ulm, Germany
7 *
8 *  This program is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *  Copyright assigned to U.S. Government, 1994.
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.OARcorp.com/rtems/license.html.
20 *
21 *  $Id$
22 */
23
24
25#include <rtems.h>
26
27/*
28 *  Simple spin delay in microsecond units for device drivers.
29 *  This is very dependent on the clock speed of the target.
30 *
31 *  Since we don't have a real time clock, this is a very rough
32 *  approximation, assuming that each cycle of the delay loop takes
33 *  approx. 4 machine cycles.
34 *
35 *  e.g.: clicks_per_second = 20MHz
36 *        => 5e-8 secs per instruction
37 *        => 4 * 5e-8 secs per delay loop
38 */
39
40void CPU_delay( unsigned32 microseconds )
41{
42  register unsigned32 clicks_per_usec =
43    rtems_cpu_configuration_get_clicks_per_second() / 1000000 ;
44  register unsigned32 _delay =
45    (microseconds) * (clicks_per_usec);
46  asm volatile (
47"0:     add  #-4,%0\n
48        nop\n
49        cmp/pl %0\n
50        bt 0b
51        nop"
52     :: "r" (_delay) );
53}
Note: See TracBrowser for help on using the repository browser.