summaryrefslogtreecommitdiff
path: root/tube-rotator
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-05-20 03:17:50 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-05-20 03:17:50 +0200
commitfbf5b3887cd720430477729e2505951e7eefdcd5 (patch)
treea0d0f18e80b48bb934e26c642ef90e57a7f55cd1 /tube-rotator
parentadded conversion from speed value to rpm (diff)
prevent stepper from being reastarted if already running
Diffstat (limited to 'tube-rotator')
-rw-r--r--tube-rotator/stepper.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tube-rotator/stepper.c b/tube-rotator/stepper.c
index a498b43..2de1fc2 100644
--- a/tube-rotator/stepper.c
+++ b/tube-rotator/stepper.c
@@ -49,6 +49,7 @@ uint8_t step_table [] =
volatile uint16_t target_speed;
uint16_t current_speed;
+uint8_t running;
void stepper_init(void)
{
@@ -60,6 +61,8 @@ void stepper_init(void)
void stepper_start(void)
{
+ if(running) return;
+
current_speed = STEPPER_SPEED_MIN;
STEPPER_PORT |= (1<<STEPPER_ENABLE_A_BIT) | (1<<STEPPER_ENABLE_B_BIT);
TCNT1 = 0;
@@ -67,6 +70,7 @@ void stepper_start(void)
TCCR1A = 0; // prescaler 1:64, WGM = 4 (CTC)
TCCR1B = 1<<WGM12 | 1<<CS11 | 1<<CS10; //
TIMSK1 = 1<<OCIE1A;
+ running = 1;
}
void stepper_stop(void)
@@ -74,6 +78,7 @@ void stepper_stop(void)
STEPPER_PORT &= ~(0xF << STEPPER_FIRST_BIT | 1<<STEPPER_ENABLE_A_BIT | 1<<STEPPER_ENABLE_B_BIT);
TCCR1B = 0; // no clock source
TIMSK1 = 0; // disable timer interrupt
+ running = 0;
}
static inline void stepper_handle(void)