From 3f1a3107d81a696b9dedc48c1a9bbc8029682c6b Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Sun, 22 Apr 2012 00:10:04 +0200 Subject: digital/beacon: add motor control to the debug menu & display motor state in the debug task --- digital/beacon/src/debug_avr.c | 5 +++++ digital/beacon/src/motor.c | 10 ++++++++++ digital/beacon/src/motor.h | 3 +++ 3 files changed, 18 insertions(+) (limited to 'digital') diff --git a/digital/beacon/src/debug_avr.c b/digital/beacon/src/debug_avr.c index 00568628..284d1fbf 100644 --- a/digital/beacon/src/debug_avr.c +++ b/digital/beacon/src/debug_avr.c @@ -32,6 +32,7 @@ #include "codewheel.h" #include "laser.h" #include "network.h" +#include "motor.h" HAL_UsartDescriptor_t appUsartDescriptor; // USART descriptor (required by stack) HAL_AppTimer_t debugTimer; // TIMER descripor used by the DEBUG task @@ -136,6 +137,9 @@ void usartRXCallback(uint16_t bytesToRead) led_off(2); led_off(3); break; + case 't': + motor_start_stop_control(); + break; /* Default */ default : uprintf(" ?? Unknown command ??\r\n"); @@ -222,5 +226,6 @@ void debug_task(void) uprintf("[2] Scanning State = %d -- Value = %d\r\n",servo_get_state(SERVO_2),servo_get_value(SERVO_2)); uprintf("CodeWheel = %d\r\n",codewheel_get_value()); uprintf("Calibration state = %d\r\n",calibration_get_state()); + uprintf("Motor state = %d\r\n",motor_get_state()); #endif } diff --git a/digital/beacon/src/motor.c b/digital/beacon/src/motor.c index 907559ea..330a861c 100644 --- a/digital/beacon/src/motor.c +++ b/digital/beacon/src/motor.c @@ -50,3 +50,13 @@ TMotor_state motor_get_state(void) else return MOTOR_STOPPED; } + +/* This function starts or stops the motor according to the current state */ +void motor_start_stop_control(void) +{ + + if(motor_get_state == MOTOR_IN_ROTATION) + motor_stop(); + else + motor_start(); +} diff --git a/digital/beacon/src/motor.h b/digital/beacon/src/motor.h index 9c02d2a3..c0b2c4f0 100644 --- a/digital/beacon/src/motor.h +++ b/digital/beacon/src/motor.h @@ -44,4 +44,7 @@ void motor_stop(void); /* This function returns the motor state */ TMotor_state motor_get_state(void); +/* This function starts or stops the motor according to the current state */ +void motor_start_stop_control(void); + #endif -- cgit v1.2.3