Minor fix related to spindle_stop() crashing abort in certain cases.

- Updated spindle_stop() to fix abort bug and to be more in line with
v0.8.
This commit is contained in:
Sonny Jeon
2012-03-10 12:34:09 -07:00
parent 86cdae0060
commit d3be216931
5 changed files with 24 additions and 16 deletions

View File

@ -3,6 +3,7 @@
Part of Grbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2012 Sungeun K. Jeon
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -27,22 +28,26 @@
#include <stdint.h>
// TODO: Deprecated. Need to update for new version.
static int current_direction;
static uint8_t current_direction;
void spindle_init()
{
current_direction = 0;
SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT);
SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT);
spindle_run(0, 0);
spindle_stop();
}
void spindle_stop()
{
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
}
void spindle_run(int direction, uint32_t rpm)
{
if (direction != current_direction) {
plan_synchronize();
if(direction) {
if (direction) {
if(direction > 0) {
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
} else {
@ -50,13 +55,8 @@ void spindle_run(int direction, uint32_t rpm)
}
SPINDLE_ENABLE_PORT |= 1<<SPINDLE_ENABLE_BIT;
} else {
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
spindle_stop();
}
current_direction = direction;
}
}
void spindle_stop()
{
spindle_run(0, 0);
}