- 将ADC缓冲区从6通道减少到3通道,专门用于MCU温度、DRV温度和VBUS监测 - 实现了注入组ADC同步采样,通过TIMER1 TRGO触发三相电流同时采样 - 添加了PWM中心对齐模式以提供更好的采样窗口 - 在FOC控制器中增加了ADC错误检查和三相公共模偏置消除 - 优化了电流采样更新机制,使用中断驱动的数据搬运 - 调整了ADC通道配置,规则组用于后台温度/VBUS采样,注入组用于PWM同步电流采样
42 lines
736 B
C++
42 lines
736 B
C++
#ifndef _ADC_H
|
|
#define _ADC_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "config.h"
|
|
|
|
class sampler {
|
|
private:
|
|
float vbus_samples[ADC_FILTER_SIZE];
|
|
float currU_samples[ADC_FILTER_SIZE];
|
|
float currV_samples[ADC_FILTER_SIZE];
|
|
float currW_samples[ADC_FILTER_SIZE];
|
|
float mcu_temp_samples[ADC_FILTER_SIZE];
|
|
float drv_temp_samples[ADC_FILTER_SIZE];
|
|
u8 current_sample_head;
|
|
|
|
float tempora_sample;
|
|
|
|
public:
|
|
u8 init(void);
|
|
void update_mcu_temp(void);
|
|
void update_drv_temp(void);
|
|
void update_vbus_voltage(void);
|
|
void update_current(void);
|
|
|
|
float get_mcu_temp(void);
|
|
float get_drv_temp(void);
|
|
float get_vbus_voltage(void);
|
|
float get_current(char);
|
|
};
|
|
|
|
void ADC0_1_IRQHandler(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|