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