这篇教程C++ ADC_Init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ADC_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ ADC_Init函数的具体用法?C++ ADC_Init怎么用?C++ ADC_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ADC_Init函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(void) { // b. Umleiten der Standardausgabe stdout (Teil 2) //stdout = &mystdout; // Init everything // Init Touch & Potis DDRA = 0x00; // ADWandler-Pins auf Eingang schalten uint16_t ADC_val; ADC_Init(); // Init LED Matrix TLC5940_Init(); // Init SPI init_SPI(); // Init Timer timer_config(); TLC5940_SetAllDC(63); TLC5940_ClockInDC(); TLC5940_SetAllGS(0); // Init all 74hc595 init_74hc595(); // Init all 74hc165 init_74hc165(); // Enable Interrupts globally // TEMP TEMP TEMP DDRC |= 0b01000000; // Kalibriere Touchpanel calibrate(); sei(); // Init UART uart_init(); while (1) { static uint8_t current_potentiometer = 0; // POTENTIOMETER auslesen { /* switch( current_potentiometer ) { // case 1: // PORTC &= ~0b01000000; // break; case 2: PORTC |= 0b01000000; break; } */ // erstes Auslesen immer Fehlerhaft wegen Touchpanel evtl // zweiter Wert beinhaltet richtiges Ergebniss! // POTI_ADC_SAMPLES sollte daher 2 sein damit nach dem zweiten lesen in ADC_val das richtige ergebniss steht ADC_val = 0; for ( uint8_t count = 0 ; count < POTI_ADC_SAMPLES ; count++ ) ADC_val = ADC_Read(potentiometer[current_potentiometer].adc_channel); if( ADC_val > ( potentiometer[current_potentiometer].value + ADC_delta_for_change_poti ) || ( ADC_val < ( potentiometer[current_potentiometer].value - ADC_delta_for_change_poti ) ) ) // +- 8 von 1024 Quantisierungsstufen / 128 Midi Schritte . // if( ADC_val > ( potentiometer[current_potentiometer].value + 10 ) || ( ADC_val < ( potentiometer[current_potentiometer].value - 10 ) ) ) { potentiometer[current_potentiometer].value = ADC_val; controlChange(midi_channel, midi_poti_offset + current_potentiometer,ADC_val/8); //printf("%i. Poti %i/n", current_potentiometer , potentiometer[current_potentiometer].value ); } current_potentiometer++; if ( current_potentiometer == potentiometer_count) current_potentiometer = 0; } //Display_SetCross(4,2); // TOUCHPANEL auslesen read_touchscreen(); if(touchscreen.FLAG_Display_change) { TLC5940_SetAllGS(0); //Display_SetParabel(touchscreen.last_x , touchscreen.last_y ); Display_SetCross(touchscreen.last_LED_x,touchscreen.last_LED_y); touchscreen.FLAG_Display_change = 0; } } }
开发者ID:Brostrix,项目名称:avr_midi_controler,代码行数:100,
示例2: ADC_DMA_Configvoid ADC_DMA_Config(void){ ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; DMA_InitTypeDef DMA_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable ADC3, DMA2 and GPIO clocks ****************************************/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOF, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE); /* DMA2 Stream0 channel0 configuration **************************************/ DMA_InitStructure.DMA_Channel = DMA_Channel_2; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC3->DR; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADCConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 4;//-------------- DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//---------------- DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_Low; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); DMA_Cmd(DMA2_Stream0, ENABLE); /* Configure ADC3 Channel12 pin as analog input ******************************/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;//------------- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOF, &GPIO_InitStructure); /* ADC Common Init **********************************************************/ ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles; ADC_CommonInit(&ADC_CommonInitStructure); /* ADC3 Init ****************************************************************/ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ScanConvMode = ENABLE;//------------------ ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfConversion = 4; ADC_Init(ADC3, &ADC_InitStructure); /* ADC3 regular channel12 configuration *************************************/ ADC_RegularChannelConfig(ADC3, ADC_Channel_5, 1, ADC_SampleTime_3Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_6, 2, ADC_SampleTime_3Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 3, ADC_SampleTime_3Cycles); ADC_RegularChannelConfig(ADC3, ADC_Channel_8, 4, ADC_SampleTime_3Cycles); /* Enable DMA request after last transfer (Single-ADC mode) */ ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE); /* Enable ADC3 DMA */ ADC_DMACmd(ADC3, ENABLE); /* Enable ADC3 */ ADC_Cmd(ADC3, ENABLE);}
开发者ID:glocklueng,项目名称:open-stm32f407ig-board,代码行数:74,
示例3: Init_Taskvoid Init_Task(uint32_t task_init_data){ int tester=0; //uint_8 sys=0; bool bInitOpen=FALSE; bool bInitStill=FALSE; bool bInitVLPS=FALSE; MQX_TICK_STRUCT ttt; _mqx_uint mqx_ret; trace_init(); show_version_information(); //////////////zga add //Set LPTMR to timeout about 5 seconds Lptmr_Init(1000, LPOCLK); ADC_Init(); Calibrate_ADC(); ADC_Init(); DMA1_Init(); //////////////zga add // clear flag APP_TRACE("start 1/n/r"); _task_create_at(0, SHELL_TASK, 0, shell_task_stack, SHELL_TASK_STACK_SIZE); _task_create_at(0, MMA8415_TASK, 0, mma8451_task_stack, MMA8451_TASK_STACK_SIZE); Lptmr_Start(); for(;;) { mqx_ret = _lwsem_wait(&g_lptmr_int_sem); // _time_delay_ticks(10); tester++;//_time_delay_ticks(10); //APP_TRACE("tester is: %d/r/n",tester); _time_get_elapsed_ticks(&ttt); APP_TRACE("high ttt %d, low ttt%d/r/n", ttt.TICKS[1],ttt.TICKS[0]); if(Measured) { Measured=0; APP_TRACE ("light: %d ,%d /r/n", (uint16_t) MeasuredValues[1],tester); } if((GetTouchON()==TRUE)) { SetSysStatus(ACTIVE_OPEN); } // for test SetSysStatus(ACTIVE_OPEN); switch (sysStatus) { case ACTIVE_OPEN: bInitStill=FALSE; bInitVLPS=FALSE; APP_TRACE ("ACTIVE_OPEN/r/n"); if(bInitOpen==FALSE) { bInitOpen=TRUE; putmma8451running(); SysTick_PDD_EnableDevice(SysTick_BASE_PTR, PDD_ENABLE); } break; case ACTIVE_STILL: bInitOpen=FALSE; bInitVLPS=FALSE; APP_TRACE ("ACTIVE_still/r/n"); if(bInitStill==FALSE) { bInitStill=TRUE; putmma8451detect(); } enter_vlps(); case VLPSMODE: bInitOpen=FALSE; bInitStill=FALSE; APP_TRACE ("vlpsmode/r/n"); if(bInitVLPS==FALSE) { bInitVLPS=TRUE; putmma8451standby(); } enter_vlps(); default: break; } } }
开发者ID:ethan-jiang-1,项目名称:hello_starfish,代码行数:93,
示例4: mainvoid main(){ delay1s(); AUXR = AUXR|0x40; // T1, 1T Mode// IE2 |= ESPI; EXTI0_Init(); //4432的中断设置 UART_Init(); //波特率9600 SPI_Init(MASTER); delay1s(); SI4432_Init(); SI4432_SetRxMode(); //接收模式 ADC_Init(AFPORT_P1_4); delay1s();#if MULTI_SENSOR SendString("ROMID Search.../r/n"); SendROMID(DS18B20_SearchRomID()); SendString("/r/n"); //调试信息时候用#endif //----------------------------------------------------- EA = 1; //注意:外设初始化完再开中断! while(1) { if(Trans_RevPakFin) { Trans_RevPakFin = 0; //液位采集计算 ADC_STARTCOV(ADC_CH4,ADC_SPEED_540T); while(!(g_sensor_sta1&PRS_RDY)); //等待压力采集完成 //温度采集计算// TemperDatHandle(); //液位开关采集 sensor_data.possw = POSSW; //流量开关采集 // sensor_data.flow = FLOW; //打包 if(1==Pak_Handle()) { g_sensor_sta1 = 0; //清除所有传感器标志位 LED2 = 0; SendString("valid cmd received./r/n"); delay200ms(); LED2 = 1; } } //********************code for test**************************************// DATA_Cmd_ACK();// LED2 = 0;// SendString("valid cmd received./r/n"); // delay200ms();// LED2 = 1;// ADC_STARTCOV(ADC_CH4,ADC_SPEED_540T);// while(!(g_sensor_sta1&PRS_RDY)); //等待压力采集完成// sprintf("level: %d:/r/n",);// SendString("level: %s:/r/n"); // sensor_data.flow = FLOW;// SendString("flow data:/r/n"); // SendByteASCII(sensor_data.flow);// SendString("/r/n"); // delay1s();// delay1s(); //********************end of code for test************************************** }//end of while}//end of main
开发者ID:dammstanger,项目名称:AutoPump_SlaverV1.0,代码行数:67,
示例5: adcInitvoid adcInit(drv_adc_config_t *init){ ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; DMA_InitTypeDef DMA_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; bool multiChannel = init->powerAdcChannel > 0; /* Enable ADC1, DMA2 clocks *************************************************/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); /* DMA2 Stream0 channel0 configuration **************************************/ DMA_DeInit(DMA2_Stream0); DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adcValues; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = multiChannel ? 2 : 1; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); DMA_Cmd(DMA2_Stream0, ENABLE); /* Configure ADC3 Channel12 pin as analog input ******************************/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOC, &GPIO_InitStructure); /* ADC Common Init **********************************************************/ ADC_DeInit(); ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles; ADC_CommonInit(&ADC_CommonInitStructure); /* ADC1 Init ****************************************************************/ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ScanConvMode = multiChannel ? ENABLE : DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_ExternalTrigConv = 0; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfConversion = multiChannel ? 2 : 1; ADC_Init(ADC1, &ADC_InitStructure); /* Enable ADC1 DMA */ //ADC_DMACmd(ADC1, ENABLE); ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_28Cycles); if (multiChannel) ADC_RegularChannelConfig(ADC1, init->powerAdcChannel, 2, ADC_SampleTime_28Cycles); ADC_DMACmd(ADC1, ENABLE); ADC_Cmd(ADC1, ENABLE); // Calibrate ADC //ADC_ResetCalibration(ADC1); //while(ADC_GetResetCalibrationStatus(ADC1)); // ADC_StartCalibration(ADC1); // while(ADC_GetCalibrationStatus(ADC1)); // Fire off ADC ADC_SoftwareStartConv(ADC1);}
开发者ID:Linjieqiang,项目名称:Nev_MultirotorControl,代码行数:75,
示例6: mainint main(void){char temp, i;LCD_Initialize();DDRB = 0b00000000;PORTB = 0b00001111;DDRA = 0xFF;ADC_Init();int value = 0;int calculations = 0; char dzialanie = 0; int digit = 0; do{ int digit = getADC(0); char sw0 = PINB & 0b00000001; char sw1 = PINB & 0b00000010; if(sw0 != 0b00000001) { state++; _delay_ms(300); } char str[15]; sprintf(str, "%15d", lastValue); LCD_GoTo(1,0); LCD_WriteText(str); switch(state){ case 0: if(sw1 != 0b00000010){ setNewValue(mappingLogToLinear(digit, digitMap, 10)); _delay_ms(300); } sprintf(str, "%15d", mappingLogToLinear(digit, digitMap,10)); LCD_GoTo(1,1); LCD_WriteText(str); break; case 1: if(sw1 != 0b00000010){ setSign(mappingLogToLinear(digit, signMap, 2)); power = 0; _delay_ms(300); } switch(mappingLogToLinear(digit, signMap,2)){ case 0: LCD_GoTo(1,1); LCD_WriteText("-"); break; case 1: LCD_GoTo(1,1); LCD_WriteText("+"); break; } break; case 2: if(sw1 != 0b00000010){ doCalculations(mappingLogToLinear(digit, expressionMap, 4)); power = 0; newValue=0; state = 0; _delay_ms(300); } switch(mappingLogToLinear(digit, expressionMap,4)){ case 0: LCD_GoTo(1,1); LCD_WriteText("+"); break; case 1: LCD_GoTo(1,1); LCD_WriteText("-"); break; case 2: LCD_GoTo(1,1); LCD_WriteText("*"); break; case 3: LCD_GoTo(1,1); LCD_WriteText("/"); break; } break; }/* char sw0 = PINB & 0b00000001;//.........这里部分代码省略.........
开发者ID:Roen00,项目名称:calculator-micro-controller,代码行数:101,
示例7: hal_adc_openint hal_adc_open(HAL_ADC_HANDLE *handle, void *params){ ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; DMA_InitTypeDef DMA_InitStructure; UNUSED(params); /* DMA2_Stream0 channel0 configuration **************************************/ DMA_DeInit(DMA2_Stream0); DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)convertedValues; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 1; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); /* DMA2_Stream0 enable */ DMA_Cmd(DMA2_Stream0, ENABLE); /* ADC Common Init **********************************************************/ ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles; ADC_CommonInit(&ADC_CommonInitStructure); /* ADC1 Init ****************************************************************/ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfConversion = 1; ADC_Init(ADC1, &ADC_InitStructure); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* ADC1 regular channel18 (VBAT) configuration ******************************/ ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_480Cycles); /* Enable DMA request after last transfer (Single-ADC mode) */ ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE); /* Enable ADC1 **************************************************************/ ADC_Cmd(ADC1, ENABLE); ADC_SoftwareStartConv(ADC1); *handle = (void *)convertedValues; return HAL_ADC_E_SUCCESS;}
开发者ID:BGCX261,项目名称:zhonx2-git,代码行数:63,
示例8: main/******************************************************************************** Function Name : main* Description : Main program* Input : None* Output : None* Return : None*******************************************************************************/int main(void){ /* define local values */ u16 DataValue = 0x0; u16 Keta = 0; u16 cnt = 0; // counter u32 wcnt = 0; // counter for wait u16 Temperature = 0 ; u8 a, b, c, d;#ifdef DEBUG debug();#endif /* System Clocks Configuration */ RCC_Configuration(); /* NVIC configuration */ NVIC_Configuration(); /* Configure the GPIO ports */ GPIO_Configuration(); // ADC用のGPIOの C++ ADC_RegularChannelConfig函数代码示例 C++ ADC_GetResetCalibrationStatus函数代码示例
|