aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-17 16:12:00 -0800
committerJosh Blum <josh@joshknows.com>2010-12-11 18:43:09 -0800
commitb621dea91eeebe05c4823bc2da8780fa12997169 (patch)
tree3545fc910b17b4c5401a76dd30188944934b7dc1 /firmware
parent57fcedbba7cbedda714aefa6653bf00e30e5981a (diff)
downloaduhd-b621dea91eeebe05c4823bc2da8780fa12997169.tar.gz
uhd-b621dea91eeebe05c4823bc2da8780fa12997169.tar.bz2
uhd-b621dea91eeebe05c4823bc2da8780fa12997169.zip
usrp2: replaced spi and i2c async stuff with sync (since were out of the fast-path)
Diffstat (limited to 'firmware')
-rw-r--r--firmware/microblaze/apps/txrx_uhd.c95
-rw-r--r--firmware/microblaze/lib/Makefile.inc1
-rw-r--r--firmware/microblaze/lib/spi.c6
-rw-r--r--firmware/microblaze/lib/spi.h8
-rw-r--r--firmware/microblaze/lib/u2_init.c2
-rw-r--r--firmware/microblaze/usrp2/Makefile.am4
6 files changed, 22 insertions, 94 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c
index 8a4abadf0..4adccfed9 100644
--- a/firmware/microblaze/apps/txrx_uhd.c
+++ b/firmware/microblaze/apps/txrx_uhd.c
@@ -40,12 +40,12 @@
#include <string.h>
#include "clocks.h"
#include "usrp2/fw_common.h"
-#include <i2c_async.h>
#include <i2c.h>
#include <ethertype.h>
#include <arp_cache.h>
#include "udp_fw_update.h"
#include "pkt_ctrl.h"
+#include "banal.h"
static void setup_network(void);
@@ -55,10 +55,6 @@ static void setup_network(void);
static eth_mac_addr_t fp_mac_addr_src, fp_mac_addr_dst;
static struct socket_address fp_socket_src, fp_socket_dst;
-// ----------------------------------------------------------------
-void start_rx_streaming_cmd(void);
-void stop_rx_cmd(void);
-
void handle_udp_data_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
@@ -89,33 +85,6 @@ void handle_udp_data_packet(
#define OTW_GPIO_BANK_TO_NUM(bank) \
(((bank) == USRP2_DIR_RX)? (GPIO_RX_BANK) : (GPIO_TX_BANK))
-//setup the output data
-static usrp2_ctrl_data_t ctrl_data_out;
-static struct socket_address i2c_src;
-static struct socket_address spi_src;
-
-static volatile bool i2c_done = false;
-void i2c_read_done_callback(void) {
- //printf("I2C read done callback\n");
- i2c_async_data_ready(ctrl_data_out.data.i2c_args.data);
- i2c_done = true;
- i2c_register_callback(0);
-}
-
-void i2c_write_done_callback(void) {
- //printf("I2C write done callback\n");
- i2c_done = true;
- i2c_register_callback(0);
-}
-
-static volatile bool spi_done = false;
-static volatile uint32_t spi_readback_data;
-void get_spi_readback_data(void) {
- ctrl_data_out.data.spi_args.data = spi_get_data();
- spi_done = true;
- spi_register_callback(0);
-}
-
void handle_udp_ctrl_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
@@ -141,6 +110,7 @@ void handle_udp_ctrl_packet(
}
//setup the output data
+ usrp2_ctrl_data_t ctrl_data_out;
ctrl_data_out.proto_ver = USRP2_FW_COMPAT_NUM;
ctrl_data_out.id=USRP2_CTRL_ID_HUH_WHAT;
ctrl_data_out.seq=ctrl_data_in->seq;
@@ -154,7 +124,6 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_WAZZUP_BRO:
ctrl_data_out.id = USRP2_CTRL_ID_WAZZUP_DUDE;
memcpy(&ctrl_data_out.data.ip_addr, get_ip_addr(), sizeof(struct ip_addr));
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
/*******************************************************************
@@ -162,21 +131,19 @@ void handle_udp_ctrl_packet(
******************************************************************/
case USRP2_CTRL_ID_TRANSACT_ME_SOME_SPI_BRO:{
//transact
- bool success = spi_async_transact(
- //(ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX,
+ uint32_t result = spi_transact(
+ (ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX,
ctrl_data_in->data.spi_args.dev, //which device
ctrl_data_in->data.spi_args.data, //32 bit data
ctrl_data_in->data.spi_args.num_bits, //length in bits
- (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE | //flags
- (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL,
- get_spi_readback_data //callback
+ (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE |
+ (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL
);
//load output
+ ctrl_data_out.data.spi_args.data = result;
ctrl_data_out.id = USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE;
- spi_src = src;
}
-// send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
/*******************************************************************
@@ -184,13 +151,11 @@ void handle_udp_ctrl_packet(
******************************************************************/
case USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO:{
uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes;
- i2c_register_callback(i2c_read_done_callback);
- i2c_async_read(
+ i2c_read(
ctrl_data_in->data.i2c_args.addr,
+ ctrl_data_out.data.i2c_args.data,
num_bytes
);
- i2c_src = src;
-// i2c_dst = dst;
ctrl_data_out.id = USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE;
ctrl_data_out.data.i2c_args.bytes = num_bytes;
}
@@ -198,14 +163,11 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO:{
uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes;
- i2c_register_callback(i2c_read_done_callback);
- i2c_async_write(
+ i2c_write(
ctrl_data_in->data.i2c_args.addr,
ctrl_data_in->data.i2c_args.data,
num_bytes
);
- i2c_src = src;
-// i2c_dst = dst;
ctrl_data_out.id = USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE;
ctrl_data_out.data.i2c_args.bytes = num_bytes;
}
@@ -237,7 +199,6 @@ void handle_udp_ctrl_packet(
}
ctrl_data_out.id = USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
case USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO:
@@ -260,7 +221,6 @@ void handle_udp_ctrl_packet(
}
ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
break;
case USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO:{
@@ -287,9 +247,8 @@ void handle_udp_ctrl_packet(
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
}
-
+ send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out));
}
static void handle_inp_packet(uint32_t *buff, size_t num_lines){
@@ -317,27 +276,10 @@ static void handle_inp_packet(uint32_t *buff, size_t num_lines){
//------------------------------------------------------------------
/*
- * 1's complement sum for IP and UDP headers
- *
- * init chksum to zero to start.
- */
-static unsigned int
-CHKSUM(unsigned int x, unsigned int *chksum)
-{
- *chksum += x;
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- *chksum = (*chksum & 0xffff) + (*chksum>>16);
- return x;
-}
-
-/*
* Called when eth phy state changes (w/ interrupts disabled)
*/
-volatile bool link_is_up = false; // eth handler sets this
-void
-link_changed_callback(int speed)
-{
- link_is_up = speed != 0;
+void link_changed_callback(int speed){
+ bool link_is_up = speed != 0;
hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
printf("\neth link changed: speed = %d\n", speed);
if (link_is_up) send_gratuitous_arp();
@@ -421,17 +363,6 @@ main(void)
release_incoming_buffer();
}
- if(i2c_done) {
- i2c_done = false;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, i2c_src, &ctrl_data_out, sizeof(ctrl_data_out));
- //printf("Sending UDP packet from main loop for I2C...\n");
- }
-
- if(spi_done) {
- spi_done = false;
- send_udp_pkt(USRP2_UDP_CTRL_PORT, spi_src, &ctrl_data_out, sizeof(ctrl_data_out));
- }
-
int pending = pic_regs->pending; // poll for under or overrun
if (pending & PIC_UNDERRUN_INT){
diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc
index 471a244e0..d99fc4d98 100644
--- a/firmware/microblaze/lib/Makefile.inc
+++ b/firmware/microblaze/lib/Makefile.inc
@@ -30,7 +30,6 @@ COMMON_SRCS = \
$(top_srcdir)/lib/hal_io.c \
$(top_srcdir)/lib/hal_uart.c \
$(top_srcdir)/lib/i2c.c \
- $(top_srcdir)/lib/i2c_async.c \
$(top_srcdir)/lib/mdelay.c \
$(top_srcdir)/lib/memcpy_wa.c \
$(top_srcdir)/lib/memset_wa.c \
diff --git a/firmware/microblaze/lib/spi.c b/firmware/microblaze/lib/spi.c
index 2a41a1bfa..af0d8a68f 100644
--- a/firmware/microblaze/lib/spi.c
+++ b/firmware/microblaze/lib/spi.c
@@ -20,9 +20,9 @@
#include "pic.h"
#include "nonstdio.h"
-void (*volatile spi_callback)(void); //SPI callback when xfer complete.
+//void (*volatile spi_callback)(void); //SPI callback when xfer complete.
-static void spi_irq_handler(unsigned irq);
+//static void spi_irq_handler(unsigned irq);
void
spi_init(void)
@@ -66,6 +66,7 @@ spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags
return 0;
}
+/*
void spi_register_callback(void (*volatile callback)(void)) {
spi_callback = callback;
}
@@ -106,3 +107,4 @@ spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*
return true;
}
+*/
diff --git a/firmware/microblaze/lib/spi.h b/firmware/microblaze/lib/spi.h
index 54618cedd..71245150a 100644
--- a/firmware/microblaze/lib/spi.h
+++ b/firmware/microblaze/lib/spi.h
@@ -48,12 +48,12 @@ void spi_wait(void);
uint32_t
spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags);
-uint32_t spi_get_data(void);
+//uint32_t spi_get_data(void);
//static void spi_irq_handler(unsigned irq);
-void spi_register_callback(void (*volatile callback)(void));
+//void spi_register_callback(void (*volatile callback)(void));
-bool
-spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void));
+//bool
+//spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void));
// ----------------------------------------------------------------
// Routines that manipulate the FLASH SPI BUS
diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c
index 2a6ae5a60..a2669103a 100644
--- a/firmware/microblaze/lib/u2_init.c
+++ b/firmware/microblaze/lib/u2_init.c
@@ -22,7 +22,6 @@
#include "hal_io.h"
#include "hal_uart.h"
#include "i2c.h"
-#include "i2c_async.h"
#include "mdelay.h"
#include "clocks.h"
#include "usrp2/fw_common.h"
@@ -59,7 +58,6 @@ u2_init(void)
// init i2c so we can read our rev
pic_init(); // progammable interrupt controller
i2c_init();
- i2c_register_handler(); //for using async I2C
hal_enable_ints();
// flash all leds to let us know board is alive
diff --git a/firmware/microblaze/usrp2/Makefile.am b/firmware/microblaze/usrp2/Makefile.am
index 7a58e7253..7fd353204 100644
--- a/firmware/microblaze/usrp2/Makefile.am
+++ b/firmware/microblaze/usrp2/Makefile.am
@@ -24,8 +24,6 @@ AM_LDFLAGS = \
$(COMMON_LFLAGS) \
-Wl,-defsym -Wl,_TEXT_START_ADDR=0x0050 \
-Wl,-defsym -Wl,_STACK_SIZE=3072
-
-LDADD = libusrp2.a
LDADD = libusrp2.a
@@ -38,7 +36,7 @@ libusrp2_a_SOURCES = \
$(COMMON_SRCS) \
sd.c \
ethernet.c \
- udp_fw_update.c
+ udp_fw_update.c
noinst_PROGRAMS = \
usrp2_txrx_uhd.elf