Skip to content

Commit

Permalink
Removed decimation in CPLD
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Bartolucci authored and Marco Bartolucci committed May 15, 2017
1 parent d47dece commit 747d8e2
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 212 deletions.
54 changes: 12 additions & 42 deletions firmware/common/hackrf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ static struct gpio_t gpio_max5864_select = GPIO(2, 7);
// static struct gpio_t gpio_rffc5072_reset = GPIO(2, 14);
// #endif

static struct gpio_t gpio_sync_in_a = GPIO(3, 10);
static struct gpio_t gpio_sync_in_b = GPIO(3, 11);
static struct gpio_t gpio_sync_out_a = GPIO(3, 8);
static struct gpio_t gpio_sync_out_b = GPIO(3, 9);
//static struct gpio_t gpio_sync_in_a = GPIO(3, 10);
//static struct gpio_t gpio_sync_in_b = GPIO(3, 11);
//static struct gpio_t gpio_sync_out_a = GPIO(3, 8);
//static struct gpio_t gpio_sync_out_b = GPIO(3, 9);

/* RF supply (VAA) control */
#ifdef HACKRF_ONE
Expand Down Expand Up @@ -824,11 +824,11 @@ void pin_setup(void) {
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);

gpio_input(&gpio_sync_in_a);
gpio_input(&gpio_sync_in_b);
//gpio_input(&gpio_sync_in_a);
//gpio_input(&gpio_sync_in_b);

gpio_output(&gpio_sync_out_a);
gpio_output(&gpio_sync_out_b);
//gpio_output(&gpio_sync_out_a);
//gpio_output(&gpio_sync_out_b);
#endif

#ifdef RAD1O
Expand All @@ -841,11 +841,11 @@ void pin_setup(void) {
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);

gpio_input(&gpio_sync_in_a);
gpio_input(&gpio_sync_in_b);
//gpio_input(&gpio_sync_in_a);
//gpio_input(&gpio_sync_in_b);

gpio_output(&gpio_sync_out_a);
gpio_output(&gpio_sync_out_b);
//gpio_output(&gpio_sync_out_a);
//gpio_output(&gpio_sync_out_b);
#endif

/* enable input on SCL and SDA pins */
Expand Down Expand Up @@ -902,33 +902,3 @@ void led_off(const led_t led) {
void led_toggle(const led_t led) {
gpio_toggle(&gpio_led[led]);
}

void hw_sync_syn() {
gpio_set(&gpio_sync_out_a);
}

void hw_sync_stop() {
gpio_clear(&gpio_sync_out_a);
gpio_clear(&gpio_sync_out_b);
}

void hw_sync_ack() {
gpio_set(&gpio_sync_out_b);
}

void hw_sync_copy_state() {
if(gpio_read(&gpio_sync_in_a)) {
gpio_set(&gpio_sync_out_a);
} else {
gpio_clear(&gpio_sync_out_a);
}
if(gpio_read(&gpio_sync_in_b)) {
gpio_set(&gpio_sync_out_b);
} else {
gpio_clear(&gpio_sync_out_b);
}
}

bool hw_sync_ready() {
return (gpio_read(&gpio_sync_in_a) && gpio_read(&gpio_sync_in_b));
}
Binary file modified firmware/cpld/sgpio_if/default_sync.xsvf
Binary file not shown.
246 changes: 123 additions & 123 deletions firmware/cpld/sgpio_if/top.jed

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions firmware/cpld/sgpio_if/top.ucf
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ NET "HOST_DATA<4>" LOC = "P67" | IOSTANDARD = LVCMOS33 | SLEW = SLOW ;
NET "HOST_DATA<5>" LOC = "P64" | IOSTANDARD = LVCMOS33 | SLEW = SLOW ;
NET "HOST_DATA<6>" LOC = "P61" | IOSTANDARD = LVCMOS33 | SLEW = SLOW ;
NET "HOST_DATA<7>" LOC = "P77" | IOSTANDARD = LVCMOS33 | SLEW = SLOW ;
NET "HOST_DECIM_SEL<0>" LOC = "P90" | IOSTANDARD = LVCMOS33 ;
NET "HOST_DECIM_SEL<1>" LOC = "P81" | IOSTANDARD = LVCMOS33 ;
NET "HOST_DECIM_SEL<2>" LOC = "P78" | IOSTANDARD = LVCMOS33 ;
NET "HOST_DIRECTION" LOC = "P71" | IOSTANDARD = LVCMOS33 ;
NET "HOST_DISABLE" LOC = "P76" | IOSTANDARD = LVCMOS33 ;
NET "HOST_Q_INVERT" LOC = "P70" | IOSTANDARD = LVCMOS33 ;
Expand Down
28 changes: 3 additions & 25 deletions firmware/cpld/sgpio_if/top.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ entity top is
HOST_SYNC : in std_logic;
HOST_DISABLE : in std_logic;
HOST_DIRECTION : in std_logic;
HOST_DECIM_SEL : in std_logic_vector(2 downto 0);
HOST_Q_INVERT : in std_logic;

DA : in std_logic_vector(7 downto 0);
Expand Down Expand Up @@ -65,10 +64,6 @@ architecture Behavioral of top is
signal data_from_host_i : std_logic_vector(7 downto 0);
signal data_to_host_o : std_logic_vector(7 downto 0);

signal decimate_count : std_logic_vector(2 downto 0) := "111";
signal decimate_sel_i : std_logic_vector(2 downto 0);
signal decimate_en : std_logic;

signal q_invert : std_logic;
signal rx_q_invert_mask : std_logic_vector(7 downto 0);
signal tx_q_invert_mask : std_logic_vector(7 downto 0);
Expand Down Expand Up @@ -100,31 +95,14 @@ begin
data_from_host_i <= HOST_DATA;

HOST_CAPTURE <= host_data_capture_o;
host_sync_i <= HOST_SYNC;
HOST_SYNC_CMD <= host_sync_o;
host_sync_i <= HOST_SYNC;
HOST_SYNC_CMD <= host_sync_o;

host_data_enable_i <= not HOST_DISABLE;
transfer_direction_i <= to_dac when HOST_DIRECTION = '1'
else from_adc;

decimate_sel_i <= HOST_DECIM_SEL;

------------------------------------------------

decimate_en <= '1' when decimate_count = "111" else '0';

process(host_clk_i)
begin
if rising_edge(host_clk_i) then
if codec_clk_i = '1' then
if decimate_count = "111" or host_data_enable_i = '0' then
decimate_count <= decimate_sel_i;
else
decimate_count <= decimate_count + 1;
end if;
end if;
end if;
end process;

q_invert <= HOST_Q_INVERT;
rx_q_invert_mask <= X"80" when q_invert = '1' else X"7f";
Expand Down Expand Up @@ -179,7 +157,7 @@ begin
end if;
else
if codec_clk_i = '0' then
host_data_capture_o <= host_data_enable_i and decimate_en and host_sync_latched;
host_data_capture_o <= host_data_enable_i and host_sync_latched;
end if;
end if;
end if;
Expand Down
2 changes: 0 additions & 2 deletions firmware/hackrf_usb/hackrf_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ int main(void) {
sweep_mode();
}

start_streaming_on_hw_sync();

// Set up IN transfer of buffer 0.
if ( usb_bulk_buffer_offset >= 16384
&& phase == 1
Expand Down
19 changes: 2 additions & 17 deletions firmware/hackrf_usb/usb_api_transceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,16 @@ void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) {
led_off(LED3);
rf_path_set_direction(&rf_path, RF_PATH_DIRECTION_OFF);
vector_table.irq[NVIC_SGPIO_IRQ] = sgpio_isr_rx;

hw_sync_stop();
}

hw_sync_stop();

if( _transceiver_mode != TRANSCEIVER_MODE_OFF ) {
si5351c_activate_best_clock_source(&clock_gen);

if( _hw_sync_mode != HW_SYNC_MODE_OFF) {
hw_sync_syn();
} else {
baseband_streaming_enable(&sgpio_config);
hw_sync_enable();
}
baseband_streaming_enable(&sgpio_config);
}
}

Expand Down Expand Up @@ -323,14 +319,3 @@ usb_request_status_t usb_vendor_request_set_hw_sync_mode(
return USB_REQUEST_STATUS_OK;
}
}

void start_streaming_on_hw_sync()
{
if( _hw_sync_mode != HW_SYNC_MODE_OFF) {
while(!hw_sync_ready()) { }
hw_sync_ack();
led_on(LED3);

baseband_streaming_enable(&sgpio_config);
}
}

0 comments on commit 747d8e2

Please sign in to comment.