3 * Copyright 2007 Free Software Foundation, Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "memory_map.h"
22 // Delay about one millisecond.
24 // Need 33,333 cycles at 33 MHz.
25 // Each time around the loop is 10 cycles
28 #define LOOPCNT(wb_div) (MASTER_CLK_RATE/(wb_div) / 10000)
31 delay_1ms(int loop_count)
34 for (i = 0; i < loop_count; i++){
35 asm volatile ("or r0, r0, r0\n\
45 // delay about ms milliseconds
49 static int loop_count = -1;
51 if (hwconfig_simulation_p())
55 // set correct loop_count
56 static unsigned short lc[8] = {
67 loop_count = lc[hwconfig_wishbone_divisor() & 0x7];
71 for (i = 0; i < ms; i++)
72 delay_1ms(loop_count);