diff --git a/meta-facebook/aalc-rpu/src/platform/plat_fsc.c b/meta-facebook/aalc-rpu/src/platform/plat_fsc.c index 0f81856575..46531b1769 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_fsc.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_fsc.c @@ -43,7 +43,7 @@ extern pid_cfg pump_pid_table[]; extern stepwise_cfg pump_stepwise_auto_mode_table[]; extern stepwise_cfg pump_stepwise_auto_tune_table[]; -static uint8_t setpoint[SETPOINT_FLAG_MAX] = { 0, 40 }; +static float setpoint[SETPOINT_FLAG_MAX] = { 0, 40.0 }; uint8_t fsc_debug_set(uint8_t enable) { @@ -75,14 +75,14 @@ void set_fsc_tbl_enable(uint8_t flag) fsc_tbl_enable = flag; } -uint8_t get_fsc_setpoint(uint8_t idx) +float get_fsc_setpoint(uint8_t idx) { if (idx >= SETPOINT_FLAG_MAX) { return 0xFF; } return setpoint[idx]; } -void set_fsc_setpoint(uint8_t idx, uint8_t val) +void set_fsc_setpoint(uint8_t idx, float val) { if (idx < SETPOINT_FLAG_MAX) { setpoint[idx] = val; @@ -188,7 +188,7 @@ static uint8_t calculatePID(zone_cfg *zone_p, uint8_t *duty) (int16_t)tmp : tmp; - FSC_PRINTF("\t\t----- sensor_num %x, temp = %f, p->setpoint %d\n", p->sensor_num, + FSC_PRINTF("\t\t----- sensor_num %x, temp = %f, p->setpoint %f\n", p->sensor_num, temp, p->setpoint); // hysteresis @@ -204,7 +204,7 @@ static uint8_t calculatePID(zone_cfg *zone_p, uint8_t *duty) } // p term - float error = (float)p->setpoint - temp; + float error = p->setpoint - temp; float pterm = p->kp * error; FSC_PRINTF("\t\t\tp->kp = %f, error = %f, pterm = %f\n", p->kp, error, pterm); @@ -293,7 +293,7 @@ void change_lpm_setpoint(uint8_t onoff) { if (onoff) { zone_table[1].pid_tbl = pump_pid_table; - zone_table[1].pid_tbl->setpoint = get_fsc_setpoint(SETPOINT_FLAG_LPM) + 1; + zone_table[1].pid_tbl->setpoint = get_fsc_setpoint(SETPOINT_FLAG_LPM) + 1.0; zone_table[1].sw_tbl = pump_stepwise_auto_tune_table; } else { if (zone_table[1].pid_tbl) { @@ -311,7 +311,8 @@ void change_temp_setpoint(uint8_t onoff) zone_table[0].pid_tbl->integral = 0.0; zone_table[0].pid_tbl->last_error = 0.0; zone_table[0].pid_tbl->last_temp = FSC_TEMP_INVALID; - zone_table[0].pid_tbl->setpoint = onoff ? get_fsc_setpoint(SETPOINT_FLAG_OUTLET_TEMP) : 40; + zone_table[0].pid_tbl->setpoint = + onoff ? get_fsc_setpoint(SETPOINT_FLAG_OUTLET_TEMP) : 40.0; } /** @@ -417,4 +418,4 @@ void fsc_init(void) fsc_thread_handler, zone_table, UINT_TO_POINTER(zone_table_size), NULL, CONFIG_MAIN_THREAD_PRIORITY, 0, K_NO_WAIT); k_thread_name_set(&fsc_thread, "fsc_thread"); -} +} \ No newline at end of file diff --git a/meta-facebook/aalc-rpu/src/platform/plat_fsc.h b/meta-facebook/aalc-rpu/src/platform/plat_fsc.h index 9eb15b05d2..4431f194ea 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_fsc.h +++ b/meta-facebook/aalc-rpu/src/platform/plat_fsc.h @@ -72,7 +72,7 @@ typedef struct { /* pid */ typedef struct { uint8_t sensor_num; - int setpoint; + float setpoint; /*uint8_t setpoint_type;*/ float kp; float ki; @@ -123,8 +123,8 @@ void fsc_init(void); void controlFSC(uint8_t action); uint8_t fsc_debug_set(uint8_t enable); uint8_t fsc_debug_get(void); -uint8_t get_fsc_setpoint(uint8_t idx); -void set_fsc_setpoint(uint8_t idx, uint8_t val); +float get_fsc_setpoint(uint8_t idx); +void set_fsc_setpoint(uint8_t idx, float val); void change_lpm_setpoint(uint8_t onoff); void change_temp_setpoint(uint8_t onoff); diff --git a/meta-facebook/aalc-rpu/src/platform/plat_fsc_table.c b/meta-facebook/aalc-rpu/src/platform/plat_fsc_table.c index 730d9c28de..84dc033e39 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_fsc_table.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_fsc_table.c @@ -23,7 +23,7 @@ pid_cfg hex_fan_pid_table[] = { { .sensor_num = SENSOR_NUM_BPB_RPU_COOLANT_OUTLET_TEMP_C, - .setpoint = 40, + .setpoint = 40.0, .kp = -15, .ki = -0.1, .kd = -0.01, @@ -67,7 +67,7 @@ stepwise_cfg hex_fan_stepwise_table[] = { pid_cfg pump_pid_table[] = { { .sensor_num = SENSOR_NUM_BPB_RPU_COOLANT_FLOW_RATE_LPM, - .setpoint = 40, + .setpoint = 40.0, .kp = 0.5, .ki = 0.03, .kd = 0.01, @@ -157,4 +157,4 @@ zone_cfg zone_table[] = { }, }; -uint32_t zone_table_size = ARRAY_SIZE(zone_table); +uint32_t zone_table_size = ARRAY_SIZE(zone_table); \ No newline at end of file diff --git a/meta-facebook/aalc-rpu/src/platform/plat_hwmon.c b/meta-facebook/aalc-rpu/src/platform/plat_hwmon.c index e1e152f87e..f6951ded92 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_hwmon.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_hwmon.c @@ -426,13 +426,19 @@ void pump_redundant_handler_disable(struct k_timer *timer) } K_TIMER_DEFINE(pump_redundant_timer, pump_redundant_handler, pump_redundant_handler_disable); -static uint8_t pump_redundant_switch_time = 30; +static uint16_t pump_redundant_switch_time = 30; static uint8_t pump_redundant_switch_time_type = 0; /* for test, 0: day, 1: minute */ -uint8_t get_pump_redundant_switch_time() + +uint16_t get_pump_redundant_switch_time() { return pump_redundant_switch_time; } -void set_pump_redundant_switch_time(uint8_t time) +uint8_t get_pump_redundant_switch_time_type() +{ + return pump_redundant_switch_time_type; +} + +void set_pump_redundant_switch_time(uint16_t time) { pump_redundant_switch_time = time; } diff --git a/meta-facebook/aalc-rpu/src/platform/plat_hwmon.h b/meta-facebook/aalc-rpu/src/platform/plat_hwmon.h index f966b78cbf..2eab3f21d9 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_hwmon.h +++ b/meta-facebook/aalc-rpu/src/platform/plat_hwmon.h @@ -60,8 +60,9 @@ bool pump_setting_set_pump_redundant(pump_reset_struct *data, uint8_t bit_val); bool modbus_pump_setting_unsupport_function(pump_reset_struct *data, uint8_t bit_val); bool set_all_pump_power(bool switch_val); bool rpu_remote_power_cycle_function(pump_reset_struct *data, uint8_t bit_val); -uint8_t get_pump_redundant_switch_time(); -void set_pump_redundant_switch_time(uint8_t time); +uint16_t get_pump_redundant_switch_time(); +uint8_t get_pump_redundant_switch_time_type(); +void set_pump_redundant_switch_time(uint16_t time); void set_pump_redundant_switch_time_type(uint8_t type); void pump_redundant_enable(uint8_t onoff); uint8_t pwm_control(uint8_t group, uint8_t duty); diff --git a/meta-facebook/aalc-rpu/src/platform/plat_modbus.c b/meta-facebook/aalc-rpu/src/platform/plat_modbus.c index d0546cb7ec..d65d5824ed 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_modbus.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_modbus.c @@ -360,7 +360,8 @@ uint8_t modbus_pump_setting(modbus_command_mapping *cmd) set_is_pump_not_access(1, false); set_is_pump_not_access(2, false); // restore leak led - led_ctrl(LED_IDX_E_LEAK, LED_STOP_BLINK); + led_ctrl(LED_IDX_E_LEAK, LED_STOP_BLINK); // only stop blind behavior + led_ctrl(LED_IDX_E_LEAK, LED_TURN_OFF); // default led status(turn off) set_status_flag(STATUS_FLAG_FAILURE, GPIO_FAIL_BPB_HSC, 0); for (uint8_t i = PUMP_FAIL_EMERGENCY_BUTTON; i <= PUMP_FAIL_CLOSE_PUMP; i++) { set_status_flag(STATUS_FLAG_FAILURE, i, 0); @@ -743,7 +744,7 @@ uint8_t modbus_get_setpoint(modbus_command_mapping *cmd) { CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL); - cmd->data[0] = get_fsc_setpoint(cmd->arg0); + cmd->data[0] = (uint16_t)(get_fsc_setpoint(cmd->arg0) / cmd->arg1 / pow_of_10(cmd->arg2)); return MODBUS_EXC_NONE; } @@ -751,9 +752,9 @@ uint8_t modbus_set_setpoint(modbus_command_mapping *cmd) { CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL); - set_fsc_setpoint(cmd->arg0, (uint8_t)cmd->data[0]); + set_fsc_setpoint(cmd->arg0, (float)cmd->data[0] * cmd->arg1 * pow_of_10(cmd->arg2)); uint8_t idx = cmd->arg0; - set_fsc_setpoint(idx, (uint8_t)cmd->data[0]); + set_fsc_setpoint(idx, (float)cmd->data[0] * cmd->arg1 * pow_of_10(cmd->arg2)); if ((get_status_flag(STATUS_FLAG_SETPOINT_FLAG) && BIT(idx))) { switch (idx) { case SETPOINT_FLAG_LPM: @@ -801,6 +802,31 @@ uint8_t modbus_set_setpoint_enable(modbus_command_mapping *cmd) return MODBUS_EXC_NONE; } +uint8_t modbus_get_pump_redundant_switch_day(modbus_command_mapping *cmd) +{ + CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL); + + if (get_pump_redundant_switch_time_type()) + cmd->data[0] = (uint16_t)((double)get_pump_redundant_switch_time() / 1440.0 + 0.5); + else + cmd->data[0] = get_pump_redundant_switch_time(); + + return MODBUS_EXC_NONE; +} +uint8_t modbus_set_pump_redundant_switch_day(modbus_command_mapping *cmd) +{ + CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL); + + if (!cmd->data[0]) + return MODBUS_EXC_ILLEGAL_DATA_VAL; + else { + set_pump_redundant_switch_time_type(0); + set_pump_redundant_switch_time(cmd->data[0]); + } + + return MODBUS_EXC_NONE; +} + uint8_t modbus_get_board_stage(modbus_command_mapping *cmd) { CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL); @@ -1376,9 +1402,11 @@ modbus_command_mapping modbus_command_table[] = { modbus_get_setpoint_enable, SETPOINT_FLAG_OUTLET_TEMP, 0, 0, 1 }, // Control { MODBUS_AUTO_TUNE_COOLANT_FLOW_RATE_TARGET_SET_ADDR, modbus_set_setpoint, - modbus_get_setpoint, SETPOINT_FLAG_LPM, 0, 0, 1 }, + modbus_get_setpoint, SETPOINT_FLAG_LPM, 1, -1, 1 }, { MODBUS_AUTO_TUNE_COOLANT_OUTLET_TEMPERATURE_TARGET_SET_ADDR, modbus_set_setpoint, - modbus_get_setpoint, SETPOINT_FLAG_OUTLET_TEMP, 0, 0, 1 }, + modbus_get_setpoint, SETPOINT_FLAG_OUTLET_TEMP, 1, -1, 1 }, + { MODBUS_PUMP_REDUNDANT_SWITCHED_INTERVAL_ADDR, modbus_set_pump_redundant_switch_day, + modbus_get_pump_redundant_switch_day, SETPOINT_FLAG_LPM, 0, 0, 1 }, { MODBUS_MANUAL_CONTROL_PUMP_DUTY_SET_ADDR, modbus_set_manual_pwm, modbus_get_manual_pwm, MANUAL_PWM_E_PUMP, 0, 0, 1 }, { MODBUS_MANUAL_CONTROL_FAN_DUTY_SET_ADDR, modbus_set_manual_pwm, modbus_get_manual_pwm, diff --git a/meta-facebook/aalc-rpu/src/platform/plat_pwm.c b/meta-facebook/aalc-rpu/src/platform/plat_pwm.c index 78475db95d..ede750a62c 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_pwm.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_pwm.c @@ -329,7 +329,11 @@ uint8_t ctl_pwm_pump(uint8_t pump1_duty, uint8_t pump2_duty, uint8_t pump3_duty) (redundant_mode == PUMP_REDUNDANT_13) ? PWM_DEVICE_E_PB_PUMB_2 : (redundant_mode == PUMP_REDUNDANT_23) ? PWM_DEVICE_E_PB_PUMB_1 : PWM_DEVICE_E_MAX; - if (redundant_dev != PWM_DEVICE_E_MAX && redundant_dev_pre != redundant_dev) { + + if (!get_is_redundant_transforming()) + redundant_dev_now = redundant_dev; + + if (redundant_dev_now != PWM_DEVICE_E_MAX && redundant_dev_pre != redundant_dev_now) { switch (redundant_phase) { case REDUNDANCY_TRANSFORM_DISABLE: if (redundant_dev_pre != PWM_DEVICE_E_MAX) { diff --git a/meta-facebook/aalc-rpu/src/platform/plat_shell.c b/meta-facebook/aalc-rpu/src/platform/plat_shell.c index 20f093410f..c9e1efd760 100644 --- a/meta-facebook/aalc-rpu/src/platform/plat_shell.c +++ b/meta-facebook/aalc-rpu/src/platform/plat_shell.c @@ -416,7 +416,7 @@ static void cmd_pump_redundant_enable(const struct shell *shell, size_t argc, ch static void cmd_pump_redundant_switch_day_set(const struct shell *shell, size_t argc, char **argv) { uint8_t type = strtoul(argv[1], NULL, 10); - uint8_t time = strtoul(argv[2], NULL, 10); + uint16_t time = strtoul(argv[2], NULL, 10); set_pump_redundant_switch_time_type(type); set_pump_redundant_switch_time(time);