将 `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` 的重复包含, 并将角度传感器和采样器通过类实例方式初始化。
27 lines
449 B
C++
27 lines
449 B
C++
#ifndef _angsensor_H
|
|
#define _angsensor_H
|
|
#include <cstdio>
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#include "gd32c10x_eval.h"
|
|
#include "stdio.h"
|
|
|
|
u16 spi_rw_half_word(u32 spi_periph, const u16 i_HalfWord);
|
|
int spi_rw_half_word_dma(uint32_t spi_periph, uint16_t tx_data,
|
|
uint16_t *rx_data);
|
|
|
|
class angle_sensor {
|
|
public:
|
|
angle_sensor();
|
|
float readAngle(void);
|
|
|
|
protected:
|
|
void KTH7823_init(void);
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif |