#ifndef ADC_CFG_H_ #define ADC_CFG_H_ #include "base/define.h" #define AN_UA_CH ADC_Channel_12 //AD2 #define AN_MAL_CH ADC_Channel_13 //AD2 #define RAD_01_CH ADC_Channel_2 //AD2 #define AN_CAP_AD_CH ADC_Channel_15 //AD2 #define VCC_2V5_CH ADC_Channel_1 //AD1 #define VCC_1V25_CH ADC_Channel_3 //AD1 #define V_LA_M_CH ADC_Channel_6 //AD1 #define V_LA_H_CH ADC_Channel_7 //AD1 #define AD_OUTA_CH ADC_Channel_10 //AD1 #define AD_OUTB_CH ADC_Channel_11 //AD1 #define ADC_CURR_DE ADC2 #define AD_SCAN_COUNT 16 #define AD_SCAN_SAMPLE 8 #define FIREBUS_ADC_BUF_LEN 160 extern volatile uint16_t FireBus_ADC_Buf[FIREBUS_ADC_BUF_LEN]; #define ADC_SPEED_SLOW ADC_SampleTime_239Cycles5 #define ADC_SPEED_MIDLE ADC_SampleTime_71Cycles5 #define ADC_SPEED_HIGH ADC_SampleTime_13Cycles5 #define ADC_SPEED_HFAST ADC_SampleTime_7Cycles5 void AdcDef_Init(void); void StartADC2Channel(uint32_t channel, uint32_t speed); #define ADC_CurChnnelSet(channel,speed) StartADC2Channel(channel,speed) //桥丝电阻测量通道 #define ADC_ResistorChannelSet(speed) StartADC2Channel(RAD_01_CH,speed); //电容电压测量 #define ADC_CAPVolChannelSet(speed) StartADC2Channel(AN_CAP_AD_CH,speed); void StartADC1Channel(uint32_t channel); void StartADC2ChannelV2(uint32_t channel); uint32_t GetADC2_Fast(void); //电流采集通道 #define ADC_GetCurADCFast() GetADC2_Fast() //桥丝电阻采集通道 #define ADC_GetResistorADCFast() GetADC2_Fast() //电容电压采集通道 #define ADC_GetCAPVolADCFast() GetADC2_Fast() uint32_t GetADC1_Fast(void); uint32_t GetADC2_Value(uint32_t channel); #define ADC_GetCurADC(chnnel) GetADC2_Value(channel) void GetADC1_Value(uint32_t channel,uint16_t* buf,uint16_t len); float Get_Temperature(void); /* @brief 稳定获取总线电流 @rtv 返回电流值 0.1uA */ uint16_t ADC_Comm1p6mA_EndCur(void); /* @brief 稳定获取总线电流 */ uint16_t ADC_GetBaseStableCur(void); /* @brief 电流降到指定电流下的时间 @param 采样超时 @param end_adv 检测启动和结束判线 @param 最大电流ad @param 电流下降过程中最大向上波动 @rtv 时间采集值0.1ms */ uint16_t AD_GetChgEnergy(uint16_t sample_timeout, uint16_t end_adv,uint16_t* max_cul,uint16_t *shake_adv); /* @brief 电流降到指定电流下的时间 @param 执行时间 单位0.1ms @rtv 最大波动AD值 */ uint16_t AD_CurMonitor(uint32_t us_times); /* 使用该函数,对ADC触发一次采样,到用该函数前,应调用一次StartADC0Channel(ch) */ uint16_t GetADC_Fast(ADC_TypeDef* adc_periph); /*获取桥丝电阻*/ void AD_SampleResistor(uint16_t* channels_re); /*测量电容电压*/ uint16_t AD_SampleCap(uint16_t delay); #endif