diff options
author | jcorgan | 2008-12-27 21:09:26 +0000 |
---|---|---|
committer | jcorgan | 2008-12-27 21:09:26 +0000 |
commit | 297479844e3d9a6eea54fa69147e6a20c0bfc412 (patch) | |
tree | 786591a2e3c8aa77d8149630a6a5d00974585af7 /usrp2/firmware/apps/app_common_v2.c | |
parent | a09700c26a39ebddbeb56b5ecddedf50f0cc7ac4 (diff) | |
download | gnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.tar.gz gnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.tar.bz2 gnuradio-297479844e3d9a6eea54fa69147e6a20c0bfc412.zip |
Implements USRP2 peek() command, allowing arbitrary reads from the internal
Wishbone bus. Minor fix for USRP2 sync_to_pps() (uses correct packet type.)
Example:
>>> from gnuradio import usrp2
>>> u = usrp2.source_32fc()
>>> u.peek(0x1234, 4) # Read four bytes at offset 0x1234 (code)
(185, 244, 253, 164)
>>>
The return value will be zero length upon error.
The read address must be 32-bit aligned, and only the lower 16 bits are
significant. The length must be an integral multiple of 4 bytes. There is
currently a read limit of 176 bytes per read; to change requires some additional
firmware changes to allocate a larger reply packet.
WARNING: Trying to read from memory locations not serviced by RAM or by a
Wishbone peripheral may result in a hang requiring a USRP2 power cycle. The
USRP2 internal memory map is documented in usrp2/firmware/lib/memory_map.h.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10172 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp2/firmware/apps/app_common_v2.c')
-rw-r--r-- | usrp2/firmware/apps/app_common_v2.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/usrp2/firmware/apps/app_common_v2.c b/usrp2/firmware/apps/app_common_v2.c index 9bb5e4d74..b51c3b23c 100644 --- a/usrp2/firmware/apps/app_common_v2.c +++ b/usrp2/firmware/apps/app_common_v2.c @@ -332,6 +332,30 @@ dboard_info_cmd(const op_generic_t *p, } static size_t +peek_cmd(const op_peek_t *p, + void *reply_payload, size_t reply_payload_space) +{ + op_generic_t *r = (op_generic_t *) reply_payload; + + putstr("peek: addr="); puthex32(p->addr); + printf(" bytes=%u\n", p->bytes); + + if (reply_payload_space < (sizeof(*r) + p->bytes)) { + putstr("peek: insufficient reply packet space\n"); + return 0; // FIXME do partial read? + } + + r->opcode = OP_PEEK_REPLY; + r->len = sizeof(*r)+p->bytes; + r->rid = p->rid; + r->ok = true; + + memcpy_wa(reply_payload+sizeof(*r), p->addr, p->bytes); + + return r->len; +} + +static size_t generic_reply(const op_generic_t *p, void *reply_payload, size_t reply_payload_space, bool ok) @@ -435,6 +459,10 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) sync_to_pps((op_generic_t *) payload)); break; + case OP_PEEK: + subpktlen = peek_cmd((op_peek_t *)payload, reply_payload, reply_payload_space); + break; + default: printf("app_common_v2: unhandled opcode = %d\n", gp->opcode); break; |