static uint8_t m_clk_divisor_ = M_START_DIVISOR;\r
static uint8_t m_clk_divisor_counter_ = 0;\r
static uint16_t m_steps_to_go_ = 0;\r
+static uint16_t m_steps_to_go_back_ = 0;\r
\r
inline void m_timer_enable(void)\r
{\r
m_timer_disable();\r
M_PORT &= ~(1 << M_ENABLE);\r
m_steps_to_go_ = 0;\r
+ m_steps_to_go_back_ = 0;\r
}\r
\r
ISR(TIMER0_OVF_vect)\r
{\r
if (m_steps_to_go_ == 0)\r
- motor_stop();\r
+ {\r
+ if(m_steps_to_go_back_)\r
+ { \r
+ M_PORT ^= (1 << M_DIRECTION);\r
+ m_steps_to_go_=m_steps_to_go_back_;\r
+ m_steps_to_go_back_=0;\r
+ } else \r
+ motor_stop();\r
+ } \r
if (m_clk_divisor_counter_ == 0)\r
{\r
m_clk_divisor_counter_ = m_clk_divisor_;\r
CDC_Device_SendString(&VirtualSerial_CDC_Interface, tmp);\r
}\r
\r
-void motor_run(uint16_t steps, uint8_t direction)\r
+void motor_run(uint16_t steps, uint8_t direction,uint16_t steps_back)\r
{\r
//reset by pulling reset low for 100ms\r
M_PORT &= ~(1 << M_RESET);\r
\r
m_clk_divisor_counter_ = 0;\r
m_steps_to_go_ = steps;\r
+ m_steps_to_go_back_ = steps_back;\r
\r
if (direction)\r
M_PORT |= (1 << M_DIRECTION);\r
case 't': led_toggle(); break;\r
case 'r': reset2bootloader(); break;\r
case 's': motor_stop(); break;\r
- case 'c': motor_run(50,0); break;\r
- case 'w': motor_run(50,1); break;\r
- case 'C': motor_run(300,0); break;\r
- case 'W': motor_run(300,1); break;\r
+ case 'y': motor_run(30,0,20); break;\r
+ case 'x': motor_run(140,0,40); break;\r
+ case 'c': motor_run(60,0,20); break;\r
+ case 'v': motor_run(40,0,20); break;\r
+ case 'q': motor_run(140,1,40); break;\r
+ case 'w': motor_run(60,1,20); break;\r
+ case 'e': motor_run(40,1,20); break;\r
+ case 'C': motor_run(330,0,40); break;\r
+ case 'W': motor_run(330,1,40); break;\r
case '+': motor_set_speed(++cur_speed); break;\r
case '-': motor_set_speed(--cur_speed); break;\r
default: CDC_Device_SendString(&VirtualSerial_CDC_Interface, "error\n\r"); return;\r