From 37bc397e9a719ee2571adf09945430f0fe7fe941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 17 Nov 2020 00:53:21 +0100 Subject: [PATCH] Add reset-cal shell command and modify cal command to show existing calibration --- stm-firmware/calibration.c | 7 ++++++- stm-firmware/shell.c | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/stm-firmware/calibration.c b/stm-firmware/calibration.c index 35f3509..b55945c 100644 --- a/stm-firmware/calibration.c +++ b/stm-firmware/calibration.c @@ -189,12 +189,17 @@ shellmatta_retCode_t calibration_sequence_shell_cmd(shellmatta_handle_t shell, c static volatile int flag; char *stdin_data; uint32_t stdin_len; - + bool cal_active; switch (cal_state) { case CAL_START: /* Clear errors of PT1000 reading */ safety_controller_ack_flag(ERR_FLAG_MEAS_ADC_WATCHDOG); + adc_pt1000_get_resistance_calibration(&offset, &sens_dev, &cal_active); + if (cal_active) { + shellmatta_printf(shell, "Already calibrated.\r\n\tOffset: %f\r\n\tSens: %f\r\n", offset, sens_dev); + shellmatta_printf(shell, "Press CTRL-C to abort new calibration.\r\n"); + } shellmatta_printf(shell, "Starting calibration: Insert 1000 Ohm calibration resistor and press ENTER\r\n"); cal_state = CAL_WAIT_RES1; ret_val = SHELLMATTA_CONTINUE; diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index 4b865d7..1c115d5 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -648,6 +648,17 @@ static shellmatta_retCode_t shell_cmd_dump_safety_mem(const shellmatta_handle_t return SHELLMATTA_BUSY; } +shellmatta_retCode_t shell_cmd_reset_cal(const shellmatta_handle_t handle, const char *arguments, uint32_t length) +{ + (void)handle; + (void)arguments; + (void)length; + + adc_pt1000_set_resistance_calibration(0.0f, 0.0f, false); + + return SHELLMATTA_OK; +} + //typedef struct shellmatta_cmd //{ // char *cmd; /**< command name */ @@ -657,7 +668,7 @@ static shellmatta_retCode_t shell_cmd_dump_safety_mem(const shellmatta_handle_t // shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */ // struct shellmatta_cmd *next; /**< pointer to next command or NULL */ //} shellmatta_cmd_t; -static shellmatta_cmd_t cmd[18] = { +static shellmatta_cmd_t cmd[19] = { { .cmd = "version", .cmdAlias = "ver", @@ -800,8 +811,16 @@ static shellmatta_cmd_t cmd[18] = { .helpText = "", .usageText = "safety-mem-dump [output-file]", .cmdFct = shell_cmd_dump_safety_mem, - .next = NULL, + .next = &cmd[18], }, + { + .cmd = "reset-cal", + .cmdAlias = NULL, + .helpText = "Reset Calibration", + .usageText = "", + .cmdFct = shell_cmd_reset_cal, + .next = NULL, + } }; shellmatta_handle_t shell_init(shellmatta_write_t write_func)