示例#1
0
文件: io.c 项目: gvb/quickstart
/**
 * I/O task: reads and writes the I/O.
 */
static void io_task(void *params)
{
	portTickType last_wake_time;
	int ticks=0;

#if (PART != LM3S2110)
	adc_setup();
#endif

#if (DEBUG > 0)
	lprintf("io_task() running.\r\n");
#endif

	/* Start our periodic time starting in 3. 2. 1. NOW! */
	last_wake_time = xTaskGetTickCount();

	while(1) {	/* forever loop */
		wdt_checkin[wdt_io] = 0;

#if (PART != LM3S2110)
		scan_proc_adc();
#endif
		/*
		 * Send a char out the serial port every 10 sec.
		 */
		if (ticks>=POLL_HZ*10) {
			lstr(".");
			ticks=0;
		}
		ticks++;

		vTaskDelayUntil(&last_wake_time, POLL_DELAY);
	}
}
示例#2
0
文件: main.c 项目: GDXN/bano
int main(void)
{
  bano_info_t info;
  uint8_t i;
  uint8_t j;
  uint16_t x;

  info = bano_info_default;
  info.disable_mask = BANO_DISABLE_ALL;
  info.disable_mask &= ~BANO_DISABLE_ADC;
  bano_init(&info);
  nrf905_set_pa_pwr(3);
  nrf905_cmd_wc();

  adc_setup();
  adc_start_free_running();

  for (j = 0; j != 4; ++j)
  {
    x = 0;
    for (i = 0; i != 8; ++i) x += adc_read();
    x /= i;
    bano_send_set(0x2a2b, x);
    bano_send_set(0x2a2b, x);
  }

  bano_loop();
  bano_fini();

  return 0;
}
示例#3
0
int main(void)
{
	adc_core ad9625_core;

	ad9625_setup(SPI_DEVICE_ID, 0);

	jesd204b_setup(AD9625_JESD_BASEADDR, jesd204b_st);

	jesd204b_gt_setup(gt_link);
	jesd204b_gt_en_sync_sysref(gt_link);

	ad9625_spi_write(0, AD9625_REG_TEST_CNTRL, 0x0F);
	ad9625_spi_write(0, AD9625_REG_OUTPUT_MODE, 0x00);
	ad9625_spi_write(0, AD9625_REG_TRANSFER, 0x01);

	ad9625_core.adc_baseaddr = AD9625_CORE_BASEADDR;
	ad9625_core.dmac_baseaddr = AD9625_DMA_BASEADDR;
	ad9625_core.no_of_channels = 1;
	ad9625_core.resolution = 12;

	adc_setup(ad9625_core);

	xil_printf("Start capturing data...\n\r");

	adc_capture(ad9625_core, 16384, ADC_DDR_BASEADDR);

	xil_printf("Done.\n\r");

	return 0;
}
示例#4
0
文件: adc-temp.c 项目: brabo/disco
int main(void)
{
	int i;
	int j = 0;
	clock_setup();
	usart_setup();
	printf("hi guys!\n");
	adc_setup();

	/* green led for ticking */
	gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
			LED_DISCO_GREEN_PIN);

	while (1) {
		//uint16_t input_adc0 = read_adc_naiive(0);
		//uint16_t target = input_adc0 / 2;
		//uint16_t input_adc1 = ((uint16_t)((read_adc_naiive(18) - 760) / 25) + 25);
		int i;
		for (i = 0; i < 0x13; i++) {
			uint16_t input_adc1 = read_adc_naiive(i);
			printf("tick: %d: adc1_%02X=%d\n", j++, i, input_adc1);
		}
		uint32_t reg = ADC_CCR;
		printf("reg = 0x%08X\r\n", reg);

		/* LED on/off */
		gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);

		for (i = 0; i < 1000000; i++) { /* Wait a bit. */
			__asm__("NOP");
		}
	}

	return 0;
}
示例#5
0
文件: adcpoll.c 项目: fjrti/remix
int main(void) {
    int key;
    adc_setup();
    draw_text();
    char temp[5];
    while (1) {
        for (i = 0; i < 4; i++) {
            if (adc_isdone(adcchannels[i]) == 1)
                adc_sample(adcchannels[i], 128);
            tsample = adc_getsample(adcchannels[i]);
            if (! tsample == 0) {
                sprintf(temp, "%d", adcchannels[i]);
                term_puts(1, i + 4, temp);
                sprintf(temp, "%d", adcsmoothing[i]);
                term_puts(5, i + 4, temp);
                sprintf(temp, "%d", tsample);
                term_puts(11, i + 4, temp);
            }
        }
        key = term_getchar(NOWAIT);
        if (key != -1) {
            if (handle_kbd((int)key))
                break;
        }
    }
    term_clrscr();
    term_moveto(1, 1);
    return 0;
}
示例#6
0
文件: hal.c 项目: zbanks/hackboard
void hal_setup(){
    adc_setup();
    //buck_setup();
    //usb_setup();
    //pwm_setup();
    hbridge_setup();
}
int main(void)
{
    int i;
    int j = 0;
    clock_setup();
    usart_setup();
    printf("hi guys!\n");
    adc_setup();
    dac_setup();
    gpio_set_mode(LED_DISCOVERY_USER_PORT, GPIO_MODE_OUTPUT_2_MHZ,
                  GPIO_CNF_OUTPUT_PUSHPULL, LED_DISCOVERY_USER_PIN);

    while (1) {
        uint16_t input_adc0 = read_adc_naiive(0);
        uint16_t target = input_adc0 / 2;
        dac_load_data_buffer_single(target, RIGHT12, CHANNEL_2);
        dac_software_trigger(CHANNEL_2);
        uint16_t input_adc1 = read_adc_naiive(1);
        printf("tick: %d: adc0= %u, target adc1=%d, adc1=%d\n",
               j++, input_adc0, target, input_adc1);
        gpio_toggle(LED_DISCOVERY_USER_PORT, LED_DISCOVERY_USER_PIN); /* LED on/off */
        for (i = 0; i < 1000000; i++) /* Wait a bit. */
            __asm__("NOP");
    }

    return 0;
}
示例#8
0
int main(void)
{
	m_red(ON);
	m_usb_init();
	while(!m_usb_isconnected()); // wait for a serial msg
	m_red(OFF);
	
	m_clockdivide(0); // set clock frequency to 16MHz
	
	adc_setup();
	m_disableJTAG();
	set(ADCSRA,ADEN);//enable ADC
	
	sei();//enable global interrupts
	
	set(ADCSRA,ADSC);//start conversion
	while(1){
		if(FLAG){ // compare readings and move motor accordingly
			m_green(TOGGLE);
			clear(ADCSRA,ADEN); // Disable ADC
			
			m_usb_tx_string("\nF0:");
			m_usb_tx_int(ir[0]);
			m_usb_tx_string("\tF1: ");
			m_usb_tx_int(ir[1]);
			m_usb_tx_string("\tF4: ");
			m_usb_tx_int(ir[2]);
			
			FLAG = 0;
			set(ADCSRA,ADEN); // enable ADC again
			set(ADCSRA,ADSC);//start next conversion
		}
	}
}
int main(void)
{
	int i;
	int j = 0;
	clock_setup();
	usart_setup();
	printf("hi guys!\n");
	adc_setup();
	dac_setup();

	/* green led for ticking */
	gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
			LED_DISCO_GREEN_PIN);

	while (1) {
		uint16_t input_adc0 = read_adc_naiive(0);
		uint16_t target = input_adc0 / 2;
		dac_load_data_buffer_single(target, RIGHT12, CHANNEL_2);
		dac_software_trigger(CHANNEL_2);
		uint16_t input_adc1 = read_adc_naiive(1);
		printf("tick: %d: adc0= %u, target adc1=%d, adc1=%d\n",
			j++, input_adc0, target, input_adc1);

		/* LED on/off */
		gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);

		for (i = 0; i < 1000000; i++) { /* Wait a bit. */
			__asm__("NOP");
		}
	}

	return 0;
}
示例#10
0
文件: main.c 项目: kajm/PingPong
/* HUVUDPROGRAM */
int main (void)
{
	/* INITIERING */
	sysclk_init();			// Systemklocka.
	board_init();			// Arduino-kort.
	configure_console();	// Konsoll-/terminalfönster.
	adc_setup();			// AD-omvandlare.
	pwm_setup();			// PWM-signal.
	motor_shield_setup();	// Motor-shield.

	/* PROCESS 1 - PID-REGLERING */
	if (xTaskCreate(pid, (const signed char * const) "PID-reglering", 1024, NULL, 2, NULL) != pdPASS)
	{
		printf("Misslyckades med att skapa process för PID-reglering.\r\n");
	}
	
	/* PROCESS 2 - KOMMUNIKATION MATLAB */
	if (xTaskCreate(matlab, (const signed char * const) "Matlab-kommunikation", 1024, NULL, 1, NULL) != pdPASS)
	{
		printf("Misslyckades med att skapa process för kommunikation med Matlab.\r\n");
	}
	
	// Schemaläggning startar.
	vTaskStartScheduler();
}
示例#11
0
文件: main.c 项目: michaelnen/1404a
int main (void)
{
	// Insert system clock initialization code here (sysclk_init()).
	
	board_init();
	sysclk_init();

	// Insert application code here, after the board has been initialized.
	
	//Initiera delay
	delay_init();	
	
	
	
	//Initiera LCD
	LCDInit();
	
	//Initiera AD-omvandlare
	adc_setup();
	
	//Starta upp LCD
	setupLCD();
	
	
	//Initiera interupt
	configure_tc();
	
	int delay_time = 200000;	/* variable determining the length of a delay */
	
	PIOB_init(27);
	for (;;)	/* repeat blink in infinity */
	{

		letterS(delay_time);
		
		paus(delay_time * 3);
		
		letterO(delay_time);
		
		paus(delay_time * 3);
		
		letterS(delay_time);

		paus(delay_time * 5);
		
		clearDisplay();
		delay(delay_time);
		
		printNumber(result);
		
		
		
	}
	
	return 0;	
	
}
示例#12
0
文件: main.c 项目: 363546178/no-OS
/***************************************************************************//**
 * @brief Main function.
 *
 * @return 0.
*******************************************************************************/
int main(){

    uint32_t mode;

    Xil_ICacheEnable();
    Xil_DCacheEnable();

    /* AD9467 Setup. */
    ad9467_setup(SPI_DEVICE_ID, 0);

    /* AD9517 Setup. */
    ad9517_setup(SPI_DEVICE_ID, 1);    // Initialize device.
    ad9517_power_mode(3, 0);                     // Set channel 3 for normal operation
    ad9517_frequency(3, 250000000);              // Set the channel 3 frequency to 250Mhz
    ad9517_update();                             // Update registers

    /* Read the device ID for AD9467 and AD9517. */
    xil_printf("\n\r********************************************************************\r\n");
    xil_printf("  ADI AD9467-FMC-EBZ Reference Design\n\r");
    xil_printf("  AD9467 CHIP ID: 0x%02x\n\r", ad9467_read(AD9467_REG_CHIP_ID));
    xil_printf("  AD9467 CHIP GRADE: 0x%02x\n\r", ad9467_read(AD9467_REG_CHIP_GRADE));
    xil_printf("  AD9517 CHIP ID: 0x%02x", ad9517_read(AD9517_REG_PART_ID));
    xil_printf("\n\r********************************************************************\r\n");

    /* AD9467 test. */
    adc_setup(0);

    for (mode = MIDSCALE; mode <= ONE_ZERO_TOGGLE; mode++)        // Data pattern checks
    {
        adc_test(mode, OFFSET_BINARY);       // Data format is offset binary
        adc_test(mode, TWOS_COMPLEMENT);     // Data format is twos complement
    }
    xil_printf("Testing done.\n\r");
    /* AD9467 Setup for data acquisition */
    ad9467_output_invert(0);    // Output invert Off
    ad9467_transfer();          // Synchronously update registers
    ad9467_output_format(0);    // Offset binary
    ad9467_transfer();          // Synchronously update registers
    ad9467_reset_PN9(0);        // Clear PN9 bit
    ad9467_transfer();          // Synchronously update registers
    ad9467_reset_PN23(0);       // Clear PN23 bit
    ad9467_transfer();          // Synchronously update registers
    ad9467_test_mode(0);        // Test mode Off
    ad9467_transfer();          // Synchronously update registers

    xil_printf("Start capturing data...\n\r");

    while(1)
    {
        adc_capture(1024, DDR_BASEADDR);
    }

    Xil_DCacheDisable();
    Xil_ICacheDisable();

    return 0;
}
示例#13
0
文件: lab5t1.c 项目: janicepham/EE138
int main(void)
{
	DDRB = 0xFF;		// set portB as output
	adc_setup();
	sei();
	while(1){
			ADCSRA |= (1 << ADSC);
	}
}
// python function setup()
static PyObject *py_setup_adc(PyObject *self, PyObject *args)
{
    if (adc_setup())
        Py_RETURN_NONE;
    
    PyErr_SetString(PyExc_RuntimeError, "Unable to setup ADC system. Possible causes are: \n"
                                        "  - Module 'ti_am335x_adc' is not loaded \n"
                                        "  - ADC channels are not enabled in the overlay \n");
    return NULL;
}
static void trigger_next_adc_job_if_any(struct pcf50633 *pcf)
{
	struct pcf50633_adc *adc = __to_adc(pcf);
	int head;

	head = adc->queue_head;

	if (!adc->queue[head])
		return;

	adc_setup(pcf, adc->queue[head]->mux, adc->queue[head]->avg);
}
示例#16
0
int main(void) {
    DDRB |= 0b1111111;
    DDRA |= 0b11100001;
    PORTB = 0;

    adc_setup();
    task_setup();
    task_start();

    task_manager();
    return 0;
}
示例#17
0
文件: launchpad_adc.c 项目: Ruhtu/emg
void main(void) {
 
  general_setup();
  adc_setup();
  uart_setup();
  
  __enable_interrupt();
  //__bis_SR_register(CPUOFF+GIE);

  while(1) {
  }
  
}
int main(void)
{
	uint8_t channel_array[16];
	uint16_t temperature = 0;

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 on */
	gpio_set(GPIOC, GPIO15);		/* LED2 on */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	/* Set the injected sequence here, with number of channels */
	adc_set_injected_sequence(ADC1, 1, channel_array);

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since the injected sampling is triggered by the timer, it gets
		 * updated automatically, we just need to periodically read out the value.
		 * It would be better to check if the JEOC bit is set, and clear it following
		 * so that you do not read the same value twice, especially for a slower
		 * sampling rate.
		 */

		temperature = adc_read_injected(ADC1,1); //get the result from ADC_JDR1 on ADC1 (only bottom 16bits)

		/*
		 * That's actually not the real temperature - you have to compute it
		 * as described in the datasheet.
		 */
		my_usart_print_int(USART2, temperature);

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
示例#19
0
文件: adc.c 项目: 3yc/libopencm3
int main(void)
{
	u8 channel_array[16];
	u16 temperature;

	rcc_clock_setup_in_hse_16mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	adc_setup();

	gpio_clear(GPIOB, GPIO7);	/* LED1 on */
	gpio_set(GPIOB, GPIO6);		/* LED2 off */

	/* Send a message on USART1. */
	usart_send(USART1, 's');
	usart_send(USART1, 't');
	usart_send(USART1, 'm');
	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	adc_set_regular_sequence(ADC1, 1, channel_array);

	/*
	 * If the ADC_CR2_ON bit is already set -> setting it another time
	 * starts the conversion.
	 */
	adc_on(ADC1);

	/* Wait for end of conversion. */
	while (!(ADC_SR(ADC1) & ADC_SR_EOC));

	temperature = ADC_DR(ADC1);

	/*
	 * That's actually not the real temperature - you have to compute it
	 * as described in the datasheet.
	 */
	my_usart_print_int(USART1, temperature);

	gpio_clear(GPIOB, GPIO6); /* LED2 on */

	while(1); /* Halt. */

	return 0;
}
int main(void)
{
	u8 channel_array[16];

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	irq_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 on */
	gpio_set(GPIOC, GPIO15);		/* LED2 on */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	/* Set the injected sequence here, with number of channels */
	adc_set_injected_sequence(ADC1, 1, channel_array);

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since sampling is triggered by the timer and copying the value
		 * out of the data register is handled by the interrupt routine,
		 * we just need to print the value and toggle the LED. It may be useful
		 * to buffer the adc values in some cases.
		 */

		/*
		 * That's actually not the real temperature - you have to compute it
		 * as described in the datasheet.
		 */
		my_usart_print_int(USART2, temperature);

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
示例#21
0
int main(void)
{
	uint8_t channel_array[16];
	uint16_t temperature;

	rcc_clock_setup_in_hse_16mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	adc_setup();

	gpio_clear(GPIOB, GPIO7);	/* LED1 on */
	gpio_set(GPIOB, GPIO6);		/* LED2 off */

	/* Send a message on USART1. */
	usart_send(USART1, 's');
	usart_send(USART1, 't');
	usart_send(USART1, 'm');
	usart_send(USART1, '\r');
	usart_send(USART1, '\n');

	/* Select the channel we want to convert. 16=temperature_sensor. */
	channel_array[0] = 16;
	adc_set_regular_sequence(ADC1, 1, channel_array);

	/*
	 * Start the conversion directly (not trigger mode).
	 */
	adc_start_conversion_direct(ADC1);

	/* Wait for end of conversion. */
	while (!(ADC_SR(ADC1) & ADC_SR_EOC));

	temperature = ADC_DR(ADC1);

	/*
	 * That's actually not the real temperature - you have to compute it
	 * as described in the datasheet.
	 */
	my_usart_print_int(USART1, temperature);

	gpio_clear(GPIOB, GPIO6); /* LED2 on */

	while(1); /* Halt. */

	return 0;
}
int main(void)
{

	rcc_clock_setup_in_hse_12mhz_out_72mhz();
	gpio_setup();
	usart_setup();
	timer_setup();
	irq_setup();
	adc_setup();

	gpio_set(GPIOA, GPIO8);	                /* LED1 off */
	gpio_set(GPIOC, GPIO15);		/* LED5 off */

	/* Send a message on USART1. */
	usart_send_blocking(USART2, 's');
	usart_send_blocking(USART2, 't');
	usart_send_blocking(USART2, 'm');
	usart_send_blocking(USART2, '\r');
	usart_send_blocking(USART2, '\n');

	/* Moved the channel selection and sequence init to adc_setup() */

	/* Continously convert and poll the temperature ADC. */
	while (1) {
		/*
		 * Since sampling is triggered by the timer and copying the values
		 * out of the data registers is handled by the interrupt routine,
		 * we just need to print the values and toggle the LED. It may be useful
		 * to buffer the adc values in some cases.
		 */

		my_usart_print_int(USART2, temperature);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, v_refint);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, lisam_adc1);
		usart_send_blocking(USART2, ' ');
		my_usart_print_int(USART2, lisam_adc2);
		usart_send_blocking(USART2, '\r');

		gpio_toggle(GPIOA, GPIO8); /* LED2 on */

	}

	return 0;
}
示例#23
0
文件: main.c 项目: DrSutherland/no-OS
/***************************************************************************//**
 * @brief Main function.
 *
 * @return 0.
*******************************************************************************/
int main(){

	u32 mode;

	Xil_ICacheEnable();
    Xil_DCacheEnable();

    /* AD9467 Setup. */
    ad9467_setup(XPAR_AXI_SPI_0_BASEADDR, 1);

	/* AD9517 Setup. */
	ad9517_setup(XPAR_AXI_SPI_0_BASEADDR, 2);	// Initialize device.
	ad9517_power_mode(3, 0);					// Set channel 3 for normal operation
	ad9517_frequency(3, 250000000); 			// Set the channel 3 frequency to 250Mhz
	ad9517_update();							// Update registers

	/* Read the device ID for AD9467 and AD9517. */
	xil_printf("AD9467[REG_CHIP_ID]: %02x\n\r",
			   ad9467_read(AD9467_REG_CHIP_ID));
	xil_printf("AD9467[REG_CHIP_GRADE]: %02x\n\r",
			    ad9467_read(AD9467_REG_CHIP_GRADE));
	xil_printf("AD9517[REG_PART_ID]: %02x\n\r",
			    ad9517_read(AD9517_REG_PART_ID));

	/* AD9467 test. */
	adc_setup(0);
	for (mode = 0x01; mode <= 0x07; mode++)		// Data pattern checks
	{
		adc_test(mode, 0x0);    // Data format is offset binary
		adc_test(mode, 0x1);    // Data format is twos complement
	}
	ad9467_output_invert(0);    // Output invert Off
	ad9467_output_format(0);    // Offset binary
	ad9467_reset_PN9(0);        // Clear PN9 bit
	ad9467_reset_PN23(0);       // Clear PN23 bit
	ad9467_test_mode(0);        // Test mode Off
	ad9467_transfer();          // Synchronously update registers

	xil_printf("done\n\r");

	Xil_DCacheDisable();
	Xil_ICacheDisable();

	return 0;
}
示例#24
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    P2DIR = 0x00;
	adc_setup();
	SPI_setup();

    int count = 0;
    volatile int freq = adc_value();
  	while(1) {
		if (count == 24) {
			freq = adc_value();
			count = 0;
		}
		count++;
		toggle_waves(freq);
    }
	return 0;
}
示例#25
0
int main(void)
{
       	uint16_t temp;

	clock_setup();
	gpio_setup();
	adc_setup();
	usart_setup();

	while (1) {
	  adc_start_conversion_regular(ADC1);
	  while (!(adc_eoc(ADC1)));
	  temp=adc_read_regular(ADC1);
 	  gpio_port_write(GPIOE, temp << 4);
	  my_usart_print_int(USART2, temp);
	}

	return 0;
}
示例#26
0
/***************************************************************************//**
* @brief main
*******************************************************************************/
int main(void)
{
	spi_device		ad9434_device;
	adc_core		ad9434_core;
	dmac_core		ad9434_dma;
	dmac_xfer		rx_xfer;
	uint8_t			nr_of_lanes = 12;
	uint8_t			over_range_signal = 1;
	ad_platform_init();

	ad9434_core.base_address = XPAR_AXI_AD9434_BASEADDR;
	ad9434_core.no_of_channels = 1;
	ad9434_core.resolution = 12;

	ad9434_dma.base_address = XPAR_AXI_AD9434_DMA_BASEADDR;

	ad_spi_init(&ad9434_device);
	ad9434_device.chip_select = SPI_CHIP_SELECT(0);
#ifdef ZYNQ
	rx_xfer.start_address = XPAR_DDR_MEM_BASEADDR + 0x800000;
#endif
	ad9434_dma.type = DMAC_RX;
	ad9434_dma.transfer = &rx_xfer;
	rx_xfer.id = 0;
	rx_xfer.no_of_samples = 32768;

	ad9434_setup(&ad9434_device);

	adc_setup(ad9434_core);

	ad9434_testmode_set(&ad9434_device, TESTMODE_PN9_SEQ);
	adc_delay_calibrate(ad9434_core, nr_of_lanes + over_range_signal, ADC_PN9);

	ad9434_testmode_set(&ad9434_device, TESTMODE_OFF);
	ad9434_outputmode_set(&ad9434_device, OUTPUT_MODE_TWOS_COMPLEMENT);
	if(!dmac_start_transaction(ad9434_dma)) {
		ad_printf("Capture done!\n");
	};

	ad_platform_close();
	return 0;
}
示例#27
0
文件: main.c 项目: jgac1g08/uavcamera
int main()
{
    io_pins_setup();
    module_setup();
    adc_setup();
    timer1_setup();

    // enable global interrupts
    sei();

    while (1)
    {
        comms_update();

        if (adc_z_want_update)
            adc_buffer_update();
    }

    return (0);
}
/*--------------------------------------------------------------------*/
int main(void)
{
	uint32_t i,j;

	cntr=4;
	clock_setup();
	gpio_setup();
	adc_setup();
	dma_setup();
/* Start of the ADC. Should continue indefinitely with DMA in circular mode */
    adc_start_conversion_regular(ADC1);
	while (1) {
/* Blink the LED (PB8, PB9) on the board. */
		uint32_t count = 500*v[1];
		gpio_toggle(GPIOD, GPIO12);
		for (i = 0; i < count; i++) __asm__("nop");
		gpio_toggle(GPIOD, GPIO13);
		for (i = 0; i < count; i++) __asm__("nop");
	}

	return 0;
}
示例#29
0
int main(void)
{
	uint16_t temp;

	adc_setup();
	usart_setup();

	while (1) {
		adc_start_conversion_regular(ADC1);
		while (!(adc_eoc(ADC1)));

		temp = adc_read_regular(ADC1);
		my_usart_print_int(USART1, temp);

		int i;
		for (i = 0; i < 800000; i++) {   /* Wait a bit. */
			__asm__("nop");
		}
	}

	return 0;
}
示例#30
0
int main()
{
    adc_struct ADC;
    adc_struct *HwMon = &ADC;

    adc_setup(
                HwMon,
                AD5324,
                SPI0,
                7, // nCS
                5, // SCK
                6  // MOSI
             );
    
    // Sawtooth function
    while (1)
    {
        uint16_t i;

        for (i=0; i<4095; i++)
        {
            adc_write(HwMon, ADC_OUT_A, i);
            adc_write(HwMon, ADC_OUT_B, i);
            adc_write(HwMon, ADC_OUT_C, i);
            adc_write(HwMon, ADC_OUT_D, i);
        }

        for (i=4095; i>0; i--)
        {
            adc_write(HwMon, ADC_OUT_A, i);
            adc_write(HwMon, ADC_OUT_B, i);
            adc_write(HwMon, ADC_OUT_C, i);
            adc_write(HwMon, ADC_OUT_D, i);
        }
    }

    return 0;
}