diff --git a/apps/chrg/applications/bsp/chrg_switch.c b/apps/chrg/applications/bsp/chrg_switch.c index f5a2b91..4ff0633 100644 --- a/apps/chrg/applications/bsp/chrg_switch.c +++ b/apps/chrg/applications/bsp/chrg_switch.c @@ -75,38 +75,51 @@ int chrg_switch_south_lv1 (eIDX_CH ch) int chrg_switch_south_lv2_1 (eIDX_CH ch) { - if (ch >= TOTAL_CHS) { - return -1; + int ret = -1; + + if (IDX_CH_0 == ch) { + ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A1, PIN_SW_SOUTH_LV2_B1, IDX_CH_2); + } else if (IDX_CH_1 == ch) { + ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A1, PIN_SW_SOUTH_LV2_B1, IDX_CH_0); } - return chrg_switch_ch(PIN_SW_SOUTH_LV2_A1, PIN_SW_SOUTH_LV2_B1, ch); + return ret; } int chrg_switch_south_lv2_2 (eIDX_CH ch) { - if (ch >= TOTAL_CHS) { + int ret = -1; + + if (IDX_CH_0 == ch) { + ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A2, PIN_SW_SOUTH_LV2_B2, IDX_CH_2); + } else if (IDX_CH_1 == ch) { + ret = chrg_switch_ch(PIN_SW_SOUTH_LV2_A2, PIN_SW_SOUTH_LV2_B2, IDX_CH_0); + } else { return -1; } - return chrg_switch_ch(PIN_SW_SOUTH_LV2_A2, PIN_SW_SOUTH_LV2_B2, ch); + return ret; } // 南向通道选择 int chrg_switch_south (eIDX_SOUTH_CH ch) { - if (ch >= TOTAL_SOUTH_CHS) { + int ret = -1; + if (ch >= TOTAL_SOU_CHS) { return -1; } - if (ch < IDX_SOUTH_4) { - chrg_switch_south_lv1(IDX_CH_0); - chrg_switch_south_lv2_1((eIDX_CH)ch); + if ((IDX_SOU_CH1 == ch)||(IDX_SOU_CH2 == ch)) { + ret = chrg_switch_south_lv1(IDX_CH_1); + ret |= chrg_switch_south_lv2_2((eIDX_CH)ch); + } else if ((IDX_SOU_CH3 == ch)||(IDX_SOU_CH4 == ch)) { + ret = chrg_switch_south_lv1(IDX_CH_0); + ret |= chrg_switch_south_lv2_1((eIDX_CH)(ch-IDX_SOU_CH3)); } else { - chrg_switch_south_lv1(IDX_CH_1); - chrg_switch_south_lv2_2((eIDX_CH)(ch-IDX_SOUTH_4)); + return -1; } - return 0; + return ret; } static int chrg_switch_south_pins_init (void) @@ -128,7 +141,7 @@ static int chrg_switch_init (void) chrg_switch_south_pins_init(); chrg_switch_north(IDX_CH_0); - chrg_switch_south(IDX_SOUTH_0); + chrg_switch_south(IDX_SOU_CH1); return 0; } diff --git a/apps/chrg/applications/bsp/chrg_switch.h b/apps/chrg/applications/bsp/chrg_switch.h index 6813a12..6c27342 100644 --- a/apps/chrg/applications/bsp/chrg_switch.h +++ b/apps/chrg/applications/bsp/chrg_switch.h @@ -14,25 +14,21 @@ typedef enum { // U14 U23 U24 U25 // ---------------- IDX_CH_0 = 0, // J3 U24 J12 J16 - IDX_CH_1, // J4 U25 J13 J17 + IDX_CH_1, // J4 U25 -J13 -J17 IDX_CH_2, // J9 - J14 J18 - IDX_CH_3, // J10 - J15 J19 + IDX_CH_3, // J10 - -J15 -J19 TOTAL_CHS } eIDX_CH; // 南向选择 组合 typedef enum { - IDX_SOUTH_0 = 0, // U24_J12 - IDX_SOUTH_1, // U24_J13 - IDX_SOUTH_2, // U24_J14 - IDX_SOUTH_3, // U24_J15 - IDX_SOUTH_4, // U25_J16 - IDX_SOUTH_5, // U25_J17 - IDX_SOUTH_6, // U25_J18 - IDX_SOUTH_7, // U25_J19 + IDX_SOU_CH1 = 0, // U25_J18 + IDX_SOU_CH2, // U25_J16 + IDX_SOU_CH3, // U24_J14 + IDX_SOU_CH4, // U24_J12 - TOTAL_SOUTH_CHS + TOTAL_SOU_CHS } eIDX_SOUTH_CH; diff --git a/apps/chrg/applications/thread/chrg_north.c b/apps/chrg/applications/thread/chrg_north.c index fbb253f..7332a54 100644 --- a/apps/chrg/applications/thread/chrg_north.c +++ b/apps/chrg/applications/thread/chrg_north.c @@ -44,7 +44,7 @@ void chrg_north_sw_uart (eIDX_CH ch, eIDX_ID id) if (ID_SOURCE == id) { rt_pin_write(sw_uart[ch], PIN_HIGH); - } else { + } else if (ID_SINK == id) { rt_pin_write(sw_uart[ch], PIN_LOW); } diff --git a/apps/chrg/applications/thread/chrg_roll.c b/apps/chrg/applications/thread/chrg_roll.c index 4f1328d..80f4d61 100644 --- a/apps/chrg/applications/thread/chrg_roll.c +++ b/apps/chrg/applications/thread/chrg_roll.c @@ -15,7 +15,7 @@ struct chrg_roll_t chrgroll = { .tid = RT_NULL, .idx = 0, .en_nor = {1, 1, 1, 1}, - .en_sou = {1, 1, 1, 1, 0, 0, 0, 0}, + .en_sou = {1, 1, 1, 1}, }; rt_uint8_t chrg_roll_get_idx (void) @@ -46,7 +46,7 @@ static void chrg_roll_thread_entry (void *data) return ; } - rt_uint8_t idx = 0; + rt_uint8_t idx = 0, sou_idx = 0; rt_err_t ret = RT_EOK; rt_uint32_t recved = 0; struct chrg_north_t *pNOR = &chrgnorth; @@ -55,7 +55,7 @@ static void chrg_roll_thread_entry (void *data) while (1) { rt_mutex_take(pROLL->mutex, RT_WAITING_FOREVER); - pROLL->idx = idx%(TOTAL_CHS+TOTAL_SOUTH_CHS); + pROLL->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS); rt_mutex_release(pROLL->mutex); if (pROLL->idx < TOTAL_CHS) { @@ -75,23 +75,25 @@ static void chrg_roll_thread_entry (void *data) chrg_north_sw_uart(pNOR->idx, ID_SINK); sink_get_vc(pSW->sink.loadv, pSW->sink.loadc); } + + rt_kprintf("Nor[%d].%d\r\n", pNOR->idx, pSW->id); } } else { - if (0 == pROLL->en_sou[pROLL->idx]) { + sou_idx = pROLL->idx - TOTAL_CHS; + if (0 == pROLL->en_sou[sou_idx]) { idx++; rt_thread_mdelay(1); continue; } else { - pSOU->idx = (eIDX_SOUTH_CH)(pROLL->idx - TOTAL_CHS); + pSOU->idx = (eIDX_SOUTH_CH)sou_idx; chrg_switch_south(pSOU->idx); pSW = &pSOU->sw[pSOU->idx]; - if (ID_SOURCE == pSW->id) { + // todo pkg send + if (ID_ELOAD == pSW->id) { source_get_vc(pSW->source.voltage, pSW->source.current); - } else if (ID_SINK == pSW->id) { - sink_get_vc(pSW->sink.loadv, pSW->sink.loadc); } - + rt_kprintf("Sou[%d].%d\r\n", pSOU->idx, pSW->id); } } diff --git a/apps/chrg/applications/thread/chrg_roll.h b/apps/chrg/applications/thread/chrg_roll.h index 9bba6fb..0f35fc2 100644 --- a/apps/chrg/applications/thread/chrg_roll.h +++ b/apps/chrg/applications/thread/chrg_roll.h @@ -20,7 +20,7 @@ struct chrg_roll_t { rt_uint8_t idx; // 轮巡索引 0-3:nor 4-11:sou rt_uint8_t en_nor[TOTAL_CHS]; // 北向通路使能 - rt_uint8_t en_sou[TOTAL_SOUTH_CHS]; // 南向通路使能 + rt_uint8_t en_sou[TOTAL_SOU_CHS]; // 南向通路使能 }; extern struct chrg_roll_t chrgroll; diff --git a/apps/chrg/applications/thread/chrg_south.c b/apps/chrg/applications/thread/chrg_south.c index 60bf2c6..56f3435 100644 --- a/apps/chrg/applications/thread/chrg_south.c +++ b/apps/chrg/applications/thread/chrg_south.c @@ -15,6 +15,19 @@ struct chrg_south_t chrgsouth = { .tid = RT_NULL, .tty = RT_NULL, .rx_len = 0, + .sw[IDX_SOU_CH1] = { + .id = ID_ELOAD, + }, + .sw[IDX_SOU_CH2] = { + .id = ID_ELOAD, + }, + .sw[IDX_SOU_CH3] = { + .id = ID_ELOAD, + }, + .sw[IDX_SOU_CH4] = { + .id = ID_ELOAD, + }, + }; int chrg_south_send (rt_uint8_t *data, rt_size_t length) diff --git a/apps/chrg/applications/thread/chrg_south.h b/apps/chrg/applications/thread/chrg_south.h index bd25763..aba0a00 100644 --- a/apps/chrg/applications/thread/chrg_south.h +++ b/apps/chrg/applications/thread/chrg_south.h @@ -20,7 +20,7 @@ struct chrg_south_t { rt_uint8_t rx_buf[SIZE_BUF_TTY]; eIDX_SOUTH_CH idx; // 当前通路 - struct chrg_switch_t sw[TOTAL_SOUTH_CHS]; + struct chrg_switch_t sw[TOTAL_SOU_CHS]; }; extern struct chrg_south_t chrgsouth; diff --git a/apps/chrg/applications/utils/chrg_def.h b/apps/chrg/applications/utils/chrg_def.h index 43abf33..7c30ded 100644 --- a/apps/chrg/applications/utils/chrg_def.h +++ b/apps/chrg/applications/utils/chrg_def.h @@ -7,6 +7,7 @@ typedef enum { ID_SINK = 0x01, // SINK 的 ID 为 1, 波特率 200K ID_SOURCE = 0x02, // SOURCE 的 ID 为 2, 波特率 200K + ID_ELOAD = 0x03, // LOAD ID 3, 波特率 115200 } eIDX_ID; // 电压电流极值 diff --git a/docs/HC-DFCD-300-A可编程源载板快速使用说明V1.0-202509.docx b/docs/HC-DFCD-300-A可编程源载板快速使用说明V1.0-202509.docx deleted file mode 100644 index 86d8a30..0000000 Binary files a/docs/HC-DFCD-300-A可编程源载板快速使用说明V1.0-202509.docx and /dev/null differ