From 4f2bf43ec7bda49ed16592f5c81e86f1914af3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Thu, 5 Aug 2021 19:05:16 +0100 Subject: [PATCH 1/7] [fw] fix issue with long press not working when a switch is pressed --- Firmware/Pump/app.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Firmware/Pump/app.c b/Firmware/Pump/app.c index 0c0f503..727a849 100644 --- a/Firmware/Pump/app.c +++ b/Firmware/Pump/app.c @@ -301,13 +301,6 @@ void core_callback_t_before_exec(void) clear_but_push(); if(read_BUT_PULL) clear_but_pull(); - - // update switches initial state - if(read_SW_F) - switch_pressed(DIR_FORWARD); - - if(read_SW_R) - switch_pressed(DIR_REVERSE); if(running_protocol) { From e2946e84feb9d32830f8f8f67199967c55a238f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Thu, 5 Aug 2021 19:09:56 +0100 Subject: [PATCH 2/7] [fw] remove variables duplication --- Firmware/Pump/interrupts.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Firmware/Pump/interrupts.c b/Firmware/Pump/interrupts.c index 466b194..481ed01 100644 --- a/Firmware/Pump/interrupts.c +++ b/Firmware/Pump/interrupts.c @@ -135,24 +135,20 @@ ISR(PORTC_INT0_vect, ISR_NAKED) /************************************************************************/ /* EN_DRIVER_UC & BUT_PUSH & BUT_PULL & BUT_RESET */ /************************************************************************/ -extern uint8_t but_push_counter_ms; -extern uint16_t but_long_push_counter_ms; -extern uint8_t but_pull_counter_ms; -extern uint16_t but_long_pull_counter_ms; extern uint8_t but_reset_counter_ms; +extern void clear_but_push(); +extern void clear_but_pull(); ISR(PORTD_INT0_vect, ISR_NAKED) { if(!(read_BUT_PUSH)) { - but_push_counter_ms = 25; - but_long_push_counter_ms = 500; + clear_but_push(); } if(!(read_BUT_PULL)) { - but_pull_counter_ms = 25; - but_long_pull_counter_ms = 500; + clear_but_pull(); } if(!(read_BUT_RESET)) From 06cd4f9295050b18f3760e65417f177b4f99e269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Thu, 5 Aug 2021 19:11:14 +0100 Subject: [PATCH 3/7] [fw] remove unnecessary code --- Firmware/Pump/app.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Firmware/Pump/app.c b/Firmware/Pump/app.c index 727a849..2008f31 100644 --- a/Firmware/Pump/app.c +++ b/Firmware/Pump/app.c @@ -372,8 +372,6 @@ void core_callback_t_before_exec(void) app_write_REG_DIR_STATE(&app_regs.REG_DIR_STATE); app_write_REG_STEP_STATE(&app_regs.REG_STEP_STATE); } - - return; } } } From 796604c3990f52c93b75eb930b14ca774cc9701a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Mon, 16 Aug 2021 14:27:47 +0100 Subject: [PATCH 4/7] [fw] send DIR event on every change and not depend on enabled motor --- Firmware/Pump/app_funcs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Firmware/Pump/app_funcs.c b/Firmware/Pump/app_funcs.c index 00daa70..b0d920a 100644 --- a/Firmware/Pump/app_funcs.c +++ b/Firmware/Pump/app_funcs.c @@ -167,11 +167,8 @@ bool app_write_REG_DIR_STATE(void *a) if(reg != curr_dir) { curr_dir = reg; - if(app_regs.REG_ENABLE_MOTOR_DRIVER == B_MOTOR_ENABLE) - { - if(app_regs.REG_EVT_ENABLE & B_EVT_DIR_STATE) - core_func_send_event(ADD_REG_DIR_STATE, true); - } + if(app_regs.REG_EVT_ENABLE & B_EVT_DIR_STATE) + core_func_send_event(ADD_REG_DIR_STATE, true); } if(curr_dir) From 964d47b625d6e7da5510208d85180bf120e827f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Mon, 16 Aug 2021 14:28:07 +0100 Subject: [PATCH 5/7] [fw] fix wrong DIR on explicit change --- Firmware/Pump/app_funcs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/Pump/app_funcs.c b/Firmware/Pump/app_funcs.c index b0d920a..ba11a9b 100644 --- a/Firmware/Pump/app_funcs.c +++ b/Firmware/Pump/app_funcs.c @@ -164,6 +164,8 @@ bool app_write_REG_DIR_STATE(void *a) { uint8_t reg = *((uint8_t*)a); + app_regs.REG_DIR_STATE = reg; + if(reg != curr_dir) { curr_dir = reg; @@ -176,7 +178,6 @@ bool app_write_REG_DIR_STATE(void *a) else clr_DIR; - app_regs.REG_DIR_STATE = reg; return true; } From fcafb090f66c0467c53df5a6afa6f40c4b380c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Mon, 16 Aug 2021 14:28:37 +0100 Subject: [PATCH 6/7] [fw] fix switch pressed initial state on boot --- Firmware/Pump/app.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Firmware/Pump/app.c b/Firmware/Pump/app.c index 2008f31..f25b8ef 100644 --- a/Firmware/Pump/app.c +++ b/Firmware/Pump/app.c @@ -228,13 +228,6 @@ void core_callback_reset_registers(void) // TODO: missing calibration values app_regs.REG_EVT_ENABLE = (B_EVT_STEP_STATE | B_EVT_DIR_STATE | B_EVT_SW_FORWARD_STATE | B_EVT_SW_REVERSE_STATE | B_EVT_INPUT_STATE | B_EVT_PROTOCOL_STATE); - - // update switches initial state - if(read_SW_F) - switch_pressed(DIR_FORWARD); - - if(read_SW_R) - switch_pressed(DIR_REVERSE); } void core_callback_registers_were_reinitialized(void) @@ -261,6 +254,13 @@ void core_callback_registers_were_reinitialized(void) app_write_REG_MOTOR_MICROSTEP(&app_regs.REG_MOTOR_MICROSTEP); clr_EN_DRIVER; + + // update switches initial state + if(read_SW_F) + switch_pressed(DIR_FORWARD); + + if(read_SW_R) + switch_pressed(DIR_REVERSE); } /************************************************************************/ From adbb9823b193c6e2f3a18e0c1c6f5d142f5bcb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Teixeira?= Date: Mon, 16 Aug 2021 15:28:05 +0100 Subject: [PATCH 7/7] [fw] update firmware version --- Firmware/Pump/app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Pump/app.c b/Firmware/Pump/app.c index f25b8ef..1c5045b 100644 --- a/Firmware/Pump/app.c +++ b/Firmware/Pump/app.c @@ -28,9 +28,9 @@ void hwbp_app_initialize(void) { /* Define versions */ uint8_t hwH = 1; - uint8_t hwL = 0; + uint8_t hwL = 1; uint8_t fwH = 0; - uint8_t fwL = 1; + uint8_t fwL = 2; uint8_t ass = 0; /* Start core */