예제 #1
0
파일: main.c 프로젝트: Roadfish/no-OS
/***************************************************************************//**
 * @brief main
*******************************************************************************/
int main(void)
{
	Xil_ICacheEnable();
	Xil_DCacheEnable();

	gpio_init(GPIO_DEVICE_ID);
	gpio_direction(54 + 46, 1);
	spi_init(SPI_DEVICE_ID, 1, 0);

	adc_init();
	dac_init(DATA_SEL_DDS);

	ad9361_phy = ad9361_init(&default_init_param);

	ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
	ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);

#ifdef DAC_DMA
	dac_init(DATA_SEL_DMA);
#else
	dac_init(DATA_SEL_DDS);
#endif

#ifdef CAPTURE_SCRIPT
	adc_capture(16384, ADC_DDR_BASEADDR);
	while(1);
#endif
	get_help(NULL, 0);

	while(1)
	{
		console_get_command(received_cmd);
		invalid_cmd = 0;
		for(cmd = 0; cmd < cmd_no; cmd++)
		{
			param_no = 0;
			cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name,
											  param, &param_no);
			if(cmd_type == UNKNOWN_CMD)
			{
				invalid_cmd++;
			}
			else
			{
				cmd_list[cmd].function(param, param_no);
			}
		}
		if(invalid_cmd == cmd_no)
		{
			console_print("Invalid command!\n");
		}
	}

	Xil_DCacheDisable();
	Xil_ICacheDisable();

	return 0;
}
예제 #2
0
파일: main.c 프로젝트: go2net/kt-rec-pro
/*----------------------------------------------------------------------------*/
static void sys_info_init(void)
{
    //u8 vol_tmp;

#if 1
    sys_main_vol = read_info(MEM_SYS_VOL);
    if ((sys_main_vol > MAX_MAIN_VOL) || (sys_main_vol == 0))              //每次开机时,不要超过最大音量的一半,以免开机音量过大
    {
        sys_main_vol = 20;
    }
#endif

    dac_init(sys_main_vol);
    delay_10ms(50);										//等待,检测USB,SD在线状态
    //init_rec_name();
    //restore_music_point();
#if 0
#if RTC_ENABLE
    if (work_mode != RTC_MODE)
#endif
    {
    	device_check();
#if USB_DEVICE_ENABLE
        if (pc_connect)
            work_mode = USB_DEVICE_MODE;
        else if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#else
       // if (udisk_connect || sdmmc_connect)
       //     work_mode = MUSIC_MODE;
#endif
    }
#endif

}
예제 #3
0
파일: main.c 프로젝트: ADTL/stm32f4-lab
int main()
{
	// create the UART queue
	queue_uart_char = xQueueGenericCreate(5, 10, 0);
	queue_lua_commands = xQueueGenericCreate(5, MAX_STRLEN + 1, 0);
	queue_stepmotor = xQueueGenericCreate(5, sizeof(int), 0);

	dac_init();
	ledlib_init();
	usart1_init(9600, &queue_uart_char);
	task_lua_init(&queue_lua_commands);
	task_stepmotor_init(&queue_stepmotor);

	// just send a message to indicate that it worksa
	usart1_write_string ("\r\nInit complete with motors\r\n");

    xTaskCreate(task_receive_uart_chars, (signed char*)"uart-chars", 100, 0, 1, 0);

    vTaskStartScheduler();

    /*
     * Should never reach here!
     */
    ledlib_set_error_state();
}
예제 #4
0
파일: main.c 프로젝트: UIKit0/synth123
int main(void)
{
    volatile uint16_t i;

    /* BLINK LED FOR A SHORT TIME AT RESET. */
    /* PD0 is output. */
    DDRD = 0x02;
    /* Write data on port. */
    PORTD = 0x00;
    i = 0;
    do {
        i--;
    } while(i);
    PORTD = 0x02;

    dac_init();
    uart_init();
    midi_init();

    struct midi_msg *m;
    while(1) {
        m = midi_msg_get();
        if (NULL != m) {
            if (midi_msg_is_note_on(m)) {
                dac_write(m->data1, DAC_A);
            }
        }
    }
}
예제 #5
0
void analogout_init(dac_t *obj, PinName pin)
{
    MBED_ASSERT(obj);
    if (g_sys_init == 0) {
        system_init();
        g_sys_init = 1;
    }

    struct dac_config config_dac;
    struct dac_chan_config config_dac_chan;
    uint32_t pos_input;
    pos_input = pinmap_find_peripheral(pin, PinMap_DAC);
    MBED_ASSERT(pos_input != NC);

    obj->dac = DAC_0;

    dac_get_config_defaults(&config_dac);
    dac_init(&dac_instance, (Dac *)DAC_0, &config_dac);

    dac_chan_get_config_defaults(&config_dac_chan);
    dac_chan_set_config(&dac_instance, DAC_CHANNEL_0, &config_dac_chan);
    dac_chan_enable(&dac_instance, DAC_CHANNEL_0);

    dac_enable(&dac_instance);
}
예제 #6
0
int main(void)
{	      
  int32_t dac_data = 0;
  int8_t inc_dir = 1;
  char buffer[16];
  
	RCC->AHBENR |= RCC_AHBENR_GPIOAEN; 	// enable the clock to GPIOA
	RCC->AHBENR |= RCC_AHBENR_GPIOBEN; 	// enable the clock to GPIOB
	RCC->AHBENR |= RCC_AHBENR_GPIOCEN; 	// enable the clock to GPIOC

	// Put PORTC.8 in output mode
	GPIOC->MODER |= (1 << 16);

	// Put PORTC.9 in output mode
	GPIOC->MODER |= (1 << 18);

	// Put PORTA.0 in input mode
	GPIOA->MODER &= ~(3 << 0);

	// This configures interrupt such that SysTick_Handler is called
	// at ever TIMER_TICK_HZ i.e. 1/1000 = 1ms
	SysTick_Config(SystemCoreClock / TIMER_TICK_HZ);
	
	// Initialize the lcd	
	lcd_init();
  dac_init();
  	  
	lcd_puts("   STM32F051");	
	lcd_gotoxy(1, 4);
	lcd_puts("DAC TEST");  
  delay_ms(2000);
  
  lcd_clear();
  lcd_puts("DAC Value (PA4): ");
  
  // Generate a step wave on DAC output whose amplitude is
  // proportional to the voltage on ADC input.
	while(1)
	{            
    DAC_SetChannel1Data(DAC_Align_8b_R, dac_data);
    DAC_SoftwareTriggerCmd(0, ENABLE);
    dac_data += (10 * inc_dir);
    if(dac_data > 255)
    {
      dac_data = 250;
      inc_dir = -1;
    }
    else if(dac_data < 0)
    {
      dac_data = 0;
      inc_dir = 1;
    }
    
    int_to_str(dac_data, 5, buffer, sizeof(buffer));
    lcd_gotoxy(1, 0);
    lcd_puts(buffer);
    delay_ms(1000);    
	}

}
예제 #7
0
void analogout_init(dac_t *obj, PinName pin)
{
    MBED_ASSERT(obj);
    if (g_sys_init == 0) {
        system_init();
        g_sys_init = 1;
    }
    struct dac_config config_dac;
    struct dac_chan_config config_dac_chan;
    uint32_t dacperipheral;
    uint32_t ch_index;

    dacperipheral = pinmap_find_peripheral(pin, PinMap_DAC);
    MBED_ASSERT(dacperipheral != NC);
    obj->pin = pin;
    obj->dac = dacperipheral;
    if (pin == PA02) {
        ch_index = 0;
    } else if (pin == PA05) {
        ch_index = 1;
    } else { /*Only 2 pins for DAC*/
        return 0;
    }
    obj->channel = ch_index;

    dac_get_config_defaults(&config_dac);
    dac_init(&(obj->dac_instance), (Dac *)dacperipheral, &config_dac);
    dac_chan_get_config_defaults(&config_dac_chan);
    dac_chan_set_config(&(obj->dac_instance), ch_index, &config_dac_chan);
    dac_chan_enable(&(obj->dac_instance), ch_index);
    dac_enable(&(obj->dac_instance));
}
예제 #8
0
파일: main.c 프로젝트: wuwx/simba
static int test_pcm1611s(struct harness_t *harness_p)
{
#if !defined(SKIP_TEST_PCM1611S)

    int i;
    int samples_per_second = 2 * 11025;
    struct dac_driver_t dac;

    BTASSERT(dac_init(&dac,
                      &dac_0_dev,
                      &pin_0_dev,
                      &pin_1_dev,
                      samples_per_second) == 0);

    for (i = 0; i < membersof(dac_gen_pcm1611s); i += 4096) {
        memcpy(samples, &dac_gen_pcm1611s[i], sizeof(samples));
        BTASSERT(dac_async_convert(&dac,
                                   (uint32_t *)samples,
                                   4096 / 2) == 0);
    }

    BTASSERT(dac_async_wait(&dac) == 0);

    return (0);

#else
    
    return (1);
    
#endif
}
예제 #9
0
//------------------------------------------------------------------------------
void periph_init(void)
{
     gpio_init();
     tim_init();
     usart_init();
     //rtc_init();
     adc_init();
     dac_init();
}
예제 #10
0
파일: spectrum.c 프로젝트: neosam/f1rmware
//# MENU spectrum
void spectrum_menu()
{
	lcdClear();
	lcdDisplay();
	getInputWaitRelease();

	// RF initialization from ppack.c:
	dac_init(false);
	cpu_clock_set(204); // WARP SPEED! :-)
	hackrf_clock_init();
	rf_path_pin_setup();
	/* Configure external clock in */
	scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
	sgpio_configure_pin_functions();
	ON(EN_VDD);
	ON(EN_1V8);
	OFF(MIC_AMP_DIS);
	delayms(500); // doesn't work without
	cpu_clock_set(204); // WARP SPEED! :-)
	si5351_init();
	portapack_init();

	while(1)
	{
		switch(getInput())
		{
			case BTN_UP:
				displayMode=MODE_WATERFALL;
				break;
			case BTN_DOWN:
				displayMode=MODE_SPECTRUM;
				break;
			case BTN_LEFT:
				freq -= 2000000;
				ssp1_set_mode_max2837();
				set_freq(freq);
				break;
			case BTN_RIGHT:
				freq += 2000000;
				ssp1_set_mode_max2837();
				set_freq(freq);
				break;
			case BTN_ENTER:
				//FIXME: unset the callback, reset the clockspeed, tidy up
                nvic_disable_irq(NVIC_DMA_IRQ);
                OFF(EN_VDD);
                OFF(EN_1V8);
                ON(MIC_AMP_DIS);
                systick_set_clocksource(0);
                systick_set_reload(12e6/SYSTICKSPEED/1000);
				return;

		}
	}
}
예제 #11
0
void setup() {
    pinMode(BOARD_LED_PIN, OUTPUT);
    digitalWrite(BOARD_LED_PIN, HIGH);

    Serial1.begin(9600);
    Serial1.println("**** Beginning DAC test");

    Serial1.print("Init... ");
    dac_init(DAC, DAC_CH1 | DAC_CH2);
    Serial1.println("Done.");
}
예제 #12
0
파일: ppack.c 프로젝트: cokesme/f1rmware
//# MENU Apack
void ppack_menu() {
	lcdClear();
	lcdPrintln("PPack port");
	lcdPrintln("");
	lcdPrintln("up=enable");
	lcdDisplay();
	dac_init(false);

	cpu_clock_set(204); // WARP SPEED! :-)
	hackrf_clock_init();
	rf_path_pin_setup();
	/* Configure external clock in */
	scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);

	sgpio_configure_pin_functions();

	ON(EN_VDD);
	ON(EN_1V8);
	OFF(MIC_AMP_DIS);
	complex_s8_t * samples;

	while(1){
		switch(getInputRaw()){
			case BTN_UP:
			    // ON(MIXER_EN); // hackrf does this
			    cpu_clock_set(204); // WARP SPEED! :-)
			    si5351_init();
			    portapack_init();
			    getInputWaitRelease();

			    break;
			case BTN_DOWN:
			    lcdPrintln("file");
			    writeFile("samples.8", (char*)0x20000000,(uintptr_t)s8ram-0x20000000);
			    break;
			case BTN_LEFT:
			    lcdPrintln("reset");
			    s8ram=(complex_s8_t*)0x20000000;
			    break;
			case BTN_RIGHT:
				break;
			case BTN_ENTER:
				return;
		};
		TOGGLE(LED2);
		delayms(40);
		lcdPrint(IntToStr((uintptr_t)s8ram,8,F_HEX));
		lcdPrint(" ");
		lcdPrintln(IntToStr(sctr,7,F_LONG));
		lcdDisplay();
	};
};
예제 #13
0
파일: main.c 프로젝트: wuwx/simba
static int test_sine_440_hz(struct harness_t *harness_p)
{
#if !defined(SKIP_TEST_SINE_440_HZ)
    
    int i;
    float sample;
    int samples_per_second = (membersof(dac_gen_sine) * 440);
    struct dac_driver_t dac;
    int total_number_of_samples;

    BTASSERT(dac_init(&dac,
                      &dac_0_dev,
                      &pin_0_dev,
                      NULL,
                      samples_per_second) == 0);

    /* Samples are in the range -1.0 to 1.0. Convert them to the range
       0 to AMPLITUDE_MAX. */
    for (i = 0; i < membersof(samples); i++) {
        sample = dac_gen_sine[i % membersof(dac_gen_sine)];
        samples[i] =  AMPLITUDE_MAX * ((sample + 1.0) / 2.0);
    }

    std_printf(FSTR("Converting %d samples.\r\n"), (int)membersof(samples));
    BTASSERT(dac_convert(&dac, (uint32_t *)samples, membersof(samples) / 2) == 0);

    /* Converting the signal on the DAC0-pin for 5 seconds. */
    total_number_of_samples = (5 * samples_per_second);
    std_printf(FSTR("Converting %d samples.\r\n"),
               total_number_of_samples);

    for (i = 0; i < total_number_of_samples; i += membersof(samples)) {
        BTASSERT(dac_async_convert(&dac,
                                   (uint32_t *)samples,
                                   membersof(samples) / 2) == 0);
        std_printf(FSTR("Samples left = %d\r\n"), total_number_of_samples - i);
    }

    std_printf(FSTR("Waiting for last samples to be converted\r\n"));

    BTASSERT(dac_async_wait(&dac) == 0);
    
    return (0);

#else

    (void)dac_gen_sine;
    
    return (1);
    
#endif
}
//! [setup]
void configure_dac(void)
{
//! [setup_config]
	struct dac_config config_dac;
//! [setup_config]
//! [setup_config_defaults]
	dac_get_config_defaults(&config_dac);
//! [setup_config_defaults]

//! [setup_set_config]
	dac_init(&dac_instance, DAC, &config_dac);
//! [setup_set_config]
}
예제 #15
0
//=======================================================================================
//		audio dac ramp up 
//=======================================================================================
void avi_audio_decode_rampup(void)
{
	//check ramp up 
	if((R_DAC_CHA_FIFO & 0x3000) == 0x3000) {
		return;
	}
		
	dac_init();
	dac_vref_set(1);//enable DAC
	while(R_DAC_PGA&0x0100);
	//enable cha chb 
	R_DAC_CHA_CTRL |= 0x2000;
	R_DAC_CHB_CTRL |= 0x2000; 
}
예제 #16
0
void setup() {

   pinMode(LED_PIN, OUTPUT);
   pinMode(DISC_PIN, OUTPUT);
   digitalWrite(DISC_PIN,1);
   digitalWrite(LED_PIN,1);

   Serial1.begin(9600);
   Serial1.println("Hello World!");

   Serial1.print("Init... ");
   dac_init();
   Serial1.println("Done.");
}
예제 #17
0
void cmd_writedac(char *line) {
  dac_init(DAC,DAC_CH2);

  int8_t idelta=1;
  uint8_t i=0;
  for(int n=0;n<1000000;n++) {

    if(i == 254) idelta = -1;
    if(i == 0  ) idelta =  1;

    i += idelta;

    dac_write_channel(DAC,2,i);
  }
  serial_write_string("WRITEDACFIN");
}
예제 #18
0
파일: player.c 프로젝트: DC-SWAT/DreamShell
void player_init(void)
{
  dac_init();
	wav_init(buf, sizeof(buf));
	mp3_init(buf, sizeof(buf));
	aac_init(buf, sizeof(buf));
	
  songlist_build(&songlist);
  songlist_sort(&songlist);
  
  for (int i = 0; i < songlist.size; i++)
  {
    read_song_info_for_song(&(songlist.list[i]), &songinfo);
    iprintf("%s\n", songinfo.artist);
  }
}
예제 #19
0
/**
 * \brief Initialize the DAC for unit test
 *
 * Initializes the DAC module used for sending the analog values
 * to the AC during test.
 */
static void test_dac_init(void)
{
	/* Structures for DAC configuration */
	struct dac_config config;
	struct dac_chan_config chan_config;

	/* Configure the DAC module */
	dac_get_config_defaults(&config);
	dac_init(&dac_inst, DAC, &config);

	/* Configure the DAC channel */
	dac_chan_get_config_defaults(&chan_config);
	dac_chan_set_config(&dac_inst, DAC_CHANNEL_0, &chan_config);
	dac_chan_enable(&dac_inst, DAC_CHANNEL_0);

	dac_enable(&dac_inst);
}
int main(void)
{




   /* Se inicializan el timer para generar las interrupciones que permitan generar los escalones del diente de sierra*/
timers_init ();
timers_Set_Value(intervalo);
dac_init();

	   while (1){
		   cargar_dato_dac (contEscalon);
	   }

	   return 0;
}
예제 #21
0
파일: unit_test.c 프로젝트: Realtime-7/asf
/**
 * \brief Initialize the DAC for unit test
 *
 * Initializes the DAC module used for sending the analog values
 * to the ADC during test.
 */
static void test_dac_init(void)
{
	/* Structures for DAC configuration */
	struct dac_config config;
	struct dac_chan_config chan_config;

	/* Configure the DAC module */
	dac_get_config_defaults(&config);
	config.reference    = DAC_REFERENCE_INT1V;
	config.clock_source = GCLK_GENERATOR_3;
	dac_init(&dac_inst, DAC, &config);
	dac_enable(&dac_inst);

	/* Configure the DAC channel */
	dac_chan_get_config_defaults(&chan_config);
	dac_chan_set_config(&dac_inst, DAC_CHANNEL_0, &chan_config);
	dac_chan_enable(&dac_inst, DAC_CHANNEL_0);
}
예제 #22
0
/*----------------------------------------------------------------------------*/
static void sys_info_init(void)
{

    sys_main_vol = read_info(MEM_VOL);

    if ((sys_main_vol > MAX_MAIN_VOL) || (sys_main_vol == 0))              //每次开机时,不要超过最大音量的一半,以免开机音量过大
    {
        sys_main_vol = MAX_MAIN_VOL / 2;

    }
        sys_main_vol = MAX_MAIN_VOL / 2;
	
    dac_init(MAX_MAIN_VOL);
    dsp_set_adc_con((0x0070));
    delay_10ms(200);										//等待,检测USB,SD在线状态
    init_rec_name();
    restore_music_point();

#if 0	
#if RTC_ENABLE
    if (work_mode != RTC_MODE)
#endif
    {
    	device_check();
#if USB_DEVICE_ENABLE
        if (pc_connect)
            work_mode = USB_DEVICE_MODE;
        else if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#else
        if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#endif
        else
        {
            work_mode = read_info(MEM_SYSMODE);
            if (work_mode > MAX_WORK_MODE)
            {
                work_mode = MUSIC_MODE;
            }
        }
    }
#endif
}
예제 #23
0
void comms_init(void)
{
	cdcRxChar = false;
	
	// Start the internal UARTS
	gps_uart_init();	
	ntx2b_uart_init();
	ext_uart_init();
	
	// Start the DAC
	dac_enable(&MY_DAC);
	dac_init();
	
	// Initialise the NTX2B Modulation
		
	ntx2b_mod_enable(RTTY300);

	
	
}
예제 #24
0
파일: main.c 프로젝트: wuwx/simba
static int test_ramp(struct harness_t *harness_p)
{
    int i;
    struct dac_driver_t dac;

    BTASSERT(dac_init(&dac,
                      &dac_0_dev,
                      &pin_0_dev,
                      &pin_1_dev,
                      1) == 0);

    for (i = 0; i < AMPLITUDE_MAX + 1; i++) {
        samples[0] = i;
        samples[1] = (AMPLITUDE_MAX - i);
        std_printf(FSTR("samples[0]: %5d, samples[1]: %5d\r\n"),
                   samples[0],
                   samples[1]);
        BTASSERT(dac_convert(&dac, samples, 2) == 0);
        thrd_sleep(10.0f / (AMPLITUDE_MAX + 1));
    }

    return (0);
}
예제 #25
0
/***************************************************************************//**
 * @brief main
 *******************************************************************************/
int initAd9361(void) {

	int Status;
	uint64_t Value;
	uint8_t en_dis;

	/*
	 * NOTE: The user has to choose the GPIO numbers according to desired
	 * carrier board. The following configuration is valid for boards other
	 * than the Fmcomms5.
	 */
	default_init_param.gpio_resetb = GPIO_RESET_PIN;
	default_init_param.gpio_sync = -1;
	default_init_param.gpio_cal_sw1 = -1;
	default_init_param.gpio_cal_sw2 = -1;

	/*
	 * Initialize the GPIO
	 */
	gpio_init(GPIO_DEVICE_ID);
	gpio_direction(default_init_param.gpio_resetb, 1);

	/*
	 * Initialize the SPI
	 */
	spi_init(SPI_DEVICE_ID, 1, 0);

	/*
	 * Initialize AD9361
	 */
	Status = ad9361_init(&ad9361_phy, &default_init_param);
	if (Status != 0) {
		xil_printf("Could not initialize AD9361\r\n");
		xil_printf("Status\t%d\r\n", Status);
		return 1;
	}

	/*
	 * Sampling frequency
	 */
	Status = ad9361_set_tx_sampling_freq(ad9361_phy, SAMPLING_FREQ);
	if (Status != 0) {
		xil_printf("Could not set Tx sampling freq.\r\n");
		return 1;
	}
	Status = ad9361_set_rx_sampling_freq(ad9361_phy, SAMPLING_FREQ);
	if (Status != 0) {
		xil_printf("Could not set Rx sampling freq.\r\n");
		return 1;
	}
	/*
	 * Set Tx and Rx FIR
	 */
	Status = ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
	if (Status != 0) {
		xil_printf("Could not set Tx FIR\r\n");
		return 1;
	}
	Status = ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);
	if (Status != 0) {
		xil_printf("Could not set Rx FIR\r\n");
		return 1;
	}
	// Enable both at the same time
	Status = ad9361_set_trx_fir_en_dis(ad9361_phy, 1);
	if (Status != 0) {
		xil_printf("Could not enable Tx and Rx FIR\r\n");
		return 1;
	}
	// Check status
	Status = ad9361_get_tx_fir_en_dis(ad9361_phy, &en_dis);
	if (Status == 0) {
		xil_printf("Tx FIR status\t %d\r\n", en_dis);
	} else {
		xil_printf("Could not get Tx FIR enable\r\n");
		return 1;
	}
	Status = ad9361_get_rx_fir_en_dis(ad9361_phy, &en_dis);
	if (Status == 0) {
		xil_printf("Rx FIR status\t %d\r\n", en_dis);
	} else {
		xil_printf("Could not get Rx FIR enable\r\n");
		return 1;
	}
	/*
	 * Rf bandwidth
	 */
	Status = ad9361_set_tx_rf_bandwidth(ad9361_phy, RF_BW);
	if (Status != 0) {
		xil_printf("Could not set Tx Rf bandwidth\r\n");
		return 1;
	}
	Status = ad9361_set_rx_rf_bandwidth(ad9361_phy, RF_BW);
	if (Status != 0) {
		xil_printf("Could not set Rx Rf bandwidth\r\n");
		return 1;
	}
	/*
	 * Gain control mode
	 */
	Status = ad9361_set_rx_gain_control_mode(ad9361_phy, 0,
			RF_GAIN_SLOWATTACK_AGC);
	if (Status != 0) {
		xil_printf("Could not set Rx gain control mode for channel 0\r\n");
		return 1;
	}
	/*
	 * Hardware gains
	 */
	Status = ad9361_set_rx_rf_gain(ad9361_phy, 0, -10);
	if (Status != 0) {
		xil_printf("Could not set Rx gain for channel 0\r\n");
		return 1;
	}

	Status = ad9361_get_rx_lo_freq(ad9361_phy, &Value);
	if (Status == 0) {
		xil_printf("LO Frequency\t %u \r\n", Value);
	} else {
		xil_printf("Could not get current LO frequency\r\n");
		return 1;
	}

#if ROE_CPRI_SINK == ROE_SINK_DAC
	dac_init(ad9361_phy, DATA_SEL_DMA, 1);
#endif

#ifndef AXI_ADC_NOT_PRESENT
#if defined XILINX_PLATFORM && defined CAPTURE_SCRIPT
	// NOTE: To prevent unwanted data loss, it's recommended to invalidate
	// cache after each adc_capture() call, keeping in mind that the
	// size of the capture and the start address must be alinged to the size
	// of the cache line.
	mdelay(1000);
	adc_capture(16384, ADC_DDR_BASEADDR);
	Xil_DCacheInvalidateRange(ADC_DDR_BASEADDR, 16384);
#endif
#endif

#ifdef CONSOLE_COMMANDS
	get_help(NULL, 0);

	while (1)
	{
		console_get_command(received_cmd);
		invalid_cmd = 0;
		for (cmd = 0; cmd < cmd_no; cmd++)
		{
			param_no = 0;
			cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name,
					param, &param_no);
			if (cmd_type == UNKNOWN_CMD)
			{
				invalid_cmd++;
			}
			else
			{
				cmd_list[cmd].function(param, param_no);
			}
		}
		if (invalid_cmd == cmd_no)
		{
			console_print("Invalid command!\n");
		}
	}
#endif

	printf("AD9361 Initialization Done.\n");

#ifdef XILINX_PLATFORM
	Xil_DCacheDisable();
	Xil_ICacheDisable();
#endif

	return 0;
}
예제 #26
0
void serial_process_command(char *line) {

  if(in_displayparams) {
    serial_displayparams_run(line);
    in_displayparams = false;
  }

  if(in_setdevicetag) {
    serial_setdevicetag_run(line);
    in_setdevicetag = false;
  }

  if(in_setrtc) {
    serial_setrtc_run(line);
    in_setrtc = false;
  }

  if(in_setkeyval) {
    serial_setkeyval_run(line);
    in_setkeyval = false;
  }

  serial_write_string("\r\n");
  if(strcmp(line,"HELLO") == 0) {
   serial_write_string("GREETINGS PROFESSOR FALKEN.\r\n");
  } else 
  if(strcmp(line,"LIST GAMES") == 0) {
    serial_write_string("I'M KIND OF BORED OF GAMES, TURNS OUT THE ONLY WAY TO WIN IS NOT TO PLAY...\r\n");
  } else 
  if(strcmp(line,"LOGXFER") == 0) {
    serial_sendlog();
  } else 
  if(strcmp(line,"DISPLAYPARAMS") == 0) {
    serial_displayparams();
  } else
  if(strcmp(line,"HELP") == 0) {
    serial_write_string("Available commands: HELP, LOGXFER, DISPLAYTEST, HELLO");
  } else 
  if(strcmp(line,"DISPLAYTEST") == 0) {
    display_test();
  } else
  if(strcmp(line,"LOGTEST") == 0) {
    char stemp[100];

    sprintf(stemp,"Raw log data\r\n");
    serial_write_string(stemp);

    uint8_t *flash_log = flashstorage_log_get();
    for(int n=0;n<1024;n++) {
      sprintf(stemp,"%u ",flash_log[n]);
      serial_write_string(stemp);
      if(n%64 == 0) serial_write_string("\r\n");
    }
    serial_write_string("\r\n");

    log_data_t data;
    data.time = 0;
    data.cpm  = 1;
    data.accel_x_start = 2;
    data.accel_y_start = 3;
    data.accel_z_start = 4;
    data.accel_x_end   = 5;
    data.accel_y_end   = 6;
    data.accel_z_end   = 7;
    data.log_type      = UINT_MAX;
    sprintf(stemp,"Log size: %u\r\n",flashstorage_log_size());
    serial_write_string(stemp);

    sprintf(stemp,"Writing test log entry of size: %u\r\n",sizeof(log_data_t));
    serial_write_string(stemp);

    flashstorage_log_pushback((uint8 *) &data,sizeof(log_data_t));

    sprintf(stemp,"Log size: %u\r\n",flashstorage_log_size());
    serial_write_string(stemp);
  } else 
  if(strcmp(line,"VERSION") == 0) {
    char stemp[50];
    sprintf(stemp,"Version: %s\r\n",OS100VERSION);
    serial_write_string(stemp);
  } else 
  if(strcmp(line,"GETDEVICETAG") == 0) {
    const char *devicetag = flashstorage_keyval_get("DEVICETAG");
    if(devicetag != 0) {
      char stemp[100];
      sprintf(stemp,"Devicetag: %s\r\n",devicetag);
      serial_write_string(stemp);
    } else {
      serial_write_string("No device tag set");
    }
  } else
  if(strcmp(line,"SETDEVICETAG") == 0) {
    serial_setdevicetag();
  } else 
  if(strcmp(line,"READPRIVATEKEY") == 0) {
   // serial_readprivatekey();  // removed for production
  } else
  if(strcmp(line,"WRITEPRIVATEKEY") == 0) {
   // serial_writeprivatekey(); // maybe this should be removed for production?
  } else 
  if(strcmp(line,"MAGREAD") == 0) {
    gpio_set_mode (PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit, GPIO_OUTPUT_PP); // MAGPOWER
    gpio_set_mode (PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit, GPIO_INPUT_PU);  // MAGSENSE

    // Power up magsense
    gpio_write_bit(PIN_MAP[41].gpio_device,PIN_MAP[41].gpio_bit,1);

    // wait...
    delay_us(1000);
    
    // Read magsense
    int magsense = gpio_read_bit(PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit);

    char magsenses[50];
    sprintf(magsenses,"%u\r\n",magsense);
    serial_write_string(magsenses);
  } else
  if(strcmp(line,"WRITEDAC") == 0) {
    dac_init(DAC,DAC_CH2);

    int8_t idelta=1;
    uint8_t i=0;
    for(int n=0;n<1000000;n++) {
      
      if(i == 254) idelta = -1;
      if(i == 0  ) idelta =  1;

      i += idelta;

      dac_write_channel(DAC,2,i);
    }
    serial_write_string("WRITEDACFIN");
  } else
  if(strcmp(line,"TESTHP") == 0) {
    gpio_set_mode (PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit, GPIO_OUTPUT_PP);  // HP_COMBINED
    for(int n=0;n<100000;n++) {
      gpio_write_bit(PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit,1);
      delay_us(100);
      gpio_write_bit(PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit,0);
      delay_us(100);
    }
  } else 
  if(strcmp(line,"READADC") == 0) {

    adc_init(PIN_MAP[12].adc_device); // all on ADC1

    adc_set_extsel(PIN_MAP[12].adc_device, ADC_SWSTART);
    adc_set_exttrig(PIN_MAP[12].adc_device, true);

    adc_enable(PIN_MAP[12].adc_device);
    adc_calibrate(PIN_MAP[12].adc_device);
    adc_set_sample_rate(PIN_MAP[12].adc_device, ADC_SMPR_55_5);

    gpio_set_mode (PIN_MAP[12].gpio_device,PIN_MAP[12].gpio_bit, GPIO_INPUT_ANALOG);
    gpio_set_mode (PIN_MAP[19].gpio_device,PIN_MAP[19].gpio_bit, GPIO_INPUT_ANALOG);
    gpio_set_mode (PIN_MAP[20].gpio_device,PIN_MAP[20].gpio_bit, GPIO_INPUT_ANALOG);

    int n=0;
    uint16 value1 = adc_read(PIN_MAP[12].adc_device,PIN_MAP[12].adc_channel);
    uint16 value2 = adc_read(PIN_MAP[19].adc_device,PIN_MAP[19].adc_channel);
    uint16 value3 = adc_read(PIN_MAP[20].adc_device,PIN_MAP[20].adc_channel);
    char values[50];
    sprintf(values,"PA6 ADC Read: %u\r\n",value1);
    serial_write_string(values);
    sprintf(values,"PC4 ADC Read: %u\r\n",value2);
    serial_write_string(values);
    sprintf(values,"PC5 ADC Read: %u\r\n",value3);
    serial_write_string(values);
  } else
  if(strcmp(line,"SETMICREVERSE") == 0) {
    gpio_set_mode (PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit, GPIO_OUTPUT_PP);  // MICREVERSE
    gpio_set_mode (PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit, GPIO_OUTPUT_PP);  // MICIPHONE
    gpio_write_bit(PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit,1); // MICREVERSE
    gpio_write_bit(PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit,0); // MICIPHONE
    serial_write_string("Set MICREVERSE to 1, MICIPHONE to 0\r\n");
  } else 
  if(strcmp(line,"SETMICIPHONE") == 0) {
    gpio_set_mode (PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit, GPIO_OUTPUT_PP);  // MICREVERSE
    gpio_set_mode (PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit, GPIO_OUTPUT_PP);  // MICIPHONE
    gpio_write_bit(PIN_MAP[36].gpio_device,PIN_MAP[36].gpio_bit,0); // MICREVERSE
    gpio_write_bit(PIN_MAP[35].gpio_device,PIN_MAP[35].gpio_bit,1); // MICIPHONE
    serial_write_string("Set MICREVERSE to 0, MICIPHONE to 1\r\n");
  } else
  if(strcmp(line,"TESTSIGN") == 0) {
    serial_signing_test();
  } else 
  if(strcmp(line,"PUBKEY") == 0) {
    signing_printPubKey();
    serial_write_string("\n\r");
  } else 
  if(strcmp(line,"GUID") == 0) {
    signing_printGUID();
    serial_write_string("\n\r");
  } else 
  if(strcmp(line,"KEYVALID") == 0) {
    if( signing_isKeyValid() == 1 )
      serial_write_string("uu_valid VALID KEY\r\n");
    else
      serial_write_string("uu_valid IMPROPER OR UNINITIALIZED KEY\r\n");
  } else 
  if(strcmp(line,"LOGSIG") == 0) {
    signing_hashLog();
    serial_write_string("\n\r");
  } else
  if(strcmp(line,"LOGPAUSE") == 0) {
    flashstorage_log_pause();
  } else 
  if(strcmp(line,"LOGRESUME") == 0) {
    flashstorage_log_resume();
  } else
  if(strcmp(line,"LOGCLEAR") == 0) {
    serial_write_string("Clearing flash log\r\n");
    flashstorage_log_clear();
    serial_write_string("Cleared\r\n");
  } else
  if(strcmp(line,"KEYVALDUMP") == 0) {
    serial_keyvaldump();
  } else
  if(strcmp(line,"KEYVALSET") == 0) {
    serial_setkeyval();
  } else
  if(strcmp(line,"SETRTC") == 0) {
    serial_setrtc();
  } else
  if(strcmp(line,"RTCALARM") == 0) {
    serial_write_string("Alarm triggered for 10s\r\n");
    rtc_set_alarm(RTC,rtc_get_time(RTC)+10);
  }

  serial_write_string("\r\n>");
}
예제 #27
0
//! [setup_dac]
void configure_dac(void)
{
//! [setup_dac_config]
	struct dac_config config_dac;
//! [setup_dac_config]

//! [setup_dac_config_default]
	dac_get_config_defaults(&config_dac);
//! [setup_dac_config_default]

//! [setup_dac_start_on_event]
#if (SAML21)
	dac_instance.start_on_event[DAC_CHANNEL_0] = true;
#else
	dac_instance.start_on_event = true;
#endif
//! [setup_dac_start_on_event]

//! [setup_dac_instance]
	dac_init(&dac_instance, DAC, &config_dac);
//! [setup_dac_instance]

//! [setup_dac_on_event_start_conversion]
	struct dac_events events =
#if (SAML21)
		{ .on_event_chan0_start_conversion = true };
#else
		{ .on_event_start_conversion = true };
#endif
//! [setup_dac_on_event_start_conversion]

//! [enable_dac_event]
	dac_enable_events(&dac_instance, &events);
//! [enable_dac_event]
}
//! [setup_dac]

//! [setup_dac_channel]
void configure_dac_channel(void)
{
//! [setup_dac_chan_config]
	struct dac_chan_config config_dac_chan;
//! [setup_dac_chan_config]

//! [setup_dac_chan_config_default]
	dac_chan_get_config_defaults(&config_dac_chan);
//! [setup_dac_chan_config_default]

//! [set_dac_chan_config]
	dac_chan_set_config(&dac_instance, DAC_CHANNEL_0,
			&config_dac_chan);
//! [set_dac_chan_config]

//! [enable_dac_channel]
	dac_chan_enable(&dac_instance, DAC_CHANNEL_0);
//! [enable_dac_channel]
}
//! [setup_dac_channel]

int main(void)
{
//! [data_length_var]
	uint32_t i;
//! [data_length_var]
	system_init();

//! [setup_init]
//! [init_rtc]
	configure_rtc_count();
//! [init_rtc]

//! [set_rtc_period]
	rtc_count_set_period(&rtc_instance, 1);
//! [set_rtc_period]

//! [init_dac]
	configure_dac();
//! [init_dac]

//! [init_dac_chan]
	configure_dac_channel();
//! [init_dac_chan]

//! [enable_dac]
	dac_enable(&dac_instance);
//! [enable_dac]

//! [init_event_resource]
	configure_event_resource();
//! [init_event_resource]

//! [register_dac_callback]
	dac_register_callback(&dac_instance, DAC_CHANNEL_0,
			dac_callback,DAC_CALLBACK_TRANSFER_COMPLETE);
//! [register_dac_callback]

//! [enable_dac_callback]
	dac_chan_enable_callback(&dac_instance, DAC_CHANNEL_0,
			DAC_CALLBACK_TRANSFER_COMPLETE);
//! [enable_dac_callback]

//! [setup_dac_data]
	for (i = 0;i < DATA_LENGTH;i++) {
		dac_data[i] = 0xfff * i;
	}
//! [setup_dac_data]
//! [setup_init]

//! [main_start]
//! [main_write]
	dac_chan_write_buffer_job(&dac_instance, DAC_CHANNEL_0,
			dac_data, DATA_LENGTH);
//! [main_write]

//! [main_check_transfer_done]
	while (!transfer_is_done) {
		/* Wait for transfer done */
	}
//! [main_check_transfer_done]

//! [main_loop]
	while (1) {
	}
//! [main_loop]
//! [main_start]
}
예제 #28
0
파일: platform.c 프로젝트: aiguaizai/no-OS
/***************************************************************************//**
 * @brief axiadc_init
*******************************************************************************/
void axiadc_init(struct ad9361_rf_phy *phy)
{
	adc_init(phy);
	dac_init(phy, DATA_SEL_DDS);
}
예제 #29
0
/**
 * \brief Configures the DAC in event triggered mode.
 *
 * Configures the DAC to use the module's default configuration, with output
 * channel mode configured for event triggered conversions.
 *
 * \param dev_inst  Pointer to the DAC module software instance to initialize
 */
static void configure_dac(struct dac_module *dac_module)
{
    struct dac_config config;
    struct dac_chan_config channel_config;

    /* Get the DAC default configuration */
    dac_get_config_defaults(&config);

    /* Switch to GCLK generator 0 */
    config.clock_source = GCLK_GENERATOR_0;

    dac_init(dac_module, DAC, &config);

    /* Get the default DAC channel config */
    dac_chan_get_config_defaults(&channel_config);

    /* Set the channel configuration, and enable it */
    dac_chan_set_config(dac_module, DAC_CHANNEL_0, &channel_config);
    dac_chan_enable(dac_module, DAC_CHANNEL_0);

    /* Enable event triggered conversions */
    struct dac_events events = { .on_event_start_conversion = true };
    dac_enable_events(dac_module, &events);

    dac_enable(dac_module);
}

/**
 * \brief Configures the TC to generate output events at the sample frequency.
 *
 * Configures the TC in Frequency Generation mode, with an event output once
 * each time the audio sample frequency period expires.
 *
 * \param dev_inst  Pointer to the TC module software instance to initialize
 */
static void configure_tc(struct tc_module *tc_module)
{
    struct tc_config config;
    tc_get_config_defaults(&config);

    config.clock_source    = GCLK_GENERATOR_0;
    config.wave_generation = TC_WAVE_GENERATION_MATCH_FREQ;

    tc_init(tc_module, TC3, &config);

    /* Enable periodic event output generation */
    struct tc_events events = { .generate_event_on_overflow = true };
    tc_enable_events(tc_module, &events);

    /* Set the timer top value to alter the overflow frequency */
    tc_set_top_value(tc_module,
                     system_gclk_gen_get_hz(GCLK_GENERATOR_0) / sample_rate);


    tc_enable(tc_module);
}

/**
 * \brief Configures the event system to link the sample timer to the DAC.
 *
 * Configures the event system, linking the TC module used for the audio sample
 * rate timing to the DAC, so that a new conversion is triggered each time the
 * DAC receives an event from the timer.
 */
static void configure_events(struct events_resource *event)
{
    struct events_config config;

    events_get_config_defaults(&config);

    config.generator    = EVSYS_ID_GEN_TC3_OVF;
    config.path         = EVENTS_PATH_ASYNCHRONOUS;

    events_allocate(event, &config);
    events_attach_user(event, EVSYS_ID_USER_DAC_START);
}

/**
 * \brief Main application routine
 */
int main(void)
{
    struct dac_module dac_module;
    struct tc_module tc_module;
    struct events_resource event;

    /* Initialize all the system clocks, pm, gclk... */
    system_init();

    /* Enable the internal bandgap to use as reference to the DAC */
    system_voltage_reference_enable(SYSTEM_VOLTAGE_REFERENCE_BANDGAP);

    /* Module configuration */
    configure_tc(&tc_module);
    configure_dac(&dac_module);
    configure_events(&event);

    /* Start the sample trigger timer */
    tc_start_counter(&tc_module);

    while (true) {
        while (port_pin_get_input_level(SW0_PIN) == SW0_INACTIVE) {
            /* Wait for the button to be pressed */
        }

        port_pin_toggle_output_level(LED0_PIN);

        for (uint32_t i = 0; i < number_of_samples; i++) {
            dac_chan_write(&dac_module, DAC_CHANNEL_0, wav_samples[i]);

            while (!(DAC->INTFLAG.reg & DAC_INTFLAG_EMPTY)) {
                /* Wait for data buffer to be empty */
            }

        }

        while (port_pin_get_input_level(SW0_PIN) == SW0_ACTIVE) {
            /* Wait for the button to be depressed */
        }
    }
}
예제 #30
0
////////////////////////////////////////
// Секундный тик
////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void RTC_Alarm_IRQHandler(void) { // Тик каждые 4 секунды
		int i;
#ifdef debug
		Wakeup.rtc_wakeup++;
#endif	
    if(RTC_GetITStatus(RTC_IT_ALRA) != RESET) 
		{
			RTC_ClearITPendingBit(RTC_IT_ALRA);
      EXTI_ClearITPendingBit(EXTI_Line17);
			if(!poweroff_state)
			{
			Set_next_alarm_wakeup(); // установить таймер просыпания на +4 секунды
				
			DataUpdate.Need_display_update=ENABLE;
			
			if(Power.USB_active)
			{
				USB_not_active++; // Счетчик неактивности USB
				madorc_impulse+=Detector_massive[Detector_massive_pointer]; // Счетчик импульсов для передачи по USB
			}
			
			// Счетчик времени для обновления напряжения АКБ (каждые 4 минуты)
			if(DataUpdate.Batt_update_time_counter>75) 
			{
				DataUpdate.Need_batt_voltage_update=ENABLE;
				DataUpdate.Batt_update_time_counter=0;
			} else DataUpdate.Batt_update_time_counter++;
			
			// Счетчик времени для обновления счетчика импульсов накачки
			if(DataUpdate.pump_counter_update_time>14) 
			{
#ifdef debug
				Wakeup.total_wakeup=0;
				Wakeup.total_cycle=0;
				Wakeup.rtc_wakeup=0;
				Wakeup.tim9_wakeup=0;
				Wakeup.pump_wakeup=0;
				Wakeup.comp_wakeup=0;
				Wakeup.sensor_wakeup=0;
#endif

				if(!Power.USB_active)madorc_impulse=0;
				pump_counter_avg_impulse_by_1sec[1]=pump_counter_avg_impulse_by_1sec[0];
				pump_counter_avg_impulse_by_1sec[0]=0;
				DataUpdate.pump_counter_update_time=0;

				if(pump_counter_avg_impulse_by_1sec[1]==0) //затычка на случай глюка с накачкой
				{
					dac_init();
					Pump_now(DISABLE);
					while(RTC_WakeUpCmd(DISABLE)!=SUCCESS);
					RTC_SetWakeUpCounter(0xF96); 			// Установить таймаут просыпания = 2 секунды
					current_pulse_count=0;
					while(RTC_WakeUpCmd(ENABLE)!=SUCCESS);
				}

			} else DataUpdate.pump_counter_update_time++;
	
			// Счетчик дней
			if(DataUpdate.days_sec_count>=24600) // каждые 24 часа минут
			{
				DataUpdate.days_sec_count=0;
				working_days++;
				
			} else DataUpdate.days_sec_count++;
			// Сдвиг массива дозы
			if(DataUpdate.doze_sec_count>=150) // каждые 10 минут (150)
			{
				DataUpdate.Need_update_mainscreen_counters=ENABLE;

				// -----------------------------------------------------
				DataUpdate.doze_count++;
				if(DataUpdate.doze_count>=doze_length) // Запись страницы во Flash
				//if(DataUpdate.doze_count>1) // Запись страницы во Flash
				{
					DataUpdate.doze_count=0;
					flash_write_page(DataUpdate.current_flash_page);
					DataUpdate.current_flash_page++;
					if(DataUpdate.current_flash_page > ((FLASH_END_ADDR-FLASH_START_ADDR)/FLASH_PAGE_SIZE)) // если за границами диапазона
						DataUpdate.current_flash_page=0;
				}
				// -----------------------------------------------------

				for(i=doze_length;i>0;i--)
				{
					ram_Doze_massive[i]=ram_Doze_massive[i-1];                        // сдвиг массива дозы
					ram_max_fon_massive[i]=ram_max_fon_massive[i-1];                  // сдвиг массива максимального фона
				}
				ram_Doze_massive[0]=0;
				ram_max_fon_massive[0]=0;
				DataUpdate.doze_sec_count=1; //// !!!!! 0

			} else DataUpdate.doze_sec_count++;
			////////////////////////////////////////////////////	

			
			////////////////////////////////////////////////////    
				if(Detector_massive[Detector_massive_pointer]>9)
				{	
					if(Detector_massive[Detector_massive_pointer]>199) // деление на 9 при фоне более 10 000
					{ 
						if(auto_speedup_factor!=10)auto_speedup_factor=9;
					} else
					{
						if(Detector_massive[Detector_massive_pointer]>99) // деление на 5 при фоне более 5 000
						{ 
							if(auto_speedup_factor!=5)auto_speedup_factor=5;
						} else
						{
							if(Detector_massive[Detector_massive_pointer]>19) // деление на 3 при фоне более 1 000
							{ 
								if(auto_speedup_factor!=3)auto_speedup_factor=3;
							} else
							{ // деление на 2 при фоне более 500
								if(auto_speedup_factor!=2)auto_speedup_factor=2;
							}
						}
					}
					
					if(auto_speedup_factor!=1)recalculate_fon(); // пересчет фона, если активированно ускорение
					
				} else
				{ // если ускорение не требуется
					if(auto_speedup_factor!=1){auto_speedup_factor=1;recalculate_fon();}
					else
					{	fon_level+=Detector_massive[Detector_massive_pointer];}
				}

				Detector_massive_pointer++;
				if(Detector_massive_pointer>=(Settings.Second_count>>2))	
				{
					if(auto_speedup_factor==1)fon_level-=Detector_massive[0];
					Detector_massive[0]=0;
					Detector_massive_pointer=0;
				}else
				{
					if(auto_speedup_factor==1)fon_level-=Detector_massive[Detector_massive_pointer];