int main(void) { clock_setup(); gpio_setup(); tim_setup(); spi_setup(); dac_setup(); dma_setup(); usb_setup(); /* Attach the device to USB. */ syscfg_enable_usb_pullup(); /* Clear interrupt. */ usbdevfs_clear_interrupt(USBDEVFS_ALL_INTERRUPT); /* Enable interrupt. */ usbdevfs_enable_interrupt(USBDEVFS_CORRECT_TRANSFER | USBDEVFS_ERROR | USBDEVFS_RESET | USBDEVFS_SOF); /* Wait forever and do nothing. */ while (1) __asm__ ("nop"); return 0; }
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; }
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; }
void setup() { ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_FPULazyStackingEnable(); ROM_FPUEnable(); uart_setup(); sd_init(); dac_setup(); keycontrol_setup(); initConfig(); tick_setup(); soundoutcontrol_setup(); setupADC(); setupUSBStore(); initSampleBlocks(); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ROM_IntMasterEnable(); DEBUG_PRINT("Setup complete\n", NULL); }
int main (void) { sysclk_init(); board_init(); uart_config((uint32_t)UART_BAUDRATE); init_adc(); pwm_setup(); dac_setup(); start_coms(); //Run state machine }
/***************************************************************************//** * @brief main *******************************************************************************/ int main(void) { adf4350_setup(SPI_DEVICE_ID, 0, default_adf4350_init_param); dac_setup(XPAR_AXI_AD9739A_BASEADDR); ad9739a_setup(SPI_DEVICE_ID, 1, default_ad9739a_init_param); dac_write(ADI_REG_CNTRL_2, ADI_DATA_FORMAT); dds_set_frequency(0, 300000000); dds_set_phase(0, 0); dds_set_scale(0, 250000); dds_set_frequency(1, 300000000); dds_set_phase(1, 0); dds_set_scale(1, 250000); return 0; }
void init(FMSynth * synth) { /* // ---------- SysTick timer -------- // if (SysTick_Config(SystemCoreClock / 1000)) { // Capture error while (1){}; } */ // ---------- GPIO -------- // // GIPO Periph clock enable RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); leds_setup(); buttons_setup(); dac_setup(synth); midi::init(); adc::init(); }
int sound_start ( WAVFIFO* fcb, /* Pointer to the sound FIFO control structure */ DWORD fs /* Sampling frequency [Hz] */ ) { if (fs < 8000 || fs > 44100) return 0; /* Check fs range */ fcb->ri = 0; fcb->wi = 0; fcb->ct = 0; /* Flush FIFO */ WavFifo = fcb; /* Register FIFO control structure */ dac_setup(true); //Disable power reduction for TCC0 PR.PRPC &= ~0x01; TCC0.CNT = 0; TCC0.PER = (F_CPU / 44100 - 1); TCC0.CTRLA = TC_CLKSEL_DIV1_gc; TCC0.INTCTRLA = TC_OVFINTLVL_HI_gc; return 1; }
int main(void) { uint32_t msize; uint32_t rsize; #ifdef DAC_USE_VREF vref_setup(); #endif /* DAC_USE_VREF */ dac_setup(); dac_enable(); serial_setup(); msize = 0; while (1) { rsize = serial_get_rsize(); if (rsize > (sizeof(pload_msg) - msize)) rsize = sizeof(pload_msg) - msize; if (rsize == 0) continue ; /* stop the generator if active */ if (pload_flags & PLOAD_FLAG_IS_STARTED) { #if 0 /* DEBUG */ SERIAL_WRITE_STRING("stopping\r\n"); #endif /* DEBUG */ pload_flags &= ~PLOAD_FLAG_IS_STARTED; pit_stop(1); } serial_read((uint8_t*)&pload_msg + msize, rsize); msize += rsize; if (msize != sizeof(pload_msg)) continue ; /* new message */ msize = 0; if (pload_msg.op != PLOAD_MSG_OP_SET_STEPS) continue ; /* start the generator */ if ((pload_flags & PLOAD_FLAG_IS_STARTED) == 0) { #if 0 /* DEBUG */ SERIAL_WRITE_STRING("starting\r\n"); #endif /* DEBUG */ pload_step_index = 0; pload_tick_count = (uint32_t)pload_msg.u.steps.arg1[0]; pload_repeat_index = 0; pload_current = (int32_t)pload_msg.u.steps.arg0[0]; dac_set(ma_to_dac((uint32_t)pload_current)); #if 0 /* DEBUG */ SERIAL_WRITE_STRING("dac_set:"); serial_write(uint32_to_string((uint32_t)pload_current), 8); SERIAL_WRITE_STRING("\r\n"); #endif /* DEBUG */ pload_flags |= PLOAD_FLAG_IS_STARTED; pit_start(1, F_BUS / PLOAD_CLOCK_FREQ); } } return 0; }
int main (void) { clock_setup(); //setup the main clock for 168MHz usart_setup(); //setup usart1 for debug messages debug_send("\n\n\n*************************************\n"); debug_send("* Lynx test starting up *\n"); debug_send("* Waveforms *\n"); debug_send("* Joe Roberts *\n"); debug_send("* UROP - Summer 2013 *\n"); debug_send("*************************************\n\n\n"); debug_send("ledpins_setup()\n"); ledpins_setup(); //setup the status led's gpio's debug_send("dac_setup()\n"); dac_setup(); //setup the dac gpio's debug_send("transmit_timer_setup(1)\n"); transmit_timer_setup(1); //setup the transmit timer and its interrupt debug_send("Starting the transmission timer\n"); timer_enable_counter(TIM2); while(1) { usart_wait_recv_ready(USART2); timer_disable_counter(TIM2); timer_set_counter(TIM2, 0); char message = usart_recv_blocking(USART2); debug_send("\nRecieved "); usart_send_blocking(USART2, message); bool done = false; char param; while(!done) { debug_send(": Send your parameter [0-9]\n"); usart_wait_recv_ready(USART2); param = usart_recv_blocking(USART2); if((param>47)&&(param<58)) { done = true; param = param-48; //ASCII to number } else debug_send("\nParameter must be [0-9] - try again\n"); } if(message=='n') n = 1000*param; if(message=='t') { transmit_timer_setup(10*param); timer_enable_counter(TIM2); } if(message=='w') set_waveform(param); } debug_send("We somehow escaped the for ever loop\n"); debug_send("..This is a little sad, there's not much you can do to fix this\n\n\n\n"); debug_send("goodbye, cruel world"); while(1); return 1; }
void d_dac_setup(void) { dac_setup(); adc_setup(); }
/***************************************************************************//** * @brief main *******************************************************************************/ int main(void) { jesd204b_gt_state jesd204b_gt_st; jesd204b_state jesd204b_st; daq2_gpio_ctl(GPIO_BASEADDR); ad9523_setup(SPI_DEVICE_ID, 0, ad9523_pdata_lpc); ad9144_setup(SPI_DEVICE_ID, 1, default_ad9144_init_param); jesd204b_st.lanesync_enable = 1; jesd204b_st.scramble_enable = 1; jesd204b_st.sysref_always_enable = 0; jesd204b_st.frames_per_multiframe = 32; jesd204b_st.bytes_per_frame = 1; jesd204b_st.subclass = 1; jesd204b_setup(AD9144_JESD_BASEADDR, jesd204b_st); ad9680_setup(SPI_DEVICE_ID, 2); jesd204b_st.lanesync_enable = 1; jesd204b_st.scramble_enable = 1; jesd204b_st.sysref_always_enable = 0; jesd204b_st.frames_per_multiframe = 32; jesd204b_st.bytes_per_frame = 1; jesd204b_st.subclass = 1; jesd204b_setup(AD9680_JESD_BASEADDR, jesd204b_st); jesd204b_gt_st.use_cpll = 0; jesd204b_gt_st.rx_sys_clk_sel = 3; jesd204b_gt_st.rx_out_clk_sel = 4; jesd204b_gt_st.tx_sys_clk_sel = 3; jesd204b_gt_st.tx_out_clk_sel = 4; jesd204b_gt_setup(DAQ2_GT_BASEADDR, jesd204b_gt_st); jesd204b_gt_clk_enable(JESD204B_GT_TX); jesd204b_gt_clk_enable(JESD204B_GT_RX); jesd204b_gt_clk_synchronize(JESD204B_GT_TX); jesd204b_gt_clk_synchronize(JESD204B_GT_RX); dac_setup(AD9144_CORE_BASEADDR); dds_set_frequency(0, 5000000); dds_set_phase(0, 0); dds_set_scale(0, 500000); dds_set_frequency(1, 5000000); dds_set_phase(1, 0); dds_set_scale(1, 500000); dds_set_frequency(2, 5000000); dds_set_phase(2, 90000); dds_set_scale(2, 500000); dds_set_frequency(3, 5000000); dds_set_phase(3, 90000); dds_set_scale(3, 500000); adc_setup(AD9680_CORE_BASEADDR, AD9680_DMA_BASEADDR, 2); xil_printf("Done.\n\r"); return 0; }
void dc_electronic_load_setup() { setCurrentMilliamps = 0; readCurrentMilliamps = 0; readMilliVolts = 0; setRateIndex = 0; readCurrentMilliampsDisplay = DISPLAY_MILLI; gfxState = GFX_STATE_MEASURE; dma_ring_buffer_init(&g_debugUsartDmaInputRingBuffer, DEBUG_USART_RX_DMA_CH, g_debugUsartRxBuffer, DEBUG_USART_RX_BUFFER_SIZE); debug_setup(); debug_write_line("?BEGIN setup"); process_init(); process_start(&etimer_process, NULL); process_start(&debug_process, NULL); #ifdef DISP6800_ENABLE process_start(&gfx_update_process, NULL); process_poll(&gfx_update_process); #endif spi_setup(); #ifdef DISP6800_ENABLE disp6800_setup(); gfx_setup(); #endif #ifdef ENCODER_ENABLE encoder_setup(); #endif #ifdef FLASH_ENABLE flashsst25_setup(); #endif #ifdef MAC_ENABLE mac25aa02e48_setup(); mac25aa02e48_read_eui48(); #endif #ifdef ADC_ENABLE adc_setup(); #endif #ifdef DAC_ENABLE dac_setup(); dac_set(0); #endif #ifdef NETWORK_ENABLE network_setup(EUI48); #endif #ifdef FAN_ENABLE fan_setup(); #endif #ifdef BUTTONS_ENABLE buttons_setup(); #endif time_setup(); recorder_setup(); debug_write_line("?END setup"); }