feat: 添加GD32E508 DCU应用工程的初始结构
- 新增完整的CMSIS解决方案配置,包含AC6/GCC/IAR/CLANG编译器支持 - 添加项目配置文件,定义了设备层、系统层、应用层的模块结构 - 配置ARM::CMSIS和GigaDevice::GD32E50x_DFP软件包依赖 - 创建多层代码架构:应用入口(main)、系统层(sys)、设备层(device) - 实现任务管理系统,包含任务调度器和任务执行器分离设计 - 集成ADC、CANFD、定时器、串口、温度采样等核心功能模块 - 添加详细的README文档说明项目结构和代码组织方式 - 配置AC6链接脚本和运行时环境文件 - 设置Git忽略规则以排除编译产物和临时文件
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef DEVICE_ADC_H
|
||||
#define DEVICE_ADC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief ADC 采样模块。
|
||||
* @note 负责 VIN_ADC、内部温度与内部参考电压的 DMA 扫描采样与工程值换算。
|
||||
*/
|
||||
class Adc {
|
||||
public:
|
||||
/**
|
||||
* @brief ADC 采样结果结构体。
|
||||
* @note 保存外部 VIN_ADC、内部温度与内部参考电压的原始值,以及可直接使用的工程值。
|
||||
*/
|
||||
struct Sample {
|
||||
uint16_t vin_raw; /**< @brief 外部 VIN_ADC(PA6)原始 ADC 数值。 */
|
||||
uint16_t temp_raw; /**< @brief 内部温度通道原始 ADC 数值。 */
|
||||
uint16_t vref_raw; /**< @brief 内部参考电压通道原始 ADC 数值。 */
|
||||
float vin_adc_v; /**< @brief VIN_ADC 引脚处电压,单位 V(仅为分压后的 ADC 端电压)。 */
|
||||
float vdda; /**< @brief 根据内部参考电压换算得到的 MCU 供电电压,单位 V。 */
|
||||
float temperature; /**< @brief 根据温度通道换算得到的芯片温度,单位 ℃。 */
|
||||
};
|
||||
|
||||
static void init();
|
||||
static bool dmaReady();
|
||||
static const uint16_t *dmaBuffer();
|
||||
static uint16_t readRaw(uint8_t channel);
|
||||
static uint16_t readVinRaw();
|
||||
static uint16_t readVrefRaw();
|
||||
static uint16_t readTempRaw();
|
||||
static float calculateVinAdcVoltage(uint16_t vinRaw, float vdda);
|
||||
static float calculateVdda(uint16_t vrefRaw);
|
||||
static float calculateTemperature(uint16_t tempRaw, float vdda);
|
||||
static void collectSample(Sample *sample);
|
||||
|
||||
private:
|
||||
static void initDma();
|
||||
};
|
||||
|
||||
using adc_sample_t = Adc::Sample;
|
||||
|
||||
#endif /* DEVICE_ADC_H */
|
||||
Reference in New Issue
Block a user