/** * @file device/adc.h * @brief 底层设备驱动与外设封装源文件 * @note 本文件仅补充 Doxygen 文档注释,不改变代码逻辑。 */ #ifndef _ADC_H #define _ADC_H #ifdef __cplusplus extern "C" { #endif #include "config.h" /** * @brief sampler 类或结构体 */ 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; u8 temp_vbus_head; // 环形缓冲区 head u8 mcu_temp_head; u8 drv_temp_head; float tempora_sample; float cached_mcu_temp; // getter 缓存 float cached_drv_temp; float cached_vbus; public: /** * @brief 初始化对象或模块 * @return u8 返回值 */ u8 init(void); /** * @brief 更新 mcu_temp 相关状态 * @return void */ void update_mcu_temp(void); /** * @brief 更新 drv_temp 相关状态 * @return void */ void update_drv_temp(void); /** * @brief 更新 vbus_voltage 相关状态 * @return void */ void update_vbus_voltage(void); /** * @brief 更新 current 相关状态 * @return void */ void update_current(void); /** * @brief 获取 get_mcu_temp 对应的数据或状态 * @return float 返回值 */ float get_mcu_temp(void); /** * @brief 获取 get_drv_temp 对应的数据或状态 * @return float 返回值 */ float get_drv_temp(void); /** * @brief 获取 get_vbus_voltage 对应的数据或状态 * @return float 返回值 */ float get_vbus_voltage(void); /** * @brief 获取 get_current 对应的数据或状态 * @param[in] char 参数 * @return float 返回值 */ float get_current(char); }; /** * @brief ADC0_1_IRQHandler 中断处理函数 * @return void */ void ADC0_1_IRQHandler(void); #ifdef __cplusplus } #endif #endif