Example #1
0
/**
 * Disconnects antenna from the rx path.
 */
void rf_path_set_disconnect_rx_antenna(const uint_fast8_t enable)
{
	//todo also disable rx amp when active?
	if (switchctrl & SWITCHCTRL_TX)
		return;
	if (enable)
	{
		/**
		 * open all switches in RX path
		 */
		/*
		gpio_clear(PORT_TX, PIN_TX);
		gpio_clear(PORT_RX, PIN_RX);
*/
		gpio_clear(PORT_AMP_BYPASS, PIN_AMP_BYPASS);
		gpio_clear(PORT_TX_AMP, PIN_TX_AMP);
		gpio_set(PORT_NO_TX_AMP_PWR, PIN_NO_TX_AMP_PWR);
		gpio_clear(PORT_RX_AMP, PIN_RX_AMP);
		gpio_set(PORT_NO_RX_AMP_PWR, PIN_NO_RX_AMP_PWR);
	}
	else
	{
		switchctrl_set(switchctrl);
	}

}
Example #2
0
void rf_path_set_direction(const rf_path_direction_t direction) {
	/* Turn off TX and RX amplifiers, then enable based on direction and bypass state. */
	switchctrl |= SWITCHCTRL_NO_TX_AMP_PWR | SWITCHCTRL_NO_RX_AMP_PWR;
	switch(direction) {
	case RF_PATH_DIRECTION_TX:
		switchctrl |= SWITCHCTRL_TX;
		if( (switchctrl & SWITCHCTRL_AMP_BYPASS) == 0 ) {
			/* TX amplifier is in path, be sure to enable TX amplifier. */
			switchctrl &= ~SWITCHCTRL_NO_TX_AMP_PWR;
		}
		rffc5071_tx();
		if( switchctrl & SWITCHCTRL_MIX_BYPASS ) {
			rffc5071_disable();
		} else {
			rffc5071_enable();
		}
		ssp1_set_mode_max5864();
		max5864_tx();
		ssp1_set_mode_max2837();
		max2837_tx();
		sgpio_configure(SGPIO_DIRECTION_TX);
		break;
	
	case RF_PATH_DIRECTION_RX:
		switchctrl &= ~SWITCHCTRL_TX;
		if( (switchctrl & SWITCHCTRL_AMP_BYPASS) == 0 ) {
			/* RX amplifier is in path, be sure to enable RX amplifier. */
			switchctrl &= ~SWITCHCTRL_NO_RX_AMP_PWR;
		}
		rffc5071_rx();
		if( switchctrl & SWITCHCTRL_MIX_BYPASS ) {
			rffc5071_disable();
		} else {
			rffc5071_enable();
		}
		ssp1_set_mode_max5864();
		max5864_rx();
		ssp1_set_mode_max2837();
		max2837_rx();
		sgpio_configure(SGPIO_DIRECTION_RX);
		break;
		
	case RF_PATH_DIRECTION_OFF:
	default:
#ifdef HACKRF_ONE
		rf_path_set_antenna(0);
#endif
		/* Set RF path to receive direction when "off" */
		switchctrl &= ~SWITCHCTRL_TX;
		rffc5071_disable();
		ssp1_set_mode_max5864();
		max5864_standby();
		ssp1_set_mode_max2837();
		max2837_set_mode(MAX2837_MODE_STANDBY);
		sgpio_configure(SGPIO_DIRECTION_RX);
		break;
	}

	switchctrl_set(switchctrl);
}
Example #3
0
/* antenna port power control */
void rf_path_set_antenna(const uint_fast8_t enable) {
	if (enable) {
		switchctrl |= SWITCHCTRL_ANT_PWR;
	} else {
		switchctrl &= ~(SWITCHCTRL_ANT_PWR);
	}

	switchctrl_set(switchctrl);
}
Example #4
0
/* antenna port power control */
void rf_path_set_antenna(rf_path_t* const rf_path, const uint_fast8_t enable) {
	if (enable) {
		rf_path->switchctrl |= SWITCHCTRL_ANT_PWR;
	} else {
		rf_path->switchctrl &= ~(SWITCHCTRL_ANT_PWR);
	}

	switchctrl_set(rf_path, rf_path->switchctrl);
}
Example #5
0
void rf_path_init(void) {
	ssp1_set_mode_max5864();
	max5864_shutdown();
	
	ssp1_set_mode_max2837();
	max2837_setup();
	max2837_start();
	
	rffc5071_setup();
	switchctrl_set(switchctrl);
}
Example #6
0
void rf_path_init(rf_path_t* const rf_path) {
	ssp1_set_mode_max5864();
	max5864_setup(&max5864);
	max5864_shutdown(&max5864);
	
	ssp1_set_mode_max2837();
	max2837_setup(&max2837);
	max2837_start(&max2837);
	
	rffc5071_setup(&rffc5072);
	switchctrl_set(rf_path, switchctrl);
}
Example #7
0
void rf_path_set_lna(const uint_fast8_t enable) {
	if( enable ) {
		if( switchctrl & SWITCHCTRL_TX ) {
			/* AMP_BYPASS=0, NO_RX_AMP_PWR=1, NO_TX_AMP_PWR=0 */
			switchctrl |= SWITCHCTRL_NO_RX_AMP_PWR;
			switchctrl &= ~(SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_NO_TX_AMP_PWR);
		} else {
			/* AMP_BYPASS=0, NO_RX_AMP_PWR=0, NO_TX_AMP_PWR=1 */
			switchctrl |= SWITCHCTRL_NO_TX_AMP_PWR;
			switchctrl &= ~(SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_NO_RX_AMP_PWR);
		}
	} else {
		/* AMP_BYPASS=1, NO_RX_AMP_PWR=1, NO_TX_AMP_PWR=1 */
		switchctrl |= SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_NO_TX_AMP_PWR | SWITCHCTRL_NO_RX_AMP_PWR;
	}
	
	switchctrl_set(switchctrl);
}
Example #8
0
void rf_path_pin_setup(rf_path_t* const rf_path) {
#ifdef HACKRF_ONE
	/* Configure RF switch control signals */
	scu_pinmux(SCU_HP,             SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_LP,             SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX_MIX_BP,      SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_NO_MIX_BYPASS,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_RX_MIX_BP,      SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX_AMP,         SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX,             SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_MIX_BYPASS,     SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_RX,             SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_NO_TX_AMP_PWR,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_AMP_BYPASS,     SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_RX_AMP,         SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_NO_RX_AMP_PWR,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);

	/* Configure RF power supply (VAA) switch */
	scu_pinmux(SCU_NO_VAA_ENABLE,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);

	/* Configure RF switch control signals as outputs */
	gpio_output(rf_path->gpio_amp_bypass);
	gpio_output(rf_path->gpio_no_mix_bypass);
	gpio_output(rf_path->gpio_rx_amp);
	gpio_output(rf_path->gpio_no_rx_amp_pwr);
	gpio_output(rf_path->gpio_hp);
	gpio_output(rf_path->gpio_lp);
	gpio_output(rf_path->gpio_tx_mix_bp);
	gpio_output(rf_path->gpio_rx_mix_bp);
	gpio_output(rf_path->gpio_tx_amp);
	gpio_output(rf_path->gpio_no_tx_amp_pwr);
	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);
#endif
}
Example #9
0
void rf_path_pin_setup() {
#ifdef HACKRF_ONE
	/* Configure RF switch control signals */
	scu_pinmux(SCU_HP,             SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_LP,             SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX_MIX_BP,      SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_NO_MIX_BYPASS,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_RX_MIX_BP,      SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX_AMP,         SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_TX,             SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_MIX_BYPASS,     SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_RX,             SCU_GPIO_FAST | SCU_CONF_FUNCTION4);
	scu_pinmux(SCU_NO_TX_AMP_PWR,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_AMP_BYPASS,     SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_RX_AMP,         SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
	scu_pinmux(SCU_NO_RX_AMP_PWR,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);

	/* Configure RF power supply (VAA) switch */
	scu_pinmux(SCU_NO_VAA_ENABLE,  SCU_GPIO_FAST | SCU_CONF_FUNCTION0);

	/* Configure RF switch control signals as outputs */
	GPIO0_DIR |= PIN_AMP_BYPASS;
	GPIO1_DIR |= (PIN_NO_MIX_BYPASS | PIN_RX_AMP | PIN_NO_RX_AMP_PWR);
	GPIO2_DIR |= (PIN_HP | PIN_LP | PIN_TX_MIX_BP | PIN_RX_MIX_BP | PIN_TX_AMP);
	GPIO3_DIR |= PIN_NO_TX_AMP_PWR;
	GPIO5_DIR |= (PIN_TX | PIN_MIX_BYPASS | PIN_RX);

	/*
	 * Safe (initial) switch settings turn off both amplifiers and antenna port
	 * power and enable both amp bypass and mixer bypass.
	 */
	switchctrl_set(SWITCHCTRL_AMP_BYPASS | SWITCHCTRL_MIX_BYPASS);

	/* Configure RF power supply (VAA) switch control signal as output */
	GPIO_DIR(PORT_NO_VAA_ENABLE) |= PIN_NO_VAA_ENABLE;

	/* Safe state: start with VAA turned off: */
	disable_rf_power();
#endif
}
Example #10
0
void rf_path_set_filter(const rf_path_filter_t filter) {
	switch(filter) {
	default:
	case RF_PATH_FILTER_BYPASS:
		switchctrl |= SWITCHCTRL_MIX_BYPASS;
		rffc5071_disable();
		break;
		
	case RF_PATH_FILTER_LOW_PASS:
		switchctrl &= ~(SWITCHCTRL_HP | SWITCHCTRL_MIX_BYPASS);
		rffc5071_enable();
		break;
		
	case RF_PATH_FILTER_HIGH_PASS:
		switchctrl &= ~SWITCHCTRL_MIX_BYPASS;
		switchctrl |= SWITCHCTRL_HP;
		rffc5071_enable();
		break;
	}

	switchctrl_set(switchctrl);
}