fixed synchronization problem with spindle_control
This commit is contained in:
parent
a18a89c779
commit
4cac11ec86
@ -25,13 +25,16 @@
|
|||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
static int current_direction;
|
||||||
|
|
||||||
void spindle_init()
|
void spindle_init()
|
||||||
{
|
{
|
||||||
SPINDLE_ENABLE_DDR |= 1<<SPINDLE_ENABLE_BIT;
|
spindle_run(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spindle_run(int direction, uint32_t rpm)
|
void spindle_run(int direction, uint32_t rpm)
|
||||||
{
|
{
|
||||||
|
if (direction != current_direction) {
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
if(direction >= 0) {
|
if(direction >= 0) {
|
||||||
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
|
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
|
||||||
@ -39,10 +42,11 @@ void spindle_run(int direction, uint32_t rpm)
|
|||||||
SPINDLE_DIRECTION_PORT |= 1<<SPINDLE_DIRECTION_BIT;
|
SPINDLE_DIRECTION_PORT |= 1<<SPINDLE_DIRECTION_BIT;
|
||||||
}
|
}
|
||||||
SPINDLE_ENABLE_PORT |= 1<<SPINDLE_ENABLE_BIT;
|
SPINDLE_ENABLE_PORT |= 1<<SPINDLE_ENABLE_BIT;
|
||||||
|
current_direction = direction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void spindle_stop()
|
void spindle_stop()
|
||||||
{
|
{
|
||||||
st_synchronize();
|
spindle_run(0, 0);
|
||||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user