![]() |
|
|||
File indexing completed on 2025-05-11 08:24:01
0001 /* 0002 * This routine is a simple spin delay 0003 * 0004 * Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de) 0005 * 0006 * COPYRIGHT (c) 1999, Ralf Corsepius, Ulm, Germany 0007 * 0008 * This program is distributed in the hope that it will be useful, 0009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 0011 * 0012 * 0013 * COPYRIGHT (c) 1989-1999. 0014 * On-Line Applications Research Corporation (OAR). 0015 * 0016 * The license and distribution terms for this file may be 0017 * found in the file LICENSE in this distribution or at 0018 * http://www.rtems.org/license/LICENSE. 0019 */ 0020 0021 0022 #include <rtems.h> 0023 0024 extern uint32_t bsp_clicks_per_second; 0025 0026 /* 0027 * Simple spin delay in microsecond units for device drivers. 0028 * This is very dependent on the clock speed of the target. 0029 * 0030 * Since we don't have a real time clock, this is a very rough 0031 * approximation, assuming that each cycle of the delay loop takes 0032 * approx. 4 machine cycles. 0033 * 0034 * e.g.: clicks_per_second = 20MHz 0035 * => 5e-8 secs per instruction 0036 * => 4 * 5e-8 secs per delay loop 0037 */ 0038 0039 void CPU_delay( uint32_t microseconds ) 0040 { 0041 register uint32_t clicks_per_usec = bsp_clicks_per_second / 1000000; 0042 register uint32_t _delay = (microseconds) * (clicks_per_usec); 0043 0044 __asm__ volatile ( 0045 "0: add #-4,%0\n\ 0046 nop\n\ 0047 cmp/pl %0\n\ 0048 bt 0b\n\ 0049 nop" 0050 :: "r" (_delay) ); 0051 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |