[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6528 - in gnuradio/branches/developers/matt/u2f: firm
From: |
eb |
Subject: |
[Commit-gnuradio] r6528 - in gnuradio/branches/developers/matt/u2f: firmware top/u2_basic |
Date: |
Mon, 24 Sep 2007 19:46:41 -0600 (MDT) |
Author: eb
Date: 2007-09-24 19:46:41 -0600 (Mon, 24 Sep 2007)
New Revision: 6528
Added:
gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
Modified:
gnuradio/branches/developers/matt/u2f/firmware/Makefile
gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
gnuradio/branches/developers/matt/u2f/top/u2_basic/u2_basic.v
Log:
working interrupt controller and timer interrupts
Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile 2007-09-25
01:20:22 UTC (rev 6527)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile 2007-09-25
01:46:41 UTC (rev 6528)
@@ -16,8 +16,8 @@
.PRECIOUS : %.bin
-ROMS = test1.rom eth_test.rom
-DUMPS = test1.dump eth_test.dump
+ROMS = test1.rom eth_test.rom timer_test.rom
+DUMPS = test1.dump eth_test.dump timer_test.dump
all: $(ROMS) $(DUMPS)
@@ -27,11 +27,12 @@
eth_test.exe: eth_test.o u2_init.o spi.o buffer_pool.o sim_io.o
$(CC) $(LDFLAGS) $^ -o $@
+timer_test.exe: timer_test.o u2_init.o spi.o sim_io.o
+ $(CC) $(LDFLAGS) $^ -o $@
+
clean:
rm -f *.o *.bin *.rom *.exe *.dump
-install-sim: all
- cp -a *.rom ../top/u2_sim
# dependencies
bootstrap.o: memory_map.h spi.h buffer_pool.h sim_io.h bootstrap.c
Modified: gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/memory_map.h 2007-09-25
01:20:22 UTC (rev 6527)
+++ gnuradio/branches/developers/matt/u2f/firmware/memory_map.h 2007-09-25
01:46:41 UTC (rev 6528)
@@ -177,27 +177,34 @@
///////////////////////////////////////////////////
// Interrupt Controller, Slave 8
-#define PIC_BASE 0xE0000
+#define PIC_BASE 0xE000
typedef struct {
- volatile int EdgeEnable;
- volatile int Polarity;
- volatile int Mask;
- volatile int Pending;
+ volatile int edge_enable;
+ volatile int polarity; // mask: 1 -> rising edge
+ volatile int mask; // mask: 1 -> disabled
+ volatile int pending; // mask: 1 -> pending; write 1's to
clear pending ints
} pic_regs_t;
#define pic_regs ((pic_regs_t *) PIC_BASE)
-#define PHY_INT 0x10
-#define I2C_INT 0x08
-#define SPI_INT 0x04
-#define TIMER_INT 0x02
-#define BUFFER_INT 0x01
+#define PIC_PHY_INT 0x10 // ethernet PHY interrupt
+#define PIC_I2C_INT 0x08
+#define PIC_SPI_INT 0x04
+#define PIC_TIMER_INT 0x02
+#define PIC_BUFFER_INT 0x01
+#define PIC_ALL_INTS (PIC_BUFFER_INT | PIC_TIMER_INT | TIMER_SPI_INT |
PIC_I2C_INT | PIC_PHY_INT)
+
///////////////////////////////////////////////////
// Timer, Slave 9
#define TIMER_BASE 0xE800
-#define timer ((int *) TIMER_BASE)
+typedef struct {
+ volatile int time; // R: current, W: set time to interrupt
+} timer_regs_t;
+
+#define timer_regs ((timer_regs_t *) TIMER_BASE)
+
#endif
Copied: gnuradio/branches/developers/matt/u2f/firmware/timer_test.c (from rev
6525, gnuradio/branches/developers/matt/u2f/firmware/eth_test.c)
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
(rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/timer_test.c 2007-09-25
01:46:41 UTC (rev 6528)
@@ -0,0 +1,70 @@
+#include "u2_init.h"
+#include "memory_map.h"
+#include "spi.h"
+#include "sim_io.h"
+#include "buffer_pool.h"
+
+// Globals
+#define EMPTY 0
+#define FILLING 1
+#define FULL 2
+#define EMPTYING 3
+
+#define PORT 2 // ethernet = 2, serdes = 0
+int dsp_rx_buf, dsp_tx_buf, serdes_rx_buf, serdes_tx_buf;
+int dsp_rx_idle, dsp_tx_idle, serdes_rx_idle, serdes_tx_idle;
+
+int buffer_state[4];
+
+#define DELTA_T 500 // 500 us (10ns per tick)
+
+/* FIXME figure out magic that ties this into the vector */
+
+void int_handler_func () __attribute__ ((interrupt_handler));
+
+void int_handler_func () {
+ int t = timer_regs->time;
+ timer_regs->time = t + DELTA_T;
+ pic_regs->pending = PIC_TIMER_INT;
+
+ sim_puts("Tick:");
+ sim_puthex_nl(t);
+}
+
+int
+main(void)
+{
+ int t;
+
+ sim_puts("Start INIT\n");
+
+ u2_init();
+
+ sim_puts("Setting up interrupt controller\n");
+
+ // setup interrupt controller
+
+ // FIXME assume processor interrupts are enabled here.
+ // uP is level triggered
+
+ pic_regs->edge_enable = PIC_TIMER_INT | PIC_PHY_INT;
+ pic_regs->polarity = PIC_TIMER_INT | PIC_PHY_INT; // rising edge
+ pic_regs->mask = ~0; // mask all interrupts
+ pic_regs->pending = ~0; // clear all pending ints
+
+ // setup timer
+
+ sim_puts("Setting up timer\n");
+ t = timer_regs->time;
+ timer_regs->time = t + DELTA_T;
+
+ pic_regs->mask &= ~PIC_TIMER_INT;
+
+ while(1){
+ }
+
+ sim_puts("Done Testing\n");
+
+ sim_finish();
+ return 1;
+}
Modified: gnuradio/branches/developers/matt/u2f/top/u2_basic/u2_basic.v
===================================================================
--- gnuradio/branches/developers/matt/u2f/top/u2_basic/u2_basic.v
2007-09-25 01:20:22 UTC (rev 6527)
+++ gnuradio/branches/developers/matt/u2f/top/u2_basic/u2_basic.v
2007-09-25 01:46:41 UTC (rev 6528)
@@ -433,7 +433,7 @@
// Interrupt Controller, Slave #8
simple_pic simple_pic
-
(.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[1:0]),
+
(.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[3:2]),
.we_i(s8_we),.dat_i(s8_dat_o[7:0]),.dat_o(s8_dat_i[7:0]),.ack_o(s8_ack),.int_o(proc_int),
.irq({3'b000,PHY_INTn,i2c_int,spi_int,timer_int,buffer_int}) );
assign s8_dat_i[31:8] = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6528 - in gnuradio/branches/developers/matt/u2f: firmware top/u2_basic,
eb <=