示例#1
0
文件: tuning.c 项目: barto-/hackrf
bool set_freq_explicit(const uint64_t if_freq_hz, const uint64_t lo_freq_hz,
		const rf_path_filter_t path)
{
	if ((if_freq_hz < ((uint64_t)MIN_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ))
			|| (if_freq_hz > ((uint64_t)MAX_BYPASS_FREQ_MHZ * FREQ_ONE_MHZ))) {
		return false;
	}

	if ((path != RF_PATH_FILTER_BYPASS) &&
			((lo_freq_hz < MIN_LO_FREQ_HZ) || (lo_freq_hz > MAX_LO_FREQ_HZ))) {
		return false;
	}

	if (path > 2) {
		return false;
	}

	rf_path_set_filter(&rf_path, path);
	max2837_set_frequency(&max2837, if_freq_hz);
	if (lo_freq_hz > if_freq_hz) {
		sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 1);
	} else {
		sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0);
	}
	if (path != RF_PATH_FILTER_BYPASS) {
		(void)mixer_set_frequency(&mixer, lo_freq_hz / FREQ_ONE_MHZ);
	}
	return true;
}
示例#2
0
void settings_apply_play_freq(int value, bool playback)
{
    static const unsigned long play_sampr[] = { SAMPR_44, SAMPR_48 };
    static int prev_setting = 0;

    if ((unsigned)value >= ARRAYLEN(play_sampr))
        value = 0;

    bool changed = value != prev_setting;
    prev_setting = value;

    unsigned long elapsed = 0;
    unsigned long offset = 0;
    bool playing = changed && !playback &&
                   audio_status() == AUDIO_STATUS_PLAY;

    if (playing)
    {
        struct mp3entry *id3 = audio_current_track();
        elapsed = id3->elapsed;
        offset = id3->offset;
    }

    if (changed && !playback)
        audio_hard_stop();

    /* Other sub-areas of playback pick it up from the mixer */
    mixer_set_frequency(play_sampr[value]);

    if (playing)
        audio_play(elapsed, offset);
}
示例#3
0
文件: tuning.c 项目: barto-/hackrf
/*
 * Set freq/tuning between 0MHz to 7250 MHz (less than 16bits really used)
 * hz between 0 to 999999 Hz (not checked)
 * return false on error or true if success.
 */
bool set_freq(const uint64_t freq)
{
	bool success;
	uint32_t mixer_freq_mhz;
	uint32_t MAX2837_freq_hz;
	uint64_t real_mixer_freq_hz;

	const uint32_t freq_mhz = freq / 1000000;
	const uint32_t freq_hz = freq % 1000000;

	success = true;

	const max2837_mode_t prior_max2837_mode = max2837_mode(&max2837);
	max2837_set_mode(&max2837, MAX2837_MODE_STANDBY);
	if(freq_mhz < MAX_LP_FREQ_MHZ)
	{
		rf_path_set_filter(&rf_path, RF_PATH_FILTER_LOW_PASS);
#ifdef RAD1O
		max2837_freq_nominal_hz = 2300000000;
#else
		/* IF is graduated from 2650 MHz to 2343 MHz */
		max2837_freq_nominal_hz = 2650000000 - (freq / 7);
#endif
		mixer_freq_mhz = (max2837_freq_nominal_hz / FREQ_ONE_MHZ) + freq_mhz;
		/* Set Freq and read real freq */
		real_mixer_freq_hz = mixer_set_frequency(&mixer, mixer_freq_mhz);
		max2837_set_frequency(&max2837, real_mixer_freq_hz - freq);
		sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 1);
	}else if( (freq_mhz >= MIN_BYPASS_FREQ_MHZ) && (freq_mhz < MAX_BYPASS_FREQ_MHZ) )
	{
		rf_path_set_filter(&rf_path, RF_PATH_FILTER_BYPASS);
		MAX2837_freq_hz = (freq_mhz * FREQ_ONE_MHZ) + freq_hz;
		/* mixer_freq_mhz <= not used in Bypass mode */
		max2837_set_frequency(&max2837, MAX2837_freq_hz);
		sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0);
	}else if(  (freq_mhz >= MIN_HP_FREQ_MHZ) && (freq_mhz <= MAX_HP_FREQ_MHZ) )
	{
		if (freq_mhz < MID1_HP_FREQ_MHZ) {
			/* IF is graduated from 2150 MHz to 2750 MHz */
			max2837_freq_nominal_hz = 2150000000 + (((freq - 2750000000) * 60) / 85);
		} else if (freq_mhz < MID2_HP_FREQ_MHZ) {
			/* IF is graduated from 2350 MHz to 2650 MHz */
			max2837_freq_nominal_hz = 2350000000 + ((freq - 3600000000) / 5);
		} else {
			/* IF is graduated from 2500 MHz to 2738 MHz */
			max2837_freq_nominal_hz = 2500000000 + ((freq - 5100000000) / 9);
		}
		rf_path_set_filter(&rf_path, RF_PATH_FILTER_HIGH_PASS);
		mixer_freq_mhz = freq_mhz - (max2837_freq_nominal_hz / FREQ_ONE_MHZ);
		/* Set Freq and read real freq */
		real_mixer_freq_hz = mixer_set_frequency(&mixer, mixer_freq_mhz);
		max2837_set_frequency(&max2837, freq - real_mixer_freq_hz);
		sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0);
	}else
	{
		/* Error freq_mhz too high */
		success = false;
	}
	max2837_set_mode(&max2837, prior_max2837_mode);
	if( success ) {
		freq_cache = freq;
		hackrf_ui_setFrequency(freq);
	}
	return success;
}
示例#4
0
void doFeld(){
	char tu=0,td=0,tl=0,tr=0;
	char tuN=0,tdN=0,tlN=0,trN=0;
	char page=0;
	char tu2=0,td2=0,td2N=0,tl2=0,tr2=0;
	uint16_t sf=3500;
	char tu3=0,td3=0,tl3=0,tr3=0;

	int ctr=0;
	/* Blink LED1 on the board. */

	while (1) 
	{


		lcdClear(0xff);
		lcdPrintln("Feld-Test v11");
		lcdPrintln("");
		lcdPrint("Page ");lcdPrintln(IntToStr(page,2,0));
		if (page==0){
			tu=GET(BY_MIX); tuN=GET(BY_MIX_N);
			lcdPrint(IntToStr(tu,1,F_HEX)); lcdPrint(IntToStr(tuN,1,F_HEX)); lcdPrintln(" Up BY_MIX/_N");
			td=GET(BY_AMP); tdN=GET(BY_AMP_N);
			lcdPrint(IntToStr(td,1,F_HEX)); lcdPrint(IntToStr(tdN,1,F_HEX)); lcdPrintln(" Dn BY_AMP/_N");
			tl=GET(TX_RX);tlN=GET(TX_RX_N);
			lcdPrint(IntToStr(tl,1,F_HEX)); lcdPrint(IntToStr(tlN,1,F_HEX)); lcdPrintln(" Lt TX_RX/_N");
			tr=GET(LOW_HIGH_FILT); trN=GET(LOW_HIGH_FILT_N);
			lcdPrint(IntToStr(tr,1,F_HEX)); lcdPrint(IntToStr(trN,1,F_HEX)); lcdPrintln(" Rt LOW_HIGH_FILT/_N");
			lcdPrintln("Enter for next page");
			lcdDisplay(); 
			switch(getInput()){
				case BTN_UP:
					tu=1-tu;
					if (tu){
						OFF(BY_MIX_N);
						ON(BY_MIX);
					}else{
						OFF(BY_MIX);
						ON(BY_MIX_N);
					};
					break;
				case BTN_DOWN:
					td=1-td;
					if (td){
						OFF(BY_AMP_N);
						ON(BY_AMP);
					}else{
						OFF(BY_AMP);
						ON(BY_AMP_N);
					};
					break;
				case BTN_LEFT:
					tl=1-tl;
					if (tl){
						OFF(TX_RX_N);
						ON(TX_RX);
					}else{
						OFF(TX_RX);
						ON(TX_RX_N);
					};
					break;
				case BTN_RIGHT:
					tr=1-tr;
					if (tr){
						OFF(LOW_HIGH_FILT_N);
						ON(LOW_HIGH_FILT);
					}else{
						OFF(LOW_HIGH_FILT);
						ON(LOW_HIGH_FILT_N);
					};
					break;
				case BTN_ENTER:
					page++;
					break;
			};
		}else if (page==1){
			lcdPrint("  "); lcdPrintln(" Up   ");
			td2=GET(RX_LNA);td2N=GET(TX_AMP);
			lcdPrint(IntToStr(td2,1,F_HEX)); lcdPrint(IntToStr(td2N,1,F_HEX)); lcdPrintln(" Dn RX/TX");
			lcdPrint(IntToStr(tl2,1,F_HEX)); lcdPrint(" ");                    lcdPrintln(" Lt MIXER_EN");
			lcdPrint(IntToStr(tr2,2,F_HEX)); lcdPrintln(" Rt SI-clkdis");
			lcdPrintln("Enter for next page");
			lcdDisplay(); 
			switch(getInput()){
				case BTN_UP:
					tu2=1-tu2;
					if (tu2){
						;
					}else{
						;
					};
					break;
				case BTN_DOWN:
					td2=td2+2*td2N;
					td2++;
					td2=td2%3;
					switch (td2){
						case(0):
							OFF(RX_LNA);
							OFF(TX_AMP);
							break;
						case(1):
							ON(RX_LNA);
							OFF(TX_AMP);
							break;
						case(2):
							OFF(RX_LNA);
							ON(TX_AMP);
							break;
					};
					break;
				case BTN_LEFT:
					tl2=1-tl2;
					if (tl2){
						ON(MIXER_EN);
					}else{
						OFF(MIXER_EN);
					};
					break;
				case BTN_RIGHT:
					tr2=1-tr2;
					if (tr2){
						si5351c_power_down_all_clocks();
					}else{
						si5351c_set_clock_source(PLL_SOURCE_XTAL);
					};
					break;
				case BTN_ENTER:
					page++;
					break;
			};

		}else if (page==2){
			lcdPrint("SF: ");lcdPrint(IntToStr(sf,4,F_ZEROS)); lcdPrintln(" MHz");
			tl3=GET(CE_VCO);
			lcdPrint(IntToStr(tl3,1,F_HEX)); lcdPrint(" "); lcdPrintln(" Lt CE_VCO");
			lcdPrint("  "); lcdPrintln(" Rt ");
			lcdPrintln("Enter for next page");
			lcdDisplay(); 
			switch(getInput()){
				case BTN_UP:
					sf+=100;
					mixer_set_frequency(sf);
					break;
				case BTN_DOWN:
					sf-=100;
					mixer_set_frequency(sf);
					break;
				case BTN_LEFT:
					tl3=1-tl3;
					if (tl3){
						ON(CE_VCO);
						mixer_setup();
						mixer_set_frequency(sf);
					}else{
						OFF(CE_VCO);
					};
					break;
				case BTN_RIGHT:
					tr3=1-tr3;
					if (tr3){
						;
					}else{
						;
					};
					break;
				case BTN_ENTER:
					page++;
					break;
			};

		};
		if (page>2){page=0;}

		ON(LED1);
		delayNop(200000);
		OFF(LED1);
		delayNop(200000);

		ctr++;
		lcdNl();
		lcdPrint(IntToStr(ctr,4,F_HEX));
	}
};