更新OTA功能,config独立成文件统一定义
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控制器初始化参数
This commit is contained in:
+10
-20
@@ -1,6 +1,6 @@
|
||||
#include "Timer.h"
|
||||
#include "Can.h"
|
||||
#include "DengFOC.h"
|
||||
#include "FOC.h"
|
||||
#include "Timer.h"
|
||||
#include "gd32c10x.h"
|
||||
#include "gd32c10x_gpio.h"
|
||||
@@ -12,16 +12,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
constexpr int TIMER2_PRESCALER = 119; // 120MHz / 120 = 1MHz
|
||||
constexpr int TIMER2_PERIOD = 99; // 1MHz / 100 = 100us
|
||||
|
||||
constexpr int TIMER1_PRESCALER = 0; // 不分频,计数器时钟为120MHz
|
||||
constexpr int TIMER1_PERIOD = 5999; // 120MHz / (0+1) / (5999+1) = 20kHz
|
||||
constexpr int TIMER1_CH0_PULSE = 0;
|
||||
constexpr int TIMER1_CH1_PULSE = 0;
|
||||
constexpr int TIMER1_CH2_PULSE = 0;
|
||||
constexpr int TIMER1_CH3_COMPARE_VALUE =
|
||||
(TIMER1_PERIOD + 1) * 0.5 - 1; // PWM周期50%位置触发中断
|
||||
|
||||
volatile u32 total_us100_counter = 0; // 总计数器,每100微秒增加1
|
||||
extern u16 adc_value[7];
|
||||
@@ -46,7 +36,7 @@ void nvic_config(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配置定时器2
|
||||
* @brief 配置定时器2-任务管理
|
||||
* @return void
|
||||
*
|
||||
*配置定时器2,用于定时执行FOC控制、采样、CAN发送等任务
|
||||
@@ -87,7 +77,7 @@ void TIMER2_config(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配置TIMER2中断
|
||||
* @brief 配置TIMER2-任务管理中断
|
||||
* @return void
|
||||
*/
|
||||
void User_timer_init(void) {
|
||||
@@ -98,7 +88,7 @@ void User_timer_init(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIMER2中断处理函数
|
||||
* @brief TIMER2-任务管理中断处理函数
|
||||
* @return void
|
||||
*/
|
||||
void TIMER2_IRQHandler(void) {
|
||||
@@ -174,7 +164,7 @@ void TIMER2_IRQHandler(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIMER1 GPIO配置函数
|
||||
* @brief TIMER1-PWM GPIO配置函数
|
||||
*/
|
||||
void timer1_gpio_config(void) {
|
||||
// 时钟使能
|
||||
@@ -198,7 +188,7 @@ void timer1_gpio_config(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIMER1 配置函数
|
||||
* @brief TIMER1-PWM 配置函数
|
||||
*/
|
||||
void timer1_pwm_config(void) {
|
||||
timer_parameter_struct timer_initpara;
|
||||
@@ -242,11 +232,11 @@ void timer1_pwm_config(void) {
|
||||
TIMER_OC_MODE_PWM0); // CH3也设为PWM模式
|
||||
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_0,
|
||||
TIMER1_CH0_PULSE);
|
||||
TIMER1_DEFAULT_PULSE);
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_1,
|
||||
TIMER1_CH1_PULSE);
|
||||
TIMER1_DEFAULT_PULSE);
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_2,
|
||||
TIMER1_CH2_PULSE);
|
||||
TIMER1_DEFAULT_PULSE);
|
||||
// 设置CH3比较值为PWM周期x%位置
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_3,
|
||||
TIMER1_CH3_COMPARE_VALUE);
|
||||
@@ -262,7 +252,7 @@ void timer1_pwm_config(void) {
|
||||
timer_enable(TIMER1);
|
||||
}
|
||||
|
||||
// 添加TIMER1中断处理函数
|
||||
// 添加TIMER1-PWM中断处理函数
|
||||
/**
|
||||
* @brief TIMER1中断处理函数
|
||||
* @return void
|
||||
|
||||
Reference in New Issue
Block a user