refactor: 对齐 DLD154V4B 规格和 M1H 参考
- 灵敏度表改为 M1H 值: {216,108,36,10} / {108,72,18,9}
- 时序参数对齐: OUT_DELAY 39→38, PULSE_DELAY 10→19
- LED 宏命名对齐 154V4B: LEDA=红(PB1), LEDB=绿(PA9), LEDC=黄(PA10)
- RLY1/RLY2 引脚交换: PA6=RLY1, PA5=RLY2
This commit is contained in:
@@ -206,8 +206,9 @@ void loop_timer_io_init(void)
|
||||
gpio_init(GPIOA, &gpio_init_struct);
|
||||
|
||||
|
||||
LEDA_OFF;
|
||||
LEDC_OFF;
|
||||
LEDA_OFF; // 红灭
|
||||
LEDB_OFF; // 绿灭
|
||||
LEDC_OFF; // 黄灭
|
||||
RLY1_OFF;
|
||||
RLY2_OFF;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef enum
|
||||
#define LED_RED_GPIO GPIOB
|
||||
#define LED_GPIO_CRM_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define LED_GREEN_PIN GPIO_PINS_9 // GPIO_PINS_13 //GPIO_PINS_9
|
||||
#define LED_GREEN_PIN GPIO_PINS_9
|
||||
#define LED_GREEN_GPIO GPIOA
|
||||
#define LED_GREEN_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
@@ -91,17 +91,26 @@ typedef enum
|
||||
#define LED_YELLOW_GPIO GPIOA
|
||||
#define LED_YELLOW_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
#define LEDB_OFF // gpio_bits_set(LED_RED_GPIO, LED_RED_PIN)
|
||||
#define LEDB_ON // gpio_bits_reset(LED_RED_GPIO, LED_RED_PIN)
|
||||
// LED 命名对齐 DLD154V4B 规格:
|
||||
// LEDA = 红色呼吸灯 (PB1, TMR14 PWM)
|
||||
// LEDB = 绿色有车指示灯 (PA9)
|
||||
// LEDC = 黄色故障指示灯 (PA10)
|
||||
// 注意: DEBUG 模式下 PA9 复用为 UART TX,LEDB 宏为空
|
||||
|
||||
// LEDA — 红色 (PB1),GPIO 直接控制(初始化闪烁用,正常运行时 PWM)
|
||||
#define LEDA_OFF gpio_bits_set(LED_RED_GPIO, LED_RED_PIN)
|
||||
#define LEDA_ON gpio_bits_reset(LED_RED_GPIO, LED_RED_PIN)
|
||||
|
||||
// LEDB — 绿色 (PA9),有车亮
|
||||
#ifdef DEBUG
|
||||
#define LEDA_OFF
|
||||
#define LEDA_ON
|
||||
#define LEDB_OFF
|
||||
#define LEDB_ON
|
||||
#else
|
||||
#define LEDA_OFF gpio_bits_set(LED_GREEN_GPIO, LED_GREEN_PIN)
|
||||
#define LEDA_ON gpio_bits_reset(LED_GREEN_GPIO, LED_GREEN_PIN)
|
||||
#define LEDB_OFF gpio_bits_set(LED_GREEN_GPIO, LED_GREEN_PIN)
|
||||
#define LEDB_ON gpio_bits_reset(LED_GREEN_GPIO, LED_GREEN_PIN)
|
||||
#endif
|
||||
|
||||
// LEDC — 黄色 (PA10),故障指示
|
||||
#define LEDC_OFF gpio_bits_set(LED_YELLOW_GPIO, LED_YELLOW_PIN)
|
||||
#define LEDC_ON gpio_bits_reset(LED_YELLOW_GPIO, LED_YELLOW_PIN)
|
||||
|
||||
@@ -110,24 +119,15 @@ typedef enum
|
||||
|
||||
|
||||
|
||||
// RLY
|
||||
//#define RLY1_PIN GPIO_PINS_6
|
||||
//#define RLY1_GPIO GPIOA
|
||||
//#define RLY1_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
//#define RLY2_PIN GPIO_PINS_5
|
||||
//#define RLY2_GPIO GPIOA
|
||||
//#define RLY2_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
//功能继电器
|
||||
#define RLY1_PIN GPIO_PINS_5
|
||||
// RLY1 — 主输出 (PA6),存在/脉冲
|
||||
#define RLY1_PIN GPIO_PINS_6
|
||||
#define RLY1_GPIO GPIOA
|
||||
#define RLY1_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
// 固定继电器 存在继电器
|
||||
#define RLY2_PIN GPIO_PINS_6
|
||||
// RLY2 — 辅助输出 (PA5),方向/第二路
|
||||
#define RLY2_PIN GPIO_PINS_5
|
||||
#define RLY2_GPIO GPIOA
|
||||
#define RLY2_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
#define RLY2_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
#define RLY1_ON gpio_bits_set(RLY1_GPIO, RLY1_PIN)
|
||||
#define RLY1_OFF gpio_bits_reset(RLY1_GPIO, RLY1_PIN)
|
||||
@@ -155,23 +155,23 @@ typedef enum
|
||||
#define USER_BUTTON_PORT GPIOA
|
||||
#define USER_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
// 灵敏度L
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L
|
||||
#define SW1_BUTTON_PIN GPIO_PINS_0
|
||||
#define SW1_BUTTON_PORT GPIOA
|
||||
#define SW1_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
// 灵敏度H
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
|
||||
#define SW2_BUTTON_PIN GPIO_PINS_1
|
||||
#define SW2_BUTTON_PORT GPIOA
|
||||
#define SW2_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
// 输出方式
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
#define SW3_BUTTON_PIN GPIO_PINS_2
|
||||
#define SW3_BUTTON_PORT GPIOA
|
||||
#define SW3_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
// 延时
|
||||
// <EFBFBD><EFBFBD>ʱ
|
||||
#define SW4_BUTTON_PIN GPIO_PINS_3
|
||||
#define SW4_BUTTON_PORT GPIOA
|
||||
#define SW4_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
// 安全复位
|
||||
// <EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>λ
|
||||
#define SW5_BUTTON_PIN GPIO_PINS_4
|
||||
#define SW5_BUTTON_PORT GPIOA
|
||||
#define SW5_BUTTON_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HOLD_TIME 5*1200
|
||||
#define LC_HOLD_TIME 4*1200 //时间4分钟
|
||||
#define IN_DELAY 10
|
||||
#define OUT_DELAY 39
|
||||
#define PLUSE_DELAY 10
|
||||
// 时序参数(每 tick ≈50ms),对齐 M1H 参考实现
|
||||
#define HOLD_TIME (5 * 1200) // 有限存在保持(约5分钟)
|
||||
#define LC_HOLD_TIME (4 * 1200) // 安全复位时间(约4分钟)
|
||||
#define IN_DELAY 10 // 进入防抖 500ms
|
||||
#define OUT_DELAY 38 // 离开防抖 1.9s
|
||||
#define PULSE_DELAY 19 // 脉冲宽度 950ms
|
||||
|
||||
|
||||
#define MAX_CMP_LOOP_UNIT 4 // 5 组
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
|
||||
|
||||
|
||||
const uint16_t SensTable[4] = {300, 60, 32, 21 };
|
||||
const uint16_t SensTable_1[4] = {60, 32, 21, 14 }; //释放灵敏度
|
||||
// 灵敏度表(对齐 M1H 参考实现)
|
||||
// 进入阈值 = Origin × SensTable[SENS] / 65536
|
||||
// 离开阈值(滞回)= Origin × SensTable_1[SENS] / 65536,约为进入的一半
|
||||
const uint16_t SensTable[4] = {216, 108, 36, 10}; // 0=低灵敏, 3=高灵敏
|
||||
const uint16_t SensTable_1[4] = {108, 72, 18, 9}; // 释放灵敏度(滞回)
|
||||
|
||||
const uint16_t DELAY_TIME[4] = {0, 10}; //0、0.6秒、1.6秒、3秒 {0,12,32,60}; //0、0.6秒、1.6秒、3秒
|
||||
|
||||
@@ -345,7 +348,7 @@ void update_flt_history(uint32_t new_flt, int32_t firstOrder, int32_t secondOrde
|
||||
if (flt_mgr.init_samples >= INIT_SAMPLE_COUNT) {
|
||||
flt_mgr.stable_init_value = flt_mgr.init_sum / INIT_SAMPLE_COUNT;
|
||||
flt_mgr.is_initialized = 1;
|
||||
LEDA_OFF;
|
||||
LEDB_OFF;
|
||||
stage_config[0].base_value = flt_mgr.stable_init_value;
|
||||
update_lower_upper(&stage_config[0]);
|
||||
flt_mgr.init_freq = (float)(g_sys_freq )/((float)(flt_mgr.stable_init_value << XNSUM_FOR_ORIGIN_FACTOR)/((float)(loop1_LPCNT))) * g_input_div;
|
||||
@@ -727,7 +730,7 @@ void TMR15_GLOBAL_IRQHandler(void)
|
||||
loop1_FLAG_PLUSE_IN_F = 1;
|
||||
}
|
||||
loop1_INCNT = 0;
|
||||
LEDA_ON;
|
||||
LEDB_ON;
|
||||
}
|
||||
|
||||
if(loop1_FLAG_PLUSE_IN_F)
|
||||
@@ -760,14 +763,14 @@ void TMR15_GLOBAL_IRQHandler(void)
|
||||
loop1_FLAG_OUT = 0;
|
||||
loop1_FLAG_PLUSE = 1;
|
||||
loop1_OUTCNT = 0;
|
||||
LEDA_OFF;
|
||||
LEDB_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
if(loop1_FLAG_PLUSE) // Give 500ms
|
||||
{
|
||||
loop1_OUTCNT++;
|
||||
if(loop1_OUTCNT > PLUSE_DELAY)
|
||||
if(loop1_OUTCNT > PULSE_DELAY)
|
||||
{
|
||||
loop1_FLAG_PLUSE = 0;
|
||||
loop1_OUTCNT = 0;
|
||||
@@ -971,7 +974,7 @@ void vd1_task(void){
|
||||
loop1_VD_FLAG = 1; //???????1
|
||||
loop1_FLAG_IN = 1; //??????
|
||||
|
||||
LEDA_ON;
|
||||
LEDB_ON;
|
||||
|
||||
|
||||
if(!SET_SAFE)
|
||||
@@ -1026,7 +1029,7 @@ void vd1_task(void){
|
||||
g_loop_acs_info.flag_event = 1;
|
||||
g_loop_acs_info.car_state = 0;
|
||||
// g_led_A_state = 0;
|
||||
LEDA_OFF;
|
||||
LEDB_OFF;
|
||||
loop1_ORG_CNT = 0;
|
||||
loop1_ORG_SUM = 0;
|
||||
Hold_CNT = 0;
|
||||
@@ -1085,16 +1088,16 @@ void loop_task_function(void *pvParameters)
|
||||
if(!loop1_LOOP_OK0){
|
||||
for(swcnt = 0; swcnt < 6; swcnt++){
|
||||
if(gpio_output_data_bit_read(LED_GREEN_GPIO, LED_GREEN_PIN)){
|
||||
LEDA_ON;
|
||||
LEDB_ON;
|
||||
}
|
||||
else{
|
||||
LEDA_OFF;
|
||||
LEDB_OFF;
|
||||
}
|
||||
vTaskDelay(200);
|
||||
// TODO: 添加看门狗
|
||||
}
|
||||
loop1_LOOP_OK0= 1;
|
||||
LEDA_OFF;
|
||||
LEDB_OFF;
|
||||
}
|
||||
|
||||
if(loop1_CAP_OK){
|
||||
@@ -1132,7 +1135,7 @@ void loop_task_function(void *pvParameters)
|
||||
// loop1_FLAG_PLUSE = 0;
|
||||
|
||||
// 线圈断开,继电器释放,状态为0,车辆状态也为0
|
||||
RLY1_OFF; RLY2_OFF; LEDA_OFF;
|
||||
RLY1_OFF; RLY2_OFF; LEDB_OFF;
|
||||
|
||||
if(gpio_output_data_bit_read(LED_YELLOW_GPIO, LED_YELLOW_PIN)){
|
||||
LED_YELLOW_ON;
|
||||
@@ -1152,10 +1155,10 @@ void loop_task_function(void *pvParameters)
|
||||
g_xn_counter = 0;
|
||||
|
||||
// if(gpio_output_data_bit_read(LED_GREEN_GPIO, LED_GREEN_PIN)){
|
||||
// LEDA_ON;
|
||||
// LEDB_ON;
|
||||
// }
|
||||
// else{
|
||||
// LEDA_OFF;
|
||||
// LEDB_OFF;
|
||||
// }
|
||||
//
|
||||
// if(gpio_output_data_bit_read(LED_YELLOW_GPIO, LED_YELLOW_PIN)){
|
||||
|
||||
Reference in New Issue
Block a user