diff --git a/firmware/common/sgpio.c b/firmware/common/sgpio.c index 145ef4ad..5e49c85c 100644 --- a/firmware/common/sgpio.c +++ b/firmware/common/sgpio.c @@ -25,6 +25,8 @@ #include +#include + void sgpio_configure_pin_functions() { scu_pinmux(SCU_PINMUX_SGPIO0, SCU_GPIO_FAST | SCU_CONF_FUNCTION3); scu_pinmux(SCU_PINMUX_SGPIO1, SCU_GPIO_FAST | SCU_CONF_FUNCTION3); @@ -104,7 +106,7 @@ void sgpio_test_interface() { SGPIO11 Direction Output (1/High=TX mode LPC43xx=>CPLD=>DAC, 0/Low=RX mode LPC43xx<=CPLD<=ADC) */ void sgpio_configure( - const transceiver_mode_t transceiver_mode, + const sgpio_direction_t direction, const bool multi_slice ) { // Disable all counters during configuration @@ -114,7 +116,7 @@ void sgpio_configure( // Set SGPIO output values. const uint_fast8_t cpld_direction = - (transceiver_mode == TRANSCEIVER_MODE_TX) ? 1 : 0; + (direction == SGPIO_DIRECTION_TX) ? 1 : 0; SGPIO_GPIO_OUTREG = (cpld_direction << 11) /* 1=Output SGPIO11 High(TX mode), 0=Output SGPIO11 Low(RX mode)*/ | (1L << 10) // disable codec data stream during configuration (Output SGPIO10 High) @@ -122,7 +124,7 @@ void sgpio_configure( // Enable SGPIO pin outputs. const uint_fast16_t sgpio_gpio_data_direction = - (transceiver_mode == TRANSCEIVER_MODE_TX) + (direction == SGPIO_DIRECTION_TX) ? (0xFF << 0) : (0x00 << 0); SGPIO_GPIO_OENREG = @@ -181,10 +183,10 @@ void sgpio_configure( for(uint_fast8_t i=0; i +typedef enum { + SGPIO_DIRECTION_RX, + SGPIO_DIRECTION_TX, +} sgpio_direction_t; + void sgpio_configure_pin_functions(); void sgpio_test_interface(); void sgpio_configure( - const transceiver_mode_t transceiver_mode, + const sgpio_direction_t direction, const bool multi_slice ); void sgpio_cpld_stream_enable(); diff --git a/firmware/hackrf_usb/hackrf_usb.c b/firmware/hackrf_usb/hackrf_usb.c index 342ec163..85d01a94 100644 --- a/firmware/hackrf_usb/hackrf_usb.c +++ b/firmware/hackrf_usb/hackrf_usb.c @@ -188,19 +188,20 @@ void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) { gpio_set(PORT_LED1_3, PIN_LED2); usb_endpoint_init(&usb_endpoint_bulk_in); rf_path_set_direction(RF_PATH_DIRECTION_RX); + sgpio_configure(SGPIO_DIRECTION_RX, true); } else if (transceiver_mode == TRANSCEIVER_MODE_TX) { gpio_clear(PORT_LED1_3, PIN_LED2); gpio_set(PORT_LED1_3, PIN_LED3); usb_endpoint_init(&usb_endpoint_bulk_out); rf_path_set_direction(RF_PATH_DIRECTION_TX); + sgpio_configure(SGPIO_DIRECTION_TX, true); } else { gpio_clear(PORT_LED1_3, PIN_LED2); gpio_clear(PORT_LED1_3, PIN_LED3); rf_path_set_direction(RF_PATH_DIRECTION_OFF); + sgpio_configure(SGPIO_DIRECTION_RX, true); } - sgpio_configure(transceiver_mode, true); - if( transceiver_mode != TRANSCEIVER_MODE_OFF ) { vector_table_entry_t sgpio_isr_fn = sgpio_isr_rx; if( transceiver_mode == TRANSCEIVER_MODE_TX ) {