void init_adc1(void)
{
ADC_InitTypeDef ADC_InitStructure;
GPIO_InitStructure.GPIO_Pin = /*GPIO_Pin_4|*/GPIO_Pin_5 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOC, &GPIO_InitStructure);
// RCC_ADCCLKConfig(RCC_PCLK2_Div2);
ADC_DeInit(ADC1);
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 2; //
ADC_Init(ADC1, &ADC_InitStructure);
adc_channel_config();
ADC_DMACmd(ADC1,ENABLE);
ADC_Cmd(ADC1, ENABLE);
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
}
void ADC1_DMAConfig(void){
DMA_InitTypeDef DMA_InitStructure;
DMA_Cmd(DMA1_Channel1,DISABLE);
DMA_DeInit ( DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)0x4001244C; // ADC->DR Adresi
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) ADC_ValArray; // hedef adresimiz
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; // ADC kaynak. Veri y�n� ADC -> Haf?za
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; // ADC adresi sabit kalacak
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; // Her de?er al?nd???na memory adresi 1 art?r?lacak
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; // Kaynaktan al?nacak veri 16 bit
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // Hedef b�y�kl�?� 16 bit
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //veri al?nd?ktan sonra ba?a d�n�lecek.
DMA_InitStructure.DMA_Priority = DMA_Priority_High ; // Kanal �nceli?i y�ksek. ( bu bize kalm??)
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; // haf?zadan haf?zaya transfer kapal?.
DMA_InitStructure.DMA_BufferSize = 100; //
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA1_Channel1,ENABLE);
}
if (GPIOB->IDR&GPIO_Pin_9) RAM[0]=0;else RAM[0]=1;
if(RAM[0]&&!RAM[20])ADC_ExternalTrigConvCmd(ADC1, ENABLE);
RAM[20]=RAM[0];