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

Last change on this file since c8f3e82 was 13597a72, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/02 at 22:02:33

2002-11-01 Joel Sherrill <joel@…>

  • delay/delay.c, score/ispsh7032.c: Removed warnings.
  • 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 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  $Id$
21 */
22
23
24#include <rtems.h>
25
26/*
27 *  Simple spin delay in microsecond units for device drivers.
28 *  This is very dependent on the clock speed of the target.
29 *
30 *  Since we don't have a real time clock, this is a very rough
31 *  approximation, assuming that each cycle of the delay loop takes
32 *  approx. 4 machine cycles.
33 *
34 *  e.g.: clicks_per_second = 20MHz
35 *        => 5e-8 secs per instruction
36 *        => 4 * 5e-8 secs per delay loop
37 */
38
39void CPU_delay( unsigned32 microseconds )
40{
41  register unsigned32 clicks_per_usec =
42    rtems_cpu_configuration_get_clicks_per_second() / 1000000 ;
43  register unsigned32 _delay =
44    (microseconds) * (clicks_per_usec);
45  asm volatile (
46"0:     add  #-4,%0\n\
47        nop\n\
48        cmp/pl %0\n\
49        bt 0b\n\
50        nop"
51     :: "r" (_delay) );
52}
Note: See TracBrowser for help on using the repository browser.