Files
Motor_v2/Robot_V2/device/adc.h
T
cbb 0c5ab9c1d8 feat(ADC): 重构采样器初始化为构造函数
将 `sampler::init()` 方法改为构造函数 `sampler()`,并在其中完成 DMA 和 ADC 的初始化配置,
同时进行初始采样操作。

feat(CAN): 更新角度传感器类接口并修复拼写错误
将全局函数 `KHT7823_readAngle()` 替换为 `angle_sensor::readAngle()` 类成员函数调用,
统一命名风格并修正部分函数名中的拼写错误(如 KHT7823 -> KTH7823)。

refactor(Can): 移除冗余的 timeout 成员变量
在 `CAN_transmiter` 类中移除了未使用的 `timeout` 成员变量,减少资源占用。

refactor(Timer): 删除重复注释内容
清理 `Timer.cpp` 中关于定时器配置的重复注释信息,保留核心常量定义。

refactor(ADC): 修正头文件中函数声明
将 `adc.h` 中的 `init()` 函数声明更新为构造函数 `sampler()`,保持实现与声明一致。

refactor(ang_sensor): 将角度传感器相关功能封装为类
将原先分散的 C 风格函数封装进 `angle_sensor` 类中,提升代码结构清晰度和可维护性。
添加构造函数和读取角度的方法,并修正原有函数命名不一致问题。

refactor(main): 调整初始化顺序并移除多余包含
修改 `main.cpp` 中外设初始化顺序,移除对 `core_cm4.h` 的重复包含,
并将角度传感器和采样器通过类实例方式初始化。
2025-11-01 23:41:32 +08:00

39 lines
705 B
C++

#ifndef _ADC_H
#define _ADC_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stdint.h"
constexpr u8 FILTER_SIZE = 6;
class sampler {
private:
float vbus_samples[FILTER_SIZE + 1];
float currU_samples[FILTER_SIZE + 1];
float currV_samples[FILTER_SIZE + 1];
float currW_samples[FILTER_SIZE + 1];
float mcu_temp_samples[FILTER_SIZE + 1];
float drv_temp_samples[FILTER_SIZE + 1];
float tempora_sample;
public:
sampler();
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);
};
#ifdef __cplusplus
}
#endif
#endif