From 3b0087c956dc93e9f7f438c20e565335451501db Mon Sep 17 00:00:00 2001 From: wrh Date: Wed, 26 Aug 2026 10:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=80=9A=E9=81=93=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E5=AE=8F=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=BD=93=E5=AE=8F?= =?UTF-8?q?=E4=B8=BA1=E6=97=B6=E4=BB=A3=E8=A1=A8=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=8F=AF++=EF=BC=8C=E4=BB=A3=E8=A1=A8=E5=9B=9B=E9=80=9A?= =?UTF-8?q?=E9=81=93=EF=BC=8C=E5=8F=8D=E4=B9=8B=E4=B8=BA=E5=8D=95=E9=80=9A?= =?UTF-8?q?=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 实现单/多通道硬件的兼容适配 --- apps/chrg/applications/thread/chrg_roll_nor.c | 8 ++++---- apps/chrg/applications/thread/chrg_roll_sou.c | 4 ++-- apps/chrg/applications/utils/chrg_def.h | 13 +++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/chrg/applications/thread/chrg_roll_nor.c b/apps/chrg/applications/thread/chrg_roll_nor.c index b99b523..c70d52b 100644 --- a/apps/chrg/applications/thread/chrg_roll_nor.c +++ b/apps/chrg/applications/thread/chrg_roll_nor.c @@ -997,17 +997,17 @@ void chrg_roll_nor_thread_entry (void *data) rt_mutex_release(pTHR->mutex); if (state_work_ret != 0) { /* 南向状态动作未成功入队时保留原状态,下轮重试且禁止北向先行。 */ - index++; + CHRG_CHANNEL_NEXT(index); rt_thread_mdelay(2); continue; } if (source_waiting || sink_waiting) { - index++; + CHRG_CHANNEL_NEXT(index); rt_thread_mdelay(2); continue; } if (0 == pNOR->enable[idx]) { - index++; + CHRG_CHANNEL_NEXT(index); rt_thread_mdelay(2); continue; } else { @@ -1018,7 +1018,7 @@ void chrg_roll_nor_thread_entry (void *data) (void)chrg_roll_nor_auto_request(idx, pSW, pTHR, pTN, pNOR); } - index++; + CHRG_CHANNEL_NEXT(index); rt_thread_mdelay(NORTH_POLL_INTERVAL_MS); continue; } diff --git a/apps/chrg/applications/thread/chrg_roll_sou.c b/apps/chrg/applications/thread/chrg_roll_sou.c index 0643b9f..4c91f93 100644 --- a/apps/chrg/applications/thread/chrg_roll_sou.c +++ b/apps/chrg/applications/thread/chrg_roll_sou.c @@ -820,7 +820,7 @@ void chrg_roll_sou_thread_entry (void *data) idx = index%(TOTAL_SOU_CHS); // [0, 3] response_part = pROLL->part; if (0 == chrgsouth.enable[idx]) { // 通道未启用 - index++; + CHRG_CHANNEL_NEXT(index); rt_thread_mdelay(10); continue; } else { // 通道启用 @@ -837,7 +837,7 @@ void chrg_roll_sou_thread_entry (void *data) chrg_eload_refresh(ID_ELOAD, pROLL->part); } if (pROLL->part < TOTAL_MB_R) { - index++; + CHRG_CHANNEL_NEXT(index); } } } diff --git a/apps/chrg/applications/utils/chrg_def.h b/apps/chrg/applications/utils/chrg_def.h index 77b313c..181f43c 100644 --- a/apps/chrg/applications/utils/chrg_def.h +++ b/apps/chrg/applications/utils/chrg_def.h @@ -12,6 +12,19 @@ #include +/* + * 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路选通 typedef enum { IDX_CH1 = 0, // 通路1