STM32F302的ADC采集芯片破解
- 芯片破解void ADC2_init(void)
- {
-         GPIO_InitTypeDef          GPIO_InitStructure;
-         ADC_InitTypeDef           ADC_InitStructure;
-         ADC_CommonInitTypeDef     ADC_CommonInitStructure;
-         
-         RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2);
-   /* Enable ADC12 clock */
-   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);
-   /* ADC Channel configuration */
-   /* GPIOC Periph clock enable */
-   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC|RCC_AHBPeriph_GPIOA, ENABLE);
-   /* Configure ADC Channel5 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);
-         
-   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
-   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
-   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
-   GPIO_Init(GPIOA, &GPIO_InitStructure);
-   ADC_StructInit(&ADC_InitStructure);
-   /* Calibration procedure */  
-   ADC_VoltageRegulatorCmd(ADC2, ENABLE);
-   ADC_SelectCalibrationMode(ADC2, ADC_CalibrationMode_Single);
-   ADC_StartCalibration(ADC2);
-   while(ADC_GetCalibrationStatus(ADC2) != RESET );
-   calibration_value = ADC_GetCalibrationValue(ADC2);
-   ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;                                                                    
-   ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;                    
-   ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;            
-   ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;                  
-   ADC_CommonInitStructure.ADC_TwoSamplingDelay = 0;         
-   ADC_CommonInit(ADC2, &ADC_CommonInitStructure);
-   ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable;
-   ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
-   //ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;         
-   ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;
-   ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
-   ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;   
-   ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Enable;  //自动注入使能
-   ADC_InitStructure.ADC_NbrOfRegChannel = 1;
-   ADC_Init(ADC2, &ADC_InitStructure);
-   /* Enable ADC2 */
-   ADC_Cmd(ADC2, ENABLE);
- }
 
  
 
  芯片解密
  芯片解密
