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:
@@ -35,25 +35,45 @@ OF SUCH DAMAGE.
|
||||
#include "gd32c10x_fmc.h"
|
||||
|
||||
/* FMC mask */
|
||||
/** @brief LOW_8BITS_MASK 宏定义 */
|
||||
#define LOW_8BITS_MASK ((uint32_t)0x000000FFU)
|
||||
/** @brief HIGH_8BITS_MASK 宏定义 */
|
||||
#define HIGH_8BITS_MASK ((uint32_t)0x0000FF00U)
|
||||
/** @brief LOW_8BITS_MASK1 宏定义 */
|
||||
#define LOW_8BITS_MASK1 ((uint32_t)0x00FF0000U)
|
||||
/** @brief HIGH_8BITS_MASK1 宏定义 */
|
||||
#define HIGH_8BITS_MASK1 ((uint32_t)0xFF000000U)
|
||||
/** @brief LOW_16BITS_MASK 宏定义 */
|
||||
#define LOW_16BITS_MASK ((uint32_t)0x0000FFFFU)
|
||||
/** @brief HIGH_16BITS_MASK 宏定义 */
|
||||
#define HIGH_16BITS_MASK ((uint32_t)0xFFFF0000U)
|
||||
|
||||
/* USER of option bytes mask */
|
||||
/** @brief OB_USER_MASK 宏定义 */
|
||||
#define OB_USER_MASK ((uint8_t)0xF8U)
|
||||
|
||||
/* OB_WP mask */
|
||||
/** @brief OB_WP0_MASK 宏定义 */
|
||||
#define OB_WP0_MASK ((uint32_t)0x000000FFU)
|
||||
/** @brief OB_WP1_MASK 宏定义 */
|
||||
#define OB_WP1_MASK ((uint32_t)0x0000FF00U)
|
||||
/** @brief OB_WP2_MASK 宏定义 */
|
||||
#define OB_WP2_MASK ((uint32_t)0x00FF0000U)
|
||||
/** @brief OB_WP3_MASK 宏定义 */
|
||||
#define OB_WP3_MASK ((uint32_t)0xFF000000U)
|
||||
|
||||
/* return the FMC state */
|
||||
/**
|
||||
* @brief fmc_state_get 函数
|
||||
* @return fmc_state_enum 返回值
|
||||
*/
|
||||
static fmc_state_enum fmc_state_get(void);
|
||||
/* check FMC ready or not */
|
||||
/**
|
||||
* @brief fmc_ready_wait 函数
|
||||
* @param[in] timeout 参数
|
||||
* @return fmc_state_enum 返回值
|
||||
*/
|
||||
static fmc_state_enum fmc_ready_wait(uint32_t timeout);
|
||||
|
||||
/* FMC main memory programming functions */
|
||||
@@ -446,6 +466,11 @@ fmc_state_enum ob_erase(void)
|
||||
\arg FMC_PGAERR: program alignment error
|
||||
\arg FMC_TOERR: timeout error
|
||||
*/
|
||||
/**
|
||||
* @brief ob_write_protection_enable 函数
|
||||
* @param[in] ob_wp 参数
|
||||
* @return fmc_state_enum 返回值
|
||||
*/
|
||||
fmc_state_enum ob_write_protection_enable(uint32_t ob_wp)
|
||||
{
|
||||
uint32_t i;
|
||||
@@ -505,6 +530,11 @@ fmc_state_enum ob_write_protection_enable(uint32_t ob_wp)
|
||||
\arg FMC_PGAERR: program alignment error
|
||||
\arg FMC_TOERR: timeout error
|
||||
*/
|
||||
/**
|
||||
* @brief ob_security_protection_config 函数
|
||||
* @param[in] ob_spc 参数
|
||||
* @return fmc_state_enum 返回值
|
||||
*/
|
||||
fmc_state_enum ob_security_protection_config(uint8_t ob_spc)
|
||||
{
|
||||
uint32_t i;
|
||||
@@ -571,6 +601,13 @@ fmc_state_enum ob_security_protection_config(uint8_t ob_spc)
|
||||
\arg FMC_PGAERR: program alignment error
|
||||
\arg FMC_TOERR: timeout error
|
||||
*/
|
||||
/**
|
||||
* @brief ob_user_write 函数
|
||||
* @param[in] ob_fwdgt 参数
|
||||
* @param[in] ob_deepsleep 参数
|
||||
* @param[in] ob_stdby 参数
|
||||
* @return fmc_state_enum 返回值
|
||||
*/
|
||||
fmc_state_enum ob_user_write(uint8_t ob_fwdgt, uint8_t ob_deepsleep, uint8_t ob_stdby)
|
||||
{
|
||||
uint32_t i;
|
||||
@@ -700,6 +737,11 @@ uint16_t fmc_ecc_address_get(void)
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
/**
|
||||
* @brief fmc_ecc_flag_get 函数
|
||||
* @param[in] flag 参数
|
||||
* @return FlagStatus 返回值
|
||||
*/
|
||||
FlagStatus fmc_ecc_flag_get(uint32_t flag)
|
||||
{
|
||||
FlagStatus status = RESET;
|
||||
@@ -725,6 +767,11 @@ FlagStatus fmc_ecc_flag_get(uint32_t flag)
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
/**
|
||||
* @brief fmc_ecc_flag_clear 函数
|
||||
* @param[in] flag 参数
|
||||
* @return void
|
||||
*/
|
||||
void fmc_ecc_flag_clear(uint32_t flag)
|
||||
{
|
||||
FMC_ECCCS |= flag;
|
||||
|
||||
Reference in New Issue
Block a user