commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5139 - in gnuradio/branches/developers/matt/u2f: . fi


From: matt
Subject: [Commit-gnuradio] r5139 - in gnuradio/branches/developers/matt/u2f: . firmware
Date: Thu, 26 Apr 2007 19:13:38 -0600 (MDT)

Author: matt
Date: 2007-04-26 19:13:38 -0600 (Thu, 26 Apr 2007)
New Revision: 5139

Added:
   gnuradio/branches/developers/matt/u2f/firmware/
   gnuradio/branches/developers/matt/u2f/firmware/bootstrap.c
   gnuradio/branches/developers/matt/u2f/firmware/make
   gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
   gnuradio/branches/developers/matt/u2f/firmware/spi.c
Log:
beginnings of a library to run this chip.  Includes code to bring up the clocks


Added: gnuradio/branches/developers/matt/u2f/firmware/bootstrap.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/bootstrap.c                  
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/bootstrap.c  2007-04-27 
01:13:38 UTC (rev 5139)
@@ -0,0 +1,22 @@
+
+#include "memory_map.h"
+
+int main() {
+
+  // Set up AD9510
+  spi_init();
+
+  spi_transact(SPI_TXONLY, SPI_SS_AD9510, 0x00004500, 24); // CLK2 drives 
distribution
+  spi_wait();
+  spi_transact(SPI_TXONLY, SPI_SS_AD9510, 0x00003D80, 24); // Turn on output 
1, normal levels
+  spi_wait();
+  spi_transact(SPI_TXONLY, SPI_SS_AD9510, 0x00004B80, 24); // Bypass divider
+  spi_wait();
+  spi_transact(SPI_TXONLY, SPI_SS_AD9510, 0x00005A01, 24); // Update Regs
+  spi_wait();
+
+  // Allow for clock switchover
+  char clock_controls = (char)0x1C;
+  char *p = (char *) OUTPUTS_BASE + 3;
+  *p = clock_controls;
+}

Added: gnuradio/branches/developers/matt/u2f/firmware/make
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/make                         
(rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/make 2007-04-27 01:13:38 UTC 
(rev 5139)
@@ -0,0 +1,18 @@
+#!/bin/sh
+# $Id: gccrom,v 1.3 2007/04/25 22:15:06 sybreon Exp $
+# $Log: gccrom,v $
+# Revision 1.3  2007/04/25 22:15:06  sybreon
+# Added support for 8-bit and 16-bit data types.
+#
+# Revision 1.2  2007/04/04 06:14:39  sybreon
+# Minor changes
+#
+# Revision 1.1  2007/03/09 17:41:56  sybreon
+# initial import
+#
+mb-gcc -g -mxl-soft-div -mxl-soft-mul -msoft-float -o rom.o $@ && \
+mb-objcopy -O binary rom.o rom.bin && \
+#hexdump -v -e'1/4 "%.8X\n"' rom.bin > ../sim/aeMB.rom && \
+mb-objdump -DSCs rom.o > rom.dump && \
+#rm rom.bin && \
+echo "ROM generated"


Property changes on: gnuradio/branches/developers/matt/u2f/firmware/make
___________________________________________________________________
Name: svn:executable
   + *

Added: gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/memory_map.h                 
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/memory_map.h 2007-04-27 
01:13:38 UTC (rev 5139)
@@ -0,0 +1,42 @@
+
+/**********************************************************
+ * Memory map for embedded wishbone bus
+ **********************************************************
+ */
+
+#define RAM_BASE 0x0000
+
+/////////////////////////////////////////////////////
+// SPI Wishbone Core.  See core docs for more info
+#define SPI_BASE 0x1000   // Base address (16-bit)
+
+// Register address offsets
+#define SPI_TXRX0 0x000 
+#define SPI_TXRX1 0x004
+#define SPI_TXRX2 0x008
+#define SPI_TXRX3 0x00c
+#define SPI_CTRL 0x010
+#define SPI_DIV 0x014
+#define SPI_SS 0x018
+
+// Masks for controlling different peripherals
+#define SPI_SS_AD9510  1
+#define SPI_SS_AD9777  2
+
+// Masks for different parts of CTRL reg
+#define SPI_CTRL_ASS 1<<13
+#define SPI_CTRL_IE 1<<12
+#define SPI_CTRL_LSB 1<<11
+#define SPI_CTRL_TXNEG 1<<10
+#define SPI_CTRL_RXNEG 1<<9
+#define SPI_CTRL_GO_BSY 1<<8
+#define SPI_CTRL_CHAR_LEN 0x7F
+
+#define SPI_TXONLY 0
+#define SPI_TXRX  1
+////////////////////////////////////////////////
+// I2C
+#define I2C_BASE 0x2000
+#define GPIO_BASE 0x3000
+#define OUTPUTS_BASE 0x4000
+

Added: gnuradio/branches/developers/matt/u2f/firmware/spi.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/spi.c                        
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/spi.c        2007-04-27 
01:13:38 UTC (rev 5139)
@@ -0,0 +1,46 @@
+#include "memory_map.h"
+
+void
+spi_init() {
+  int *p;
+  int val;
+  
+  // Set divider
+  p = (int *)(SPI_BASE+SPI_DIV);
+  *p = 1;  // Div-by-4.  For div-by-2 use 0 here
+}
+
+void
+spi_wait() {
+  int *p;
+  p = (int *)(SPI_BASE+SPI_CTRL);
+  while(*p & SPI_CTRL_GO_BSY)
+    {}
+}
+
+int
+spi_transact(int readback, int slave, int data, int length) {
+  int *p;
+  spi_wait();
+
+  // Tell it which SPI device to access
+  p = (int *)(SPI_BASE+SPI_SS);
+  *p = slave & 0xFF;
+
+  // Data we will send
+  p = (int *)(SPI_BASE+SPI_TXRX0);
+  *p = data;
+
+  // Run it -- write once and rewrite with GO set
+  p = (int *)(SPI_BASE+SPI_CTRL);
+  *p = SPI_CTRL_ASS | SPI_CTRL_TXNEG | (SPI_CTRL_CHAR_LEN & length);
+  *p = SPI_CTRL_GO_BSY | SPI_CTRL_ASS | SPI_CTRL_TXNEG | (SPI_CTRL_CHAR_LEN & 
length);
+
+  if(readback) {
+    spi_wait();
+    p = (int *)(SPI_BASE+SPI_TXRX1);
+    return *p;
+  }
+  else
+    return 0;
+}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]