summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018/stepper.c
diff options
context:
space:
mode:
Diffstat (limited to 'usb-i2c-sl018/stepper.c')
-rw-r--r--usb-i2c-sl018/stepper.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usb-i2c-sl018/stepper.c b/usb-i2c-sl018/stepper.c
index f8f2991..4258da7 100644
--- a/usb-i2c-sl018/stepper.c
+++ b/usb-i2c-sl018/stepper.c
@@ -95,8 +95,11 @@ void init_stepper(void)
STEPPER_DDR |= (0xF << STEPPER_FIRST_BIT) | (1<<STEPPER_ENABLE_BIT);
}
-void start_stepper(stepper_direction_t direction)
+uint8_t start_stepper(stepper_direction_t direction)
{
+ if(TCCR1B)
+ return 0;
+
step_cnt = 0;
step_direction = direction;
STEPPER_PORT |= 1<<STEPPER_ENABLE_BIT;
@@ -108,6 +111,8 @@ void start_stepper(stepper_direction_t direction)
//OCR1A = 155; // (1+155)*256 = 40000 -> 2 ms @ 20 MHz
TCNT1 = 0; // reseting timer
TIMSK1 = 1<<OCIE1A; // enable Interrupt
+
+ return 1;
}