#define M_RESET 3\r
#define M_FULLSTEPS 4\r
\r
-static uint8_t m_clk_divisor_ = 0;\r
+#define M_START_DIVISOR 2;\r
+\r
+static uint8_t cur_speed = 0xFF - M_START_DIVISOR;\r
+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
\r
m_clk_divisor_counter_--;\r
}\r
\r
+static char set_speed_msg[] = "m_clk_divisor_ = %d\n\r";\r
+\r
void motor_set_speed(uint8_t speed)\r
{\r
m_clk_divisor_ = 0xFF - speed;\r
- CDC_Device_SendString(&VirtualSerial_CDC_Interface, "m_clk_divisor_ = %d\n",m_clk_divisor_);\r
+ char tmp[sizeof(set_speed_msg)+4];\r
+ sprintf(tmp, set_speed_msg,m_clk_divisor_);\r
+ CDC_Device_SendString(&VirtualSerial_CDC_Interface, tmp);\r
}\r
\r
void motor_run(uint16_t steps, uint8_t direction)\r
OCR0A = 255; // (1+139)*8 = 1120 -> 70us @ 16 MHz -> 1*alpha\r
}\r
\r
-uint8_t cur_speed = 0xFF;\r
void handle_cmd(uint8_t cmd)\r
{\r
switch(cmd) {\r
case 'W': motor_run(300,1); 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"); return;\r
+ default: CDC_Device_SendString(&VirtualSerial_CDC_Interface, "error\n\r"); return;\r
}\r
- CDC_Device_SendString(&VirtualSerial_CDC_Interface, "ok\n");\r
+ CDC_Device_SendString(&VirtualSerial_CDC_Interface, "ok\n\r");\r
}\r
\r
\r