Introduce a layer of macro indirection to all stepper pins. This allows other stepper drivers to redefine them, so they can use SPI/I2C instead of direct pin manipulation.
This commit is contained in:
parent
a57869ba49
commit
b55995aae8
|
@ -112,11 +112,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
|||
|
||||
#if defined(DUAL_X_CARRIAGE) && defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 \
|
||||
&& defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
||||
#define enable_x() do { WRITE(X_ENABLE_PIN, X_ENABLE_ON); WRITE(X2_ENABLE_PIN, X_ENABLE_ON); } while (0)
|
||||
#define disable_x() do { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); WRITE(X2_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
|
||||
#define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0)
|
||||
#define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
|
||||
#elif defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
||||
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
|
||||
#define disable_x() { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
|
||||
#define enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
|
||||
#define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
|
||||
#else
|
||||
#define enable_x() ;
|
||||
#define disable_x() ;
|
||||
|
@ -124,11 +124,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
|||
|
||||
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); }
|
||||
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||
#define enable_y() { Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }
|
||||
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||
#else
|
||||
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
|
||||
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||
#define enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON)
|
||||
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
|
||||
#endif
|
||||
#else
|
||||
#define enable_y() ;
|
||||
|
@ -137,11 +137,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
|||
|
||||
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
|
||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||
#define enable_z() { Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }
|
||||
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||
#else
|
||||
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
|
||||
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||
#define enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON)
|
||||
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
|
||||
#endif
|
||||
#else
|
||||
#define enable_z() ;
|
||||
|
@ -149,32 +149,32 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
|||
#endif
|
||||
|
||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#define enable_e0() E0_ENABLE_WRITE(E_ENABLE_ON)
|
||||
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e0() /* nothing */
|
||||
#define disable_e0() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#define enable_e1() E1_ENABLE_WRITE(E_ENABLE_ON)
|
||||
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e1() /* nothing */
|
||||
#define disable_e1() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#define enable_e2() E2_ENABLE_WRITE(E_ENABLE_ON)
|
||||
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e2() /* nothing */
|
||||
#define disable_e2() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
|
||||
#define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#define enable_e3() E3_ENABLE_WRITE(E_ENABLE_ON)
|
||||
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e3() /* nothing */
|
||||
#define disable_e3() /* nothing */
|
||||
|
|
|
@ -4284,17 +4284,17 @@ void controllerFan()
|
|||
{
|
||||
lastMotorCheck = millis();
|
||||
|
||||
if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN) || (soft_pwm_bed > 0)
|
||||
if(!READ(X_ENABLE_PIN) || !Y_ENABLE_READ || !Z_ENABLE_READ || (soft_pwm_bed > 0)
|
||||
#if EXTRUDERS > 2
|
||||
|| !READ(E2_ENABLE_PIN)
|
||||
|| !E2_ENABLE_READ
|
||||
#endif
|
||||
#if EXTRUDER > 1
|
||||
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
||||
|| !READ(X2_ENABLE_PIN)
|
||||
|| !X2_ENABLE_READ
|
||||
#endif
|
||||
|| !READ(E1_ENABLE_PIN)
|
||||
|| !E1_ENABLE_READ)
|
||||
#endif
|
||||
|| !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
|
||||
|| !E0_ENABLE_READ) //If any of the drivers are enabled...
|
||||
{
|
||||
lastMotor = millis(); //... set time to NOW so the fan will turn on
|
||||
}
|
||||
|
@ -4518,7 +4518,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
|
|||
if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
|
||||
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
|
||||
{
|
||||
bool oldstatus=READ(E0_ENABLE_PIN);
|
||||
bool oldstatus=E0_ENABLE_READ;
|
||||
enable_e0();
|
||||
float oldepos=current_position[E_AXIS];
|
||||
float oldedes=destination[E_AXIS];
|
||||
|
@ -4530,7 +4530,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
|
|||
plan_set_e_position(oldepos);
|
||||
previous_millis_cmd=millis();
|
||||
st_synchronize();
|
||||
WRITE(E0_ENABLE_PIN,oldstatus);
|
||||
E0_ENABLE_WRITE(oldstatus);
|
||||
}
|
||||
#endif
|
||||
#if defined(DUAL_X_CARRIAGE)
|
||||
|
|
|
@ -349,51 +349,51 @@ ISR(TIMER1_COMPA_vect)
|
|||
if((out_bits & (1<<X_AXIS))!=0){
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
if (extruder_duplication_enabled){
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
WRITE(X2_DIR_PIN, INVERT_X_DIR);
|
||||
X_DIR_WRITE(INVERT_X_DIR);
|
||||
X2_DIR_WRITE(INVERT_X_DIR);
|
||||
}
|
||||
else{
|
||||
if (current_block->active_extruder != 0)
|
||||
WRITE(X2_DIR_PIN, INVERT_X_DIR);
|
||||
X2_DIR_WRITE(INVERT_X_DIR);
|
||||
else
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
X_DIR_WRITE(INVERT_X_DIR);
|
||||
}
|
||||
#else
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
X_DIR_WRITE(INVERT_X_DIR);
|
||||
#endif
|
||||
count_direction[X_AXIS]=-1;
|
||||
}
|
||||
else{
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
if (extruder_duplication_enabled){
|
||||
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
||||
WRITE(X2_DIR_PIN, !INVERT_X_DIR);
|
||||
X_DIR_WRITE(!INVERT_X_DIR);
|
||||
X2_DIR_WRITE( !INVERT_X_DIR);
|
||||
}
|
||||
else{
|
||||
if (current_block->active_extruder != 0)
|
||||
WRITE(X2_DIR_PIN, !INVERT_X_DIR);
|
||||
X2_DIR_WRITE(!INVERT_X_DIR);
|
||||
else
|
||||
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
||||
X_DIR_WRITE(!INVERT_X_DIR);
|
||||
}
|
||||
#else
|
||||
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
||||
X_DIR_WRITE(!INVERT_X_DIR);
|
||||
#endif
|
||||
count_direction[X_AXIS]=1;
|
||||
}
|
||||
if((out_bits & (1<<Y_AXIS))!=0){
|
||||
WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
||||
Y_DIR_WRITE(INVERT_Y_DIR);
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
||||
Y2_DIR_WRITE(!(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
||||
#endif
|
||||
|
||||
count_direction[Y_AXIS]=-1;
|
||||
}
|
||||
else{
|
||||
WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
||||
Y_DIR_WRITE(!INVERT_Y_DIR);
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
||||
Y2_DIR_WRITE((INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
||||
#endif
|
||||
|
||||
count_direction[Y_AXIS]=1;
|
||||
|
@ -485,10 +485,10 @@ ISR(TIMER1_COMPA_vect)
|
|||
}
|
||||
|
||||
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
|
||||
WRITE(Z_DIR_PIN,INVERT_Z_DIR);
|
||||
Z_DIR_WRITE(INVERT_Z_DIR);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
|
||||
Z2_DIR_WRITE(INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=-1;
|
||||
|
@ -506,10 +506,10 @@ ISR(TIMER1_COMPA_vect)
|
|||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
|
||||
Z_DIR_WRITE(!INVERT_Z_DIR);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,!INVERT_Z_DIR);
|
||||
Z2_DIR_WRITE(!INVERT_Z_DIR);
|
||||
#endif
|
||||
|
||||
count_direction[Z_AXIS]=1;
|
||||
|
@ -565,17 +565,17 @@ ISR(TIMER1_COMPA_vect)
|
|||
* low instead of doing each in turn. The extra tests add enough
|
||||
* lag to allow it work with without needing NOPs */
|
||||
if (counter_x > 0) {
|
||||
WRITE(X_STEP_PIN, HIGH);
|
||||
X_STEP_WRITE(HIGH);
|
||||
}
|
||||
|
||||
counter_y += current_block->steps_y;
|
||||
if (counter_y > 0) {
|
||||
WRITE(Y_STEP_PIN, HIGH);
|
||||
Y_STEP_WRITE( HIGH);
|
||||
}
|
||||
|
||||
counter_z += current_block->steps_z;
|
||||
if (counter_z > 0) {
|
||||
WRITE(Z_STEP_PIN, HIGH);
|
||||
Z_STEP_WRITE( HIGH);
|
||||
}
|
||||
|
||||
#ifndef ADVANCE
|
||||
|
@ -588,19 +588,19 @@ ISR(TIMER1_COMPA_vect)
|
|||
if (counter_x > 0) {
|
||||
counter_x -= current_block->step_event_count;
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
WRITE(X_STEP_PIN, LOW);
|
||||
X_STEP_WRITE(LOW);
|
||||
}
|
||||
|
||||
if (counter_y > 0) {
|
||||
counter_y -= current_block->step_event_count;
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(Y_STEP_PIN, LOW);
|
||||
Y_STEP_WRITE( LOW);
|
||||
}
|
||||
|
||||
if (counter_z > 0) {
|
||||
counter_z -= current_block->step_event_count;
|
||||
count_position[Z_AXIS]+=count_direction[Z_AXIS];
|
||||
WRITE(Z_STEP_PIN, LOW);
|
||||
Z_STEP_WRITE(LOW);
|
||||
}
|
||||
|
||||
#ifndef ADVANCE
|
||||
|
@ -614,67 +614,67 @@ ISR(TIMER1_COMPA_vect)
|
|||
if (counter_x > 0) {
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
if (extruder_duplication_enabled){
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE( !INVERT_X_STEP_PIN);
|
||||
}
|
||||
else {
|
||||
if (current_block->active_extruder != 0)
|
||||
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE( !INVERT_X_STEP_PIN);
|
||||
else
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
}
|
||||
#else
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
#endif
|
||||
counter_x -= current_block->step_event_count;
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
if (extruder_duplication_enabled){
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
}
|
||||
else {
|
||||
if (current_block->active_extruder != 0)
|
||||
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
else
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
}
|
||||
#else
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
counter_y += current_block->steps_y;
|
||||
if (counter_y > 0) {
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
|
||||
#endif
|
||||
|
||||
counter_y -= current_block->step_event_count;
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
Y2_STEP_WRITE( INVERT_Y_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
counter_z += current_block->steps_z;
|
||||
if (counter_z > 0) {
|
||||
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
Z_STEP_WRITE( !INVERT_Z_STEP_PIN);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
Z2_STEP_WRITE(!INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
|
||||
counter_z -= current_block->step_event_count;
|
||||
count_position[Z_AXIS]+=count_direction[Z_AXIS];
|
||||
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
Z_STEP_WRITE( INVERT_Z_STEP_PIN);
|
||||
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -771,60 +771,60 @@ ISR(TIMER1_COMPA_vect)
|
|||
// Set E direction (Depends on E direction + advance)
|
||||
for(unsigned char i=0; i<4;i++) {
|
||||
if (e_steps[0] != 0) {
|
||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
E0_STEP_WRITE( INVERT_E_STEP_PIN);
|
||||
if (e_steps[0] < 0) {
|
||||
WRITE(E0_DIR_PIN, INVERT_E0_DIR);
|
||||
E0_DIR_WRITE(INVERT_E0_DIR);
|
||||
e_steps[0]++;
|
||||
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E0_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[0] > 0) {
|
||||
WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
|
||||
E0_DIR_WRITE(!INVERT_E0_DIR);
|
||||
e_steps[0]--;
|
||||
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E0_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
WRITE(E1_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
E1_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[1] < 0) {
|
||||
WRITE(E1_DIR_PIN, INVERT_E1_DIR);
|
||||
E1_DIR_WRITE(INVERT_E1_DIR);
|
||||
e_steps[1]++;
|
||||
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
|
||||
E1_DIR_WRITE(!INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
WRITE(E2_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
E2_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[2] < 0) {
|
||||
WRITE(E2_DIR_PIN, INVERT_E2_DIR);
|
||||
E2_DIR_WRITE(INVERT_E2_DIR);
|
||||
e_steps[2]++;
|
||||
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
|
||||
E2_DIR_WRITE(!INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
if (e_steps[3] != 0) {
|
||||
WRITE(E3_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
E3_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[3] < 0) {
|
||||
WRITE(E3_DIR_PIN, INVERT_E3_DIR);
|
||||
E3_DIR_WRITE(INVERT_E3_DIR);
|
||||
e_steps[3]++;
|
||||
WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[3] > 0) {
|
||||
WRITE(E3_DIR_PIN, !INVERT_E3_DIR);
|
||||
E3_DIR_WRITE(!INVERT_E3_DIR);
|
||||
e_steps[3]--;
|
||||
WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -840,81 +840,81 @@ void st_init()
|
|||
|
||||
//Initialize Dir Pins
|
||||
#if defined(X_DIR_PIN) && X_DIR_PIN > -1
|
||||
SET_OUTPUT(X_DIR_PIN);
|
||||
X_DIR_INIT;
|
||||
#endif
|
||||
#if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
|
||||
SET_OUTPUT(X2_DIR_PIN);
|
||||
X2_DIR_INIT;
|
||||
#endif
|
||||
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
|
||||
SET_OUTPUT(Y_DIR_PIN);
|
||||
Y_DIR_INIT;
|
||||
|
||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
|
||||
SET_OUTPUT(Y2_DIR_PIN);
|
||||
Y2_DIR_INIT;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
|
||||
SET_OUTPUT(Z_DIR_PIN);
|
||||
Z_DIR_INIT;
|
||||
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
|
||||
SET_OUTPUT(Z2_DIR_PIN);
|
||||
Z2_DIR_INIT;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
|
||||
SET_OUTPUT(E0_DIR_PIN);
|
||||
E0_DIR_INIT;
|
||||
#endif
|
||||
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
|
||||
SET_OUTPUT(E1_DIR_PIN);
|
||||
E1_DIR_INIT;
|
||||
#endif
|
||||
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
|
||||
SET_OUTPUT(E2_DIR_PIN);
|
||||
E2_DIR_INIT;
|
||||
#endif
|
||||
#if defined(E3_DIR_PIN) && (E3_DIR_PIN > -1)
|
||||
SET_OUTPUT(E3_DIR_PIN);
|
||||
E3_DIR_INIT;
|
||||
#endif
|
||||
|
||||
//Initialize Enable Pins - steppers default to disabled.
|
||||
|
||||
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
|
||||
SET_OUTPUT(X_ENABLE_PIN);
|
||||
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
||||
X_ENABLE_INIT;
|
||||
if(!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
||||
SET_OUTPUT(X2_ENABLE_PIN);
|
||||
if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH);
|
||||
X2_ENABLE_INIT;
|
||||
if(!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
||||
SET_OUTPUT(Y_ENABLE_PIN);
|
||||
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
||||
Y_ENABLE_INIT;
|
||||
if(!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
|
||||
|
||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(Y2_ENABLE_PIN);
|
||||
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
|
||||
Y2_ENABLE_INIT;
|
||||
if(!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
||||
SET_OUTPUT(Z_ENABLE_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||
Z_ENABLE_INIT;
|
||||
if(!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
|
||||
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(Z2_ENABLE_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
|
||||
Z2_ENABLE_INIT;
|
||||
if(!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E0_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||
E0_ENABLE_INIT;
|
||||
if(!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E1_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||
E1_ENABLE_INIT;
|
||||
if(!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E2_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
E2_ENABLE_INIT;
|
||||
if(!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E3_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E3_ENABLE_PIN,HIGH);
|
||||
E3_ENABLE_INIT;
|
||||
if(!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
|
||||
//endstops and pullups
|
||||
|
@ -964,51 +964,51 @@ void st_init()
|
|||
|
||||
//Initialize Step Pins
|
||||
#if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
|
||||
SET_OUTPUT(X_STEP_PIN);
|
||||
WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
|
||||
X_STEP_INIT;
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
disable_x();
|
||||
#endif
|
||||
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
|
||||
SET_OUTPUT(X2_STEP_PIN);
|
||||
WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
|
||||
X2_STEP_INIT;
|
||||
X2_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
disable_x();
|
||||
#endif
|
||||
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
|
||||
SET_OUTPUT(Y_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||
Y_STEP_INIT;
|
||||
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
|
||||
SET_OUTPUT(Y2_STEP_PIN);
|
||||
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||
Y2_STEP_INIT;
|
||||
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
#endif
|
||||
disable_y();
|
||||
#endif
|
||||
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
|
||||
SET_OUTPUT(Z_STEP_PIN);
|
||||
WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||
Z_STEP_INIT;
|
||||
Z_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
|
||||
SET_OUTPUT(Z2_STEP_PIN);
|
||||
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||
Z2_STEP_INIT;
|
||||
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
disable_z();
|
||||
#endif
|
||||
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
|
||||
SET_OUTPUT(E0_STEP_PIN);
|
||||
WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
E0_STEP_INIT;
|
||||
E0_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
disable_e0();
|
||||
#endif
|
||||
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
|
||||
SET_OUTPUT(E1_STEP_PIN);
|
||||
WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
E1_STEP_INIT;
|
||||
E1_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
disable_e1();
|
||||
#endif
|
||||
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
|
||||
SET_OUTPUT(E2_STEP_PIN);
|
||||
WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
E2_STEP_INIT;
|
||||
E2_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
disable_e2();
|
||||
#endif
|
||||
#if defined(E3_STEP_PIN) && (E3_STEP_PIN > -1)
|
||||
SET_OUTPUT(E3_STEP_PIN);
|
||||
WRITE(E3_STEP_PIN,INVERT_E_STEP_PIN);
|
||||
E3_STEP_INIT;
|
||||
E3_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
disable_e3();
|
||||
#endif
|
||||
|
||||
|
@ -1127,31 +1127,31 @@ void babystep(const uint8_t axis,const bool direction)
|
|||
case X_AXIS:
|
||||
{
|
||||
enable_x();
|
||||
uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction.
|
||||
uint8_t old_x_dir_pin= X_DIR_READ; //if dualzstepper, both point to same direction.
|
||||
|
||||
//setup new step
|
||||
WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction);
|
||||
X_DIR_WRITE((INVERT_X_DIR)^direction);
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction);
|
||||
X2_DIR_WRITE((INVERT_X_DIR)^direction);
|
||||
#endif
|
||||
|
||||
//perform step
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
#endif
|
||||
|
||||
_delay_us(1U); // wait 1 microsecond
|
||||
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
X2_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
#endif
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(X_DIR_PIN,old_x_dir_pin);
|
||||
X_DIR_WRITE(old_x_dir_pin);
|
||||
#ifdef DUAL_X_CARRIAGE
|
||||
WRITE(X2_DIR_PIN,old_x_dir_pin);
|
||||
X2_DIR_WRITE(old_x_dir_pin);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1159,31 +1159,31 @@ void babystep(const uint8_t axis,const bool direction)
|
|||
case Y_AXIS:
|
||||
{
|
||||
enable_y();
|
||||
uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction.
|
||||
uint8_t old_y_dir_pin= Y_DIR_READ; //if dualzstepper, both point to same direction.
|
||||
|
||||
//setup new step
|
||||
WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction);
|
||||
Y_DIR_WRITE((INVERT_Y_DIR)^direction);
|
||||
#ifdef DUAL_Y_CARRIAGE
|
||||
WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction);
|
||||
Y2_DIR_WRITE((INVERT_Y_DIR)^direction);
|
||||
#endif
|
||||
|
||||
//perform step
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
|
||||
#ifdef DUAL_Y_CARRIAGE
|
||||
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
|
||||
#endif
|
||||
|
||||
_delay_us(1U); // wait 1 microsecond
|
||||
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
#ifdef DUAL_Y_CARRIAGE
|
||||
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
#endif
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(Y_DIR_PIN,old_y_dir_pin);
|
||||
Y_DIR_WRITE(old_y_dir_pin);
|
||||
#ifdef DUAL_Y_CARRIAGE
|
||||
WRITE(Y2_DIR_PIN,old_y_dir_pin);
|
||||
Y2_DIR_WRITE(old_y_dir_pin);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1193,29 +1193,29 @@ void babystep(const uint8_t axis,const bool direction)
|
|||
case Z_AXIS:
|
||||
{
|
||||
enable_z();
|
||||
uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction.
|
||||
uint8_t old_z_dir_pin= Z_DIR_READ; //if dualzstepper, both point to same direction.
|
||||
//setup new step
|
||||
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
Z2_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
#endif
|
||||
//perform step
|
||||
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
Z2_STEP_WRITE( !INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
|
||||
_delay_us(1U); // wait 1 microsecond
|
||||
|
||||
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
Z_STEP_WRITE( INVERT_Z_STEP_PIN);
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(Z_DIR_PIN,old_z_dir_pin);
|
||||
Z_DIR_WRITE(old_z_dir_pin);
|
||||
#ifdef Z_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Z2_DIR_PIN,old_z_dir_pin);
|
||||
Z2_DIR_WRITE(old_z_dir_pin);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1226,29 +1226,29 @@ void babystep(const uint8_t axis,const bool direction)
|
|||
enable_x();
|
||||
enable_y();
|
||||
enable_z();
|
||||
uint8_t old_x_dir_pin= READ(X_DIR_PIN);
|
||||
uint8_t old_y_dir_pin= READ(Y_DIR_PIN);
|
||||
uint8_t old_z_dir_pin= READ(Z_DIR_PIN);
|
||||
uint8_t old_x_dir_pin= X_DIR_READ;
|
||||
uint8_t old_y_dir_pin= Y_DIR_READ;
|
||||
uint8_t old_z_dir_pin= Z_DIR_READ;
|
||||
//setup new step
|
||||
WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
X_DIR_WRITE((INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
Y_DIR_WRITE((INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
|
||||
|
||||
//perform step
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|
||||
X_STEP_WRITE( !INVERT_X_STEP_PIN);
|
||||
Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
|
||||
Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
|
||||
|
||||
_delay_us(1U); // wait 1 microsecond
|
||||
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
|
||||
Z_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(X_DIR_PIN,old_x_dir_pin);
|
||||
WRITE(Y_DIR_PIN,old_y_dir_pin);
|
||||
WRITE(Z_DIR_PIN,old_z_dir_pin);
|
||||
X_DIR_WRITE(old_x_dir_pin);
|
||||
Y_DIR_WRITE(old_y_dir_pin);
|
||||
Z_DIR_WRITE(old_z_dir_pin);
|
||||
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -22,30 +22,31 @@
|
|||
#define stepper_h
|
||||
|
||||
#include "planner.h"
|
||||
#include "stepper_indirection.h"
|
||||
|
||||
#if EXTRUDERS > 3
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 3) { WRITE(E3_STEP_PIN, v); } else { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 3) { WRITE(E3_DIR_PIN, !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 3) { WRITE(E3_DIR_PIN, INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}}
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
|
||||
#elif EXTRUDERS > 2
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
|
||||
#elif EXTRUDERS > 1
|
||||
#ifndef DUAL_X_CARRIAGE
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
|
||||
#else
|
||||
extern bool extruder_duplication_enabled;
|
||||
#define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
|
||||
#define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
|
||||
#define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
|
||||
#define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
|
||||
#endif
|
||||
#else
|
||||
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
|
||||
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
|
||||
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
|
||||
#define WRITE_E_STEP(v) E0_STEP_WRITE(v)
|
||||
#define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
|
||||
#define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
|
||||
#endif
|
||||
|
||||
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
||||
|
|
156
Marlin/stepper_indirection.h
Normal file
156
Marlin/stepper_indirection.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
stepper_indirection.h - stepper motor driver indirection macros
|
||||
to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
|
||||
Part of Marlin
|
||||
|
||||
Copyright (c) 2015 Dominik Wenger
|
||||
|
||||
Marlin is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Marlin is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Marlin. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STEPPER_INDIRECTION_H
|
||||
#define STEPPER_INDIRECTION_H
|
||||
|
||||
// X motor
|
||||
#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
|
||||
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
|
||||
#define X_STEP_READ READ(X_STEP_PIN)
|
||||
|
||||
#define X_DIR_INIT SET_OUTPUT(X_DIR_PIN)
|
||||
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
|
||||
#define X_DIR_READ READ(X_DIR_PIN)
|
||||
|
||||
#define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
|
||||
#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
|
||||
#define X_ENABLE_READ READ(X_ENABLE_PIN)
|
||||
|
||||
// X2 motor
|
||||
#define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN)
|
||||
#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
|
||||
#define X2_STEP_READ READ(X2_STEP_PIN)
|
||||
|
||||
#define X2_DIR_INIT SET_OUTPUT(X2_DIR_PIN)
|
||||
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
|
||||
#define X2_DIR_READ READ(X_DIR_PIN)
|
||||
|
||||
#define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
|
||||
#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
|
||||
#define X2_ENABLE_READ READ(X_ENABLE_PIN)
|
||||
|
||||
// Y motor
|
||||
#define Y_STEP_INIT SET_OUTPUT(Y_STEP_PIN)
|
||||
#define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
|
||||
#define Y_STEP_READ READ(Y_STEP_PIN)
|
||||
|
||||
#define Y_DIR_INIT SET_OUTPUT(Y_DIR_PIN)
|
||||
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
|
||||
#define Y_DIR_READ READ(Y_DIR_PIN)
|
||||
|
||||
#define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
|
||||
#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
|
||||
#define Y_ENABLE_READ READ(Y_ENABLE_PIN)
|
||||
|
||||
// Y2 motor
|
||||
#define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN)
|
||||
#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
|
||||
#define Y2_STEP_READ READ(Y2_STEP_PIN)
|
||||
|
||||
#define Y2_DIR_INIT SET_OUTPUT(Y2_DIR_PIN)
|
||||
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
|
||||
#define Y2_DIR_READ READ(Y2_DIR_PIN)
|
||||
|
||||
#define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
|
||||
#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
|
||||
#define Y2_ENABLE_READ READ(Y2_ENABLE_PIN)
|
||||
|
||||
// Z motor
|
||||
#define Z_STEP_INIT SET_OUTPUT(Z_STEP_PIN)
|
||||
#define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
|
||||
#define Z_STEP_READ READ(Z_STEP_PIN)
|
||||
|
||||
#define Z_DIR_INIT SET_OUTPUT(Z_DIR_PIN)
|
||||
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
|
||||
#define Z_DIR_READ READ(Z_DIR_PIN)
|
||||
|
||||
#define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
|
||||
#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
|
||||
#define Z_ENABLE_READ READ(Z_ENABLE_PIN)
|
||||
|
||||
// Z2 motor
|
||||
#define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN)
|
||||
#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
|
||||
#define Z2_STEP_READ READ(Z2_STEP_PIN)
|
||||
|
||||
#define Z2_DIR_INIT SET_OUTPUT(Z2_DIR_PIN)
|
||||
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
|
||||
#define Z2_DIR_READ READ(Z2_DIR_PIN)
|
||||
|
||||
#define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
|
||||
#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
|
||||
#define Z2_ENABLE_READ READ(Z2_ENABLE_PIN)
|
||||
|
||||
// E0 motor
|
||||
#define E0_STEP_INIT SET_OUTPUT(E0_STEP_PIN)
|
||||
#define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
|
||||
#define E0_STEP_READ READ(E0_STEP_PIN)
|
||||
|
||||
#define E0_DIR_INIT SET_OUTPUT(E0_DIR_PIN)
|
||||
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
|
||||
#define E0_DIR_READ READ(E0_DIR_PIN)
|
||||
|
||||
#define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
|
||||
#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
|
||||
#define E0_ENABLE_READ READ(E0_ENABLE_PIN)
|
||||
|
||||
// E1 motor
|
||||
#define E1_STEP_INIT SET_OUTPUT(E1_STEP_PIN)
|
||||
#define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
|
||||
#define E1_STEP_READ READ(E1_STEP_PIN)
|
||||
|
||||
#define E1_DIR_INIT SET_OUTPUT(E1_DIR_PIN)
|
||||
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
|
||||
#define E1_DIR_READ READ(E1_DIR_PIN)
|
||||
|
||||
#define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
|
||||
#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
|
||||
#define E1_ENABLE_READ READ(E1_ENABLE_PIN)
|
||||
|
||||
// E2 motor
|
||||
#define E2_STEP_INIT SET_OUTPUT(E2_STEP_PIN)
|
||||
#define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
|
||||
#define E2_STEP_READ READ(E2_STEP_PIN)
|
||||
|
||||
#define E2_DIR_INIT SET_OUTPUT(E2_DIR_PIN)
|
||||
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
|
||||
#define E2_DIR_READ READ(E2_DIR_PIN)
|
||||
|
||||
#define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
|
||||
#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
|
||||
#define E2_ENABLE_READ READ(E2_ENABLE_PIN)
|
||||
|
||||
// E3 motor
|
||||
#define E3_STEP_INIT SET_OUTPUT(E3_STEP_PIN)
|
||||
#define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
|
||||
#define E3_STEP_READ READ(E3_STEP_PIN)
|
||||
|
||||
#define E3_DIR_INIT SET_OUTPUT(E3_DIR_PIN)
|
||||
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
|
||||
#define E3_DIR_READ READ(E3_DIR_PIN)
|
||||
|
||||
#define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
|
||||
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
|
||||
#define E3_ENABLE_READ READ(E3_ENABLE_PIN)
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue