refactor(build): 更新项目配置和链接器设置 - 修改GD32C103CB的ROM基地址和大小配置 - 更新系统时钟向量表偏移量设置 - 在cproject.yml中添加BIN输出格式支持 - 增加-O3优化级别和代码移除选项 - 更新csolution版本依赖 feat(device): 优化ADC采样和配置管理 - 将DengFOC依赖替换为FOC模块 - 从config.h引入配置常量 - 重命名FILTER_SIZE为ADC_FILTER_SIZE以提高清晰度 - 优化温度和电流采样滤波实现 refactor(algorithm): 简化FOC控制函数接口 - 为angle_control、velocity_control等函数移除不必要的参数 - 统一函数指针类型定义 - 优化电流计算函数的代码格式 - 调整PID控制器初始化参数
40 lines
796 B
C++
40 lines
796 B
C++
#ifndef _angsensor_H
|
|
#define _angsensor_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#include "gd32c10x_eval.h"
|
|
#include "stdio.h"
|
|
#include "config.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:
|
|
u8 init(void);
|
|
float read_sensorAngle(void);
|
|
float update(void);
|
|
void reset(void);
|
|
float getAngle(void) const;
|
|
float getRawAngle(void) const;
|
|
float getcurrent_sensorangle(void) const;
|
|
u8 angle_set(float angle);
|
|
|
|
protected:
|
|
float m_cumulativeAngle;
|
|
float current_angle_deg;
|
|
float current_angle_rad;
|
|
bool m_firstUpdate;
|
|
float m_lastAngle;
|
|
float m_lastcumulativeAngle;
|
|
float velocity[VEL_FILTER_SIZE] = {0.0f};
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif |