We don't need the old standard one. The STEP_ADD and STEP_IF_COUNTER are also good for non-Toshiba stepper driver.

This commit is contained in:
Wurstnase 2015-05-07 18:55:47 +02:00
parent 91fa1dea82
commit 073e4af7e2

View File

@ -676,60 +676,34 @@ ISR(TIMER1_COMPA_vect) {
#endif //ADVANCE
#define _COUNTER(axis) counter_## axis
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
#ifdef CONFIG_STEPPERS_TOSHIBA
/**
* The Toshiba stepper controller require much longer pulses.
* So we 'stage' decompose the pulses between high and low
* instead of doing each in turn. The extra tests add enough
* lag to allow it work with without needing NOPs
*/
#define STEP_ADD(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { _WRITE_STEP(AXIS, HIGH); }
STEP_ADD(x,X);
STEP_ADD(y,Y);
STEP_ADD(z,Z);
#ifndef ADVANCE
STEP_ADD(e,E);
#endif
#define STEP_ADD(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
#define STEP_IF_COUNTER(axis, AXIS) \
if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_WRITE_STEP(AXIS, LOW); \
}
STEP_ADD(x,X);
STEP_ADD(y,Y);
STEP_ADD(z,Z);
#ifndef ADVANCE
STEP_ADD(e,E);
#endif
STEP_IF_COUNTER(x, X);
STEP_IF_COUNTER(y, Y);
STEP_IF_COUNTER(z, Z);
#ifndef ADVANCE
STEP_IF_COUNTER(e, E);
#endif
#define STEP_IF_COUNTER(axis, AXIS) \
if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
}
#else // !CONFIG_STEPPERS_TOSHIBA
STEP_IF_COUNTER(x, X);
STEP_IF_COUNTER(y, Y);
STEP_IF_COUNTER(z, Z);
#ifndef ADVANCE
STEP_IF_COUNTER(e, E);
#endif
#define APPLY_MOVEMENT(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { \
_APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
}
APPLY_MOVEMENT(x, X);
APPLY_MOVEMENT(y, Y);
APPLY_MOVEMENT(z, Z);
#ifndef ADVANCE
APPLY_MOVEMENT(e, E);
#endif
#endif // CONFIG_STEPPERS_TOSHIBA
step_events_completed++;
if (step_events_completed >= current_block->step_event_count) break;
}
@ -1024,6 +998,7 @@ void st_init() {
#endif
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)
#define _DISABLE(axis) disable_## axis()
#define AXIS_INIT(axis, AXIS, PIN) \