From 8df0a6c7741a7b2ba4185194eb6c38d4e24e0422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 20 Apr 2020 21:30:00 +0200 Subject: [PATCH 01/10] Fix license header --- stm-firmware/include/reflow-controller/temp-converter-data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/include/reflow-controller/temp-converter-data.h b/stm-firmware/include/reflow-controller/temp-converter-data.h index d4517e4..7719127 100644 --- a/stm-firmware/include/reflow-controller/temp-converter-data.h +++ b/stm-firmware/include/reflow-controller/temp-converter-data.h @@ -8,7 +8,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * - * GDSII-Converter is distributed in the hope that it will be useful, + * The Reflow Oven Control Firmware is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. From b9a38549dceb2dc709dc10a6f740947e0d31c759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 23 Apr 2020 00:09:44 +0200 Subject: [PATCH 02/10] Add stack_check_collision() function --- stm-firmware/include/reflow-controller/stack-check.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stm-firmware/include/reflow-controller/stack-check.h b/stm-firmware/include/reflow-controller/stack-check.h index f73dd29..8e0e290 100644 --- a/stm-firmware/include/reflow-controller/stack-check.h +++ b/stm-firmware/include/reflow-controller/stack-check.h @@ -29,6 +29,18 @@ int32_t stack_check_get_usage(); int32_t stack_check_get_free(); +static inline int stack_check_collision() +{ + int ret = 0; + int32_t free_space = stack_check_get_free(); + + if ((unsigned int)free_space < STACK_CHECK_MIN_HEAP_GAP) { + ret = -1; + } + + return ret; +} + static inline uint32_t read_stack_pointer() { uint32_t stack_pointer; From ffe195d7b27faef5c7b3a8fa161c75a58110a672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 18:09:39 +0200 Subject: [PATCH 03/10] ADC Measurment: Introduce ADC_PT1000_WATCHDOG_SAMPLE_COUNT in order to filter out false Watchdog errors produces by EMI problems" --- stm-firmware/adc-meas.c | 9 ++++++++- stm-firmware/include/reflow-controller/adc-meas.h | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/stm-firmware/adc-meas.c b/stm-firmware/adc-meas.c index 1699efb..2323291 100644 --- a/stm-firmware/adc-meas.c +++ b/stm-firmware/adc-meas.c @@ -322,6 +322,7 @@ static inline __attribute__((optimize("O3"))) float adc_pt1000_dma_avg_pre_filte void ADC_IRQHandler(void) { uint32_t adc1_sr; + static uint32_t watchdog_errors; adc1_sr = ADC1->SR; @@ -330,11 +331,17 @@ void ADC_IRQHandler(void) pt1000_error |= ADC_PT1000_OVERFLOW; /* Disable ADC in case of overrrun*/ adc_pt1000_disable(); + + if (!(adc1_sr & ADC_SR_AWD)) { + watchdog_errors = 0; + } } if (adc1_sr & ADC_SR_AWD) { ADC1->SR &= ~ADC_SR_AWD; - pt1000_error |= ADC_PT1000_WATCHDOG_ERROR; + watchdog_errors++; + if (watchdog_errors >= ADC_PT1000_WATCHDOG_SAMPLE_COUNT) + pt1000_error |= ADC_PT1000_WATCHDOG_ERROR; } } diff --git a/stm-firmware/include/reflow-controller/adc-meas.h b/stm-firmware/include/reflow-controller/adc-meas.h index b850962..d9b0a31 100644 --- a/stm-firmware/include/reflow-controller/adc-meas.h +++ b/stm-firmware/include/reflow-controller/adc-meas.h @@ -59,6 +59,12 @@ */ #define ADC_PT1000_UPPER_WATCHDOG 4000U +/** + * @brief Number of ADC samples the value has to be outside the Watchdog limit (@ref ADC_PT1000_UPPER_WATCHDOG and @ref ADC_PT1000_LOWER_WATCHDOG) + * in order to produce a watchdog error + */ +#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 10U + enum adc_pt1000_error {ADC_PT1000_NO_ERR= 0, ADC_PT1000_WATCHDOG_ERROR=(1UL<<0), ADC_PT1000_OVERFLOW=(1UL<<1), ADC_PT1000_INACTIVE = (1UL<<2)}; /** From 5ae31a17057f34bb1349a890116bdb67e7ce0d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 19:20:45 +0200 Subject: [PATCH 04/10] Increase ADC_PT1000_WATCHDOG_SAMPLE_COUNT to 50 --- stm-firmware/include/reflow-controller/adc-meas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/include/reflow-controller/adc-meas.h b/stm-firmware/include/reflow-controller/adc-meas.h index d9b0a31..12f7dcd 100644 --- a/stm-firmware/include/reflow-controller/adc-meas.h +++ b/stm-firmware/include/reflow-controller/adc-meas.h @@ -63,7 +63,7 @@ * @brief Number of ADC samples the value has to be outside the Watchdog limit (@ref ADC_PT1000_UPPER_WATCHDOG and @ref ADC_PT1000_LOWER_WATCHDOG) * in order to produce a watchdog error */ -#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 10U +#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 50U enum adc_pt1000_error {ADC_PT1000_NO_ERR= 0, ADC_PT1000_WATCHDOG_ERROR=(1UL<<0), ADC_PT1000_OVERFLOW=(1UL<<1), ADC_PT1000_INACTIVE = (1UL<<2)}; From 85fe0f67497230a0495c8554b11f40b2fa8b9592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 19:52:48 +0200 Subject: [PATCH 05/10] Fix LEDs in ptdump command --- stm-firmware/shell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index b4cd5da..9c54313 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -274,8 +274,11 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t shellmatta_printf(handle, "\x1b[1A\x1b[150D\x1b[K"); shell_cmd_pt1000_res(handle, "", 0UL); - led_set(0, led_status); - led_set(1, !led_status); + led_set(1, led_status); + if (adc_pt1000_check_error() & ADC_PT1000_WATCHDOG_ERROR) { + led_set(0, 1); + } + led_status ^= 0x1; systick_wait_ms(150); From 2d3b61550bdded263cd1f33e9ce94fc08a9d7312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 19:53:06 +0200 Subject: [PATCH 06/10] Fix ADC Watchdog handling --- stm-firmware/adc-meas.c | 13 ++++++------- stm-firmware/include/reflow-controller/adc-meas.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/stm-firmware/adc-meas.c b/stm-firmware/adc-meas.c index 2323291..2ea8762 100644 --- a/stm-firmware/adc-meas.c +++ b/stm-firmware/adc-meas.c @@ -36,6 +36,7 @@ static volatile int * volatile streaming_flag_ptr = NULL; static uint32_t filter_startup_cnt; static volatile float adc_pt1000_raw_reading_hf; static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES]; +static volatile uint32_t adc_watchdog_counter = 0UL; volatile float * volatile stream_buffer = NULL; volatile uint32_t stream_count; @@ -322,7 +323,6 @@ static inline __attribute__((optimize("O3"))) float adc_pt1000_dma_avg_pre_filte void ADC_IRQHandler(void) { uint32_t adc1_sr; - static uint32_t watchdog_errors; adc1_sr = ADC1->SR; @@ -331,16 +331,12 @@ void ADC_IRQHandler(void) pt1000_error |= ADC_PT1000_OVERFLOW; /* Disable ADC in case of overrrun*/ adc_pt1000_disable(); - - if (!(adc1_sr & ADC_SR_AWD)) { - watchdog_errors = 0; - } } if (adc1_sr & ADC_SR_AWD) { ADC1->SR &= ~ADC_SR_AWD; - watchdog_errors++; - if (watchdog_errors >= ADC_PT1000_WATCHDOG_SAMPLE_COUNT) + adc_watchdog_counter++; + if (adc_watchdog_counter >= ADC_PT1000_WATCHDOG_SAMPLE_COUNT) pt1000_error |= ADC_PT1000_WATCHDOG_ERROR; } } @@ -376,6 +372,9 @@ void DMA2_Stream0_IRQHandler() if (streaming_flag_ptr) append_stream_buffer(adc_val); + if (adc_watchdog_counter > 0UL) + adc_watchdog_counter--; + /* Call moving average filter */ adc_pt1000_filter(adc_val); } diff --git a/stm-firmware/include/reflow-controller/adc-meas.h b/stm-firmware/include/reflow-controller/adc-meas.h index 12f7dcd..8a06231 100644 --- a/stm-firmware/include/reflow-controller/adc-meas.h +++ b/stm-firmware/include/reflow-controller/adc-meas.h @@ -63,7 +63,7 @@ * @brief Number of ADC samples the value has to be outside the Watchdog limit (@ref ADC_PT1000_UPPER_WATCHDOG and @ref ADC_PT1000_LOWER_WATCHDOG) * in order to produce a watchdog error */ -#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 50U +#define ADC_PT1000_WATCHDOG_SAMPLE_COUNT 25U enum adc_pt1000_error {ADC_PT1000_NO_ERR= 0, ADC_PT1000_WATCHDOG_ERROR=(1UL<<0), ADC_PT1000_OVERFLOW=(1UL<<1), ADC_PT1000_INACTIVE = (1UL<<2)}; From cf3818040c6a5d339d725480cc615cf1586f016f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 20:20:57 +0200 Subject: [PATCH 07/10] Add support for subdirectories in create-c-file script --- stm-firmware/create-c-file-with-header.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stm-firmware/create-c-file-with-header.py b/stm-firmware/create-c-file-with-header.py index 67176c1..5ad8c48 100755 --- a/stm-firmware/create-c-file-with-header.py +++ b/stm-firmware/create-c-file-with-header.py @@ -2,6 +2,7 @@ import os import sys +import pathlib license_header = """/* Reflow Oven Controller * @@ -22,7 +23,6 @@ license_header = """/* Reflow Oven Controller * along with the reflow oven controller project. * If not, see . */ - """ project_dir = os.path.dirname(os.path.realpath(__file__)) @@ -37,19 +37,23 @@ cpath = os.path.join(project_dir, sys.argv[1]+'.c') hfile = sys.argv[1]+'.h' hpath = os.path.join(module_include_dir, hfile) -h_define = '__'+hfile.replace('.', '_').replace('-', '_').upper()+'__' +h_define = '__'+hfile.replace('.', '_').replace('-', '_').replace('/', '_').upper()+'__' if os.path.exists(cpath) or os.path.exists(hpath): print("File already exists! Abort!") sys.exit() print('Creating C file: %s' % (cpath)) +cfile_folder = os.path.dirname(cpath) +pathlib.Path(cfile_folder).mkdir(parents=True, exist_ok=True) with open(cpath, 'x') as f: f.write(license_header) f.write('\n') f.write('#include <%s>' % (os.path.join(include_prefix, hfile))) print('Creating H file: %s' % (hpath)) +hfile_folder = os.path.dirname(hpath) +pathlib.Path(hfile_folder).mkdir(parents=True, exist_ok=True) with open(hpath, 'x') as f: f.write(license_header) f.write('\n') From 6e07a363f4e2e6c1bcc5c517a6b4367d0c508d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 20:21:13 +0200 Subject: [PATCH 08/10] Add settings module --- stm-firmware/Makefile | 12 +-------- .../settings/settings-sd-card.h | 24 ++++++++++++++++++ .../reflow-controller/settings/settings.h | 25 +++++++++++++++++++ stm-firmware/settings/settings-sd-card.c | 21 ++++++++++++++++ stm-firmware/settings/settings.c | 21 ++++++++++++++++ 5 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 stm-firmware/include/reflow-controller/settings/settings-sd-card.h create mode 100644 stm-firmware/include/reflow-controller/settings/settings.h create mode 100644 stm-firmware/settings/settings-sd-card.c create mode 100644 stm-firmware/settings/settings.c diff --git a/stm-firmware/Makefile b/stm-firmware/Makefile index fc35fde..337c6b3 100644 --- a/stm-firmware/Makefile +++ b/stm-firmware/Makefile @@ -34,26 +34,16 @@ DEFINES += -DSHELLMATTA_HELP_ALIAS=\"?\" # RCC Manager CFILES += stm-periph/clock-enable-manager.c - CFILES += stm-periph/uart.c stm-periph/dma-ring-buffer.c - CFILES += digio.c - CFILES += stm-periph/unique-id.c - CFILES += calibration.c - CFILES += temp-converter.c - CFILES += rotary-encoder.c - CFILES += stack-check.c - -#CFILES += onewire-temp-sensors.c - CFILES += fatfs/diskio.c fatfs/ff.c fatfs/ffsystem.c fatfs/ffunicode.c fatfs/shimatta_sdio_driver/shimatta_sdio.c - CFILES += pid-controller.c oven-driver.c +CFILES += settings/settings.c settings-sd-card.c DEFINES += -DDEBUGBUILD diff --git a/stm-firmware/include/reflow-controller/settings/settings-sd-card.h b/stm-firmware/include/reflow-controller/settings/settings-sd-card.h new file mode 100644 index 0000000..c657069 --- /dev/null +++ b/stm-firmware/include/reflow-controller/settings/settings-sd-card.h @@ -0,0 +1,24 @@ +/* Reflow Oven Controller +* +* Copyright (C) 2020 Mario Hüttel +* +* This file is part of the Reflow Oven Controller Project. +* +* The reflow oven controller is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with the reflow oven controller project. +* If not, see . +*/ + +#ifndef __SETTINGS_SETTINGS_SD_CARD_H__ +#define __SETTINGS_SETTINGS_SD_CARD_H__ + +#endif /* __SETTINGS_SETTINGS_SD_CARD_H__ */ diff --git a/stm-firmware/include/reflow-controller/settings/settings.h b/stm-firmware/include/reflow-controller/settings/settings.h new file mode 100644 index 0000000..dcb43dd --- /dev/null +++ b/stm-firmware/include/reflow-controller/settings/settings.h @@ -0,0 +1,25 @@ +/* Reflow Oven Controller +* +* Copyright (C) 2020 Mario Hüttel +* +* This file is part of the Reflow Oven Controller Project. +* +* The reflow oven controller is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with the reflow oven controller project. +* If not, see . +*/ + + +#ifndef __SETTINGS_SETTINGS_H__ +#define __SETTINGS_SETTINGS_H__ + +#endif /* __SETTINGS_SETTINGS_H__ */ diff --git a/stm-firmware/settings/settings-sd-card.c b/stm-firmware/settings/settings-sd-card.c new file mode 100644 index 0000000..5239091 --- /dev/null +++ b/stm-firmware/settings/settings-sd-card.c @@ -0,0 +1,21 @@ +/* Reflow Oven Controller +* +* Copyright (C) 2020 Mario Hüttel +* +* This file is part of the Reflow Oven Controller Project. +* +* The reflow oven controller is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with the reflow oven controller project. +* If not, see . +*/ + +#include diff --git a/stm-firmware/settings/settings.c b/stm-firmware/settings/settings.c new file mode 100644 index 0000000..07643ce --- /dev/null +++ b/stm-firmware/settings/settings.c @@ -0,0 +1,21 @@ +/* Reflow Oven Controller +* +* Copyright (C) 2020 Mario Hüttel +* +* This file is part of the Reflow Oven Controller Project. +* +* The reflow oven controller is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with the reflow oven controller project. +* If not, see . +*/ + +#include From 4df68880f00f1e2ec65c4d7283c705c1523e2e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 21:23:25 +0200 Subject: [PATCH 09/10] Add correct handling of sd card, add reset command, add ls command --- stm-firmware/Makefile | 2 +- .../shimatta_sdio_driver/shimatta_sdio.c | 6 +- .../shimatta_sdio_driver/shimatta_sdio.h | 2 + .../shimatta_sdio_config.h | 10 +-- .../reflow-controller/settings/settings.h | 2 + .../include/reflow-controller/shell.h | 2 + stm-firmware/main.c | 34 +++++++++- stm-firmware/shell.c | 66 ++++++++++++++++++- 8 files changed, 111 insertions(+), 13 deletions(-) diff --git a/stm-firmware/Makefile b/stm-firmware/Makefile index 337c6b3..1f93bdd 100644 --- a/stm-firmware/Makefile +++ b/stm-firmware/Makefile @@ -43,7 +43,7 @@ CFILES += rotary-encoder.c CFILES += stack-check.c CFILES += fatfs/diskio.c fatfs/ff.c fatfs/ffsystem.c fatfs/ffunicode.c fatfs/shimatta_sdio_driver/shimatta_sdio.c CFILES += pid-controller.c oven-driver.c -CFILES += settings/settings.c settings-sd-card.c +CFILES += settings/settings.c settings/settings-sd-card.c DEFINES += -DDEBUGBUILD diff --git a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c index 4867957..d764419 100644 --- a/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c +++ b/stm-firmware/fatfs/shimatta_sdio_driver/shimatta_sdio.c @@ -32,9 +32,9 @@ static struct sd_info card_info; // = {.type = CARD_NONE}; * @brief checkNotInserted * @return return 0 if card is inserted, else 1 */ -static int sdio_check_inserted() { +int sdio_check_inserted() { #if SDIO_ENABLE_INS - return ((INS_PORT->IDR & INS_PIN) == (INS_ACTIVE_LEVEL<IDR & (1<IDR & WRITEPROT_PIN) == (WRITEPROT_ACTIVE_LEVEL<IDR & (1< #include #include +#include "fatfs/shimatta_sdio_driver/shimatta_sdio.h" #include #include #include @@ -60,6 +61,9 @@ static uint32_t rot; static volatile float pid_out; static volatile float current_temperature; +FATFS fs; +FATFS *fs_ptr = &fs; + static inline void uart_gpio_config() { #ifdef DEBUGBUILD @@ -104,11 +108,32 @@ static inline void setup_sell_uart(struct stm_uart *uart) NVIC_EnableIRQ(DMA2_Stream7_IRQn); } +static bool mount_sd_card_if_avail(bool mounted) +{ + FRESULT res; + + if (sdio_check_inserted() && mounted) { + memset(fs_ptr, 0, sizeof(FATFS)); + return false; + } + + if (!sdio_check_inserted() && !mounted) { + res = f_mount(fs_ptr, "0:/", 1); + if (res == FR_OK) { + return true; + } else { + return false; + } + } + + return mounted; +} + const char *oven_controller_hello_world = "Hello world :)\n"; int main() { - FATFS fs; + bool sd_card_mounted = false; FIL test_file; const char *uart_input; size_t uart_input_len; @@ -132,8 +157,10 @@ int main() setup_sell_uart(&shell_uart); shell_handle = shell_init(write_shell_callback); + shell_print_motd(shell_handle); - if (f_mount(&fs, "0:/", 1) == FR_OK) { + if (f_mount(fs_ptr, "0:/", 1) == FR_OK) { + sd_card_mounted = true; f_open(&test_file, "hello-world.txt", FA_OPEN_APPEND | FA_WRITE); f_write(&test_file, oven_controller_hello_world, strlen(oven_controller_hello_world), NULL); f_close(&test_file); @@ -143,6 +170,9 @@ int main() pid_zero(&pid); while (1) { + + sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted); + pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value); if (pt1000_value_status >= 0) { diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index 9c54313..254d08b 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -18,6 +18,8 @@ * If not, see . */ +#include +#include #include #include #include @@ -30,7 +32,7 @@ #include #include #include - +#include #include #include @@ -290,6 +292,43 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t return SHELLMATTA_OK; } +static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const char *arguments, + uint32_t length) +{ + (void)length; + (void)arguments; + DIR dir; + FRESULT res; + FILINFO fno; + + res = f_opendir(&dir, "/"); + if (res != FR_OK) { + shellmatta_printf(handle, "Filesystem inaccessible. Is an SD Card inserted?\r\n"); + return SHELLMATTA_OK; + } + + while (f_readdir(&dir, &fno) == FR_OK) { + if (fno.fname[0] == 0) + break; + shellmatta_printf(handle, "%c\t%s\r\n", (fno.fattrib & AM_DIR ? 'd' : 'f'), fno.fname); + } + + f_closedir(&dir); + + return SHELLMATTA_OK; +} + +static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, const char *arguments, + uint32_t length) +{ + (void)handle; + (void)length; + (void)arguments; + + NVIC_SystemReset(); + + return SHELLMATTA_BUSY; +} //typedef struct shellmatta_cmd //{ // char *cmd; /**< command name */ @@ -300,7 +339,7 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t // struct shellmatta_cmd *next; /**< pointer to next command or NULL */ //} shellmatta_cmd_t; -static shellmatta_cmd_t cmd[10] = { +static shellmatta_cmd_t cmd[12] = { { .cmd = "version", .cmdAlias = "ver", @@ -379,8 +418,25 @@ static shellmatta_cmd_t cmd[10] = { .helpText = "Get current rotary encoder value", .usageText = "", .cmdFct = shell_cmd_rot, + .next = &cmd[10], + }, + { + .cmd = "ls", + .cmdAlias = NULL, + .helpText = "List filesystem contents", + .usageText = "", + .cmdFct = shell_cmd_ls, + .next = &cmd[11], + }, + { + .cmd = "reset", + .cmdAlias = NULL, + .helpText = "Reset controller", + .usageText = "Resets the controller", + .cmdFct = shell_cmd_reset, .next = NULL, } + }; shellmatta_handle_t shell_init(shellmatta_write_t write_func) @@ -396,6 +452,12 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func) return handle; } +void shell_print_motd(shellmatta_handle_t shell) +{ + shellmatta_printf(shell, "\r\nShimatta 仕舞った Reflow Controller ready\r\n\r\n"); + shell_cmd_ver(shell, NULL, 0UL); + shell_handle_input(shell, "\r\n", 2UL); +} void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len) { From 9761204b08e039f894fab6888fb95dc4d50d59c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 26 Apr 2020 22:25:50 +0200 Subject: [PATCH 10/10] Update shellmatta to newest version --- stm-firmware/shellmatta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/shellmatta b/stm-firmware/shellmatta index 6c76dfc..ebf65d7 160000 --- a/stm-firmware/shellmatta +++ b/stm-firmware/shellmatta @@ -1 +1 @@ -Subproject commit 6c76dfc7aed2594579f09d0b797d6a51cffff343 +Subproject commit ebf65d744838a5c7bbf6ddfff6cb4428f012fd97