refactor(FOC): 添加Doxygen文档注释并优化SVPWM算法性能
添加了完整的Doxygen文档注释到FOC算法模块的所有函数、类和变量,提升了代码可读性和维护性。同时优化了SVPWM算法实现,将atan2f替换为符号法扇区判断,显著提升计算效率(约15周期vs atan2f 300周期),并改进了arm_sin_cos_f32替代sqrtf提高性能。 feat(FOC): 统一电气角度计算避免重复运算 重构代码以统一电气角度计算,在各个控制循环中只计算一次电气角度并传递给需要的函数,避免了多次重复的fmodf运算和角度归一化操作,提升了实时控制性能。 refactor(Filter): 改进α-β观测器角度处理精度 修改角度卡尔曼滤波器在归一化角度空间[0,360)内工作,避免大累积角度的浮点精度损失问题,确保静止状态下不会产生虚假速度,同时保持与下游代码的兼容性。 refactor: 为算法模块添加完整文档注释 为所有算法模块(FOC、Filter、pid、thermal)添加了详细的Doxygen文档注释,包括函数说明、参数描述、返回值说明等,便于代码理解和API文档生成。
This commit is contained in:
@@ -34,12 +34,17 @@ OF SUCH DAMAGE.
|
||||
|
||||
#include "gd32c10x_ctc.h"
|
||||
|
||||
/** @brief CTC_FLAG_MASK 宏定义 */
|
||||
#define CTC_FLAG_MASK ((uint32_t)0x00000700U)
|
||||
|
||||
/* CTC register bit offset */
|
||||
/** @brief CTC_TRIMVALUE_OFFSET 宏定义 */
|
||||
#define CTC_TRIMVALUE_OFFSET ((uint32_t)8U)
|
||||
/** @brief CTC_TRIM_VALUE_OFFSET 宏定义 */
|
||||
#define CTC_TRIM_VALUE_OFFSET ((uint32_t)8U)
|
||||
/** @brief CTC_REFCAP_OFFSET 宏定义 */
|
||||
#define CTC_REFCAP_OFFSET ((uint32_t)16U)
|
||||
/** @brief CTC_LIMIT_VALUE_OFFSET 宏定义 */
|
||||
#define CTC_LIMIT_VALUE_OFFSET ((uint32_t)16U)
|
||||
|
||||
/*!
|
||||
@@ -163,6 +168,11 @@ void ctc_refsource_signal_select(uint32_t refs)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
/**
|
||||
* @brief ctc_refsource_prescaler_config 函数
|
||||
* @param[in] prescaler 参数
|
||||
* @return void
|
||||
*/
|
||||
void ctc_refsource_prescaler_config(uint32_t prescaler)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_REFPSC);
|
||||
@@ -300,6 +310,11 @@ void ctc_interrupt_disable(uint32_t interrupt)
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
/**
|
||||
* @brief ctc_interrupt_flag_get 函数
|
||||
* @param[in] interrupt 参数
|
||||
* @return FlagStatus 返回值
|
||||
*/
|
||||
FlagStatus ctc_interrupt_flag_get(uint32_t interrupt)
|
||||
{
|
||||
uint32_t intflag = 0U, intenable = 0U;
|
||||
@@ -337,6 +352,11 @@ FlagStatus ctc_interrupt_flag_get(uint32_t interrupt)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
/**
|
||||
* @brief ctc_interrupt_flag_clear 函数
|
||||
* @param[in] interrupt 参数
|
||||
* @return void
|
||||
*/
|
||||
void ctc_interrupt_flag_clear(uint32_t interrupt)
|
||||
{
|
||||
if(RESET != (interrupt & CTC_FLAG_MASK)){
|
||||
@@ -360,6 +380,11 @@ void ctc_interrupt_flag_clear(uint32_t interrupt)
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
/**
|
||||
* @brief ctc_flag_get 函数
|
||||
* @param[in] flag 参数
|
||||
* @return FlagStatus 返回值
|
||||
*/
|
||||
FlagStatus ctc_flag_get(uint32_t flag)
|
||||
{
|
||||
FlagStatus ret;
|
||||
@@ -386,6 +411,11 @@ FlagStatus ctc_flag_get(uint32_t flag)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
/**
|
||||
* @brief ctc_flag_clear 函数
|
||||
* @param[in] flag 参数
|
||||
* @return void
|
||||
*/
|
||||
void ctc_flag_clear(uint32_t flag)
|
||||
{
|
||||
if(RESET != (flag & CTC_FLAG_MASK)){
|
||||
|
||||
Reference in New Issue
Block a user