diff --git a/Firmware/Pump/app.c b/Firmware/Pump/app.c index 0c0f503..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 */ @@ -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); } /************************************************************************/ @@ -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) { @@ -379,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; } } } diff --git a/Firmware/Pump/app_funcs.c b/Firmware/Pump/app_funcs.c index 00daa70..ba11a9b 100644 --- a/Firmware/Pump/app_funcs.c +++ b/Firmware/Pump/app_funcs.c @@ -164,14 +164,13 @@ 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; - 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) @@ -179,7 +178,6 @@ bool app_write_REG_DIR_STATE(void *a) else clr_DIR; - app_regs.REG_DIR_STATE = reg; return true; } 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))