summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/microblaze/apps/Makefile.am4
-rw-r--r--firmware/microblaze/apps/txrx_uhd.c (renamed from firmware/microblaze/apps/txrx.c)77
-rw-r--r--firmware/microblaze/lib/Makefile.am6
-rw-r--r--firmware/microblaze/lib/db.h31
-rw-r--r--firmware/microblaze/lib/db_init.c77
-rw-r--r--firmware/microblaze/lib/lsadc.c73
-rw-r--r--firmware/microblaze/lib/lsadc.h45
-rw-r--r--firmware/microblaze/lib/lsdac.c68
-rw-r--r--firmware/microblaze/lib/lsdac.h47
-rw-r--r--firmware/microblaze/lib/u2_init.c5
10 files changed, 28 insertions, 405 deletions
diff --git a/firmware/microblaze/apps/Makefile.am b/firmware/microblaze/apps/Makefile.am
index ff426cf8c..a4f79935b 100644
--- a/firmware/microblaze/apps/Makefile.am
+++ b/firmware/microblaze/apps/Makefile.am
@@ -23,7 +23,7 @@ LDADD = $(top_srcdir)/lib/libu2fw.a
AM_CFLAGS += -I$(top_srcdir)/../../host/lib/usrp
-noinst_PROGRAMS = txrx.elf
+noinst_PROGRAMS = txrx_uhd.elf
# blink_leds \
# blink_leds2 \
@@ -66,7 +66,7 @@ noinst_PROGRAMS = txrx.elf
# tx_drop_SOURCES = tx_drop.c app_common.c
# tx_drop_rate_limited_SOURCES = tx_drop_rate_limited.c app_common.c
# tx_drop2_SOURCES = tx_drop2.c app_common.c
-txrx_elf_SOURCES = txrx.c
+txrx_uhd_elf_SOURCES = txrx_uhd.c
# app_common_v2.c
#factory_test_SOURCES = factory_test.c app_common_v2.c
#eth_serdes_SOURCES = eth_serdes.c app_passthru_v2.c
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx_uhd.c
index 561f3148f..8ff3b8c58 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx_uhd.c
@@ -45,13 +45,12 @@
#include "clocks.h"
#include <vrt/bits.h>
#include "usrp2/fw_common.h"
-#include <db.h>
#include <i2c.h>
-#include <lsdac.h>
-#include <lsadc.h>
#include <ethertype.h>
#include <arp_cache.h>
+#define LEDS_SW LED_A
+
/*
* Full duplex Tx and Rx between ethernet and DSP pipelines
*
@@ -203,20 +202,34 @@ void handle_udp_ctrl_packet(
unsigned char *payload, int payload_len
){
//printf("Got ctrl packet #words: %d\n", (int)payload_len);
+ usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload;
+ uint32_t ctrl_data_in_id = ctrl_data_in->id;
+
+ //ensure that the protocol versions match
+ if (payload_len >= sizeof(uint32_t) && ctrl_data_in->proto_ver != USRP2_PROTO_VERSION){
+ printf("!Error in control packet handler: Expected protocol version %d, but got %d\n",
+ USRP2_PROTO_VERSION, ctrl_data_in->proto_ver
+ );
+ ctrl_data_in_id = USRP2_CTRL_ID_GIVE_ME_YOUR_IP_ADDR_BRO;
+ }
+
+ //ensure that this is not a short packet
if (payload_len < sizeof(usrp2_ctrl_data_t)){
- //TODO send err packet
- return;
+ printf("!Error in control packet handler: Expected payload length %d, but got %d\n",
+ (int)sizeof(usrp2_ctrl_data_t), payload_len
+ );
+ ctrl_data_in_id = USRP2_CTRL_ID_HUH_WHAT;
}
- //setup the input and output data
- usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload;
+ //setup the output data
usrp2_ctrl_data_t ctrl_data_out = {
+ .proto_ver = USRP2_PROTO_VERSION,
.id=USRP2_CTRL_ID_HUH_WHAT,
.seq=ctrl_data_in->seq
};
//handle the data based on the id
- switch(ctrl_data_in->id){
+ switch(ctrl_data_in_id){
/*******************************************************************
* Addressing
@@ -243,12 +256,6 @@ void handle_udp_ctrl_packet(
memcpy(&ctrl_data_out.data.mac_addr, ethernet_mac_addr(), sizeof(eth_mac_addr_t));
break;
- case USRP2_CTRL_ID_GIVE_ME_YOUR_DBOARD_IDS_BRO:
- ctrl_data_out.id = USRP2_CTRL_ID_THESE_ARE_MY_DBOARD_IDS_DUDE;
- ctrl_data_out.data.dboard_ids.tx_id = read_dboard_eeprom(I2C_ADDR_TX_A);
- ctrl_data_out.data.dboard_ids.rx_id = read_dboard_eeprom(I2C_ADDR_RX_A);
- break;
-
/*******************************************************************
* SPI
******************************************************************/
@@ -297,43 +304,6 @@ void handle_udp_ctrl_packet(
break;
/*******************************************************************
- * AUX DAC/ADC
- ******************************************************************/
- case USRP2_CTRL_ID_WRITE_THIS_TO_THE_AUX_DAC_BRO:
- if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_RX){
- lsdac_write_rx(
- ctrl_data_in->data.aux_args.which,
- ctrl_data_in->data.aux_args.value
- );
- }
-
- if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_TX){
- lsdac_write_tx(
- ctrl_data_in->data.aux_args.which,
- ctrl_data_in->data.aux_args.value
- );
- }
-
- ctrl_data_out.id = USRP2_CTRL_ID_DONE_WITH_THAT_AUX_DAC_DUDE;
- break;
-
- case USRP2_CTRL_ID_READ_FROM_THIS_AUX_ADC_BRO:
- if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_RX){
- ctrl_data_out.data.aux_args.value = lsadc_read_rx(
- ctrl_data_in->data.aux_args.which
- );
- }
-
- if (ctrl_data_in->data.aux_args.dir == USRP2_DIR_TX){
- ctrl_data_out.data.aux_args.value = lsadc_read_tx(
- ctrl_data_in->data.aux_args.which
- );
- }
-
- ctrl_data_out.id = USRP2_CTRL_ID_DONE_WITH_THAT_AUX_ADC_DUDE;
- break;
-
- /*******************************************************************
* Streaming
******************************************************************/
case USRP2_CTRL_ID_SEND_STREAM_COMMAND_FOR_ME_BRO:{
@@ -342,6 +312,7 @@ void handle_udp_ctrl_packet(
if (ctrl_data_in->data.stream_cmd.continuous){
printf("Setting up continuous streaming...\n");
printf("items per frame: %d\n", (int)streaming_items_per_frame);
+ hal_set_leds(LED_A, LEDS_SW);
auto_reload_command = true;
streaming_frame_count = FRAMES_PER_CMD;
@@ -366,6 +337,7 @@ void handle_udp_ctrl_packet(
//issue regular stream commands (split commands if too large)
else{
+ hal_set_leds(0, LEDS_SW);
auto_reload_command = false;
size_t num_samps = ctrl_data_in->data.stream_cmd.num_samps;
if (num_samps == 0) num_samps = 1; //FIXME hack, zero is used when stopping continuous streaming but it somehow makes it inifinite
@@ -611,6 +583,7 @@ main(void)
print_mac_addr(ethernet_mac_addr()->addr);
newline();
print_ip_addr(get_ip_addr()); newline();
+ printf("Control protocol version: %d\n", USRP2_PROTO_VERSION);
ethernet_register_link_changed_callback(link_changed_callback);
ethernet_init();
@@ -621,6 +594,8 @@ main(void)
register_udp_listener(USRP2_UDP_CTRL_PORT, handle_udp_ctrl_packet);
register_udp_listener(USRP2_UDP_DATA_PORT, handle_udp_data_packet);
+ hal_set_led_src(0, LEDS_SW);
+
#if 0
// make bit 15 of Tx gpio's be a s/w output
hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
diff --git a/firmware/microblaze/lib/Makefile.am b/firmware/microblaze/lib/Makefile.am
index 3d02cfe8b..783895850 100644
--- a/firmware/microblaze/lib/Makefile.am
+++ b/firmware/microblaze/lib/Makefile.am
@@ -28,7 +28,6 @@ libu2fw_a_SOURCES = \
bsm12.c \
buffer_pool.c \
clocks.c \
- db_init.c \
dbsm.c \
eeprom.c \
ethernet.c \
@@ -38,8 +37,6 @@ libu2fw_a_SOURCES = \
hal_io.c \
hal_uart.c \
i2c.c \
- lsadc.c \
- lsdac.c \
mdelay.c \
memcpy_wa.c \
memset_wa.c \
@@ -62,7 +59,6 @@ noinst_HEADERS = \
bsm12.h \
buffer_pool.h \
clocks.h \
- db.h \
dbsm.h \
eth_mac.h \
eth_mac_regs.h \
@@ -71,8 +67,6 @@ noinst_HEADERS = \
hal_io.h \
hal_uart.h \
i2c.h \
- lsadc.h \
- lsdac.h \
mdelay.h \
memcpy_wa.h \
memory_map.h \
diff --git a/firmware/microblaze/lib/db.h b/firmware/microblaze/lib/db.h
deleted file mode 100644
index 358cb222b..000000000
--- a/firmware/microblaze/lib/db.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2009 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/>.
- */
-
-/*
- * Interface to daughterboard code
- */
-
-#ifndef INCLUDED_DB_H
-#define INCLUDED_DB_H
-
-#include <usrp2_types.h>
-#include <usrp2_i2c_addr.h>
-
-int read_dboard_eeprom(int i2c_addr);
-
-#endif /* INCLUDED_DB_H */
diff --git a/firmware/microblaze/lib/db_init.c b/firmware/microblaze/lib/db_init.c
deleted file mode 100644
index 23805d9cd..000000000
--- a/firmware/microblaze/lib/db_init.c
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-/*
- * Copyright 2008,2009 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 <memory_map.h>
-#include <i2c.h>
-#include <string.h>
-#include <stdio.h>
-#include <db.h>
-#include <hal_io.h>
-#include <nonstdio.h>
-
-
-typedef enum { UDBE_OK, UDBE_NO_EEPROM, UDBE_INVALID_EEPROM } usrp_dbeeprom_status_t;
-
-static usrp_dbeeprom_status_t
-read_raw_dboard_eeprom (unsigned char *buf, int i2c_addr)
-{
- if (!eeprom_read (i2c_addr, 0, buf, DB_EEPROM_CLEN))
- return UDBE_NO_EEPROM;
-
- if (buf[DB_EEPROM_MAGIC] != DB_EEPROM_MAGIC_VALUE)
- return UDBE_INVALID_EEPROM;
-
- int sum = 0;
- unsigned int i;
- for (i = 0; i < DB_EEPROM_CLEN; i++)
- sum += buf[i];
-
- if ((sum & 0xff) != 0)
- return UDBE_INVALID_EEPROM;
-
- return UDBE_OK;
-}
-
-
-/*
- * Return DBID, -1 <none> or -2 <invalid eeprom contents>
- */
-int
-read_dboard_eeprom(int i2c_addr)
-{
- unsigned char buf[DB_EEPROM_CLEN];
-
- usrp_dbeeprom_status_t s = read_raw_dboard_eeprom (buf, i2c_addr);
-
- //printf("\nread_raw_dboard_eeprom: %d\n", s);
-
- switch (s){
- case UDBE_OK:
- return (buf[DB_EEPROM_ID_MSB] << 8) | buf[DB_EEPROM_ID_LSB];
-
- case UDBE_NO_EEPROM:
- default:
- return -1;
-
- case UDBE_INVALID_EEPROM:
- return -2;
- }
-}
diff --git a/firmware/microblaze/lib/lsadc.c b/firmware/microblaze/lib/lsadc.c
deleted file mode 100644
index 7983552e7..000000000
--- a/firmware/microblaze/lib/lsadc.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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 "lsadc.h"
-#include "spi.h"
-#include "memory_map.h"
-
-
-// AD9712 or AD7922 1 MS/s, 10-/12-bit ADCs
-
-//#define SPI_SS_DEBUG SPI_SS_RX_DB
-#define SPI_SS_DEBUG 0
-
-
-void
-lsadc_init(void)
-{
- // nop
-}
-
-/*
- * The ADC's are pipelined. That is, you have to tell them
- * which of the two inputs you want one cycle ahead of time.
- * We could optimize and keep track of which one we used last
- * time, but for simplicity we'll always tell it which
- * one we want. This takes 2 16-bit xfers, one to set the
- * input and one to read the one we want.
- */
-
-int
-_lsadc_read(int which_adc, int slave_select)
-{
- uint32_t r;
- int channel = which_adc & 0x1;
-
- // Set CHN and STY equal to channel number. We don't want "daisy chain mode"
- uint16_t cmd = (channel << 13) | (channel << 12);
-
- spi_transact(SPI_TXONLY, slave_select | SPI_SS_DEBUG,
- cmd, 16, SPIF_PUSH_RISE | SPIF_LATCH_RISE);
-
- r = spi_transact(SPI_TXRX, slave_select | SPI_SS_DEBUG,
- cmd, 16, SPIF_PUSH_RISE | SPIF_LATCH_RISE);
-
- return r & 0x0fff;
-}
-
-int
-lsadc_read_rx(int which_adc)
-{
- return _lsadc_read(which_adc, SPI_SS_RX_ADC);
-}
-
-int
-lsadc_read_tx(int which_adc)
-{
- return _lsadc_read(which_adc, SPI_SS_TX_ADC);
-}
diff --git a/firmware/microblaze/lib/lsadc.h b/firmware/microblaze/lib/lsadc.h
deleted file mode 100644
index 319f34d91..000000000
--- a/firmware/microblaze/lib/lsadc.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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_LSADC_H
-#define INCLUDED_LSADC_H
-
-#include "memory_map.h"
-
-/*!
- * \brief One time call to initialize low-speed ADCs.
- */
-void lsadc_init(void);
-
-/*!
- * \brief Read one of the low-speed Rx daughterboard ADCs.
- * \param which_adc in [0, 1]
- *
- * \returns 12-bit value in [0,4095]
- */
-int lsadc_read_rx(int which_adc);
-
-/*!
- * \brief Read one of the low-speed Tx daughterboard ADCs.
- * \param which_adc in [0, 1]
- *
- * \returns 12-bit value in [0,4095]
- */
-int lsadc_read_tx(int which_adc);
-
-
-#endif /* INCLUDED_LSADC_H */
diff --git a/firmware/microblaze/lib/lsdac.c b/firmware/microblaze/lib/lsdac.c
deleted file mode 100644
index 6bc2e5cb5..000000000
--- a/firmware/microblaze/lib/lsdac.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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 "lsdac.h"
-#include "spi.h"
-#include "memory_map.h"
-
-// AD5624, AD5623
-
-#define CMD(x) ((x) << 19)
-#define CMD_WR_INPUT_N CMD(0) // write input N
-#define CMD_UP_DAC_N CMD(1) // update DAC N from input reg
-#define CMD_WR_INPUT_N_LDAC CMD(2) // write input N, update all
-#define CMD_WR_UP_DAC_N CMD(3) // write and update N
-#define CMD_WR_PWR_CONFIG CMD(4) // write power up/down config reg
-#define CMD_SW_RESET CMD(5) // force s/w reset
-#define CMD_WR_LDAC_CFG CMD(6) // write LDAC config reg
-#define CMD_WR_INT_REF_CFG CMD(7) // write internal ref cfg reg (AD5623R only)
-
-
-//#define SPI_SS_DEBUG SPI_SS_TX_DB
-#define SPI_SS_DEBUG 0
-
-inline static void
-_write_rx(uint32_t v)
-{
- spi_transact(SPI_TXONLY, SPI_SS_RX_DAC | SPI_SS_DEBUG, v, 24, SPIF_PUSH_RISE);
-}
-
-inline static void
-_write_tx(uint32_t v)
-{
- spi_transact(SPI_TXONLY, SPI_SS_TX_DAC | SPI_SS_DEBUG, v, 24, SPIF_PUSH_RISE);
-}
-
-void
-lsdac_init(void)
-{
- _write_tx(CMD_SW_RESET | 0x1); // power-on reset
- _write_rx(CMD_SW_RESET | 0x1); // power-on reset
-}
-
-void
-lsdac_write_rx(int which_dac, int value)
-{
- _write_rx(CMD_WR_UP_DAC_N | ((which_dac & 0x7) << 16) | ((value << 4) & 0xffff));
-}
-
-void
-lsdac_write_tx(int which_dac, int value)
-{
- _write_tx(CMD_WR_UP_DAC_N | ((which_dac & 0x7) << 16) | ((value << 4) & 0xffff));
-}
diff --git a/firmware/microblaze/lib/lsdac.h b/firmware/microblaze/lib/lsdac.h
deleted file mode 100644
index 9cad917e3..000000000
--- a/firmware/microblaze/lib/lsdac.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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_LSDAC_H
-#define INCLUDED_LSDAC_H
-
-#include "memory_map.h"
-
-/*!
- * \brief One time call to initialize low-speed DACs.
- */
-void lsdac_init(void);
-
-/*!
- * \brief Write one of the low-speed Rx daughterboard DACs.
- * \param which_dac in [0, 3]
- * \param unsigned 12-bit value in [0, 4095]
- *
- * value maps linearly to output voltage from 0 to 3.3V
- */
-void lsdac_write_rx(int which_dac, int value);
-
-/*!
- * \brief Write one of the low-speed Tx daughterboard DACs.
- * \param which_dac in [0, 3]
- * \param unsigned 12-bit value in [0, 4095]
- *
- * value maps linearly to output voltage from 0 to 3.3V
- */
-void lsdac_write_tx(int which_dac, int value);
-
-
-#endif /* INCLUDED_LSDAC_H */
diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c
index bd3302d95..399d834cb 100644
--- a/firmware/microblaze/lib/u2_init.c
+++ b/firmware/microblaze/lib/u2_init.c
@@ -20,14 +20,11 @@
#include "spi.h"
#include "pic.h"
#include "hal_io.h"
-#include "lsadc.h"
-#include "lsdac.h"
#include "buffer_pool.h"
#include "hal_uart.h"
#include "i2c.h"
#include "mdelay.h"
#include "clocks.h"
-#include "db.h"
#include "usrp2_i2c_addr.h"
//#include "nonstdio.h"
@@ -84,8 +81,6 @@ u2_init(void)
pic_init(); // progammable interrupt controller
bp_init(); // buffer pool
- lsadc_init(); // low-speed ADCs
- lsdac_init(); // low-speed DACs
hal_enable_ints();