OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [sh/] [sh7032/] [delay/] [delay.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: delay.c,v 1.2 2001-09-27 12:01:31 chris Exp $
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
 
40
void 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.