summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-23 15:35:48 -0800
committerJosh Blum <josh@joshknows.com>2010-11-23 15:35:48 -0800
commitf56c1247cbe7b7e90acee2711b5dda3356b9486a (patch)
tree81dadc83537c2c50550cd94e224571e472176c6f /firmware/microblaze/lib
parent9f94ef843ceca63bcb83b2d473cbba709c9110b6 (diff)
parenteb26e8adb4a5718ee3db3bb7f32c0cd31d060af9 (diff)
downloaduhd-f56c1247cbe7b7e90acee2711b5dda3356b9486a.tar.gz
uhd-f56c1247cbe7b7e90acee2711b5dda3356b9486a.tar.bz2
uhd-f56c1247cbe7b7e90acee2711b5dda3356b9486a.zip
Merge branch 'next' of ettus.sourcerepo.com:ettus/uhdpriv into next
Diffstat (limited to 'firmware/microblaze/lib')
-rw-r--r--firmware/microblaze/lib/eeprom.c12
-rw-r--r--firmware/microblaze/lib/eth_addrs.c21
-rw-r--r--firmware/microblaze/lib/ethernet.h6
-rw-r--r--firmware/microblaze/lib/i2c.h3
-rw-r--r--firmware/microblaze/lib/net_common.c11
-rw-r--r--firmware/microblaze/lib/pic.c2
6 files changed, 53 insertions, 2 deletions
diff --git a/firmware/microblaze/lib/eeprom.c b/firmware/microblaze/lib/eeprom.c
index b12ffe082..d4e170046 100644
--- a/firmware/microblaze/lib/eeprom.c
+++ b/firmware/microblaze/lib/eeprom.c
@@ -17,9 +17,21 @@
#include "i2c.h"
#include "mdelay.h"
+#include "usrp2/fw_common.h"
static const int EEPROM_PAGESIZE = 16;
+bool find_safe_booted_flag(void) {
+ unsigned char flag_byte;
+ eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1);
+ return (flag_byte == 0x5E);
+}
+
+void set_safe_booted_flag(bool flag) {
+ unsigned char flag_byte = flag ? 0x5E : 0xDC;
+ eeprom_write(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1);
+}
+
bool
eeprom_write (int i2c_addr, int eeprom_offset, const void *buf, int len)
{
diff --git a/firmware/microblaze/lib/eth_addrs.c b/firmware/microblaze/lib/eth_addrs.c
index c6320e4fa..ff5d04f4d 100644
--- a/firmware/microblaze/lib/eth_addrs.c
+++ b/firmware/microblaze/lib/eth_addrs.c
@@ -46,9 +46,20 @@ unprogrammed(const void *t, size_t len)
//////////////////// MAC Addr Stuff ///////////////////////
static int8_t src_mac_addr_initialized = false;
+
+static const eth_mac_addr_t default_mac_addr = {{
+ 0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff
+ }};
+
static eth_mac_addr_t src_mac_addr = {{
0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff
}};
+
+void set_default_mac_addr(void)
+{
+ src_mac_addr_initialized = true;
+ src_mac_addr = default_mac_addr;
+}
const eth_mac_addr_t *
ethernet_mac_addr(void)
@@ -88,10 +99,20 @@ ethernet_set_mac_addr(const eth_mac_addr_t *t)
//////////////////// IP Addr Stuff ///////////////////////
static int8_t src_ip_addr_initialized = false;
+
+static const struct ip_addr default_ip_addr = {
+ (192 << 24 | 168 << 16 | 10 << 8 | 2 << 0)
+};
+
static struct ip_addr src_ip_addr = {
(192 << 24 | 168 << 16 | 10 << 8 | 2 << 0)
};
+void set_default_ip_addr(void)
+{
+ src_ip_addr_initialized = true;
+ src_ip_addr = default_ip_addr;
+}
const struct ip_addr *get_ip_addr(void)
{
diff --git a/firmware/microblaze/lib/ethernet.h b/firmware/microblaze/lib/ethernet.h
index 8c6d8b567..52b297349 100644
--- a/firmware/microblaze/lib/ethernet.h
+++ b/firmware/microblaze/lib/ethernet.h
@@ -44,6 +44,9 @@ void ethernet_register_link_changed_callback(ethernet_link_changed_callback_t cb
*/
const eth_mac_addr_t *ethernet_mac_addr(void);
+/*!set mac addr to default*/
+void set_default_mac_addr(void);
+
/*!
* \brief write mac address to eeprom and begin using it
*/
@@ -54,6 +57,9 @@ bool ethernet_set_mac_addr(const eth_mac_addr_t *t);
*/
const struct ip_addr *get_ip_addr(void);
+/*!set ip addr to default*/
+void set_default_ip_addr(void);
+
/*!
* \brief write ip address to eeprom and begin using it
*/
diff --git a/firmware/microblaze/lib/i2c.h b/firmware/microblaze/lib/i2c.h
index 6ff0e6982..1af4d72df 100644
--- a/firmware/microblaze/lib/i2c.h
+++ b/firmware/microblaze/lib/i2c.h
@@ -33,4 +33,7 @@ bool eeprom_write (int i2c_addr, int eeprom_offset, const void *buf, int len);
bool eeprom_read (int i2c_addr, int eeprom_offset, void *buf, int len);
+bool find_safe_booted_flag(void);
+void set_safe_booted_flag(bool flag);
+
#endif /* INCLUDED_I2C_H */
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index beaaa5948..6305408d6 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -291,8 +291,17 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst,
{
switch (icmp->type){
case ICMP_DUR: // Destinatino Unreachable
- //stop_streaming(); //FIXME
if (icmp->code == ICMP_DUR_PORT){ // port unreachable
+ //handle destination port unreachable (the host ctrl+c'd the app):
+
+ //end async update packets per second
+ sr_tx_ctrl->cyc_per_up = 0;
+
+ //the end continuous streaming command
+ sr_rx_ctrl->cmd = 1 << 31; //no samples now
+ sr_rx_ctrl->time_secs = 0;
+ sr_rx_ctrl->time_ticks = 0; //latch the command
+
//struct udp_hdr *udp = (struct udp_hdr *)((char *)icmp + 28);
//printf("icmp port unr %d\n", udp->dest);
putchar('i');
diff --git a/firmware/microblaze/lib/pic.c b/firmware/microblaze/lib/pic.c
index e89d2b755..226da5f85 100644
--- a/firmware/microblaze/lib/pic.c
+++ b/firmware/microblaze/lib/pic.c
@@ -44,7 +44,7 @@ pic_init(void)
// uP is level triggered
pic_regs->mask = ~0; // mask all interrupts
- pic_regs->edge_enable = PIC_ONETIME_INT;
+ pic_regs->edge_enable = PIC_ONETIME_INT | PIC_UNDERRUN_INT | PIC_OVERRUN_INT | PIC_PPS_INT;
pic_regs->polarity = ~0 & ~PIC_PHY_INT; // rising edge
pic_regs->pending = ~0; // clear all pending ints
}