From 11e856ebca352af1b0444aec6d57ea61c0b48037 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 1 May 2011 14:18:16 -0700 Subject: 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. --- firmware/zpu/apps/txrx_uhd.c | 51 +++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'firmware') 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 #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; /******************************************************************* -- cgit v1.2.3