ADC就是模数转换
发现PB0引脚可复用成ADC_IN8
//adc.h
#ifndef __ADC_H
#define __ADC_H
#include "stm32f10x.h"
void ADC1_Init(void);
u16 Get_adc(u8 channel);
#endif
//adc.c
#include "adc.h"
void ADC1_Init(void)
{
ADC_InitTypeDef ADC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1|RCC_APB2Periph_GPIOB, ENABLE);
// 允许GPIOB和ADC1时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; // PB0-IN8
GPIO_In