diff options
author | Josh Blum <josh@joshknows.com> | 2011-05-01 14:18:16 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-05-01 14:18:16 -0700 |
commit | 11e856ebca352af1b0444aec6d57ea61c0b48037 (patch) | |
tree | 976b7835f6899df38efb7717f1f47caf162dbf5a /firmware | |
parent | 493ed897f24fff5265b766ee634916b002cadf94 (diff) | |
download | uhd-11e856ebca352af1b0444aec6d57ea61c0b48037.tar.gz uhd-11e856ebca352af1b0444aec6d57ea61c0b48037.tar.bz2 uhd-11e856ebca352af1b0444aec6d57ea61c0b48037.zip |
usrp2: combined peek and poke commands and added virtual firmware registers
It would be nice to have persistent registers in the device to do things like device locking.
Rather than invent a new communication type, we just repurposed the register manipulation.
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/zpu/apps/txrx_uhd.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c index a9dc2aa4c..975ec58e2 100644 --- a/firmware/zpu/apps/txrx_uhd.c +++ b/firmware/zpu/apps/txrx_uhd.c @@ -43,6 +43,9 @@ #include <bootloader_utils.h> #endif +//virtual registers in the firmware to store persistent values +static uint32_t fw_regs[8]; + extern uint16_t dsp0_dst_port, err0_dst_port, dsp1_dst_port; static void handle_udp_data_packet( @@ -167,40 +170,34 @@ static void handle_udp_ctrl_packet( /******************************************************************* * Peek and Poke Register ******************************************************************/ - case USRP2_CTRL_ID_POKE_THIS_REGISTER_FOR_ME_BRO: - switch(ctrl_data_in->data.poke_args.num_bytes){ - case sizeof(uint32_t): - *((uint32_t *) ctrl_data_in->data.poke_args.addr) = (uint32_t)ctrl_data_in->data.poke_args.data; - break; - - case sizeof(uint16_t): - *((uint16_t *) ctrl_data_in->data.poke_args.addr) = (uint16_t)ctrl_data_in->data.poke_args.data; - break; + case USRP2_CTRL_ID_GET_THIS_REGISTER_FOR_ME_BRO: + switch(ctrl_data_in->data.reg_args.action){ + case USRP2_REG_ACTION_FPGA_PEEK32: + ctrl_data_out.data.reg_args.data = *((uint32_t *) ctrl_data_in->data.reg_args.addr); + break; - case sizeof(uint8_t): - *((uint8_t *) ctrl_data_in->data.poke_args.addr) = (uint8_t)ctrl_data_in->data.poke_args.data; - break; + case USRP2_REG_ACTION_FPGA_PEEK16: + ctrl_data_out.data.reg_args.data = *((uint16_t *) ctrl_data_in->data.reg_args.addr); + break; - } - ctrl_data_out.id = USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE; - break; + case USRP2_REG_ACTION_FPGA_POKE32: + *((uint32_t *) ctrl_data_in->data.reg_args.addr) = (uint32_t)ctrl_data_in->data.reg_args.data; + break; - case USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO: - switch(ctrl_data_in->data.poke_args.num_bytes){ - case sizeof(uint32_t): - ctrl_data_out.data.poke_args.data = *((uint32_t *) ctrl_data_in->data.poke_args.addr); - break; + case USRP2_REG_ACTION_FPGA_POKE16: + *((uint16_t *) ctrl_data_in->data.reg_args.addr) = (uint16_t)ctrl_data_in->data.reg_args.data; + break; - case sizeof(uint16_t): - ctrl_data_out.data.poke_args.data = *((uint16_t *) ctrl_data_in->data.poke_args.addr); - break; + case USRP2_REG_ACTION_FW_PEEK32: + ctrl_data_out.data.reg_args.data = fw_regs[(ctrl_data_in->data.reg_args.addr)]; + break; - case sizeof(uint8_t): - ctrl_data_out.data.poke_args.data = *((uint8_t *) ctrl_data_in->data.poke_args.addr); - break; + case USRP2_REG_ACTION_FW_POKE32: + fw_regs[(ctrl_data_in->data.reg_args.addr)] = ctrl_data_in->data.reg_args.data; + break; } - ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE; + ctrl_data_out.id = USRP2_CTRL_ID_OMG_GOT_REGISTER_SO_BAD_DUDE; break; /******************************************************************* |