diff options
author | Johnathan Corgan | 2009-12-07 22:45:56 -0500 |
---|---|---|
committer | Johnathan Corgan | 2009-12-07 22:45:56 -0500 |
commit | 25a79d66e0fc10e1449de041e8d62f77619fe8de (patch) | |
tree | 8454001d3e35e8d8af1386950ef27caf7a363a57 /usrp2/firmware/apps | |
parent | 159582124b35f9e12e8702ffe970398829a3a3ed (diff) | |
parent | 66610ead14a47a20f6d89d367a505e035ef04004 (diff) | |
download | gnuradio-25a79d66e0fc10e1449de041e8d62f77619fe8de.tar.gz gnuradio-25a79d66e0fc10e1449de041e8d62f77619fe8de.tar.bz2 gnuradio-25a79d66e0fc10e1449de041e8d62f77619fe8de.zip |
Merge branch 'patches/geiger/u2_rx_stream_at' of git@gnuradio.org:jcorgan
Diffstat (limited to 'usrp2/firmware/apps')
-rw-r--r-- | usrp2/firmware/apps/app_common_v2.c | 59 | ||||
-rw-r--r-- | usrp2/firmware/apps/app_common_v2.h | 4 | ||||
-rw-r--r-- | usrp2/firmware/apps/factory_test.c | 25 | ||||
-rw-r--r-- | usrp2/firmware/apps/mimo_tx_slave.c | 10 | ||||
-rw-r--r-- | usrp2/firmware/apps/serdes_txrx.c | 10 | ||||
-rw-r--r-- | usrp2/firmware/apps/txrx.c | 61 |
6 files changed, 121 insertions, 48 deletions
diff --git a/usrp2/firmware/apps/app_common_v2.c b/usrp2/firmware/apps/app_common_v2.c index 67cccd53b..2d131bda7 100644 --- a/usrp2/firmware/apps/app_common_v2.c +++ b/usrp2/firmware/apps/app_common_v2.c @@ -152,7 +152,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, memset(&tune_result, 0, sizeof(tune_result)); bool ok = true; - + if (p->valid & CFGV_GAIN){ ok &= db_set_gain(tx_dboard, p->gain); } @@ -161,7 +161,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, bool was_streaming = is_streaming(); if (was_streaming) stop_rx_cmd(); - + u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo); bool tune_ok = db_tune(tx_dboard, f, &tune_result); ok &= tune_ok; @@ -185,7 +185,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, hb1 = 1; interp = interp >> 1; } - + if (interp < MIN_CIC_INTERP || interp > MAX_CIC_INTERP) ok = false; else { @@ -215,7 +215,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, } static size_t -config_rx_v2_cmd(const op_config_rx_v2_t *p, +config_rx_v2_cmd(const op_config_rx_v2_t *p, void *reply_payload, size_t reply_payload_space) { op_config_rx_reply_v2_t *r = (op_config_rx_reply_v2_t *) reply_payload; @@ -226,7 +226,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, memset(&tune_result, 0, sizeof(tune_result)); bool ok = true; - + if (p->valid & CFGV_GAIN){ ok &= db_set_gain(rx_dboard, p->gain); } @@ -235,7 +235,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, bool was_streaming = is_streaming(); if (was_streaming) stop_rx_cmd(); - + u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo); bool tune_ok = db_tune(rx_dboard, f, &tune_result); ok &= tune_ok; @@ -249,17 +249,17 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, int decim = p->decim; int hb1 = 0; int hb2 = 0; - + if(!(decim & 1)) { hb2 = 1; decim = decim >> 1; } - + if(!(decim & 1)) { hb1 = 1; decim = decim >> 1; } - + if (decim < MIN_CIC_DECIM || decim > MAX_CIC_DECIM) ok = false; else { @@ -294,7 +294,7 @@ read_time_cmd(const op_generic_t *p, void *reply_payload, size_t reply_payload_space) { op_read_time_reply_t *r = (op_read_time_reply_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room r->opcode = OP_READ_TIME_REPLY; @@ -323,7 +323,7 @@ dboard_info_cmd(const op_generic_t *p, void *reply_payload, size_t reply_payload_space) { op_dboard_info_reply_t *r = (op_dboard_info_reply_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room r->opcode = OP_DBOARD_INFO_REPLY; @@ -411,14 +411,14 @@ generic_reply(const op_generic_t *p, bool ok) { op_generic_t *r = (op_generic_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room - + r->opcode = p->opcode | OP_REPLY_BIT; r->len = sizeof(*r); r->rid = p->rid; r->ok = ok; - + return r->len; } @@ -426,14 +426,14 @@ static size_t add_eop(void *reply_payload, size_t reply_payload_space) { op_generic_t *r = (op_generic_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room - + r->opcode = OP_EOP; r->len = sizeof(*r); r->rid = 0; r->ok = 0; - + return r->len; } @@ -443,15 +443,15 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4; unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)]; int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t); - + // initialize reply memset(reply, 0, sizeof(reply)); set_reply_hdr((u2_eth_packet_t *) reply, pkt); - + // point to beginning of payload (subpackets) unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t); int payload_len = len - sizeof(u2_eth_packet_t); - + size_t subpktlen = 0; bool ok = false; @@ -468,7 +468,7 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_ID: subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space); break; - + case OP_CONFIG_TX_V2: subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload, reply_payload, reply_payload_space); break; @@ -478,15 +478,18 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) break; case OP_START_RX_STREAMING: - start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload); + if (pkt->fixed.timestamp == -1) // Start now (default) + start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload); + else + start_rx_streaming_at_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *)payload, pkt->fixed.timestamp); ok = true; goto generic_reply; - + case OP_STOP_RX: stop_rx_cmd(); ok = true; goto generic_reply; - + case OP_BURN_MAC_ADDR: ok = ethernet_set_mac_addr(&((op_burn_mac_addr_t *)payload)->addr); goto generic_reply; @@ -532,8 +535,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_GPIO_SET_DDR: ok = true; - hal_gpio_set_ddr(((op_gpio_t *)payload)->bank, - ((op_gpio_t *)payload)->value, + hal_gpio_set_ddr(((op_gpio_t *)payload)->bank, + ((op_gpio_t *)payload)->value, ((op_gpio_t *)payload)->mask); goto generic_reply; @@ -549,8 +552,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_GPIO_WRITE: ok = true; - hal_gpio_write(((op_gpio_t *)payload)->bank, - ((op_gpio_t *)payload)->value, + hal_gpio_write(((op_gpio_t *)payload)->bank, + ((op_gpio_t *)payload)->value, ((op_gpio_t *)payload)->mask); goto generic_reply; diff --git a/usrp2/firmware/apps/app_common_v2.h b/usrp2/firmware/apps/app_common_v2.h index 5058661ad..ff1baec06 100644 --- a/usrp2/firmware/apps/app_common_v2.h +++ b/usrp2/firmware/apps/app_common_v2.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,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 @@ -55,8 +55,10 @@ print_tune_result(char *msg, bool tune_ok, void start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p); +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time); void stop_rx_cmd(void); void restart_streaming(void); +void restart_streaming_at(uint32_t time); bool is_streaming(void); void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len); diff --git a/usrp2/firmware/apps/factory_test.c b/usrp2/firmware/apps/factory_test.c index a4bc06d58..e7dde524a 100644 --- a/usrp2/firmware/apps/factory_test.c +++ b/usrp2/firmware/apps/factory_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,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 @@ -154,7 +154,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -187,6 +187,11 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} + void stop_rx_cmd(void) { @@ -224,7 +229,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -259,22 +264,22 @@ int test_ram() { int i,j,k; output_regs->ram_page = 1<<10; - + extram[0] = 0xDEADBEEF; extram[1] = 0xF00D1234; extram[7] = 0x76543210; - + output_regs->ram_page = 2<<10; extram[7] = 0x55555555; extram[1] = 0xaaaaaaaa; extram[0] = 0xeeeeeeee; - + output_regs->ram_page = 1<<10; - + i = extram[0]; k = extram[1]; j = extram[7]; - + if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) { puts("RAM FAIL1!\n"); puthex32_nl(i); @@ -282,7 +287,7 @@ int test_ram() puthex32_nl(k); return 0; } - + output_regs->ram_page = 2<<10; j = extram[7]; @@ -306,7 +311,7 @@ int test_sd() puts("FAILED INIT of Card\n"); return 0; } - + unsigned char buf[512]; i = sd_read_block(2048,buf); if(i == 0) { diff --git a/usrp2/firmware/apps/mimo_tx_slave.c b/usrp2/firmware/apps/mimo_tx_slave.c index e7da984c5..4c284b7c9 100644 --- a/usrp2/firmware/apps/mimo_tx_slave.c +++ b/usrp2/firmware/apps/mimo_tx_slave.c @@ -160,7 +160,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -192,6 +192,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} void stop_rx_cmd(void) @@ -230,7 +234,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -310,7 +314,7 @@ main(void) //output_regs->flush_icache = 1; - + // initialize double buffering state machine for DSP RX -> Ethernet if (FW_SETS_SEQNO){ diff --git a/usrp2/firmware/apps/serdes_txrx.c b/usrp2/firmware/apps/serdes_txrx.c index 7816f7a65..aa4a3f33c 100644 --- a/usrp2/firmware/apps/serdes_txrx.c +++ b/usrp2/firmware/apps/serdes_txrx.c @@ -152,7 +152,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -184,6 +184,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} void stop_rx_cmd(void) @@ -222,7 +226,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -302,7 +306,7 @@ main(void) //output_regs->flush_icache = 1; - + // initialize double buffering state machine for DSP RX -> Ethernet if (FW_SETS_SEQNO){ diff --git a/usrp2/firmware/apps/txrx.c b/usrp2/firmware/apps/txrx.c index b2487ed89..975f314bd 100644 --- a/usrp2/firmware/apps/txrx.c +++ b/usrp2/firmware/apps/txrx.c @@ -1,5 +1,5 @@ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,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 @@ -152,7 +152,35 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); + + dsp_rx_regs->rx_time = 0; // enqueue second command +} + +void +restart_streaming_at(uint32_t time) +{ + // setup RX DSP regs + dsp_rx_regs->clear_state = 1; // reset + + streaming_p = true; + streaming_frame_count = FRAMES_PER_CMD; + + dsp_rx_regs->rx_command = + MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, + streaming_items_per_frame, + 0, 1); // set "chain" bit + + // kick off the state machine + dbsm_start(&dsp_rx_sm); + + dsp_rx_regs->rx_time = time; // enqueue first of two commands + + // make sure this one and the rest have the "now" and "chain" bits set. + dsp_rx_regs->rx_command = + MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, + streaming_items_per_frame, + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -184,6 +212,33 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void +start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{ + host_mac_addr = *host; // remember who we're sending to + + /* + * Construct ethernet header and word0 and preload into two buffers + */ + u2_eth_packet_t pkt; + memset(&pkt, 0, sizeof(pkt)); + pkt.ehdr.dst = *host; + pkt.ehdr.src = *ethernet_mac_addr(); + pkt.ehdr.ethertype = U2_ETHERTYPE; + u2p_set_word0(&pkt.fixed, 0, 0); + // DSP RX will fill in timestamp + + memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt)); + memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt)); + + + if (FW_SETS_SEQNO) + fw_seqno = 0; + + streaming_items_per_frame = p->items_per_frame; + restart_streaming_at(time); +} + void stop_rx_cmd(void) @@ -222,7 +277,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); |