加入通道轮询宏定义,当宏为1时代表通道可++,代表四通道,反之为单通道

1. 在chrg_def.h中新增多通道轮询配置宏CHRG_MULTI_CHANNEL,以及对应通道自增宏CHRG_CHANNEL_NEXT
2. 将chrg_roll_sou.c和chrg_roll_nor.c中的原生index++替换为CHRG_CHANNEL_NEXT(index)
3. 实现单/多通道硬件的兼容适配
This commit is contained in:
wrh
2026-08-26 10:52:28 +08:00
parent 6103d6949e
commit 3b0087c956
3 changed files with 19 additions and 6 deletions
@@ -997,17 +997,17 @@ void chrg_roll_nor_thread_entry (void *data)
rt_mutex_release(pTHR->mutex); rt_mutex_release(pTHR->mutex);
if (state_work_ret != 0) { if (state_work_ret != 0) {
/* 南向状态动作未成功入队时保留原状态,下轮重试且禁止北向先行。 */ /* 南向状态动作未成功入队时保留原状态,下轮重试且禁止北向先行。 */
index++; CHRG_CHANNEL_NEXT(index);
rt_thread_mdelay(2); rt_thread_mdelay(2);
continue; continue;
} }
if (source_waiting || sink_waiting) { if (source_waiting || sink_waiting) {
index++; CHRG_CHANNEL_NEXT(index);
rt_thread_mdelay(2); rt_thread_mdelay(2);
continue; continue;
} }
if (0 == pNOR->enable[idx]) { if (0 == pNOR->enable[idx]) {
index++; CHRG_CHANNEL_NEXT(index);
rt_thread_mdelay(2); rt_thread_mdelay(2);
continue; continue;
} else { } else {
@@ -1018,7 +1018,7 @@ void chrg_roll_nor_thread_entry (void *data)
(void)chrg_roll_nor_auto_request(idx, pSW, (void)chrg_roll_nor_auto_request(idx, pSW,
pTHR, pTN, pNOR); pTHR, pTN, pNOR);
} }
index++; CHRG_CHANNEL_NEXT(index);
rt_thread_mdelay(NORTH_POLL_INTERVAL_MS); rt_thread_mdelay(NORTH_POLL_INTERVAL_MS);
continue; continue;
} }
@@ -820,7 +820,7 @@ void chrg_roll_sou_thread_entry (void *data)
idx = index%(TOTAL_SOU_CHS); // [0, 3] idx = index%(TOTAL_SOU_CHS); // [0, 3]
response_part = pROLL->part; response_part = pROLL->part;
if (0 == chrgsouth.enable[idx]) { // 通道未启用 if (0 == chrgsouth.enable[idx]) { // 通道未启用
index++; CHRG_CHANNEL_NEXT(index);
rt_thread_mdelay(10); rt_thread_mdelay(10);
continue; continue;
} else { // 通道启用 } else { // 通道启用
@@ -837,7 +837,7 @@ void chrg_roll_sou_thread_entry (void *data)
chrg_eload_refresh(ID_ELOAD, pROLL->part); chrg_eload_refresh(ID_ELOAD, pROLL->part);
} }
if (pROLL->part < TOTAL_MB_R) { if (pROLL->part < TOTAL_MB_R) {
index++; CHRG_CHANNEL_NEXT(index);
} }
} }
} }
+13
View File
@@ -12,6 +12,19 @@
#include <rtthread.h> #include <rtthread.h>
/*
* Channel polling mode:
* 1 - multi-channel hardware, advance the polling channel index;
* 0 - single-channel hardware, keep polling channel 0.
*/
#define CHRG_MULTI_CHANNEL 1
#if CHRG_MULTI_CHANNEL
#define CHRG_CHANNEL_NEXT(index) do { (index)++; } while (0)
#else
#define CHRG_CHANNEL_NEXT(index) do { } while (0)
#endif
// 4路选通 // 4路选通
typedef enum { typedef enum {
IDX_CH1 = 0, // 通路1 IDX_CH1 = 0, // 通路1