uint16_t mic_read() { uint16_t level; //level = ADC1_GetBufferValue(0x00); level = ADC1_GetBufferValue(0x01); return level; }
INTERRUPT void ADC1_IRQHandler(void) { #endif //GPIO_WriteHigh(LED1_PORT, LED1_PIN); ADC1_ClearITPendingBit(ADC1_IT_EOC); //clear end of conversion flag, for one signal channel switch(adc_scan_times_flag){ case 0: ADC_Results[0] = ADC1_GetBufferValue(0); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_1);/* Select the ADC1 channel */ ADC1_StartConversion(); break; case 1: ADC_Results[1] = ADC1_GetBufferValue(1); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_2);/* Select the ADC1 channel */ ADC1_StartConversion(); break; case 2: ADC_Results[2] = ADC1_GetBufferValue(2); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_3);/* Select the ADC1 channel */ ADC1_StartConversion(); break; case 3: ADC_Results[3] = ADC1_GetBufferValue(3); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_4);/* Select the ADC1 channel */ ADC1_StartConversion(); break; case 4: ADC_Results[4] = ADC1_GetBufferValue(4); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_5);/* Select the ADC1 channel */ ADC1_StartConversion(); break; case 5: ADC_Results[0] = ADC1_GetBufferValue(0); ADC_Results[1] = ADC1_GetBufferValue(1); ADC_Results[2] = ADC1_GetBufferValue(2); ADC_Results[3] = ADC1_GetBufferValue(3); ADC_Results[4] = ADC1_GetBufferValue(4); ADC_Results[5] = ADC1_GetBufferValue(5); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_12);/* Select the ADC1 channel */ ADC1->CR2 &= (uint8_t)(~ADC1_CR2_SCAN); //ADC1_ScanMode DISABLE ADC1_StartConversion(); break; case 6: ADC_Results[6] = ADC1_GetConversionValue(); ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH); /* Clear the ADC1 channels */ ADC1->CSR |= (uint8_t)(ADC1_CHANNEL_0);/* Select the ADC1 channel */ ADC1->CR2 |= ADC1_CR2_SCAN; //ADC1_ScanMode ENABLE adc_scan_times_flag = 0; (*Intupt_ADC_Finish_ptr_fuc)(); break; default: break; } adc_scan_times_flag++; // if(adc_second_scan_flag == 0){ // ADC_Results[0] = ADC1_GetBufferValue(0); // ADC_Results[1] = ADC1_GetBufferValue(1); // ADC_Results[2] = ADC1_GetBufferValue(2); // ADC_Results[3] = ADC1_GetBufferValue(3); // //ADC1_ClearITPendingBit(ADC1_IT_EOC); //clear end of conversion flag, for one signal channel // // adc_second_scan_flag = 1; // adc_AIN12_channel_init(); // ADC1_StartConversion(); // //(*Intupt_ADC_Finish_ptr_fuc)(); // }else{ // //adc_second_scan_flag = 0; // ADC_Results[4] = ADC1_GetConversionValue(); // for AIN12 values // //ADC1_ClearITPendingBit(ADC1_IT_EOC); //clear end of conversion flag, for one signal channel // //adc_4_channel_scan_init(); // (*Intupt_ADC_Finish_ptr_fuc)(); // // } //GPIO_WriteLow(LED1_PORT, LED1_PIN); return; }