diff --git a/Control/firmware/uart_echo/main.c b/Control/firmware/uart_echo/main.c index a738256..eb97200 100755 --- a/Control/firmware/uart_echo/main.c +++ b/Control/firmware/uart_echo/main.c @@ -130,7 +130,7 @@ int main(void) if (c == 0x0A || c == 0x0D) { PRINT_PROMPT; - if (cmdStrSize < 2) + if (cmdStrSize < 1) { break; } @@ -154,6 +154,14 @@ int main(void) timer_start(TIMER_TIMEOUT, TIMER_SW_DELAY_MS(5000)); state_next = StateRemote; } + + // Switch Control + if (toupper(cmdStr[0]) == 'X') + { + timer_stop(TIMER_TIMEOUT); + setPower(PowerLow); + setSwitch(SwitchOff); + } } cmdStrSize = 0; } diff --git a/Control/firmware/uart_echo/timer.c b/Control/firmware/uart_echo/timer.c index 0a2985b..25f12f3 100644 --- a/Control/firmware/uart_echo/timer.c +++ b/Control/firmware/uart_echo/timer.c @@ -57,3 +57,9 @@ void timer_start(TimerId timerId, uint16_t count) exitCritial(); } +void timer_stop(TimerId timerId) +{ + enterCritical(); + user_timer[timerId].isRunning = 0; + exitCritial(); +} diff --git a/Control/firmware/uart_echo/timer.h b/Control/firmware/uart_echo/timer.h index 7e659a8..a95eb10 100644 --- a/Control/firmware/uart_echo/timer.h +++ b/Control/firmware/uart_echo/timer.h @@ -20,8 +20,8 @@ typedef enum _eTimerId typedef struct _sTimer_t { - int isRunning; - uint16_t count; + volatile int isRunning; + volatile uint16_t count; } Timer_t; typedef enum _eTimerClockSel @@ -39,4 +39,5 @@ typedef enum _eTimerClockSel void timer_init(Fifo *pFifo, uint16_t TIMER_RELOAD, TimerClockSel clockSel); void timer_start(TimerId timerId, uint16_t count); +void timer_stop(TimerId timerId); #endif /* TIMER_H_ */ \ No newline at end of file