Exemplo n.º 1
0
int main(void)
{
	const uint32_t freq = 2441000000U;

	pin_setup();
	gpio_set(PORT_EN1V8, PIN_EN1V8); /* 1V8 on */
	cpu_clock_init();
	ssp1_init();

	gpio_set(PORT_LED1_3, (PIN_LED1)); /* LED1 on */

	ssp1_set_mode_max2837();
	max2837_setup();
	rffc5071_setup();
	gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */

	max2837_set_frequency(freq);
	max2837_start();
	max2837_tx();
	gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */
	while (1);
	max2837_stop();

	return 0;
}
Exemplo n.º 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);
}
Exemplo n.º 3
0
void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) {
	baseband_streaming_disable();
	
	transceiver_mode = new_transceiver_mode;
	
	usb_init_buffers_bulk();

	if( transceiver_mode == TRANSCEIVER_MODE_RX ) {
		gpio_clear(PORT_LED1_3, PIN_LED3);
		gpio_set(PORT_LED1_3, PIN_LED2);
		usb_endpoint_init(&usb_endpoint_bulk_in);

		rffc5071_rx(switchctrl);
		//rffc5071_set_frequency(1700, 0); // 2600 MHz IF - 1700 MHz LO = 900 MHz RF
		max2837_start();
		max2837_rx();
	} 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);

		rffc5071_tx(switchctrl);
		//rffc5071_set_frequency(1700, 0); // 2600 MHz IF - 1700 MHz LO = 900 MHz RF
		max2837_start();
		max2837_tx();
	} else {
		gpio_clear(PORT_LED1_3, PIN_LED2);
		gpio_clear(PORT_LED1_3, PIN_LED3);
		max2837_stop();
		return;
	}

	sgpio_configure(transceiver_mode, true);

	nvic_set_priority(NVIC_SGPIO_IRQ, 0);
	nvic_enable_irq(NVIC_SGPIO_IRQ);
	SGPIO_SET_EN_1 = (1 << SGPIO_SLICE_A);

    sgpio_cpld_stream_enable();
}