[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6991 - in usrp2/trunk/firmware: apps lib
From: |
eb |
Subject: |
[Commit-gnuradio] r6991 - in usrp2/trunk/firmware: apps lib |
Date: |
Sun, 18 Nov 2007 13:13:48 -0700 (MST) |
Author: eb
Date: 2007-11-18 13:13:46 -0700 (Sun, 18 Nov 2007)
New Revision: 6991
Added:
usrp2/trunk/firmware/lib/mdelay.c
usrp2/trunk/firmware/lib/mdelay.h
Modified:
usrp2/trunk/firmware/apps/buf_ram_test.c
usrp2/trunk/firmware/apps/buf_ram_zero.c
usrp2/trunk/firmware/lib/Makefile.am
usrp2/trunk/firmware/lib/eeprom.c
usrp2/trunk/firmware/lib/u2_init.c
Log:
Moved mdelay into mdelay.{h,c}. Under simulation it waits just a few
cycles. u2_init now flashes both leds for 100ms so we know that the
board is alive when booting.
Modified: usrp2/trunk/firmware/apps/buf_ram_test.c
===================================================================
--- usrp2/trunk/firmware/apps/buf_ram_test.c 2007-11-18 07:35:24 UTC (rev
6990)
+++ usrp2/trunk/firmware/apps/buf_ram_test.c 2007-11-18 20:13:46 UTC (rev
6991)
@@ -17,43 +17,13 @@
#include "u2_init.h"
#include "memory_map.h"
-#include "eth_driver.h"
-#include "eth_mac.h"
-#include "pic.h"
#include "bool.h"
#include "nonstdio.h"
#include "hal_io.h"
+#include "mdelay.h"
-// Delay about one millisecond.
-//
-// Need 33,333 cycles at 33 MHz.
-// Each time around the loop is 10 cycles
-void
-delay_1ms(void)
-{
- int i;
- for (i = 0; i < 3333; i++){
- asm volatile ("or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n");
- }
-}
-
-// delay about ms milliseconds
static void
-mdelay(int ms)
-{
- int i;
- for (i = 0; i < ms; i++)
- delay_1ms();
-}
-
-static void
write_bufs(void)
{
int i, n;
@@ -102,16 +72,6 @@
output_regs->leds = 0;
- if (!hwconfig_simulation_p())
- mdelay(100);
-
- output_regs->leds = 0x3;
-
- if (!hwconfig_simulation_p())
- mdelay(100);
-
- output_regs->leds = 0;
-
write_bufs();
int nerrors = check_bufs();
Modified: usrp2/trunk/firmware/apps/buf_ram_zero.c
===================================================================
--- usrp2/trunk/firmware/apps/buf_ram_zero.c 2007-11-18 07:35:24 UTC (rev
6990)
+++ usrp2/trunk/firmware/apps/buf_ram_zero.c 2007-11-18 20:13:46 UTC (rev
6991)
@@ -21,42 +21,11 @@
#include "u2_init.h"
#include "memory_map.h"
#include "hal_io.h"
-#include "eth_driver.h"
-#include "eth_mac.h"
-#include "pic.h"
#include "bool.h"
+#include "mdelay.h"
-// Delay about one millisecond.
-//
-// Need 33,333 cycles at 33 MHz.
-// Each time around the loop is 10 cycles
-
-void
-delay_1ms(void)
-{
- int i;
- for (i = 0; i < 3333; i++){
- asm volatile ("or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n\
- or r0, r0, r0\n");
- }
-}
-
-// delay about ms milliseconds
static void
-mdelay(int ms)
-{
- int i;
- for (i = 0; i < ms; i++)
- delay_1ms();
-}
-
-static void
write_bufs(void)
{
int i, n;
@@ -91,11 +60,7 @@
{
u2_init();
- output_regs->leds = 0;
- mdelay(100);
- output_regs->leds = 0x3;
- mdelay(100);
- output_regs->leds = 0;
+ output_regs->leds = 0x0;
write_bufs();
int nerrors = check_bufs();
Modified: usrp2/trunk/firmware/lib/Makefile.am
===================================================================
--- usrp2/trunk/firmware/lib/Makefile.am 2007-11-18 07:35:24 UTC (rev
6990)
+++ usrp2/trunk/firmware/lib/Makefile.am 2007-11-18 20:13:46 UTC (rev
6991)
@@ -28,6 +28,7 @@
hal_io.c \
hal_uart.c \
i2c.c \
+ mdelay.c \
nonstdio.c \
pic.c \
printf.c \
Modified: usrp2/trunk/firmware/lib/eeprom.c
===================================================================
--- usrp2/trunk/firmware/lib/eeprom.c 2007-11-18 07:35:24 UTC (rev 6990)
+++ usrp2/trunk/firmware/lib/eeprom.c 2007-11-18 20:13:46 UTC (rev 6991)
@@ -16,6 +16,7 @@
*/
#include "i2c.h"
+#include "mdelay.h"
static const int EEPROM_PAGESIZE = 16;
@@ -35,7 +36,7 @@
cmd[0] = eeprom_offset++;
cmd[1] = *p++;
bool r = i2c_write (i2c_addr, cmd, sizeof (cmd));
- // mdelay (10); // FIXME put back in // delay 10ms worst case
write time
+ mdelay (10); // delay 10ms worst case write time
if (!r)
return false;
}
Added: usrp2/trunk/firmware/lib/mdelay.c
===================================================================
--- usrp2/trunk/firmware/lib/mdelay.c (rev 0)
+++ usrp2/trunk/firmware/lib/mdelay.c 2007-11-18 20:13:46 UTC (rev 6991)
@@ -0,0 +1,74 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mdelay.h"
+#include "memory_map.h"
+
+// Delay about one millisecond.
+//
+// Need 33,333 cycles at 33 MHz.
+// Each time around the loop is 10 cycles
+//
+
+#define LOOPCNT(wb_div) (MASTER_CLK_RATE/(wb_div) / 10000)
+
+inline static void
+delay_1ms(int loop_count)
+{
+ int i;
+ for (i = 0; i < loop_count; i++){
+ asm volatile ("or r0, r0, r0\n\
+ or r0, r0, r0\n\
+ or r0, r0, r0\n\
+ or r0, r0, r0\n\
+ or r0, r0, r0\n\
+ or r0, r0, r0\n\
+ or r0, r0, r0\n");
+ }
+}
+
+// delay about ms milliseconds
+void
+mdelay(int ms)
+{
+ static int loop_count = -1;
+
+ if (loop_count < 0){
+ // set correct loop_count
+ static unsigned short lc[8] = {
+ 0,
+ LOOPCNT(1),
+ LOOPCNT(2),
+ LOOPCNT(3),
+ LOOPCNT(4),
+ LOOPCNT(5),
+ LOOPCNT(6),
+ LOOPCNT(7)
+ };
+
+ if (hwconfig_simulation_p())
+ loop_count = 0;
+ else {
+ loop_count = lc[hwconfig_wishbone_divisor() & 0x7];
+ }
+ }
+
+ int i;
+ for (i = 0; i < ms; i++)
+ delay_1ms(loop_count);
+}
Property changes on: usrp2/trunk/firmware/lib/mdelay.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: usrp2/trunk/firmware/lib/mdelay.h
===================================================================
--- usrp2/trunk/firmware/lib/mdelay.h (rev 0)
+++ usrp2/trunk/firmware/lib/mdelay.h 2007-11-18 20:13:46 UTC (rev 6991)
@@ -0,0 +1,29 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_MDELAY_H
+#define INCLUDED_MDELAY_H
+
+/*!
+ * \brief Delay about ms milliseconds
+ *
+ * If simulating, _very_ short delay
+ */
+void mdelay(int ms);
+
+#endif /* INCLUDED_MDELAY_H */
Property changes on: usrp2/trunk/firmware/lib/mdelay.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: usrp2/trunk/firmware/lib/u2_init.c
===================================================================
--- usrp2/trunk/firmware/lib/u2_init.c 2007-11-18 07:35:24 UTC (rev 6990)
+++ usrp2/trunk/firmware/lib/u2_init.c 2007-11-18 20:13:46 UTC (rev 6991)
@@ -24,6 +24,7 @@
#include "hal_uart.h"
#include "i2c.h"
#include "bool.h"
+#include "mdelay.h"
/*
* We ought to arrange for this to be called before main, but for now,
@@ -81,6 +82,13 @@
hal_enable_ints();
+ // flash both leds to let us know board is alive
+ output_regs->leds = 0x0;
+ mdelay(100);
+ output_regs->leds = 0x3;
+ mdelay(100);
+ output_regs->leds = 0x0;
+
return true;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6991 - in usrp2/trunk/firmware: apps lib,
eb <=