[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6876 - gnuradio/branches/developers/matt/u2f/firmware
From: |
eb |
Subject: |
[Commit-gnuradio] r6876 - gnuradio/branches/developers/matt/u2f/firmware |
Date: |
Mon, 12 Nov 2007 19:39:49 -0700 (MST) |
Author: eb
Date: 2007-11-12 19:39:48 -0700 (Mon, 12 Nov 2007)
New Revision: 6876
Added:
gnuradio/branches/developers/matt/u2f/firmware/buf_ram_zero.c
Modified:
gnuradio/branches/developers/matt/u2f/firmware/Makefile.am
Log:
new: buf_ram_zero
Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile.am
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile.am 2007-11-13
02:33:59 UTC (rev 6875)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile.am 2007-11-13
02:39:48 UTC (rev 6876)
@@ -58,6 +58,7 @@
blink_leds \
blink_leds2 \
buf_ram_test \
+ buf_ram_zero \
eth_test \
gen_eth_packets \
ibs_rx_test \
Added: gnuradio/branches/developers/matt/u2f/firmware/buf_ram_zero.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/buf_ram_zero.c
(rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/buf_ram_zero.c
2007-11-13 02:39:48 UTC (rev 6876)
@@ -0,0 +1,113 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+// checks if all buffer reads return 0.
+
+
+#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"
+
+
+// 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;
+ int counter = 0;
+
+ for (n = 0; n < NBUFFERS; n++){
+ volatile int *p = buffer_ram(n);
+ for (i = 0; i < BUFFER_POOL_BUFFER_SIZE; i++)
+ p[i] = counter++;
+ }
+}
+
+// return number of errors detected
+static int
+check_bufs(void)
+{
+ int i, n;
+ int nerrors = 0;
+
+ for (n = 0; n < NBUFFERS; n++){
+ volatile int *p = buffer_ram(n);
+ for (i = 0; i < BUFFER_POOL_BUFFER_SIZE; i++)
+ if (p[i] != 0)
+ nerrors++;
+ }
+ return nerrors;
+}
+
+
+int
+main(void)
+{
+ u2_init();
+
+ output_regs->leds = 0;
+ mdelay(100);
+ output_regs->leds = 0x3;
+ mdelay(100);
+ output_regs->leds = 0;
+
+ write_bufs();
+ int nerrors = check_bufs();
+
+ if (nerrors == 0)
+ output_regs->leds = 0x3; // leds on -> PASS
+ else
+ output_regs->leds = 0x0; // leds off -> FAIL
+
+ return 0;
+}
Property changes on:
gnuradio/branches/developers/matt/u2f/firmware/buf_ram_zero.c
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6876 - gnuradio/branches/developers/matt/u2f/firmware,
eb <=