From eec6963759e341e2b4a29ceab29ea8d91e43fe5c Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 21 Sep 2022 12:05:17 +0100 Subject: [PATCH 1/3] Initialise RF path GPIOs to safe settings. Previously these calls were leaving the amplifiers on, since the control settings passed were missing SWITCHCTRL_NO_TX_AMP_PWR and SWITCHCTRL_NO_RX_AMP_PWR. Use the predefined SWITCHCTRL_SAFE here. Also move these calls before setting the GPIO pins to output mode, to avoid driving them to the wrong states briefly first. --- firmware/common/rf_path.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/firmware/common/rf_path.c b/firmware/common/rf_path.c index 6f1af434..691cf761 100644 --- a/firmware/common/rf_path.c +++ b/firmware/common/rf_path.c @@ -267,6 +267,12 @@ void rf_path_pin_setup(rf_path_t* const rf_path) /* Configure RF power supply (VAA) switch */ scu_pinmux(SCU_NO_VAA_ENABLE, SCU_GPIO_FAST | SCU_CONF_FUNCTION0); + /* + * Safe (initial) switch settings turn off both amplifiers and antenna port + * power and enable both amp bypass and mixer bypass. + */ + switchctrl_set(rf_path, SWITCHCTRL_SAFE); + /* Configure RF switch control signals as outputs */ gpio_output(rf_path->gpio_amp_bypass); gpio_output(rf_path->gpio_no_mix_bypass); @@ -281,12 +287,6 @@ void rf_path_pin_setup(rf_path_t* const rf_path) gpio_output(rf_path->gpio_tx); gpio_output(rf_path->gpio_mix_bypass); gpio_output(rf_path->gpio_rx); - - /* - * Safe (initial) switch settings turn off both amplifiers and antenna port - * power and enable both amp bypass and mixer bypass. - */ - switchctrl_set(rf_path, SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_MIX_BYPASS); #elif RAD1O /* Configure RF switch control signals */ // clang-format off @@ -306,6 +306,12 @@ void rf_path_pin_setup(rf_path_t* const rf_path) /* Configure RF power supply (VAA) switch */ scu_pinmux(SCU_VAA_ENABLE, SCU_GPIO_FAST | SCU_CONF_FUNCTION0); + /* + * Safe (initial) switch settings turn off both amplifiers and antenna port + * power and enable both amp bypass and mixer bypass. + */ + switchctrl_set(rf_path, SWITCHCTRL_SAFE); + /* Configure RF switch control signals as outputs */ gpio_output(rf_path->gpio_tx_rx_n); gpio_output(rf_path->gpio_tx_rx); @@ -318,12 +324,6 @@ void rf_path_pin_setup(rf_path_t* const rf_path) gpio_output(rf_path->gpio_low_high_filt_n); gpio_output(rf_path->gpio_tx_amp); gpio_output(rf_path->gpio_rx_lna); - - /* - * Safe (initial) switch settings turn off both amplifiers and antenna port - * power and enable both amp bypass and mixer bypass. - */ - switchctrl_set(rf_path, SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_MIX_BYPASS); #else (void) rf_path; /* silence unused param warning */ #endif From cf34beebb0ddb03b86a67dfee89753b8933c8bf4 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 21 Sep 2022 12:08:47 +0100 Subject: [PATCH 2/3] Remove extra call to switchctrl_set and global switchctrl variable. This call is not required since the GPIOs are already configured in rf_path_pin_setup(). The global switchctrl is not used anywhere else. --- firmware/common/rf_path.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/firmware/common/rf_path.c b/firmware/common/rf_path.c index 691cf761..a7b14050 100644 --- a/firmware/common/rf_path.c +++ b/firmware/common/rf_path.c @@ -79,8 +79,6 @@ SWITCHCTRL_MIX_BYPASS | SWITCHCTRL_HP | SWITCHCTRL_NO_RX_AMP_PWR) #endif -uint8_t switchctrl = SWITCHCTRL_SAFE; - /* * Antenna port power on HackRF One is controlled by GPO1 on the RFFC5072. * This is the only thing we use RFFC5072 GPO for on HackRF One. The value of @@ -343,7 +341,7 @@ void rf_path_init(rf_path_t* const rf_path) #ifndef HACKRF_ONE mixer_setup(&mixer); #endif - switchctrl_set(rf_path, switchctrl); + (void) rf_path; /* silence unused param warning */ } void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t direction) From 3dd2e51d714ca15fd8d8b6099e51bfc6aef29404 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 21 Sep 2022 12:17:28 +0100 Subject: [PATCH 3/3] Initialise rf_path->switchctrl to SWITCHCTRL_SAFE. This was previously never being initialised. --- firmware/common/rf_path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/common/rf_path.c b/firmware/common/rf_path.c index a7b14050..4efb0ec7 100644 --- a/firmware/common/rf_path.c +++ b/firmware/common/rf_path.c @@ -341,7 +341,7 @@ void rf_path_init(rf_path_t* const rf_path) #ifndef HACKRF_ONE mixer_setup(&mixer); #endif - (void) rf_path; /* silence unused param warning */ + rf_path->switchctrl = SWITCHCTRL_SAFE; } void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t direction)