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

4.104.114.84.95
Last change on this file since 2aabc030 was 650a5397, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/01 at 21:01:15

2001-10-12 Joel Sherrill <joel@…>

  • clock/ckinit.c, delay/delay.c, include/iosh7032.h, include/ispsh7032.h, include/sci.h, include/sh7_pfc.h, include/sh7_sci.h, sci/sci.c, score/cpu_asm.c, score/ispsh7032.c, timer/timer.c: Fixed typo.
  • Property mode set to 100644
File size: 1.3 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
50        nop"
51     :: "r" (_delay) );
52}
Note: See TracBrowser for help on using the repository browser.