Styling adjustments (PR#2668 & PR#2670)
Keep "astyled" reformatting
This commit is contained in:
committed by
Richard Wackerbarth
parent
b5fb7075b9
commit
0c7f7ebcfb
@ -37,7 +37,7 @@
|
||||
//===========================================================================
|
||||
//============================= public variables ============================
|
||||
//===========================================================================
|
||||
block_t *current_block; // A pointer to the block currently being traced
|
||||
block_t* current_block; // A pointer to the block currently being traced
|
||||
|
||||
|
||||
//===========================================================================
|
||||
@ -50,8 +50,8 @@ static unsigned char out_bits = 0; // The next stepping-bits to be output
|
||||
static unsigned int cleaning_buffer_counter;
|
||||
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
static bool performing_homing = false,
|
||||
locked_z_motor = false,
|
||||
static bool performing_homing = false,
|
||||
locked_z_motor = false,
|
||||
locked_z2_motor = false;
|
||||
#endif
|
||||
|
||||
@ -81,7 +81,7 @@ static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_
|
||||
#else
|
||||
static uint16_t
|
||||
#endif
|
||||
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_MIN_PROBE, Z2_MIN, Z2_MAX
|
||||
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_MIN_PROBE, Z2_MIN, Z2_MAX
|
||||
|
||||
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
||||
bool abort_on_endstop_hit = false;
|
||||
@ -163,24 +163,24 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
||||
// r27 to store the byte 1 of the 24 bit result
|
||||
#define MultiU16X8toH16(intRes, charIn1, intIn2) \
|
||||
asm volatile ( \
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %A1, %A2 \n\t" \
|
||||
"add %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r0 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
"d" (charIn1), \
|
||||
"d" (intIn2) \
|
||||
: \
|
||||
"r26" \
|
||||
)
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %A1, %A2 \n\t" \
|
||||
"add %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r0 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
"d" (charIn1), \
|
||||
"d" (intIn2) \
|
||||
: \
|
||||
"r26" \
|
||||
)
|
||||
|
||||
// intRes = longIn1 * longIn2 >> 24
|
||||
// uses:
|
||||
@ -194,49 +194,49 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
||||
//
|
||||
#define MultiU24X32toH16(intRes, longIn1, longIn2) \
|
||||
asm volatile ( \
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"mov r27, r1 \n\t" \
|
||||
"mul %B1, %C2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %C1, %C2 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"mul %C1, %B2 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %A1, %C2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %B2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %C1, %A2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %A2 \n\t" \
|
||||
"add r27, r1 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r27 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %D2, %A1 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %D2, %B1 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
"d" (longIn1), \
|
||||
"d" (longIn2) \
|
||||
: \
|
||||
"r26" , "r27" \
|
||||
)
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"mov r27, r1 \n\t" \
|
||||
"mul %B1, %C2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %C1, %C2 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"mul %C1, %B2 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %A1, %C2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %B2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %C1, %A2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %A2 \n\t" \
|
||||
"add r27, r1 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r27 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %D2, %A1 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %D2, %B1 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
"d" (longIn1), \
|
||||
"d" (longIn2) \
|
||||
: \
|
||||
"r26" , "r27" \
|
||||
)
|
||||
|
||||
// Some useful constants
|
||||
|
||||
@ -288,7 +288,7 @@ void enable_endstops(bool check) { check_endstops = check; }
|
||||
|
||||
// Check endstops
|
||||
inline void update_endstops() {
|
||||
|
||||
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
uint16_t
|
||||
#else
|
||||
@ -316,7 +316,7 @@ inline void update_endstops() {
|
||||
_ENDSTOP_HIT(AXIS); \
|
||||
step_events_completed = current_block->step_event_count; \
|
||||
}
|
||||
|
||||
|
||||
#if ENABLED(COREXY)
|
||||
// Head direction in -X axis for CoreXY bots.
|
||||
// If DeltaX == -DeltaY, the movement is only in Y axis
|
||||
@ -328,7 +328,7 @@ inline void update_endstops() {
|
||||
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, C_AXIS))) {
|
||||
if (TEST(out_bits, X_HEAD))
|
||||
#else
|
||||
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
|
||||
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
|
||||
#endif
|
||||
{ // -direction
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
@ -391,11 +391,11 @@ inline void update_endstops() {
|
||||
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
SET_ENDSTOP_BIT(Z, MIN);
|
||||
#if HAS_Z2_MIN
|
||||
SET_ENDSTOP_BIT(Z2, MIN);
|
||||
#else
|
||||
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
SET_ENDSTOP_BIT(Z2, MIN);
|
||||
#else
|
||||
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
|
||||
#endif
|
||||
|
||||
byte z_test = TEST_ENDSTOP(Z_MIN) << 0 + TEST_ENDSTOP(Z2_MIN) << 1; // bit 0 for Z, bit 1 for Z2
|
||||
|
||||
@ -408,14 +408,14 @@ inline void update_endstops() {
|
||||
#else // !Z_DUAL_ENDSTOPS
|
||||
|
||||
UPDATE_ENDSTOP(Z, MIN);
|
||||
|
||||
#endif // !Z_DUAL_ENDSTOPS
|
||||
#endif // Z_MIN_PIN
|
||||
|
||||
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
||||
UPDATE_ENDSTOP(Z, MIN_PROBE);
|
||||
|
||||
if (TEST_ENDSTOP(Z_MIN_PROBE))
|
||||
{
|
||||
if (TEST_ENDSTOP(Z_MIN_PROBE)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_hit_bits |= BIT(Z_MIN_PROBE);
|
||||
}
|
||||
@ -427,11 +427,11 @@ inline void update_endstops() {
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
|
||||
SET_ENDSTOP_BIT(Z, MAX);
|
||||
#if HAS_Z2_MAX
|
||||
SET_ENDSTOP_BIT(Z2, MAX);
|
||||
#else
|
||||
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
SET_ENDSTOP_BIT(Z2, MAX);
|
||||
#else
|
||||
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
|
||||
#endif
|
||||
|
||||
byte z_test = TEST_ENDSTOP(Z_MAX) << 0 + TEST_ENDSTOP(Z2_MAX) << 1; // bit 0 for Z, bit 1 for Z2
|
||||
|
||||
@ -451,7 +451,7 @@ inline void update_endstops() {
|
||||
}
|
||||
#if ENABLED(COREXZ)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
old_endstop_bits = current_endstop_bits;
|
||||
}
|
||||
|
||||
@ -495,17 +495,17 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
||||
if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000);
|
||||
step_rate -= (F_CPU / 500000); // Correct for minimal speed
|
||||
if (step_rate >= (8 * 256)) { // higher step rate
|
||||
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
|
||||
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate >> 8)][0];
|
||||
unsigned char tmp_step_rate = (step_rate & 0x00ff);
|
||||
unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
|
||||
unsigned short gain = (unsigned short)pgm_read_word_near(table_address + 2);
|
||||
MultiU16X8toH16(timer, tmp_step_rate, gain);
|
||||
timer = (unsigned short)pgm_read_word_near(table_address) - timer;
|
||||
}
|
||||
else { // lower step rates
|
||||
unsigned short table_address = (unsigned short)&speed_lookuptable_slow[0][0];
|
||||
table_address += ((step_rate)>>1) & 0xfffc;
|
||||
table_address += ((step_rate) >> 1) & 0xfffc;
|
||||
timer = (unsigned short)pgm_read_word_near(table_address);
|
||||
timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
|
||||
timer -= (((unsigned short)pgm_read_word_near(table_address + 2) * (unsigned char)(step_rate & 0x0007)) >> 3);
|
||||
}
|
||||
if (timer < 100) { timer = 100; MYSERIAL.print(MSG_STEPPER_TOO_HIGH); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
|
||||
return timer;
|
||||
@ -536,7 +536,7 @@ void set_stepper_direction() {
|
||||
Y_APPLY_DIR(!INVERT_Y_DIR, 0);
|
||||
count_direction[Y_AXIS] = 1;
|
||||
}
|
||||
|
||||
|
||||
if (TEST(out_bits, Z_AXIS)) { // C_AXIS
|
||||
Z_APPLY_DIR(INVERT_Z_DIR, 0);
|
||||
count_direction[Z_AXIS] = -1;
|
||||
@ -545,7 +545,7 @@ void set_stepper_direction() {
|
||||
Z_APPLY_DIR(!INVERT_Z_DIR, 0);
|
||||
count_direction[Z_AXIS] = 1;
|
||||
}
|
||||
|
||||
|
||||
#if DISABLED(ADVANCE)
|
||||
if (TEST(out_bits, E_AXIS)) {
|
||||
REV_E_DIR();
|
||||
@ -566,7 +566,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
||||
out_bits = current_block->direction_bits;
|
||||
set_stepper_direction();
|
||||
}
|
||||
|
||||
|
||||
#if ENABLED(ADVANCE)
|
||||
advance = current_block->initial_advance;
|
||||
final_advance = current_block->final_advance;
|
||||
@ -704,16 +704,18 @@ ISR(TIMER1_COMPA_vect) {
|
||||
timer = calc_timer(acc_step_rate);
|
||||
OCR1A = timer;
|
||||
acceleration_time += timer;
|
||||
|
||||
#if ENABLED(ADVANCE)
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
|
||||
for (int8_t i = 0; i < step_loops; i++) {
|
||||
advance += advance_rate;
|
||||
}
|
||||
//if (advance > current_block->advance) advance = current_block->advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
e_steps[current_block->active_extruder] += ((advance >> 8) - old_advance);
|
||||
old_advance = advance >> 8;
|
||||
|
||||
#endif
|
||||
#endif //ADVANCE
|
||||
}
|
||||
else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
|
||||
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
|
||||
@ -734,13 +736,13 @@ ISR(TIMER1_COMPA_vect) {
|
||||
OCR1A = timer;
|
||||
deceleration_time += timer;
|
||||
#if ENABLED(ADVANCE)
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
for (int8_t i = 0; i < step_loops; i++) {
|
||||
advance -= advance_rate;
|
||||
}
|
||||
if (advance < final_advance) advance = final_advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
e_steps[current_block->active_extruder] += ((advance >> 8) - old_advance);
|
||||
old_advance = advance >> 8;
|
||||
#endif //ADVANCE
|
||||
}
|
||||
else {
|
||||
@ -749,7 +751,7 @@ ISR(TIMER1_COMPA_vect) {
|
||||
step_loops = step_loops_nominal;
|
||||
}
|
||||
|
||||
OCR1A = (OCR1A < (TCNT1 +16)) ? (TCNT1 + 16) : OCR1A;
|
||||
OCR1A = (OCR1A < (TCNT1 + 16)) ? (TCNT1 + 16) : OCR1A;
|
||||
|
||||
// If current block is finished, reset pointer
|
||||
if (step_events_completed >= current_block->step_event_count) {
|
||||
@ -763,12 +765,11 @@ ISR(TIMER1_COMPA_vect) {
|
||||
unsigned char old_OCR0A;
|
||||
// Timer interrupt for E. e_steps is set in the main routine;
|
||||
// Timer 0 is shared with millies
|
||||
ISR(TIMER0_COMPA_vect)
|
||||
{
|
||||
ISR(TIMER0_COMPA_vect) {
|
||||
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
||||
OCR0A = old_OCR0A;
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
for(unsigned char i=0; i<4;i++) {
|
||||
for (unsigned char i = 0; i < 4; i++) {
|
||||
if (e_steps[0] != 0) {
|
||||
E0_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[0] < 0) {
|
||||
@ -782,52 +783,51 @@ ISR(TIMER1_COMPA_vect) {
|
||||
E0_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
E1_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[1] < 0) {
|
||||
E1_DIR_WRITE(INVERT_E1_DIR);
|
||||
e_steps[1]++;
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
E1_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[1] < 0) {
|
||||
E1_DIR_WRITE(INVERT_E1_DIR);
|
||||
e_steps[1]++;
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
E1_DIR_WRITE(!INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
E1_DIR_WRITE(!INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
E1_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
E2_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[2] < 0) {
|
||||
E2_DIR_WRITE(INVERT_E2_DIR);
|
||||
e_steps[2]++;
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
E2_DIR_WRITE(!INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
E2_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[2] < 0) {
|
||||
E2_DIR_WRITE(INVERT_E2_DIR);
|
||||
e_steps[2]++;
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
if (e_steps[3] != 0) {
|
||||
E3_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[3] < 0) {
|
||||
E3_DIR_WRITE(INVERT_E3_DIR);
|
||||
e_steps[3]++;
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[3] > 0) {
|
||||
E3_DIR_WRITE(!INVERT_E3_DIR);
|
||||
e_steps[3]--;
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
E2_DIR_WRITE(!INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
E2_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
if (e_steps[3] != 0) {
|
||||
E3_STEP_WRITE(INVERT_E_STEP_PIN);
|
||||
if (e_steps[3] < 0) {
|
||||
E3_DIR_WRITE(INVERT_E3_DIR);
|
||||
e_steps[3]++;
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
else if (e_steps[3] > 0) {
|
||||
E3_DIR_WRITE(!INVERT_E3_DIR);
|
||||
e_steps[3]--;
|
||||
E3_STEP_WRITE(!INVERT_E_STEP_PIN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // ADVANCE
|
||||
@ -1032,15 +1032,14 @@ void st_init() {
|
||||
TCCR1A &= ~BIT(WGM10);
|
||||
|
||||
// output mode = 00 (disconnected)
|
||||
TCCR1A &= ~(3<<COM1A0);
|
||||
TCCR1A &= ~(3<<COM1B0);
|
||||
|
||||
TCCR1A &= ~(3 << COM1A0);
|
||||
TCCR1A &= ~(3 << COM1B0);
|
||||
// Set the timer pre-scaler
|
||||
// Generally we use a divider of 8, resulting in a 2MHz timer
|
||||
// frequency on a 16MHz MCU. If you are going to change this, be
|
||||
// sure to regenerate speed_lookuptable.h with
|
||||
// create_speed_lookuptable.py
|
||||
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10);
|
||||
TCCR1B = (TCCR1B & ~(0x07 << CS10)) | (2 << CS10);
|
||||
|
||||
OCR1A = 0x4000;
|
||||
TCNT1 = 0;
|
||||
@ -1057,7 +1056,7 @@ void st_init() {
|
||||
|
||||
enable_endstops(true); // Start with endstops active. After homing they can be disabled
|
||||
sei();
|
||||
|
||||
|
||||
set_stepper_direction(); // Init directions to out_bits = 0
|
||||
}
|
||||
|
||||
@ -1067,7 +1066,7 @@ void st_init() {
|
||||
*/
|
||||
void st_synchronize() { while (blocks_queued()) idle(); }
|
||||
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e) {
|
||||
void st_set_position(const long& x, const long& y, const long& z, const long& e) {
|
||||
CRITICAL_SECTION_START;
|
||||
count_position[X_AXIS] = x;
|
||||
count_position[Y_AXIS] = y;
|
||||
@ -1076,7 +1075,7 @@ void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
void st_set_e_position(const long &e) {
|
||||
void st_set_e_position(const long& e) {
|
||||
CRITICAL_SECTION_START;
|
||||
count_position[E_AXIS] = e;
|
||||
CRITICAL_SECTION_END;
|
||||
@ -1126,7 +1125,7 @@ void quickStop() {
|
||||
_APPLY_DIR(AXIS, old_pin); \
|
||||
}
|
||||
|
||||
switch(axis) {
|
||||
switch (axis) {
|
||||
|
||||
case X_AXIS:
|
||||
BABYSTEP_AXIS(x, X, false);
|
||||
@ -1135,7 +1134,7 @@ void quickStop() {
|
||||
case Y_AXIS:
|
||||
BABYSTEP_AXIS(y, Y, false);
|
||||
break;
|
||||
|
||||
|
||||
case Z_AXIS: {
|
||||
|
||||
#if DISABLED(DELTA)
|
||||
@ -1153,16 +1152,16 @@ void quickStop() {
|
||||
old_y_dir_pin = Y_DIR_READ,
|
||||
old_z_dir_pin = Z_DIR_READ;
|
||||
//setup new step
|
||||
X_DIR_WRITE(INVERT_X_DIR^z_direction);
|
||||
Y_DIR_WRITE(INVERT_Y_DIR^z_direction);
|
||||
Z_DIR_WRITE(INVERT_Z_DIR^z_direction);
|
||||
//perform step
|
||||
X_DIR_WRITE(INVERT_X_DIR ^ z_direction);
|
||||
Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction);
|
||||
Z_DIR_WRITE(INVERT_Z_DIR ^ z_direction);
|
||||
//perform step
|
||||
X_STEP_WRITE(!INVERT_X_STEP_PIN);
|
||||
Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
|
||||
Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
|
||||
delayMicroseconds(2);
|
||||
X_STEP_WRITE(INVERT_X_STEP_PIN);
|
||||
Y_STEP_WRITE(INVERT_Y_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.
|
||||
X_DIR_WRITE(old_x_dir_pin);
|
||||
@ -1172,7 +1171,7 @@ void quickStop() {
|
||||
#endif
|
||||
|
||||
} break;
|
||||
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -1182,10 +1181,10 @@ void quickStop() {
|
||||
// From Arduino DigitalPotControl example
|
||||
void digitalPotWrite(int address, int value) {
|
||||
#if HAS_DIGIPOTSS
|
||||
digitalWrite(DIGIPOTSS_PIN,LOW); // take the SS pin low to select the chip
|
||||
digitalWrite(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
|
||||
SPI.transfer(address); // send in the address and value via SPI:
|
||||
SPI.transfer(value);
|
||||
digitalWrite(DIGIPOTSS_PIN,HIGH); // take the SS pin high to de-select the chip:
|
||||
digitalWrite(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
|
||||
//delay(10);
|
||||
#else
|
||||
UNUSED(address);
|
||||
@ -1202,7 +1201,7 @@ void digipot_init() {
|
||||
pinMode(DIGIPOTSS_PIN, OUTPUT);
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
|
||||
digipot_current(i,digipot_motor_current[i]);
|
||||
digipot_current(i, digipot_motor_current[i]);
|
||||
}
|
||||
#endif
|
||||
#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
||||
@ -1222,7 +1221,7 @@ void digipot_current(uint8_t driver, int current) {
|
||||
const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
|
||||
digitalPotWrite(digipot_ch[driver], current);
|
||||
#elif defined(MOTOR_CURRENT_PWM_XY_PIN)
|
||||
switch(driver) {
|
||||
switch (driver) {
|
||||
case 0: analogWrite(MOTOR_CURRENT_PWM_XY_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
|
||||
case 1: analogWrite(MOTOR_CURRENT_PWM_Z_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
|
||||
case 2: analogWrite(MOTOR_CURRENT_PWM_E_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
|
||||
@ -1235,19 +1234,19 @@ void digipot_current(uint8_t driver, int current) {
|
||||
|
||||
void microstep_init() {
|
||||
#if HAS_MICROSTEPS_E1
|
||||
pinMode(E1_MS1_PIN,OUTPUT);
|
||||
pinMode(E1_MS2_PIN,OUTPUT);
|
||||
pinMode(E1_MS1_PIN, OUTPUT);
|
||||
pinMode(E1_MS2_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
#if HAS_MICROSTEPS
|
||||
pinMode(X_MS1_PIN,OUTPUT);
|
||||
pinMode(X_MS2_PIN,OUTPUT);
|
||||
pinMode(Y_MS1_PIN,OUTPUT);
|
||||
pinMode(Y_MS2_PIN,OUTPUT);
|
||||
pinMode(Z_MS1_PIN,OUTPUT);
|
||||
pinMode(Z_MS2_PIN,OUTPUT);
|
||||
pinMode(E0_MS1_PIN,OUTPUT);
|
||||
pinMode(E0_MS2_PIN,OUTPUT);
|
||||
pinMode(X_MS1_PIN, OUTPUT);
|
||||
pinMode(X_MS2_PIN, OUTPUT);
|
||||
pinMode(Y_MS1_PIN, OUTPUT);
|
||||
pinMode(Y_MS2_PIN, OUTPUT);
|
||||
pinMode(Z_MS1_PIN, OUTPUT);
|
||||
pinMode(Z_MS2_PIN, OUTPUT);
|
||||
pinMode(E0_MS1_PIN, OUTPUT);
|
||||
pinMode(E0_MS2_PIN, OUTPUT);
|
||||
const uint8_t microstep_modes[] = MICROSTEP_MODES;
|
||||
for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
|
||||
microstep_mode(i, microstep_modes[i]);
|
||||
@ -1255,7 +1254,7 @@ void microstep_init() {
|
||||
}
|
||||
|
||||
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
||||
if (ms1 >= 0) switch(driver) {
|
||||
if (ms1 >= 0) switch (driver) {
|
||||
case 0: digitalWrite(X_MS1_PIN, ms1); break;
|
||||
case 1: digitalWrite(Y_MS1_PIN, ms1); break;
|
||||
case 2: digitalWrite(Z_MS1_PIN, ms1); break;
|
||||
@ -1264,7 +1263,7 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
||||
case 4: digitalWrite(E1_MS1_PIN, ms1); break;
|
||||
#endif
|
||||
}
|
||||
if (ms2 >= 0) switch(driver) {
|
||||
if (ms2 >= 0) switch (driver) {
|
||||
case 0: digitalWrite(X_MS2_PIN, ms2); break;
|
||||
case 1: digitalWrite(Y_MS2_PIN, ms2); break;
|
||||
case 2: digitalWrite(Z_MS2_PIN, ms2); break;
|
||||
@ -1276,12 +1275,12 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
||||
}
|
||||
|
||||
void microstep_mode(uint8_t driver, uint8_t stepping_mode) {
|
||||
switch(stepping_mode) {
|
||||
case 1: microstep_ms(driver,MICROSTEP1); break;
|
||||
case 2: microstep_ms(driver,MICROSTEP2); break;
|
||||
case 4: microstep_ms(driver,MICROSTEP4); break;
|
||||
case 8: microstep_ms(driver,MICROSTEP8); break;
|
||||
case 16: microstep_ms(driver,MICROSTEP16); break;
|
||||
switch (stepping_mode) {
|
||||
case 1: microstep_ms(driver, MICROSTEP1); break;
|
||||
case 2: microstep_ms(driver, MICROSTEP2); break;
|
||||
case 4: microstep_ms(driver, MICROSTEP4); break;
|
||||
case 8: microstep_ms(driver, MICROSTEP8); break;
|
||||
case 16: microstep_ms(driver, MICROSTEP16); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user