Sergey Terentiev
3 years ago
148 changed files with 2820 additions and 13242 deletions
@ -1,139 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* Software L6470 SPI functions originally from Arduino Sd2Card Library |
|||
* Copyright (c) 2009 by William Greiman |
|||
*/ |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#include "Delay.h" |
|||
|
|||
#include "../../core/serial.h" |
|||
#include "../../libs/L64XX/L64XX_Marlin.h" |
|||
|
|||
// Make sure GCC optimizes this file.
|
|||
// Note that this line triggers a bug in GCC which is fixed by casting.
|
|||
// See the note below.
|
|||
#pragma GCC optimize (3) |
|||
|
|||
// run at ~4Mhz
|
|||
inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
|
|||
for (uint8_t bits = 8; bits--;) { |
|||
WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); |
|||
b <<= 1; // little setup time
|
|||
|
|||
WRITE(L6470_CHAIN_SCK_PIN, HIGH); |
|||
DELAY_NS(125); // 10 cycles @ 84mhz
|
|||
|
|||
b |= (READ(L6470_CHAIN_MISO_PIN) != 0); |
|||
|
|||
WRITE(L6470_CHAIN_SCK_PIN, LOW); |
|||
DELAY_NS(125); // 10 cycles @ 84mhz
|
|||
} |
|||
return b; |
|||
} |
|||
|
|||
inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
|
|||
for (uint8_t bits = 8; bits--;) { |
|||
WRITE(L6470_CHAIN_SCK_PIN, LOW); |
|||
WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); |
|||
|
|||
DELAY_NS(125); // 10 cycles @ 84mhz
|
|||
WRITE(L6470_CHAIN_SCK_PIN, HIGH); |
|||
DELAY_NS(125); // Need more delay for fast CPUs
|
|||
|
|||
b <<= 1; // little setup time
|
|||
b |= (READ(L6470_CHAIN_MISO_PIN) != 0); |
|||
} |
|||
DELAY_NS(125); // 10 cycles @ 84mhz
|
|||
return b; |
|||
} |
|||
|
|||
/**
|
|||
* L64XX methods for SPI init and transfer |
|||
*/ |
|||
void L64XX_Marlin::spi_init() { |
|||
OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH); |
|||
OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH); |
|||
OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); |
|||
SET_INPUT(L6470_CHAIN_MISO_PIN); |
|||
|
|||
#if PIN_EXISTS(L6470_BUSY) |
|||
SET_INPUT(L6470_BUSY_PIN); |
|||
#endif |
|||
|
|||
OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); |
|||
} |
|||
|
|||
uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { |
|||
// First device in chain has data sent last
|
|||
extDigitalWrite(ss_pin, LOW); |
|||
|
|||
hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
|||
const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); |
|||
hal.isr_on(); // Enable interrupts
|
|||
|
|||
extDigitalWrite(ss_pin, HIGH); |
|||
return data_out; |
|||
} |
|||
|
|||
uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) { |
|||
uint8_t data_out = 0; |
|||
|
|||
// first device in chain has data sent last
|
|||
extDigitalWrite(ss_pin, LOW); |
|||
|
|||
for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted
|
|||
hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
|||
const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); |
|||
hal.isr_on(); // Enable interrupts
|
|||
if (i == chain_position) data_out = temp; |
|||
} |
|||
|
|||
extDigitalWrite(ss_pin, HIGH); |
|||
return data_out; |
|||
} |
|||
|
|||
/**
|
|||
* Platform-supplied L6470 buffer transfer method |
|||
*/ |
|||
void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) { |
|||
// First device in chain has its data sent last
|
|||
|
|||
if (spi_active) { // Interrupted SPI transfer so need to
|
|||
WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650ns
|
|||
DELAY_US(1); |
|||
} |
|||
|
|||
WRITE(L6470_CHAIN_SS_PIN, LOW); |
|||
for (uint8_t i = length; i >= 1; i--) |
|||
L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i])); |
|||
WRITE(L6470_CHAIN_SS_PIN, HIGH); |
|||
} |
|||
|
|||
#pragma GCC reset_options |
|||
|
|||
#endif // HAS_L64XX
|
@ -1,151 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
#include "../../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#include "../../gcode.h" |
|||
#include "../../../libs/L64XX/L64XX_Marlin.h" |
|||
#include "../../../module/stepper/indirection.h" |
|||
|
|||
void echo_yes_no(const bool yes); |
|||
|
|||
inline void L6470_say_status(const L64XX_axis_t axis) { |
|||
if (L64xxManager.spi_abort) return; |
|||
const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; |
|||
L64xxManager.get_status(axis); |
|||
L64xxManager.say_axis(axis); |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
char temp_buf[20]; |
|||
sprintf_P(temp_buf, PSTR(" status: %4x "), sh.STATUS_AXIS_RAW); |
|||
SERIAL_ECHO(temp_buf); |
|||
print_bin(sh.STATUS_AXIS_RAW); |
|||
switch (sh.STATUS_AXIS_LAYOUT) { |
|||
case L6470_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6470"); break; |
|||
case L6474_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6474"); break; |
|||
case L6480_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6480/powerSTEP01"); break; |
|||
} |
|||
#endif |
|||
SERIAL_ECHOPGM("\n...OUTPUT: "); |
|||
SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON ")); |
|||
SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); |
|||
SERIAL_ECHOPGM(" DIR: "); |
|||
SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE")); |
|||
if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { |
|||
SERIAL_ECHOPGM(" Last Command: "); |
|||
if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); |
|||
else SERIAL_ECHOPGM("ERROR"); |
|||
SERIAL_ECHOPGM("\n...THERMAL: "); |
|||
switch ((sh.STATUS_AXIS & (sh.STATUS_AXIS_TH_SD | sh.STATUS_AXIS_TH_WRN)) >> 11) { |
|||
case 0: SERIAL_ECHOPGM("DEVICE SHUTDOWN"); break; |
|||
case 1: SERIAL_ECHOPGM("BRIDGE SHUTDOWN"); break; |
|||
case 2: SERIAL_ECHOPGM("WARNING "); break; |
|||
case 3: SERIAL_ECHOPGM("OK "); break; |
|||
} |
|||
} |
|||
else { |
|||
SERIAL_ECHOPGM(" Last Command: "); |
|||
if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); |
|||
SERIAL_ECHOPGM("VALID "); |
|||
SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED")); |
|||
SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); |
|||
} |
|||
SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); |
|||
if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { |
|||
SERIAL_ECHOPGM(" STALL:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_A) == 0 || (sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_B) == 0); |
|||
SERIAL_ECHOPGM(" STEP-CLOCK MODE:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_SCK_MOD) != 0); |
|||
} |
|||
else { |
|||
SERIAL_ECHOPGM(" STALL: NA " |
|||
" STEP-CLOCK MODE: NA" |
|||
" UNDER VOLTAGE LOCKOUT: "); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_UVLO) == 0); |
|||
} |
|||
SERIAL_EOL(); |
|||
} |
|||
|
|||
/**
|
|||
* M122: Debug L6470 drivers |
|||
*/ |
|||
void GcodeSuite::M122() { |
|||
L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
|
|||
L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway
|
|||
|
|||
//if (parser.seen('S'))
|
|||
// tmc_set_report_interval(parser.value_bool());
|
|||
//else
|
|||
|
|||
#if AXIS_IS_L64XX(X) |
|||
L6470_say_status(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
L6470_say_status(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
L6470_say_status(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
L6470_say_status(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
L6470_say_status(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
L6470_say_status(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
L6470_say_status(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
L6470_say_status(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
L6470_say_status(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
L6470_say_status(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
L6470_say_status(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
L6470_say_status(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
L6470_say_status(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
L6470_say_status(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
L6470_say_status(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
L6470_say_status(E7); |
|||
#endif |
|||
|
|||
L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags
|
|||
L64xxManager.spi_abort = false; |
|||
L64xxManager.pause_monitor(false); |
|||
} |
|||
|
|||
#endif // HAS_L64XX
|
@ -1,417 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
#include "../../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#if AXIS_COLLISION('I') |
|||
#error "M906 parameter 'I' collision with axis name." |
|||
#endif |
|||
|
|||
#include "../../gcode.h" |
|||
#include "../../../libs/L64XX/L64XX_Marlin.h" |
|||
#include "../../../module/stepper/indirection.h" |
|||
#include "../../../module/planner.h" |
|||
|
|||
#define DEBUG_OUT ENABLED(L6470_CHITCHAT) |
|||
#include "../../../core/debug_out.h" |
|||
|
|||
/**
|
|||
* MACRO to fetch information on the items associated with current limiting |
|||
* and maximum voltage output. |
|||
* |
|||
* L6470 can be setup to shutdown if either current threshold is exceeded. |
|||
* |
|||
* L6470 output current can not be set directly. It is set indirectly by |
|||
* setting the maximum effective output voltage. |
|||
* |
|||
* Effective output voltage is set by PWM duty cycle. |
|||
* |
|||
* Maximum effective output voltage is affected by MANY variables. The main ones are: |
|||
* KVAL_HOLD |
|||
* KVAL_RUN |
|||
* KVAL_ACC |
|||
* KVAL_DEC |
|||
* Vs compensation (if enabled) |
|||
*/ |
|||
void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { |
|||
|
|||
if (L64xxManager.spi_abort) return; // don't do anything if set_directions() has occurred
|
|||
|
|||
const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; |
|||
const uint16_t status = L64xxManager.get_status(axis); //also populates shadow structure
|
|||
const uint8_t OverCurrent_Threshold = uint8_t(motor.GetParam(L6470_OCD_TH)); |
|||
|
|||
auto say_axis_status = [](const L64XX_axis_t axis, const uint16_t status) { |
|||
L64xxManager.say_axis(axis); |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
char tmp[10]; |
|||
sprintf_P(tmp, PSTR("%4x "), status); |
|||
DEBUG_ECHOPGM(" status: ", tmp); |
|||
print_bin(status); |
|||
#else |
|||
UNUSED(status); |
|||
#endif |
|||
SERIAL_EOL(); |
|||
}; |
|||
|
|||
char temp_buf[10]; |
|||
|
|||
switch (sh.STATUS_AXIS_LAYOUT) { |
|||
case L6470_STATUS_LAYOUT: // L6470
|
|||
case L6480_STATUS_LAYOUT: { // L6480 & powerstep01
|
|||
const uint16_t Stall_Threshold = (uint8_t)motor.GetParam(L6470_STALL_TH), |
|||
motor_status = (status & (STATUS_MOT_STATUS)) >> 5, |
|||
L6470_ADC_out = motor.GetParam(L6470_ADC_OUT), |
|||
L6470_ADC_out_limited = constrain(L6470_ADC_out, 8, 24); |
|||
const float comp_coef = 1600.0f / L6470_ADC_out_limited; |
|||
const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); |
|||
|
|||
say_axis_status(axis, sh.STATUS_AXIS_RAW); |
|||
|
|||
SERIAL_ECHOPGM("...OverCurrent Threshold: "); |
|||
sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); |
|||
SERIAL_ECHO(temp_buf); |
|||
SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); |
|||
SERIAL_ECHOPGM(" mA)"); |
|||
SERIAL_ECHOPGM(" Stall Threshold: "); |
|||
sprintf_P(temp_buf, PSTR("%2d ("), Stall_Threshold); |
|||
SERIAL_ECHO(temp_buf); |
|||
SERIAL_ECHO((Stall_Threshold + 1) * motor.STALL_CURRENT_CONSTANT_INV); |
|||
SERIAL_ECHOPGM(" mA)"); |
|||
SERIAL_ECHOPGM(" Motor Status: "); |
|||
switch (motor_status) { |
|||
case 0: SERIAL_ECHOPGM("stopped"); break; |
|||
case 1: SERIAL_ECHOPGM("accelerating"); break; |
|||
case 2: SERIAL_ECHOPGM("decelerating"); break; |
|||
case 3: SERIAL_ECHOPGM("at constant speed"); break; |
|||
} |
|||
SERIAL_EOL(); |
|||
|
|||
SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, |
|||
" ADC_OUT: ", L6470_ADC_out); |
|||
SERIAL_ECHOPGM(" Vs_compensation: "); |
|||
SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED")); |
|||
SERIAL_ECHOLNPGM(" Compensation coefficient: ~", comp_coef * 0.01f); |
|||
|
|||
SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD), |
|||
" KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN), |
|||
" KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC), |
|||
" KVAL_DEC: ", motor.GetParam(L6470_KVAL_DEC), |
|||
" V motor max = "); |
|||
switch (motor_status) { |
|||
case 0: SERIAL_ECHO(motor.GetParam(L6470_KVAL_HOLD) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; |
|||
case 1: SERIAL_ECHO(motor.GetParam(L6470_KVAL_RUN) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_RUN)"); break; |
|||
case 2: SERIAL_ECHO(motor.GetParam(L6470_KVAL_ACC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_ACC)"); break; |
|||
case 3: SERIAL_ECHO(motor.GetParam(L6470_KVAL_DEC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; |
|||
} |
|||
SERIAL_EOL(); |
|||
|
|||
#if ENABLED(L6470_CHITCHAT) |
|||
DEBUG_ECHOPGM("...SLEW RATE: "); |
|||
switch (sh.STATUS_AXIS_LAYOUT) { |
|||
case L6470_STATUS_LAYOUT: { |
|||
switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { |
|||
case 0: { DEBUG_ECHOLNPGM("320V/uS") ; break; } |
|||
case 1: { DEBUG_ECHOLNPGM("75V/uS") ; break; } |
|||
case 2: { DEBUG_ECHOLNPGM("110V/uS") ; break; } |
|||
case 3: { DEBUG_ECHOLNPGM("260V/uS") ; break; } |
|||
} |
|||
break; |
|||
} |
|||
case L6480_STATUS_LAYOUT: { |
|||
switch (motor.GetParam(L6470_GATECFG1) & CONFIG1_SR ) { |
|||
case CONFIG1_SR_220V_us: { DEBUG_ECHOLNPGM("220V/uS") ; break; } |
|||
case CONFIG1_SR_400V_us: { DEBUG_ECHOLNPGM("400V/uS") ; break; } |
|||
case CONFIG1_SR_520V_us: { DEBUG_ECHOLNPGM("520V/uS") ; break; } |
|||
case CONFIG1_SR_980V_us: { DEBUG_ECHOLNPGM("980V/uS") ; break; } |
|||
default: { DEBUG_ECHOLNPGM("unknown") ; break; } |
|||
} |
|||
} |
|||
} |
|||
#endif |
|||
SERIAL_EOL(); |
|||
break; |
|||
} |
|||
|
|||
case L6474_STATUS_LAYOUT: { // L6474
|
|||
const uint16_t L6470_ADC_out = motor.GetParam(L6470_ADC_OUT) & 0x1F, |
|||
L6474_TVAL_val = motor.GetParam(L6474_TVAL) & 0x7F; |
|||
|
|||
say_axis_status(axis, sh.STATUS_AXIS_RAW); |
|||
|
|||
SERIAL_ECHOPGM("...OverCurrent Threshold: "); |
|||
sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); |
|||
SERIAL_ECHO(temp_buf); |
|||
SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); |
|||
SERIAL_ECHOPGM(" mA)"); |
|||
SERIAL_ECHOPGM(" TVAL: "); |
|||
sprintf_P(temp_buf, PSTR("%2d ("), L6474_TVAL_val); |
|||
SERIAL_ECHO(temp_buf); |
|||
SERIAL_ECHO((L6474_TVAL_val + 1) * motor.STALL_CURRENT_CONSTANT_INV); |
|||
SERIAL_ECHOLNPGM(" mA) Motor Status: NA"); |
|||
|
|||
const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); //NOMORE(MicroSteps, 16);
|
|||
SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, |
|||
" ADC_OUT: ", L6470_ADC_out); |
|||
|
|||
SERIAL_ECHOLNPGM(" Vs_compensation: NA\n"); |
|||
SERIAL_ECHOLNPGM("...KVAL_HOLD: NA" |
|||
" KVAL_RUN : NA" |
|||
" KVAL_ACC: NA" |
|||
" KVAL_DEC: NA" |
|||
" V motor max = NA"); |
|||
|
|||
#if ENABLED(L6470_CHITCHAT) |
|||
DEBUG_ECHOPGM("...SLEW RATE: "); |
|||
switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { |
|||
case 0: DEBUG_ECHOLNPGM("320V/uS") ; break; |
|||
case 1: DEBUG_ECHOLNPGM("75V/uS") ; break; |
|||
case 2: DEBUG_ECHOLNPGM("110V/uS") ; break; |
|||
case 3: DEBUG_ECHOLNPGM("260V/uS") ; break; |
|||
default: DEBUG_ECHOLNPGM("slew rate: ", (motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT); break; |
|||
} |
|||
#endif |
|||
SERIAL_EOL(); |
|||
SERIAL_EOL(); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/**
|
|||
* M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the |
|||
* PWMs to the steppers |
|||
* |
|||
* On L6474 this sets the TVAL register (same address). |
|||
* |
|||
* I - select which driver(s) to change on multi-driver axis |
|||
* (default) all drivers on the axis |
|||
* 0 - monitor only the first XYZ... driver |
|||
* 1 - monitor only X2, Y2, Z2 |
|||
* 2 - monitor only Z3 |
|||
* 3 - monitor only Z4 |
|||
* Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional) |
|||
* L6474 - current in mA (4A max) |
|||
* All others - 0-255 |
|||
* |
|||
* Sets KVAL_HOLD which affects the current being driven through the stepper. |
|||
* |
|||
* L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx |
|||
* that affects the effective voltage seen by the stepper. |
|||
*/ |
|||
void GcodeSuite::M906() { |
|||
|
|||
L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
|
|||
|
|||
#define L6470_SET_KVAL_HOLD(Q) (AXIS_IS_L64XX(Q) ? stepper##Q.setTVALCurrent(value) : stepper##Q.SetParam(L6470_KVAL_HOLD, uint8_t(value))) |
|||
|
|||
DEBUG_ECHOLNPGM("M906"); |
|||
|
|||
uint8_t report_current = true; |
|||
|
|||
#if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) |
|||
const int8_t index = parser.byteval('I', -1); |
|||
#else |
|||
constexpr int8_t index = -1; |
|||
#endif |
|||
|
|||
LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) { |
|||
|
|||
report_current = false; |
|||
|
|||
if (planner.has_blocks_queued() || planner.cleaning_buffer_counter) { |
|||
SERIAL_ECHOLNPGM("Test aborted. Can't set KVAL_HOLD while steppers are moving."); |
|||
return; |
|||
} |
|||
|
|||
switch (i) { |
|||
#if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2) |
|||
case X_AXIS: |
|||
#if AXIS_IS_L64XX(X) |
|||
if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2); |
|||
#endif |
|||
break; |
|||
#endif |
|||
|
|||
#if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2) |
|||
case Y_AXIS: |
|||
#if AXIS_IS_L64XX(Y) |
|||
if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); |
|||
#endif |
|||
break; |
|||
#endif |
|||
|
|||
#if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) |
|||
case Z_AXIS: |
|||
#if AXIS_IS_L64XX(Z) |
|||
if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); |
|||
#endif |
|||
break; |
|||
#endif |
|||
|
|||
#if AXIS_IS_L64XX(I) |
|||
case I_AXIS: L6470_SET_KVAL_HOLD(I); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
case J_AXIS: L6470_SET_KVAL_HOLD(J); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
case K_AXIS: L6470_SET_KVAL_HOLD(K); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(U) |
|||
case U_AXIS: L6470_SET_KVAL_HOLD(U); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(V) |
|||
case V_AXIS: L6470_SET_KVAL_HOLD(V); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(W) |
|||
case W_AXIS: L6470_SET_KVAL_HOLD(W); break; |
|||
#endif |
|||
|
|||
#if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7) |
|||
case E_AXIS: { |
|||
const int8_t eindex = get_target_e_stepper_from_command(-2); |
|||
#if AXIS_IS_L64XX(E0) |
|||
if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7); |
|||
#endif |
|||
} break; |
|||
#endif |
|||
} |
|||
} |
|||
|
|||
if (report_current) { |
|||
#define L64XX_REPORT_CURRENT(Q) L64XX_report_current(stepper##Q, Q) |
|||
|
|||
L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway
|
|||
|
|||
#if AXIS_IS_L64XX(X) |
|||
L64XX_REPORT_CURRENT(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
L64XX_REPORT_CURRENT(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
L64XX_REPORT_CURRENT(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
L64XX_REPORT_CURRENT(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
L64XX_REPORT_CURRENT(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
L64XX_REPORT_CURRENT(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
L64XX_REPORT_CURRENT(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
L64XX_REPORT_CURRENT(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
L64XX_REPORT_CURRENT(I); |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
L64XX_REPORT_CURRENT(J); |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
L64XX_REPORT_CURRENT(K); |
|||
#endif |
|||
#if AXIS_IS_L64XX(U) |
|||
L64XX_REPORT_CURRENT(U); |
|||
#endif |
|||
#if AXIS_IS_L64XX(V) |
|||
L64XX_REPORT_CURRENT(V); |
|||
#endif |
|||
#if AXIS_IS_L64XX(W) |
|||
L64XX_REPORT_CURRENT(W); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
L64XX_REPORT_CURRENT(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
L64XX_REPORT_CURRENT(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
L64XX_REPORT_CURRENT(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
L64XX_REPORT_CURRENT(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
L64XX_REPORT_CURRENT(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
L64XX_REPORT_CURRENT(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
L64XX_REPORT_CURRENT(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
L64XX_REPORT_CURRENT(E7); |
|||
#endif |
|||
|
|||
L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags
|
|||
L64xxManager.spi_abort = false; |
|||
L64xxManager.pause_monitor(false); |
|||
} |
|||
} |
|||
|
|||
#endif // HAS_L64XX
|
@ -1,650 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
//
|
|||
// NOTE: All tests assume each axis uses matching driver chips.
|
|||
//
|
|||
|
|||
#include "../../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#include "../../gcode.h" |
|||
#include "../../../module/stepper/indirection.h" |
|||
#include "../../../module/planner.h" |
|||
#include "../../../libs/L64XX/L64XX_Marlin.h" |
|||
|
|||
#define DEBUG_OUT ENABLED(L6470_CHITCHAT) |
|||
#include "../../../core/debug_out.h" |
|||
|
|||
/**
|
|||
* M916: increase KVAL_HOLD until get thermal warning |
|||
* NOTE - on L6474 it is TVAL that is used |
|||
* |
|||
* J - select which driver(s) to monitor on multi-driver axis |
|||
* 0 - (default) monitor all drivers on the axis or E0 |
|||
* 1 - monitor only X, Y, Z, E1 |
|||
* 2 - monitor only X2, Y2, Z2, E2 |
|||
* 3 - monitor only Z3, E3 |
|||
* 4 - monitor only Z4, E4 |
|||
* |
|||
* Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement |
|||
* xxx (1-255) is distance moved on either side of current position |
|||
* |
|||
* F - feedrate |
|||
* optional - will use default max feedrate from configuration.h if not specified |
|||
* |
|||
* T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* K - value for KVAL_HOLD (0 - 255) (ignored for L6474) |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* D - time (in seconds) to run each setting of KVAL_HOLD/TVAL |
|||
* optional - defaults to zero (runs each setting once) |
|||
*/ |
|||
|
|||
/**
|
|||
* This routine is also useful for determining the approximate KVAL_HOLD |
|||
* where the stepper stops losing steps. The sound will get noticeably quieter |
|||
* as it stops losing steps. |
|||
*/ |
|||
|
|||
void GcodeSuite::M916() { |
|||
|
|||
DEBUG_ECHOLNPGM("M916"); |
|||
|
|||
L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
|
|||
|
|||
// Variables used by L64xxManager.get_user_input function - some may not be used
|
|||
char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored
|
|||
L64XX_axis_t axis_index[3]; |
|||
uint16_t axis_status[3]; |
|||
uint8_t driver_count = 1; |
|||
float position_max; |
|||
float position_min; |
|||
float final_feedrate; |
|||
uint8_t kval_hold; |
|||
uint8_t OCD_TH_val = 0; |
|||
uint8_t STALL_TH_val = 0; |
|||
uint16_t over_current_threshold; |
|||
constexpr uint8_t over_current_flag = false; // M916 doesn't play with the overcurrent thresholds
|
|||
|
|||
#define DRIVER_TYPE_L6474(Q) AXIS_DRIVER_TYPE_##Q(L6474) |
|||
|
|||
uint8_t j; // general purpose counter
|
|||
|
|||
if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) |
|||
return; // quit if invalid user input
|
|||
|
|||
DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); |
|||
|
|||
planner.synchronize(); // wait for all current movement commands to complete
|
|||
|
|||
const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; |
|||
for (j = 0; j < driver_count; j++) |
|||
L64xxManager.get_status(axis_index[j]); // clear out any pre-existing error flags
|
|||
|
|||
char temp_axis_string[] = " "; |
|||
temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section
|
|||
char gcode_string[80]; |
|||
uint16_t status_composite = 0; |
|||
|
|||
uint16_t M91x_counter = kval_hold; |
|||
uint16_t M91x_counter_max; |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { |
|||
M91x_counter_max = 128; // TVAL is 7 bits
|
|||
LIMIT(M91x_counter, 0U, 127U); |
|||
} |
|||
else |
|||
M91x_counter_max = 256; // KVAL_HOLD is 8 bits
|
|||
|
|||
uint8_t M91x_delay_s = parser.byteval('D'); // get delay in seconds
|
|||
millis_t M91x_delay_ms = SEC_TO_MS(M91x_delay_s * 60); |
|||
millis_t M91x_delay_end; |
|||
|
|||
DEBUG_ECHOLNPGM(".\n."); |
|||
|
|||
do { |
|||
|
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) |
|||
DEBUG_ECHOLNPGM("TVAL current (mA) = ", (M91x_counter + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); // report TVAL current for this run
|
|||
else |
|||
DEBUG_ECHOLNPGM("kval_hold = ", M91x_counter); // report KVAL_HOLD for this run
|
|||
|
|||
for (j = 0; j < driver_count; j++) |
|||
L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, M91x_counter); //set KVAL_HOLD or TVAL (same register address)
|
|||
|
|||
M91x_delay_end = millis() + M91x_delay_ms; |
|||
do { |
|||
// turn the motor(s) both directions
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
// get the status after the motors have stopped
|
|||
planner.synchronize(); |
|||
|
|||
status_composite = 0; // clear out the old bits
|
|||
|
|||
for (j = 0; j < driver_count; j++) { |
|||
axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low
|
|||
status_composite |= axis_status[j] ; |
|||
} |
|||
|
|||
if (status_composite) break; |
|||
} while (millis() < M91x_delay_end); |
|||
|
|||
if (status_composite) break; |
|||
|
|||
M91x_counter++; |
|||
|
|||
} while (!(status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) && (M91x_counter < M91x_counter_max)); |
|||
|
|||
DEBUG_ECHOLNPGM("."); |
|||
|
|||
#if ENABLED(L6470_CHITCHAT) |
|||
if (status_composite) { |
|||
L64xxManager.error_status_decode(status_composite, axis_index[0], |
|||
sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, |
|||
sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, |
|||
sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); |
|||
DEBUG_ECHOLNPGM("."); |
|||
} |
|||
#endif |
|||
|
|||
if ((status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD))) |
|||
DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Thermal warning/shutdown has occurred"); |
|||
else if (status_composite) |
|||
DEBUG_ECHOLNPGM(".\n.\nTest completed abnormally - non-thermal error has occurred"); |
|||
else |
|||
DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Unable to get to thermal warning/shutdown"); |
|||
|
|||
L64xxManager.pause_monitor(false); |
|||
} |
|||
|
|||
/**
|
|||
* M917: Find minimum current thresholds |
|||
* |
|||
* Decrease OCD current until overcurrent error |
|||
* Increase OCD until overcurrent error goes away |
|||
* Decrease stall threshold until stall (not done on L6474) |
|||
* Increase stall until stall error goes away (not done on L6474) |
|||
* |
|||
* J - select which driver(s) to monitor on multi-driver axis |
|||
* 0 - (default) monitor all drivers on the axis or E0 |
|||
* 1 - monitor only X, Y, Z, E1 |
|||
* 2 - monitor only X2, Y2, Z2, E2 |
|||
* Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement |
|||
* xxx (1-255) is distance moved on either side of current position |
|||
* |
|||
* F - feedrate |
|||
* optional - will use default max feedrate from Configuration.h if not specified |
|||
* |
|||
* I - starting over-current threshold |
|||
* optional - will report current value from driver if not specified |
|||
* if there are multiple drivers on the axis then all will be set the same |
|||
* |
|||
* T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* K - value for KVAL_HOLD (0 - 255) (ignored for L6474) |
|||
* optional - will report current value from driver if not specified |
|||
*/ |
|||
void GcodeSuite::M917() { |
|||
|
|||
DEBUG_ECHOLNPGM("M917"); |
|||
|
|||
L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
|
|||
|
|||
char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored
|
|||
L64XX_axis_t axis_index[3]; |
|||
uint16_t axis_status[3]; |
|||
uint8_t driver_count = 1; |
|||
float position_max; |
|||
float position_min; |
|||
float final_feedrate; |
|||
uint8_t kval_hold; |
|||
uint8_t OCD_TH_val = 0; |
|||
uint8_t STALL_TH_val = 0; |
|||
uint16_t over_current_threshold; |
|||
constexpr uint8_t over_current_flag = true; |
|||
|
|||
uint8_t j; // general purpose counter
|
|||
|
|||
if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) |
|||
return; // quit if invalid user input
|
|||
|
|||
DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); |
|||
|
|||
planner.synchronize(); // wait for all current movement commands to complete
|
|||
|
|||
const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; |
|||
for (j = 0; j < driver_count; j++) |
|||
L64xxManager.get_status(axis_index[j]); // clear error flags
|
|||
char temp_axis_string[] = " "; |
|||
temp_axis_string[0] = axis_mon[0][0]; // need a sprintf format string
|
|||
char gcode_string[80]; |
|||
uint16_t status_composite = 0; |
|||
uint8_t test_phase = 0; // 0 - decreasing OCD - exit when OCD warning occurs (ignore STALL)
|
|||
// 1 - increasing OCD - exit when OCD warning stops (ignore STALL)
|
|||
// 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
|
|||
// 3 - OCD finalized - increasing STALL - exit when STALL warning stop
|
|||
// 4 - all testing completed
|
|||
DEBUG_ECHOPGM(".\n.\n.\nover_current threshold : ", (OCD_TH_val + 1) * 375); // first status display
|
|||
DEBUG_ECHOPGM(" (OCD_TH: : ", OCD_TH_val); |
|||
if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { |
|||
DEBUG_ECHOPGM(") Stall threshold: ", (STALL_TH_val + 1) * 31.25); |
|||
DEBUG_ECHOPGM(" (STALL_TH: ", STALL_TH_val); |
|||
} |
|||
DEBUG_ECHOLNPGM(")"); |
|||
|
|||
do { |
|||
|
|||
if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) DEBUG_ECHOPGM("STALL threshold : ", (STALL_TH_val + 1) * 31.25); |
|||
DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375); |
|||
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
planner.synchronize(); |
|||
|
|||
status_composite = 0; // clear out the old bits
|
|||
|
|||
for (j = 0; j < driver_count; j++) { |
|||
axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low
|
|||
status_composite |= axis_status[j]; |
|||
} |
|||
|
|||
if (status_composite && (status_composite & sh.STATUS_AXIS_UVLO)) { |
|||
DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
for (j = 0; j < driver_count; j++) { |
|||
if (j) DEBUG_ECHOPGM("..."); |
|||
L64xxManager.error_status_decode(axis_status[j], axis_index[j], |
|||
sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, |
|||
sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, |
|||
sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); |
|||
} |
|||
#endif |
|||
return; |
|||
} |
|||
|
|||
if (status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) { |
|||
DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); |
|||
uint16_t status_composite_temp = 0; |
|||
uint8_t k = 0; |
|||
do { |
|||
k++; |
|||
if (!(k % 4)) { |
|||
kval_hold *= 0.95; |
|||
DEBUG_EOL(); |
|||
DEBUG_ECHOLNPGM("Lowering KVAL_HOLD by about 5% to ", kval_hold); |
|||
for (j = 0; j < driver_count; j++) |
|||
L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); |
|||
} |
|||
DEBUG_ECHOLNPGM("."); |
|||
reset_stepper_timeout(); // keep steppers powered
|
|||
safe_delay(5000); |
|||
status_composite_temp = 0; |
|||
for (j = 0; j < driver_count; j++) { |
|||
axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low
|
|||
status_composite_temp |= axis_status[j]; |
|||
} |
|||
} |
|||
while (status_composite_temp & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)); |
|||
DEBUG_EOL(); |
|||
} |
|||
if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B | sh.STATUS_AXIS_OCD)) { |
|||
switch (test_phase) { |
|||
|
|||
case 0: { |
|||
if (status_composite & sh.STATUS_AXIS_OCD) { |
|||
// phase 0 with OCD warning - time to go to next phase
|
|||
if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { |
|||
OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max
|
|||
test_phase = 2; // at highest value so skip phase 1
|
|||
//DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
|
|||
DEBUG_ECHOLNPGM("OCD at highest - OCD finalized"); |
|||
} |
|||
else { |
|||
OCD_TH_val++; // normal exit to next phase
|
|||
test_phase = 1; // setup for first pass of phase 1
|
|||
//DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1");
|
|||
DEBUG_ECHOLNPGM("inc OCD"); |
|||
} |
|||
} |
|||
else { // phase 0 without OCD warning - keep on decrementing if can
|
|||
if (OCD_TH_val) { |
|||
OCD_TH_val--; // try lower value
|
|||
//DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD");
|
|||
DEBUG_ECHOLNPGM("dec OCD"); |
|||
} |
|||
else { |
|||
test_phase = 2; // at lowest value without warning so skip phase 1
|
|||
//DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
|
|||
DEBUG_ECHOLNPGM("OCD finalized"); |
|||
} |
|||
} |
|||
} break; |
|||
|
|||
case 1: { |
|||
if (status_composite & sh.STATUS_AXIS_OCD) { |
|||
// phase 1 with OCD warning - increment if can
|
|||
if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { |
|||
OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max
|
|||
test_phase = 2; // at highest value so go to next phase
|
|||
//DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
|
|||
DEBUG_ECHOLNPGM("OCD finalized"); |
|||
} |
|||
else { |
|||
OCD_TH_val++; // try a higher value
|
|||
//DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD");
|
|||
DEBUG_ECHOLNPGM("inc OCD"); |
|||
} |
|||
} |
|||
else { // phase 1 without OCD warning - normal exit to phase 2
|
|||
test_phase = 2; |
|||
//DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
|
|||
DEBUG_ECHOLNPGM("OCD finalized"); |
|||
} |
|||
} break; |
|||
|
|||
case 2: { |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474
|
|||
test_phase = 4; |
|||
break; |
|||
} |
|||
if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { |
|||
// phase 2 with stall warning - time to go to next phase
|
|||
if (STALL_TH_val >= 127) { |
|||
STALL_TH_val = 127; // limit to max
|
|||
//DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
|
|||
DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); |
|||
test_phase = 4; |
|||
} |
|||
else { |
|||
test_phase = 3; // normal exit to next phase (found failing value of STALL)
|
|||
STALL_TH_val++; // setup for first pass of phase 3
|
|||
//DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
|
|||
DEBUG_ECHOLNPGM("inc Stall"); |
|||
} |
|||
} |
|||
else { // phase 2 without stall warning - decrement if can
|
|||
if (STALL_TH_val) { |
|||
STALL_TH_val--; // try a lower value
|
|||
//DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
|
|||
DEBUG_ECHOLNPGM("dec STALL"); |
|||
} |
|||
else { |
|||
DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); |
|||
test_phase = 4; |
|||
//DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
|
|||
} |
|||
} |
|||
} break; |
|||
|
|||
case 3: { |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474
|
|||
test_phase = 4; |
|||
break; |
|||
} |
|||
if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { |
|||
// phase 3 with stall warning - increment if can
|
|||
if (STALL_TH_val >= 127) { |
|||
STALL_TH_val = 127; // limit to max
|
|||
DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); |
|||
test_phase = 4; |
|||
//DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
|
|||
} |
|||
else { |
|||
STALL_TH_val++; // still looking for passing value
|
|||
//DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
|
|||
DEBUG_ECHOLNPGM("inc stall"); |
|||
} |
|||
} |
|||
else { //phase 3 without stall warning but have OCD warning
|
|||
DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); |
|||
test_phase = 4; |
|||
//DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
|
|||
} |
|||
} break; |
|||
|
|||
} |
|||
|
|||
} |
|||
else { |
|||
switch (test_phase) { |
|||
case 0: { // phase 0 without OCD warning - keep on decrementing if can
|
|||
if (OCD_TH_val) { |
|||
OCD_TH_val--; // try lower value
|
|||
//DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD");
|
|||
DEBUG_ECHOLNPGM("DEC OCD"); |
|||
} |
|||
else { |
|||
test_phase = 2; // at lowest value without warning so skip phase 1
|
|||
//DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
|
|||
DEBUG_ECHOLNPGM("OCD finalized"); |
|||
} |
|||
} break; |
|||
|
|||
case 1: //DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
|
|||
DEBUG_ECHOLNPGM("OCD finalized"); |
|||
|
|||
case 2: { // phase 2 without stall warning - keep on decrementing if can
|
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474
|
|||
test_phase = 4; |
|||
break; |
|||
} |
|||
if (STALL_TH_val) { |
|||
STALL_TH_val--; // try a lower value (stay in phase 2)
|
|||
//DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL");
|
|||
DEBUG_ECHOLNPGM("dec STALL"); |
|||
} |
|||
else { |
|||
DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); |
|||
test_phase = 4; |
|||
//DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
|
|||
} |
|||
} break; |
|||
|
|||
case 3: { |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474
|
|||
test_phase = 4; |
|||
break; |
|||
} |
|||
test_phase = 4; |
|||
//DEBUG_ECHOLNPGM("LOGIC N3 - finished!");
|
|||
DEBUG_ECHOLNPGM("finished!"); |
|||
} break; // phase 3 without any warnings - desired exit
|
|||
} //
|
|||
} // end of status checks
|
|||
|
|||
if (test_phase != 4) { |
|||
for (j = 0; j < driver_count; j++) { // update threshold(s)
|
|||
L64xxManager.set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val); |
|||
if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) L64xxManager.set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val); |
|||
if (L64xxManager.get_param(axis_index[j], L6470_OCD_TH) != OCD_TH_val) DEBUG_ECHOLNPGM("OCD mismatch"); |
|||
if ((L64xxManager.get_param(axis_index[j], L6470_STALL_TH) != STALL_TH_val) && (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT)) DEBUG_ECHOLNPGM("STALL mismatch"); |
|||
} |
|||
} |
|||
|
|||
} while (test_phase != 4); |
|||
|
|||
DEBUG_ECHOLNPGM("."); |
|||
if (status_composite) { |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
for (j = 0; j < driver_count; j++) { |
|||
if (j) DEBUG_ECHOPGM("..."); |
|||
L64xxManager.error_status_decode(axis_status[j], axis_index[j], |
|||
sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, |
|||
sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, |
|||
sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); |
|||
} |
|||
DEBUG_ECHOLNPGM("."); |
|||
#endif |
|||
DEBUG_ECHOLNPGM("Completed with errors"); |
|||
} |
|||
else |
|||
DEBUG_ECHOLNPGM("Completed with no errors"); |
|||
DEBUG_ECHOLNPGM("."); |
|||
|
|||
L64xxManager.pause_monitor(false); |
|||
} |
|||
|
|||
/**
|
|||
* M918: increase speed until error or max feedrate achieved (as shown in configuration.h)) |
|||
* |
|||
* J - select which driver(s) to monitor on multi-driver axis |
|||
* 0 - (default) monitor all drivers on the axis or E0 |
|||
* 1 - monitor only X, Y, Z, E1 |
|||
* 2 - monitor only X2, Y2, Z2, E2 |
|||
* Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement |
|||
* xxx (1-255) is distance moved on either side of current position |
|||
* |
|||
* I - over current threshold |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* K - value for KVAL_HOLD (0 - 255) (ignored for L6474) |
|||
* optional - will report current value from driver if not specified |
|||
* |
|||
* M - value for microsteps (1 - 128) (optional) |
|||
* optional - will report current value from driver if not specified |
|||
*/ |
|||
void GcodeSuite::M918() { |
|||
|
|||
DEBUG_ECHOLNPGM("M918"); |
|||
|
|||
L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
|
|||
|
|||
char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored
|
|||
L64XX_axis_t axis_index[3]; |
|||
uint16_t axis_status[3]; |
|||
uint8_t driver_count = 1; |
|||
float position_max, position_min; |
|||
float final_feedrate; |
|||
uint8_t kval_hold; |
|||
uint8_t OCD_TH_val = 0; |
|||
uint8_t STALL_TH_val = 0; |
|||
uint16_t over_current_threshold; |
|||
constexpr uint8_t over_current_flag = true; |
|||
|
|||
const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; |
|||
|
|||
uint8_t j; // general purpose counter
|
|||
|
|||
if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) |
|||
return; // quit if invalid user input
|
|||
|
|||
L64xxManager.get_status(axis_index[0]); // populate shadow array
|
|||
|
|||
uint8_t m_steps = parser.byteval('M'); |
|||
|
|||
if (m_steps != 0) { |
|||
LIMIT(m_steps, 1, sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT ? 16 : 128); // L6474
|
|||
|
|||
uint8_t stepVal; |
|||
for (stepVal = 0; stepVal < 8; stepVal++) { // convert to L64xx register value
|
|||
if (m_steps == 1) break; |
|||
m_steps >>= 1; |
|||
} |
|||
|
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) |
|||
stepVal |= 0x98; // NO SYNC
|
|||
else |
|||
stepVal |= (!SYNC_EN) | SYNC_SEL_1 | stepVal; |
|||
|
|||
for (j = 0; j < driver_count; j++) { |
|||
L64xxManager.set_param(axis_index[j], dSPIN_HARD_HIZ, 0); // can't write STEP register if stepper being powered
|
|||
// results in an extra NOOP being sent (data 00)
|
|||
L64xxManager.set_param(axis_index[j], L6470_STEP_MODE, stepVal); // set microsteps
|
|||
} |
|||
} |
|||
m_steps = L64xxManager.get_param(axis_index[0], L6470_STEP_MODE) & 0x07; // get microsteps
|
|||
|
|||
DEBUG_ECHOLNPGM("Microsteps = ", _BV(m_steps)); |
|||
DEBUG_ECHOLNPGM("target (maximum) feedrate = ", final_feedrate); |
|||
|
|||
const float feedrate_inc = final_feedrate / 10, // Start at 1/10 of max & go up by 1/10 per step
|
|||
fr_limit = final_feedrate * 0.99f; // Rounding-safe comparison value
|
|||
float current_feedrate = 0; |
|||
|
|||
planner.synchronize(); // Wait for moves to complete
|
|||
|
|||
for (j = 0; j < driver_count; j++) |
|||
L64xxManager.get_status(axis_index[j]); // Clear error flags
|
|||
|
|||
char temp_axis_string[2] = " "; |
|||
temp_axis_string[0] = axis_mon[0][0]; // Need a sprintf format string
|
|||
//temp_axis_string[1] = '\n';
|
|||
|
|||
char gcode_string[80]; |
|||
uint16_t status_composite = 0; |
|||
DEBUG_ECHOLNPGM(".\n.\n."); // Make feedrate outputs easier to read
|
|||
|
|||
do { |
|||
current_feedrate += feedrate_inc; |
|||
DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate); |
|||
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate)); |
|||
process_subcommands_now(gcode_string); |
|||
|
|||
planner.synchronize(); |
|||
|
|||
for (j = 0; j < driver_count; j++) { |
|||
axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & 0x0800; // Bits of interest are all active LOW
|
|||
status_composite |= axis_status[j]; |
|||
} |
|||
if (status_composite) break; // Break on any error
|
|||
} while (current_feedrate < fr_limit); |
|||
|
|||
DEBUG_ECHOPGM("Completed with "); |
|||
if (status_composite) { |
|||
DEBUG_ECHOLNPGM("errors"); |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
for (j = 0; j < driver_count; j++) { |
|||
if (j) DEBUG_ECHOPGM("..."); |
|||
L64xxManager.error_status_decode(axis_status[j], axis_index[j], |
|||
sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, |
|||
sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, |
|||
sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); |
|||
} |
|||
#endif |
|||
} |
|||
else |
|||
DEBUG_ECHOLNPGM("no errors"); |
|||
|
|||
L64xxManager.pause_monitor(false); |
|||
} |
|||
|
|||
#endif // HAS_L64XX
|
@ -1,7 +0,0 @@ |
|||
# DWIN for Creality Ender 3 v2 |
|||
|
|||
Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Creality/Ender-3%20V2). |
|||
|
|||
## Easy Install |
|||
|
|||
Copy the `DWIN_SET` folder onto a Micro-SD card and insert the card into the slot on the DWIN screen. Cycle the machine and wait for the screen to go from blue to orange. Turn the machine off and remove the SD card. When you turn on the machine the screen will display a "Creality" loading screen. |
File diff suppressed because it is too large
@ -1,245 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
/**
|
|||
* lcd/e3v2/jyersui/dwin.h |
|||
*/ |
|||
|
|||
#include "dwin_lcd.h" |
|||
#include "../common/dwin_set.h" |
|||
#include "../common/dwin_font.h" |
|||
#include "../common/dwin_color.h" |
|||
#include "../common/encoder.h" |
|||
#include "../../../libs/BL24CXX.h" |
|||
|
|||
#include "../../../inc/MarlinConfigPre.h" |
|||
|
|||
//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
|
|||
|
|||
enum processID : uint8_t { |
|||
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait |
|||
}; |
|||
|
|||
enum PopupID : uint8_t { |
|||
Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot, |
|||
Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing, |
|||
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom |
|||
}; |
|||
|
|||
enum menuID : uint8_t { |
|||
MainMenu, |
|||
Prepare, |
|||
Move, |
|||
HomeMenu, |
|||
ManualLevel, |
|||
ZOffset, |
|||
Preheat, |
|||
ChangeFilament, |
|||
MenuCustom, |
|||
Control, |
|||
TempMenu, |
|||
PID, |
|||
HotendPID, |
|||
BedPID, |
|||
#if HAS_PREHEAT |
|||
#define _PREHEAT_ID(N) Preheat##N, |
|||
REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID) |
|||
#endif |
|||
Motion, |
|||
HomeOffsets, |
|||
MaxSpeed, |
|||
MaxAcceleration, |
|||
MaxJerk, |
|||
Steps, |
|||
Visual, |
|||
ColorSettings, |
|||
Advanced, |
|||
ProbeMenu, |
|||
Info, |
|||
Leveling, |
|||
LevelManual, |
|||
LevelView, |
|||
MeshViewer, |
|||
LevelSettings, |
|||
ManualMesh, |
|||
UBLMesh, |
|||
InfoMain, |
|||
Tune, |
|||
PreheatHotend |
|||
}; |
|||
|
|||
// Custom icons
|
|||
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) |
|||
// index of every custom icon should be >= CUSTOM_ICON_START
|
|||
#define CUSTOM_ICON_START ICON_Checkbox_F |
|||
#define ICON_Checkbox_F 200 |
|||
#define ICON_Checkbox_T 201 |
|||
#define ICON_Fade 202 |
|||
#define ICON_Mesh 203 |
|||
#define ICON_Tilt 204 |
|||
#define ICON_Brightness 205 |
|||
#define ICON_AxisD 249 |
|||
#define ICON_AxisBR 250 |
|||
#define ICON_AxisTR 251 |
|||
#define ICON_AxisBL 252 |
|||
#define ICON_AxisTL 253 |
|||
#define ICON_AxisC 254 |
|||
#else |
|||
#define ICON_Fade ICON_Version |
|||
#define ICON_Mesh ICON_Version |
|||
#define ICON_Tilt ICON_Version |
|||
#define ICON_Brightness ICON_Version |
|||
#define ICON_AxisD ICON_Axis |
|||
#define ICON_AxisBR ICON_Axis |
|||
#define ICON_AxisTR ICON_Axis |
|||
#define ICON_AxisBL ICON_Axis |
|||
#define ICON_AxisTL ICON_Axis |
|||
#define ICON_AxisC ICON_Axis |
|||
#endif |
|||
|
|||
enum colorID : uint8_t { |
|||
Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black |
|||
}; |
|||
|
|||
#define Custom_Colors 10 |
|||
#define Color_Aqua RGB(0x00,0x3F,0x1F) |
|||
#define Color_Light_White 0xBDD7 |
|||
#define Color_Green RGB(0x00,0x3F,0x00) |
|||
#define Color_Light_Green 0x3460 |
|||
#define Color_Cyan 0x07FF |
|||
#define Color_Light_Cyan 0x04F3 |
|||
#define Color_Blue 0x015F |
|||
#define Color_Light_Blue 0x3A6A |
|||
#define Color_Magenta 0xF81F |
|||
#define Color_Light_Magenta 0x9813 |
|||
#define Color_Light_Red 0x8800 |
|||
#define Color_Orange 0xFA20 |
|||
#define Color_Light_Orange 0xFBC0 |
|||
#define Color_Light_Yellow 0x8BE0 |
|||
#define Color_Brown 0xCC27 |
|||
#define Color_Light_Brown 0x6204 |
|||
#define Color_Black 0x0000 |
|||
#define Color_Grey 0x18E3 |
|||
#define Check_Color 0x4E5C // Check-box check color
|
|||
#define Confirm_Color 0x34B9 |
|||
#define Cancel_Color 0x3186 |
|||
|
|||
class CrealityDWINClass { |
|||
public: |
|||
static constexpr size_t eeprom_data_size = 48; |
|||
static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
|
|||
bool time_format_textual : 1; |
|||
#if ENABLED(AUTO_BED_LEVELING_UBL) |
|||
uint8_t tilt_grid_size : 3; |
|||
#endif |
|||
uint16_t corner_pos : 10; |
|||
uint8_t cursor_color : 4; |
|||
uint8_t menu_split_line : 4; |
|||
uint8_t menu_top_bg : 4; |
|||
uint8_t menu_top_txt : 4; |
|||
uint8_t highlight_box : 4; |
|||
uint8_t progress_percent : 4; |
|||
uint8_t progress_time : 4; |
|||
uint8_t status_bar_text : 4; |
|||
uint8_t status_area_text : 4; |
|||
uint8_t coordinates_text : 4; |
|||
uint8_t coordinates_split_line : 4; |
|||
} eeprom_settings; |
|||
|
|||
static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" }; |
|||
static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" }; |
|||
|
|||
static void Clear_Screen(uint8_t e=3); |
|||
static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10); |
|||
static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false); |
|||
static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false); |
|||
static void Draw_Checkbox(uint8_t row, bool value); |
|||
static void Draw_Title(const char * title); |
|||
static void Draw_Title(FSTR_P const title); |
|||
static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false); |
|||
static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false); |
|||
static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0); |
|||
static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false); |
|||
static void Redraw_Screen(); |
|||
|
|||
static void Main_Menu_Icons(); |
|||
static void Draw_Main_Menu(uint8_t select=0); |
|||
static void Print_Screen_Icons(); |
|||
static void Draw_Print_Screen(); |
|||
static void Draw_Print_Filename(const bool reset=false); |
|||
static void Draw_Print_ProgressBar(); |
|||
#if ENABLED(USE_M73_REMAINING_TIME) |
|||
static void Draw_Print_ProgressRemain(); |
|||
#endif |
|||
static void Draw_Print_ProgressElapsed(); |
|||
static void Draw_Print_confirm(); |
|||
static void Draw_SD_Item(uint8_t item, uint8_t row); |
|||
static void Draw_SD_List(bool removed=false); |
|||
static void Draw_Status_Area(bool icons=false); |
|||
static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0); |
|||
static void Popup_Select(); |
|||
static void Update_Status_Bar(bool refresh=false); |
|||
|
|||
#if ENABLED(AUTO_BED_LEVELING_UBL) |
|||
static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); |
|||
static void Set_Mesh_Viewer_Status(); |
|||
#endif |
|||
|
|||
static FSTR_P Get_Menu_Title(uint8_t menu); |
|||
static uint8_t Get_Menu_Size(uint8_t menu); |
|||
static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true); |
|||
|
|||
static void Popup_Handler(PopupID popupid, bool option = false); |
|||
static void Confirm_Handler(PopupID popupid); |
|||
|
|||
static void Main_Menu_Control(); |
|||
static void Menu_Control(); |
|||
static void Value_Control(); |
|||
static void Option_Control(); |
|||
static void File_Control(); |
|||
static void Print_Screen_Control(); |
|||
static void Popup_Control(); |
|||
static void Confirm_Control(); |
|||
|
|||
static void Setup_Value(float value, float min, float max, float unit, uint8_t type); |
|||
static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr); |
|||
static void Modify_Option(uint8_t value, const char * const * options, uint8_t max); |
|||
|
|||
static void Update_Status(const char * const text); |
|||
static void Start_Print(bool sd); |
|||
static void Stop_Print(); |
|||
static void Update(); |
|||
static void State_Update(); |
|||
static void Screen_Update(); |
|||
static void AudioFeedback(const bool success=true); |
|||
static void Save_Settings(char *buff); |
|||
static void Load_Settings(const char *buff); |
|||
static void Reset_Settings(); |
|||
}; |
|||
|
|||
extern CrealityDWINClass CrealityDWIN; |
@ -1,64 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/********************************************************************************
|
|||
* @file lcd/e3v2/jyersui/dwin_lcd.cpp |
|||
* @brief DWIN screen control functions |
|||
********************************************************************************/ |
|||
|
|||
#include "../../../inc/MarlinConfigPre.h" |
|||
|
|||
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) |
|||
|
|||
#include "dwin_lcd.h" |
|||
|
|||
/*-------------------------------------- System variable function --------------------------------------*/ |
|||
|
|||
void DWIN_Startup() {} |
|||
|
|||
/*---------------------------------------- Drawing functions ----------------------------------------*/ |
|||
|
|||
// Draw the degree (°) symbol
|
|||
// Color: color
|
|||
// x/y: Upper-left coordinate of the first pixel
|
|||
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) { |
|||
DWIN_Draw_Point(Color, 1, 1, x + 1, y); |
|||
DWIN_Draw_Point(Color, 1, 1, x + 2, y); |
|||
DWIN_Draw_Point(Color, 1, 1, x, y + 1); |
|||
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 1); |
|||
DWIN_Draw_Point(Color, 1, 1, x, y + 2); |
|||
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 2); |
|||
DWIN_Draw_Point(Color, 1, 1, x + 1, y + 3); |
|||
DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3); |
|||
} |
|||
|
|||
/*---------------------------------------- Picture related functions ----------------------------------------*/ |
|||
|
|||
// Draw an Icon
|
|||
// libID: Icon library ID
|
|||
// picID: Icon ID
|
|||
// x/y: Upper-left point
|
|||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { |
|||
DWIN_ICON_Show(true, false, false, libID, picID, x, y); |
|||
} |
|||
|
|||
#endif // DWIN_CREALITY_LCD_JYERSUI
|
@ -1,998 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* The monitor_driver routines are a close copy of the TMC code |
|||
*/ |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#include "L64XX_Marlin.h" |
|||
|
|||
L64XX_Marlin L64xxManager; |
|||
|
|||
#include "../../module/stepper/indirection.h" |
|||
#include "../../gcode/gcode.h" |
|||
#include "../../module/planner.h" |
|||
#include "../../HAL/shared/Delay.h" |
|||
|
|||
static const char NUM_AXIS_LIST( |
|||
str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", |
|||
str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " |
|||
), |
|||
str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", |
|||
str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", |
|||
LIST_N(EXTRUDERS, |
|||
str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1", |
|||
str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3", |
|||
str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5", |
|||
str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7" |
|||
) |
|||
; |
|||
|
|||
#define _EN_ITEM(N) , str_E##N |
|||
PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { |
|||
NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), |
|||
str_X2, str_Y2, str_Z2, str_Z3, str_Z4 |
|||
REPEAT(E_STEPPERS, _EN_ITEM) |
|||
}; |
|||
#undef _EN_ITEM |
|||
|
|||
#define DEBUG_OUT ENABLED(L6470_CHITCHAT) |
|||
#include "../../core/debug_out.h" |
|||
|
|||
void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" NO ")); UNUSED(yes); } |
|||
|
|||
uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver
|
|||
|
|||
#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) |
|||
const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { |
|||
NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR)) |
|||
, ENABLED(INVERT_X_DIR) ^ BOTH(HAS_DUAL_X_STEPPERS, INVERT_X2_VS_X_DIR) // X2
|
|||
, ENABLED(INVERT_Y_DIR) ^ BOTH(HAS_DUAL_Y_STEPPERS, INVERT_Y2_VS_Y_DIR) // Y2
|
|||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
|
|||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
|
|||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
|
|||
REPEAT(E_STEPPERS, _EN_ITEM) |
|||
}; |
|||
#undef _EN_ITEM |
|||
|
|||
volatile uint8_t L64XX_Marlin::spi_abort = false; |
|||
uint8_t L64XX_Marlin::spi_active = false; |
|||
|
|||
L64XX_Marlin::L64XX_shadow_t L64XX_Marlin::shadow; |
|||
|
|||
//uint32_t UVLO_ADC = 0x0400; // ADC undervoltage event
|
|||
|
|||
void L6470_populate_chain_array() { |
|||
|
|||
#define _L6470_INIT_SPI(Q) do{ stepper##Q.set_chain_info(Q, Q##_CHAIN_POS); }while(0) |
|||
|
|||
#if AXIS_IS_L64XX(X) |
|||
_L6470_INIT_SPI(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
_L6470_INIT_SPI(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
_L6470_INIT_SPI(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
_L6470_INIT_SPI(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
_L6470_INIT_SPI(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
_L6470_INIT_SPI(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
_L6470_INIT_SPI(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
_L6470_INIT_SPI(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
_L6470_INIT_SPI(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
_L6470_INIT_SPI(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
_L6470_INIT_SPI(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
_L6470_INIT_SPI(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
_L6470_INIT_SPI(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
_L6470_INIT_SPI(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
_L6470_INIT_SPI(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
_L6470_INIT_SPI(E7); |
|||
#endif |
|||
} |
|||
|
|||
|
|||
/**
|
|||
* Some status bit positions & definitions differ per driver. |
|||
* Copy info to known locations to simplfy check/display logic. |
|||
* 1. Copy stepper status |
|||
* 2. Copy status bit definitions |
|||
* 3. Copy status layout |
|||
* 4. Make all error bits active low (as needed) |
|||
*/ |
|||
uint16_t L64XX_Marlin::get_stepper_status(L64XX &st) { |
|||
shadow.STATUS_AXIS_RAW = st.getStatus(); |
|||
shadow.STATUS_AXIS = shadow.STATUS_AXIS_RAW; |
|||
shadow.STATUS_AXIS_LAYOUT = st.L6470_status_layout; |
|||
shadow.AXIS_OCD_TH_MAX = st.OCD_TH_MAX; |
|||
shadow.AXIS_STALL_TH_MAX = st.STALL_TH_MAX; |
|||
shadow.AXIS_OCD_CURRENT_CONSTANT_INV = st.OCD_CURRENT_CONSTANT_INV; |
|||
shadow.AXIS_STALL_CURRENT_CONSTANT_INV = st.STALL_CURRENT_CONSTANT_INV; |
|||
shadow.L6470_AXIS_CONFIG = st.L64XX_CONFIG; |
|||
shadow.L6470_AXIS_STATUS = st.L64XX_STATUS; |
|||
shadow.STATUS_AXIS_OCD = st.STATUS_OCD; |
|||
shadow.STATUS_AXIS_SCK_MOD = st.STATUS_SCK_MOD; |
|||
shadow.STATUS_AXIS_STEP_LOSS_A = st.STATUS_STEP_LOSS_A; |
|||
shadow.STATUS_AXIS_STEP_LOSS_B = st.STATUS_STEP_LOSS_B; |
|||
shadow.STATUS_AXIS_TH_SD = st.STATUS_TH_SD; |
|||
shadow.STATUS_AXIS_TH_WRN = st.STATUS_TH_WRN; |
|||
shadow.STATUS_AXIS_UVLO = st.STATUS_UVLO; |
|||
shadow.STATUS_AXIS_WRONG_CMD = st.STATUS_WRONG_CMD; |
|||
shadow.STATUS_AXIS_CMD_ERR = st.STATUS_CMD_ERR; |
|||
shadow.STATUS_AXIS_NOTPERF_CMD = st.STATUS_NOTPERF_CMD; |
|||
|
|||
switch (shadow.STATUS_AXIS_LAYOUT) { |
|||
case L6470_STATUS_LAYOUT: { // L6470
|
|||
shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; |
|||
shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high
|
|||
break; |
|||
} |
|||
case L6474_STATUS_LAYOUT: { // L6474
|
|||
shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD ; |
|||
shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high
|
|||
break; |
|||
} |
|||
case L6480_STATUS_LAYOUT: { // L6480 & powerSTEP01
|
|||
shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; |
|||
shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_CMD_ERR | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD); // invert just error bits that are active high
|
|||
break; |
|||
} |
|||
} |
|||
return shadow.STATUS_AXIS; |
|||
} |
|||
|
|||
|
|||
void L64XX_Marlin::init() { // Set up SPI and then init chips
|
|||
ENABLE_RESET_L64XX_CHIPS(LOW); // hardware reset of drivers
|
|||
DELAY_US(100); |
|||
ENABLE_RESET_L64XX_CHIPS(HIGH); |
|||
DELAY_US(1000); // need about 650µs for the chip(s) to fully start up
|
|||
L6470_populate_chain_array(); // Set up array to control where in the SPI transfer sequence a particular stepper's data goes
|
|||
|
|||
spi_init(); // Since L64XX SPI pins are unset we must init SPI here
|
|||
|
|||
init_to_defaults(); // init the chips
|
|||
} |
|||
|
|||
uint16_t L64XX_Marlin::get_status(const L64XX_axis_t axis) { |
|||
|
|||
#define STATUS_L6470(Q) get_stepper_status(stepper##Q) |
|||
|
|||
switch (axis) { |
|||
default: break; |
|||
#if AXIS_IS_L64XX(X) |
|||
case X : return STATUS_L6470(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
case Y : return STATUS_L6470(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
case Z : return STATUS_L6470(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
case X2: return STATUS_L6470(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
case Y2: return STATUS_L6470(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
case Z2: return STATUS_L6470(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
case Z3: return STATUS_L6470(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
case Z4: return STATUS_L6470(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
case E0: return STATUS_L6470(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
case E1: return STATUS_L6470(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
case E2: return STATUS_L6470(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
case E3: return STATUS_L6470(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
case E4: return STATUS_L6470(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
case E5: return STATUS_L6470(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
case E6: return STATUS_L6470(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
case E7: return STATUS_L6470(E7); |
|||
#endif |
|||
} |
|||
|
|||
return 0; // Not needed but kills a compiler warning
|
|||
} |
|||
|
|||
uint32_t L64XX_Marlin::get_param(const L64XX_axis_t axis, const uint8_t param) { |
|||
|
|||
#define GET_L6470_PARAM(Q) L6470_GETPARAM(param, Q) |
|||
|
|||
switch (axis) { |
|||
default: break; |
|||
#if AXIS_IS_L64XX(X) |
|||
case X : return GET_L6470_PARAM(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
case Y : return GET_L6470_PARAM(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
case Z : return GET_L6470_PARAM(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
case X2: return GET_L6470_PARAM(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
case Y2: return GET_L6470_PARAM(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
case Z2: return GET_L6470_PARAM(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
case Z3: return GET_L6470_PARAM(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
case Z4: return GET_L6470_PARAM(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
case E0: return GET_L6470_PARAM(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
case E1: return GET_L6470_PARAM(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
case E2: return GET_L6470_PARAM(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
case E3: return GET_L6470_PARAM(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
case E4: return GET_L6470_PARAM(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
case E5: return GET_L6470_PARAM(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
case E6: return GET_L6470_PARAM(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
case E7: return GET_L6470_PARAM(E7); |
|||
#endif |
|||
} |
|||
|
|||
return 0; // not needed but kills a compiler warning
|
|||
} |
|||
|
|||
void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value) { |
|||
|
|||
#define SET_L6470_PARAM(Q) stepper##Q.SetParam(param, value) |
|||
|
|||
switch (axis) { |
|||
default: break; |
|||
#if AXIS_IS_L64XX(X) |
|||
case X : SET_L6470_PARAM(X); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
case Y : SET_L6470_PARAM(Y); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
case Z : SET_L6470_PARAM(Z); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
case I : SET_L6470_PARAM(I); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
case J : SET_L6470_PARAM(J); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
case K : SET_L6470_PARAM(K); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
case X2: SET_L6470_PARAM(X2); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
case Y2: SET_L6470_PARAM(Y2); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
case Z2: SET_L6470_PARAM(Z2); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
case Z3: SET_L6470_PARAM(Z3); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
case Z4: SET_L6470_PARAM(Z4); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
case E0: SET_L6470_PARAM(E0); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
case E1: SET_L6470_PARAM(E1); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
case E2: SET_L6470_PARAM(E2); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
case E3: SET_L6470_PARAM(E3); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
case E4: SET_L6470_PARAM(E4); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
case E5: SET_L6470_PARAM(E5); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
case E6: SET_L6470_PARAM(E6); break; |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
case E7: SET_L6470_PARAM(E7); break; |
|||
#endif |
|||
} |
|||
} |
|||
|
|||
inline void echo_min_max(const char a, const_float_t min, const_float_t max) { |
|||
DEBUG_CHAR(' '); DEBUG_CHAR(a); |
|||
DEBUG_ECHOLNPGM(" min = ", min, " max = ", max); |
|||
} |
|||
inline void echo_oct_used(const_float_t oct, const uint8_t stall) { |
|||
DEBUG_ECHOPGM("over_current_threshold used : ", oct); |
|||
DEBUG_ECHOPGM_P(stall ? PSTR(" (Stall") : PSTR(" (OCD")); |
|||
DEBUG_ECHOLNPGM(" threshold)"); |
|||
} |
|||
inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("Test aborted - motion out of bounds"); } |
|||
|
|||
uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], |
|||
float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, |
|||
uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold |
|||
) { |
|||
// Return TRUE if the calling routine needs to abort/kill
|
|||
|
|||
uint16_t displacement = 0; // " = 0" to eliminate compiler warning
|
|||
uint8_t j; // general purpose counter
|
|||
|
|||
if (!all_axes_homed()) { |
|||
DEBUG_ECHOLNPGM("Test aborted - home all before running this command"); |
|||
return true; |
|||
} |
|||
|
|||
uint8_t found_displacement = false; |
|||
LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) { |
|||
found_displacement = true; |
|||
displacement = _displacement; |
|||
const uint8_t axis_offset = parser.byteval('J'); |
|||
axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E
|
|||
const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', |
|||
one_or_more = !single_or_e && axis_offset == 0; |
|||
uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference
|
|||
if (single_or_e) // Single axis, E0, or E1
|
|||
axis_mon[0][1] = axis_offset + '0'; // Index given by 'J' parameter
|
|||
|
|||
if (single_or_e || one_or_more) { |
|||
for (j = 0; j < MAX_L64XX; j++) { // Count up the drivers on this axis
|
|||
PGM_P str = (PGM_P)pgm_read_ptr(&index_to_axis[j]); // Get a PGM_P from progmem
|
|||
const char c = pgm_read_byte(str); // Get a char from progmem
|
|||
if (axis_mon[0][0] == c) { // For each stepper on this axis...
|
|||
char *mon = axis_mon[driver_count_local]; |
|||
*mon++ = c; // Copy the 3 letter axis name
|
|||
*mon++ = pgm_read_byte(&str[1]); // to the axis_mon array
|
|||
*mon = pgm_read_byte(&str[2]); |
|||
axis_index[driver_count_local] = (L64XX_axis_t)j; // And store the L64XX axis index
|
|||
driver_count_local++; |
|||
} |
|||
} |
|||
if (one_or_more) driver_count = driver_count_local; |
|||
} |
|||
break; // only take first axis found
|
|||
} |
|||
|
|||
if (!found_displacement) { |
|||
DEBUG_ECHOLNPGM("Test aborted - AXIS with displacement is required"); |
|||
return true; |
|||
} |
|||
|
|||
//
|
|||
// Position calcs & checks
|
|||
//
|
|||
|
|||
const float LOGICAL_AXIS_LIST( |
|||
E_center = current_position.e, |
|||
X_center = LOGICAL_X_POSITION(current_position.x), |
|||
Y_center = LOGICAL_Y_POSITION(current_position.y), |
|||
Z_center = LOGICAL_Z_POSITION(current_position.z), |
|||
I_center = LOGICAL_I_POSITION(current_position.i), |
|||
J_center = LOGICAL_J_POSITION(current_position.j), |
|||
K_center = LOGICAL_K_POSITION(current_position.k) |
|||
); |
|||
|
|||
switch (axis_mon[0][0]) { |
|||
default: position_max = position_min = 0; break; |
|||
|
|||
case 'X': { |
|||
position_min = X_center - displacement; |
|||
position_max = X_center + displacement; |
|||
echo_min_max('X', position_min, position_max); |
|||
if (TERN0(HAS_ENDSTOPS, position_min < (X_MIN_POS) || position_max > (X_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
|
|||
#if HAS_Y_AXIS |
|||
case 'Y': { |
|||
position_min = Y_center - displacement; |
|||
position_max = Y_center + displacement; |
|||
echo_min_max('Y', position_min, position_max); |
|||
if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
#endif |
|||
|
|||
#if HAS_Z_AXIS |
|||
case 'Z': { |
|||
position_min = Z_center - displacement; |
|||
position_max = Z_center + displacement; |
|||
echo_min_max('Z', position_min, position_max); |
|||
if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
#endif |
|||
|
|||
#if HAS_I_AXIS |
|||
case AXIS4_NAME: { |
|||
position_min = I_center - displacement; |
|||
position_max = I_center + displacement; |
|||
echo_min_max(AXIS4_NAME, position_min, position_max); |
|||
if (TERN0(HAS_ENDSTOPS, position_min < (I_MIN_POS) || position_max > (I_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
#endif |
|||
|
|||
#if HAS_J_AXIS |
|||
case AXIS5_NAME: { |
|||
position_min = J_center - displacement; |
|||
position_max = J_center + displacement; |
|||
echo_min_max(AXIS5_NAME, position_min, position_max); |
|||
if (TERN1(HAS_ENDSTOPS, position_min < (J_MIN_POS) || position_max > (J_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
#endif |
|||
|
|||
#if HAS_K_AXIS |
|||
case AXIS6_NAME: { |
|||
position_min = K_center - displacement; |
|||
position_max = K_center + displacement; |
|||
echo_min_max(AXIS6_NAME, position_min, position_max); |
|||
if (TERN2(HAS_ENDSTOPS, position_min < (K_MIN_POS) || position_max > (K_MAX_POS))) { |
|||
err_out_of_bounds(); |
|||
return true; |
|||
} |
|||
} break; |
|||
#endif |
|||
|
|||
#if HAS_EXTRUDERS |
|||
case 'E': { |
|||
position_min = E_center - displacement; |
|||
position_max = E_center + displacement; |
|||
echo_min_max('E', position_min, position_max); |
|||
} break; |
|||
#endif |
|||
} |
|||
|
|||
//
|
|||
// Work on the drivers
|
|||
//
|
|||
|
|||
LOOP_L_N(k, driver_count) { |
|||
uint8_t not_found = true; |
|||
for (j = 1; j <= L64XX::chain[0]; j++) { |
|||
PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]); |
|||
if (pgm_read_byte(&str[0]) == axis_mon[k][0] && pgm_read_byte(&str[1]) == axis_mon[k][1]) { // See if a L6470 driver
|
|||
not_found = false; |
|||
break; |
|||
} |
|||
} |
|||
if (not_found) { |
|||
driver_count = k; |
|||
axis_mon[k][0] = ' '; // mark this entry invalid
|
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (driver_count == 0) { |
|||
DEBUG_ECHOLNPGM("Test aborted - not a L6470 axis"); |
|||
return true; |
|||
} |
|||
|
|||
DEBUG_ECHOPGM("Monitoring:"); |
|||
for (j = 0; j < driver_count; j++) DEBUG_ECHOPGM(" ", axis_mon[j]); |
|||
DEBUG_EOL(); |
|||
|
|||
// now have a list of driver(s) to monitor
|
|||
|
|||
//
|
|||
// TVAL & kVAL_HOLD checks & settings
|
|||
//
|
|||
const L64XX_shadow_t &sh = shadow; |
|||
get_status(axis_index[0]); // populate shadow array
|
|||
|
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - use TVAL
|
|||
uint16_t TVAL_current = parser.ushortval('T'); |
|||
if (TVAL_current) { |
|||
uint8_t TVAL_count = (TVAL_current / sh.AXIS_STALL_CURRENT_CONSTANT_INV) - 1; |
|||
LIMIT(TVAL_count, 0, sh.AXIS_STALL_TH_MAX); |
|||
for (j = 0; j < driver_count; j++) |
|||
set_param(axis_index[j], L6474_TVAL, TVAL_count); |
|||
} |
|||
// only print the tval from one of the drivers
|
|||
kval_hold = get_param(axis_index[0], L6474_TVAL); |
|||
DEBUG_ECHOLNPGM("TVAL current (mA) = ", (kval_hold + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); |
|||
} |
|||
else { |
|||
kval_hold = parser.byteval('K'); |
|||
if (kval_hold) { |
|||
DEBUG_ECHOLNPGM("kval_hold = ", kval_hold); |
|||
for (j = 0; j < driver_count; j++) |
|||
set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); |
|||
} |
|||
else { |
|||
// only print the KVAL_HOLD from one of the drivers
|
|||
kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); |
|||
DEBUG_ECHOLNPGM("KVAL_HOLD = ", kval_hold); |
|||
} |
|||
} |
|||
|
|||
//
|
|||
// Overcurrent checks & settings
|
|||
//
|
|||
|
|||
if (over_current_flag) { |
|||
|
|||
uint8_t OCD_TH_val_local = 0, // compiler thinks OCD_TH_val is unused if use it directly
|
|||
STALL_TH_val_local = 0; // just in case ...
|
|||
|
|||
over_current_threshold = parser.intval('I'); |
|||
|
|||
if (over_current_threshold) { |
|||
|
|||
OCD_TH_val_local = over_current_threshold/375; |
|||
LIMIT(OCD_TH_val_local, 0, 15); |
|||
STALL_TH_val_local = over_current_threshold/31.25; |
|||
LIMIT(STALL_TH_val_local, 0, 127); |
|||
uint16_t OCD_TH_actual = (OCD_TH_val_local + 1) * 375, |
|||
STALL_TH_actual = (STALL_TH_val_local + 1) * 31.25; |
|||
if (OCD_TH_actual < STALL_TH_actual) { |
|||
OCD_TH_val_local++; |
|||
OCD_TH_actual = (OCD_TH_val_local + 1) * 375; |
|||
} |
|||
|
|||
DEBUG_ECHOLNPGM("over_current_threshold specified: ", over_current_threshold); |
|||
if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); |
|||
echo_oct_used((OCD_TH_val_local + 1) * 375, false); |
|||
|
|||
#define SET_OVER_CURRENT(Q) do { stepper##Q.SetParam(L6470_STALL_TH, STALL_TH_val_local); stepper##Q.SetParam(L6470_OCD_TH, OCD_TH_val_local);} while (0) |
|||
|
|||
for (j = 0; j < driver_count; j++) { |
|||
set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); |
|||
set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); |
|||
} |
|||
} |
|||
else { |
|||
// only get & print the OVER_CURRENT values from one of the drivers
|
|||
STALL_TH_val_local = get_param(axis_index[0], L6470_STALL_TH); |
|||
OCD_TH_val_local = get_param(axis_index[0], L6470_OCD_TH); |
|||
|
|||
if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); |
|||
echo_oct_used((OCD_TH_val_local + 1) * 375, false); |
|||
} // over_current_threshold
|
|||
|
|||
for (j = 0; j < driver_count; j++) { // set all drivers on axis the same
|
|||
set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); |
|||
set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); |
|||
} |
|||
|
|||
OCD_TH_val = OCD_TH_val_local; // force compiler to update the main routine's copy
|
|||
STALL_TH_val = STALL_TH_val_local; // force compiler to update the main routine's copy
|
|||
} // end of overcurrent
|
|||
|
|||
//
|
|||
// Feedrate
|
|||
//
|
|||
|
|||
final_feedrate = parser.floatval('F'); |
|||
if (final_feedrate == 0) { |
|||
static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; |
|||
const uint8_t num_feedrates = COUNT(default_max_feedrate); |
|||
for (j = 0; j < num_feedrates; j++) { |
|||
if (AXIS_CHAR(j) == axis_mon[0][0]) { |
|||
final_feedrate = default_max_feedrate[j]; |
|||
break; |
|||
} |
|||
} |
|||
if (j == 3 && num_feedrates > 4) { // have more than one extruder feedrate
|
|||
uint8_t extruder_num = axis_mon[0][1] - '0'; |
|||
if (j <= num_feedrates - extruder_num) // have a feedrate specifically for this extruder
|
|||
final_feedrate = default_max_feedrate[j + extruder_num]; |
|||
else |
|||
final_feedrate = default_max_feedrate[3]; // use E0 feedrate for this extruder
|
|||
} |
|||
final_feedrate *= 60; // convert to mm/minute
|
|||
} // end of feedrate
|
|||
|
|||
return false; // FALSE indicates no user input problems
|
|||
} |
|||
|
|||
void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*/) { |
|||
if (label) SERIAL_ECHOPGM("AXIS:"); |
|||
const char * const str = L64xxManager.index_to_axis[axis]; |
|||
SERIAL_CHAR(' ', str[0], str[1], ' '); |
|||
} |
|||
|
|||
#if ENABLED(L6470_CHITCHAT) |
|||
|
|||
// Assumes status bits have been inverted
|
|||
void L64XX_Marlin::error_status_decode(const uint16_t status, const L64XX_axis_t axis, |
|||
const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, |
|||
const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, |
|||
const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout |
|||
) { |
|||
say_axis(axis); |
|||
DEBUG_ECHOPGM(" THERMAL: "); |
|||
DEBUG_ECHOPGM_P((status & _status_axis_th_sd) ? PSTR("SHUTDOWN") : (status & _status_axis_th_wrn) ? PSTR("WARNING ") : PSTR("OK ")); |
|||
DEBUG_ECHOPGM(" OVERCURRENT: "); |
|||
echo_yes_no((status & _status_axis_ocd) != 0); |
|||
if (!(_status_axis_layout == L6474_STATUS_LAYOUT)) { // L6474 doesn't have these bits
|
|||
DEBUG_ECHOPGM(" STALL: "); |
|||
echo_yes_no((status & (_status_axis_step_loss_a | _status_axis_step_loss_b)) != 0); |
|||
} |
|||
DEBUG_EOL(); |
|||
} |
|||
|
|||
#endif |
|||
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|||
////
|
|||
//// MONITOR_L6470_DRIVER_STATUS routines
|
|||
////
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#if ENABLED(MONITOR_L6470_DRIVER_STATUS) |
|||
|
|||
bool L64XX_Marlin::monitor_paused = false; // Flag to skip monitor during M122, M906, M916, M917, M918, etc.
|
|||
|
|||
struct L6470_driver_data { |
|||
L64XX_axis_t driver_index; |
|||
uint32_t driver_status; |
|||
uint8_t is_otw; |
|||
uint8_t otw_counter; |
|||
uint8_t is_ot; |
|||
uint8_t is_hi_Z; |
|||
uint8_t com_counter; |
|||
}; |
|||
|
|||
L6470_driver_data driver_L6470_data[] = { |
|||
#if AXIS_IS_L64XX(X) |
|||
{ X, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
{ Y, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
{ Z, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
{ I, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
{ J, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
{ K, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
{ X2, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
{ Y2, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
{ Z2, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
{ Z3, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
{ Z4, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
{ E0, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
{ E1, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
{ E2, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
{ E3, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
{ E4, 0, 0, 0, 0, 0, 0 }, |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
{ E5, 0, 0, 0, 0, 0, 0 } |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
{ E6, 0, 0, 0, 0, 0, 0 } |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
{ E7, 0, 0, 0, 0, 0, 0 } |
|||
#endif |
|||
}; |
|||
|
|||
void L64XX_Marlin::append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err/*=nullptr*/) { |
|||
PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[stepper_index]); |
|||
p += sprintf_P(p, PSTR("Stepper %c%c "), pgm_read_byte(&str[0]), pgm_read_byte(&str[1])); |
|||
if (err) p += sprintf_P(p, err); |
|||
} |
|||
|
|||
void L64XX_Marlin::monitor_update(L64XX_axis_t stepper_index) { |
|||
if (spi_abort) return; // don't do anything if set_directions() has occurred
|
|||
const L64XX_shadow_t &sh = shadow; |
|||
get_status(stepper_index); // get stepper status and details
|
|||
uint16_t status = sh.STATUS_AXIS; |
|||
uint8_t kval_hold, tval; |
|||
char temp_buf[120], *p = temp_buf; |
|||
uint8_t j; |
|||
for (j = 0; j < L64XX::chain[0]; j++) // find the table for this stepper
|
|||
if (driver_L6470_data[j].driver_index == stepper_index) break; |
|||
|
|||
driver_L6470_data[j].driver_status = status; |
|||
uint16_t _status = ~status; // all error bits are active low
|
|||
|
|||
if (status == 0 || status == 0xFFFF) { // com problem
|
|||
if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens
|
|||
driver_L6470_data[j].com_counter++; |
|||
append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); |
|||
DEBUG_ECHO(temp_buf); |
|||
} |
|||
else { |
|||
driver_L6470_data[j].com_counter++; |
|||
if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes
|
|||
driver_L6470_data[j].com_counter = 1; |
|||
append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); |
|||
DEBUG_ECHO(temp_buf); |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
if (driver_L6470_data[j].com_counter) { // comms re-established
|
|||
driver_L6470_data[j].com_counter = 0; |
|||
append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); |
|||
DEBUG_ECHO(temp_buf); |
|||
init_to_defaults(); |
|||
} |
|||
else { |
|||
// no com problems - do the usual checks
|
|||
if (_status & sh.L6470_ERROR_MASK) { |
|||
append_stepper_err(p, stepper_index); |
|||
|
|||
if (status & STATUS_HIZ) { // The driver has shut down. HiZ is active high
|
|||
driver_L6470_data[j].is_hi_Z = true; |
|||
p += sprintf_P(p, PSTR("%cIS SHUT DOWN"), ' '); |
|||
//if (_status & sh.STATUS_AXIS_TH_SD) { // strange - TH_SD never seems to go active, must be implied by the HiZ and TH_WRN
|
|||
if (_status & sh.STATUS_AXIS_TH_WRN) { // over current shutdown
|
|||
p += sprintf_P(p, PSTR("%cdue to over temperature"), ' '); |
|||
driver_L6470_data[j].is_ot = true; |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474
|
|||
tval = get_param(stepper_index, L6474_TVAL) - 2 * KVAL_HOLD_STEP_DOWN; |
|||
set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL
|
|||
p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (2 * KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know
|
|||
} |
|||
else { |
|||
kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - 2 * KVAL_HOLD_STEP_DOWN; |
|||
set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD
|
|||
p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), 2 * KVAL_HOLD_STEP_DOWN, kval_hold); // let user know
|
|||
} |
|||
} |
|||
else |
|||
driver_L6470_data[j].is_ot = false; |
|||
} |
|||
else { |
|||
driver_L6470_data[j].is_hi_Z = false; |
|||
|
|||
if (_status & sh.STATUS_AXIS_TH_WRN) { // have an over temperature warning
|
|||
driver_L6470_data[j].is_otw = true; |
|||
driver_L6470_data[j].otw_counter++; |
|||
kval_hold = get_param(stepper_index, L6470_KVAL_HOLD); |
|||
if (driver_L6470_data[j].otw_counter > 4) { // otw present for 2 - 2.5 seconds, reduce KVAL_HOLD
|
|||
driver_L6470_data[j].otw_counter = 0; |
|||
driver_L6470_data[j].is_otw = true; |
|||
if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474
|
|||
tval = get_param(stepper_index, L6474_TVAL) - KVAL_HOLD_STEP_DOWN; |
|||
set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL
|
|||
p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know
|
|||
} |
|||
else { |
|||
kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - KVAL_HOLD_STEP_DOWN; |
|||
set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD
|
|||
p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), KVAL_HOLD_STEP_DOWN, kval_hold); // let user know
|
|||
} |
|||
} |
|||
else if (driver_L6470_data[j].otw_counter) |
|||
p += sprintf_P(p, PSTR("%c- thermal warning"), ' '); // warn user
|
|||
} |
|||
} |
|||
|
|||
#if ENABLED(L6470_STOP_ON_ERROR) |
|||
if (_status & (sh.STATUS_AXIS_UVLO | sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) |
|||
kill(temp_buf); |
|||
#endif |
|||
|
|||
#if ENABLED(L6470_CHITCHAT) |
|||
if (_status & sh.STATUS_AXIS_OCD) |
|||
p += sprintf_P(p, PSTR("%c over current"), ' '); |
|||
|
|||
if (_status & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) |
|||
p += sprintf_P(p, PSTR("%c stall"), ' '); |
|||
|
|||
if (_status & sh.STATUS_AXIS_UVLO) |
|||
p += sprintf_P(p, PSTR("%c under voltage lock out"), ' '); |
|||
|
|||
p += sprintf_P(p, PSTR("%c\n"), ' '); |
|||
#endif |
|||
|
|||
DEBUG_ECHOLN(temp_buf); // print the error message
|
|||
} |
|||
else { |
|||
driver_L6470_data[j].is_ot = false; |
|||
driver_L6470_data[j].otw_counter = 0; //clear out warning indicators
|
|||
driver_L6470_data[j].is_otw = false; |
|||
} // end usual checks
|
|||
|
|||
} // comms established but have errors
|
|||
} // comms re-established
|
|||
} // end monitor_update()
|
|||
|
|||
|
|||
void L64XX_Marlin::monitor_driver() { |
|||
static millis_t next_cOT = 0; |
|||
if (ELAPSED(millis(), next_cOT)) { |
|||
next_cOT = millis() + 500; |
|||
|
|||
if (!monitor_paused) { // Skip during M122, M906, M916, M917 or M918 (could steal status result from test)
|
|||
|
|||
spi_active = true; // Tell set_directions() a series of SPI transfers is underway
|
|||
|
|||
#if AXIS_IS_L64XX(X) |
|||
monitor_update(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
monitor_update(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
monitor_update(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
monitor_update(I); |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
monitor_update(J); |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
monitor_update(K); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
monitor_update(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
monitor_update(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
monitor_update(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
monitor_update(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
monitor_update(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
monitor_update(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
monitor_update(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
monitor_update(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
monitor_update(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
monitor_update(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
monitor_update(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
monitor_update(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
monitor_update(E7); |
|||
#endif |
|||
|
|||
if (TERN0(L6470_DEBUG, report_L6470_status)) DEBUG_EOL(); |
|||
|
|||
spi_active = false; // done with all SPI transfers - clear handshake flags
|
|||
spi_abort = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif // MONITOR_L6470_DRIVER_STATUS
|
|||
|
|||
#endif // HAS_L64XX
|
@ -1,141 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#include <L6470.h> |
|||
#if !(L6470_LIBRARY_VERSION >= 0x000800) |
|||
#error 'L6470_LIBRARY_VERSION 0x000800 or later required' |
|||
#endif |
|||
|
|||
#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) |
|||
|
|||
#define dSPIN_STEP_CLOCK 0x58 |
|||
#define dSPIN_STEP_CLOCK_FWD dSPIN_STEP_CLOCK |
|||
#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1 |
|||
#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)) |
|||
|
|||
#define _EN_ITEM(N) , E##N |
|||
enum L64XX_axis_t : uint8_t { MAIN_AXIS_NAMES, X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; |
|||
#undef _EN_ITEM |
|||
|
|||
class L64XX_Marlin : public L64XXHelper { |
|||
public: |
|||
static PGM_P const index_to_axis[MAX_L64XX]; |
|||
|
|||
static const uint8_t index_to_dir[MAX_L64XX]; |
|||
|
|||
static uint8_t dir_commands[MAX_L64XX]; |
|||
|
|||
// Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer
|
|||
static volatile uint8_t spi_abort; |
|||
static uint8_t spi_active; |
|||
|
|||
L64XX_Marlin() {} |
|||
|
|||
static void init(); |
|||
static void init_to_defaults(); |
|||
|
|||
static uint16_t get_stepper_status(L64XX &st); |
|||
|
|||
static uint16_t get_status(const L64XX_axis_t axis); |
|||
|
|||
static uint32_t get_param(const L64XX_axis_t axis, const uint8_t param); |
|||
|
|||
static void set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value); |
|||
|
|||
//static void send_command(const L64XX_axis_t axis, uint8_t command);
|
|||
|
|||
static uint8_t get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], |
|||
float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, |
|||
uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold); |
|||
|
|||
static void transfer(uint8_t L6470_buf[], const uint8_t length); |
|||
|
|||
static void say_axis(const L64XX_axis_t axis, const uint8_t label=true); |
|||
#if ENABLED(L6470_CHITCHAT) |
|||
static void error_status_decode( |
|||
const uint16_t status, const L64XX_axis_t axis, |
|||
const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, |
|||
const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, |
|||
const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout |
|||
); |
|||
#else |
|||
FORCE_INLINE static void error_status_decode( |
|||
const uint16_t, const L64XX_axis_t, |
|||
const uint16_t, const uint16_t, |
|||
const uint16_t, const uint16_t, |
|||
const uint16_t, const uint8_t |
|||
){} |
|||
#endif |
|||
|
|||
// ~40 bytes SRAM to simplify status decode routines
|
|||
typedef struct { |
|||
uint8_t STATUS_AXIS_LAYOUT; // Copy of L6470_status_layout
|
|||
uint8_t AXIS_OCD_TH_MAX; // Size of OCD_TH field
|
|||
uint8_t AXIS_STALL_TH_MAX; // Size of STALL_TH field
|
|||
float AXIS_OCD_CURRENT_CONSTANT_INV; // mA per count
|
|||
float AXIS_STALL_CURRENT_CONSTANT_INV; // mA per count
|
|||
uint8_t L6470_AXIS_CONFIG, // Address of the CONFIG register
|
|||
L6470_AXIS_STATUS; // Address of the STATUS register
|
|||
uint16_t L6470_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD | STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B
|
|||
L6474_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD
|
|||
STATUS_AXIS_RAW, // Copy of status register contents
|
|||
STATUS_AXIS, // Copy of status register contents but with all error bits active low
|
|||
STATUS_AXIS_OCD, // Overcurrent detected bit position
|
|||
STATUS_AXIS_SCK_MOD, // Step clock mode is active bit position
|
|||
STATUS_AXIS_STEP_LOSS_A, // Stall detected on A bridge bit position
|
|||
STATUS_AXIS_STEP_LOSS_B, // Stall detected on B bridge bit position
|
|||
STATUS_AXIS_TH_SD, // Thermal shutdown bit position
|
|||
STATUS_AXIS_TH_WRN, // Thermal warning bit position
|
|||
STATUS_AXIS_UVLO, // Undervoltage lockout is active bit position
|
|||
STATUS_AXIS_WRONG_CMD, // Last command not valid bit position
|
|||
STATUS_AXIS_CMD_ERR, // Command error bit position
|
|||
STATUS_AXIS_NOTPERF_CMD; // Last command not performed bit position
|
|||
} L64XX_shadow_t; |
|||
|
|||
static L64XX_shadow_t shadow; |
|||
|
|||
#if ENABLED(MONITOR_L6470_DRIVER_STATUS) |
|||
static bool monitor_paused; |
|||
static void pause_monitor(const bool p) { monitor_paused = p; } |
|||
static void monitor_update(L64XX_axis_t stepper_index); |
|||
static void monitor_driver(); |
|||
#else |
|||
static void pause_monitor(const bool) {} |
|||
#endif |
|||
|
|||
//protected:
|
|||
// L64XXHelper methods
|
|||
static void spi_init(); |
|||
static uint8_t transfer_single(uint8_t data, int16_t ss_pin); |
|||
static uint8_t transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position); |
|||
|
|||
private: |
|||
static void append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err=nullptr); |
|||
|
|||
}; |
|||
|
|||
void echo_yes_no(const bool yes); |
|||
|
|||
extern L64XX_Marlin L64xxManager; |
@ -1,98 +0,0 @@ |
|||
### L64XX Stepper Driver |
|||
|
|||
*Arduino-L6470* library revision 0.8.0 or above is required. |
|||
|
|||
This software can be used with the L6470, L6474, L6480 and the powerSTEP01 (collectively referred to as "L64xx" from now on). Different drivers can be mixed within a system. |
|||
|
|||
These devices use voltage PWMs to drive the stepper phases. On the L6474 the phase current is controlled by the `TVAL` register. On all the other drivers the phase current is indirectly controlled via the `KVAL_HOLD` register which scales the PWM duty cycle. |
|||
|
|||
This software assumes that all drivers are in one SPI daisy chain. |
|||
|
|||
### Hardware Setup |
|||
|
|||
- MOSI from controller tied to SDI on the first device |
|||
|
|||
- SDO of the first device is tied to SDI of the next device |
|||
|
|||
- SDO of the last device is tied to MISO of the controller |
|||
|
|||
- All devices share the same `SCK_PIN` and `SS_PIN` pins. The user must supply a macro to control the `RESET_PIN`(s). |
|||
|
|||
- Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). |
|||
|
|||
- Each L6470 acts on the **last** SPI data it saw when the `SS_PIN` **goes high**. |
|||
|
|||
The L6474 uses the standard STEP DIR interface. Phase currents are changed in response to step pulses. The direction is set by the DIR pin. Instead of an ENA pin, stepper power is controlled with SPI commands. |
|||
|
|||
The other drivers operate in `STEP_CLOCK` mode. In this mode the Direction / Enable functions are done with SPI commands and the phase currents are changed in response to STEP pulses. |
|||
|
|||
### Hardware / Software Interaction |
|||
|
|||
Except for the L6474, powering up a stepper and setting the direction are done by the same command. You can't do one without the other. |
|||
|
|||
**All** directions are set **every time** a new block is popped off the queue by the stepper ISR. |
|||
|
|||
When setting direction, SPI transfers are minimized by using arrays and a specialized SPI method. *Arduino-L6470* library calls are not used. For N L64xx drivers, this results in N bytes transferred. If library calls were used then N<sup>2</sup> bytes would be sent. |
|||
|
|||
### Power-up (Reset) Sequence |
|||
|
|||
- Stepper objects are instantiated before the `setup()` entry point is reached. |
|||
|
|||
- In `setup()` (before stepper drivers are initialized) the `L6470_init()` method is called to do the following: |
|||
|
|||
- If present, pulse the hardware reset pin. |
|||
|
|||
- Populate the `L6470_chain` array, which maps positions in the SPI stream to commands/data for L64XX stepper drivers. |
|||
|
|||
- Initialize the L64XX Software SPI pin states. |
|||
|
|||
- Initialize L64XX drivers. They may be reset later by a call to `L6470_init_to_defaults()`. |
|||
|
|||
The steppers are **NOT** powered up (enabled) during this sequence. |
|||
|
|||
### `L6470_chain` array |
|||
|
|||
This array is used by all routines that transmit SPI data. For a chain with N devices, the array contains: |
|||
|
|||
Index|Value |
|||
-----|----- |
|||
0|Number of drivers in chain |
|||
1|Axis index of the first device in the chain (closest to MOSI) |
|||
...| |
|||
N|Axis index of the last device chain (closest to MISO) |
|||
|
|||
### Set Direction and Enable |
|||
|
|||
The `DIR_WRITE` macros for the L64xx drivers are written so that the standard X, Y, Z and extruder logic used by the `set_directions()` routine is not altered. These macros write the correct forward/reverse command to the corresponding location in the array `L6470_dir_commands`. On the L6474 the array the command used just enables the stepper because direction is set by the DIR pin. |
|||
|
|||
At the end of the `set_directions()` routine, the array `L6470_chain` is used to grab the corresponding direction/enable commands out of the array `L6470_dir_commands` and put them in the correct sequence in the array `L6470_buf`. Array `L6470_buf` is then passed to the **`void`** `L6470_Transfer` function which actually sends the data to the devices. |
|||
|
|||
### Utilities, etc. |
|||
|
|||
The **absolute position** registers should accurately reflect Marlin’s stepper position counts. They are set to zero during initialization. `G28` sets them to the Marlin counts for the corresponding axis after homing. NOTE: These registers are often the negative of the Marlin counts. This is because the Marlin counts reflect the logical direction while the registers reflect the stepper direction. The register contents are displayed via the `M114 D` command. |
|||
|
|||
The `L6470_monitor` feature reads the status of each device every half second. It will report if there are any error conditions present or if communications has been lost/restored. The `KVAL_HOLD` value is reduced every 2 – 2.5 seconds if the thermal warning or thermal shutdown conditions are present. |
|||
|
|||
**M122** displays the settings of most of the bits in the status register plus a couple of other items. |
|||
|
|||
**M906** can be used to set the `KVAL_HOLD` register (`TVAL` on L6474) one driver at a time. If a setting is not included with the command then the contents of the registers that affect the phase current/voltage are displayed. |
|||
|
|||
**M916, M917 & M918** |
|||
|
|||
These utilities are used to tune the system. They can get you in the ballpark for acceptable jerk, acceleration, top speed and `KVAL_HOLD` settings (`TVAL` on L6474). In general they seem to provide an overly optimistic `KVAL_HOLD` (`TVAL`) setting because of the lag between setting `KVAL_HOLD` (`TVAL`) and the driver reaching final temperature. Enabling the `L6470_monitor` feature during prints will provide the **final useful setting**. |
|||
|
|||
The amount of power needed to move the stepper without skipping steps increases as jerk, acceleration, top speed, and micro-steps increase. The power dissipated by the driver increases as the power to the stepper increases. The net result is a balancing act between jerk, acceleration, top speed, micro-steps, and power dissipated by the driver. |
|||
|
|||
**M916** - Increases `KVAL_HOLD` (`TVAL`) while moving one axis until a thermal warning is generated. This routine is also useful for determining the approximate `KVAL_HOLD` (`TVAL`) where the stepper stops losing steps. The sound will get noticeably quieter as it stops losing steps. |
|||
|
|||
**M917** - Find minimum current thresholds. This is accomplished by doing the following steps while moving an axis: |
|||
|
|||
1. Decrease OCD current until overcurrent error. |
|||
|
|||
2. Increase OCD until overcurrent error goes away. |
|||
|
|||
3. Decrease stall threshold until stall error (not available on the L6474). |
|||
|
|||
4. Increase stall until stall error goes away (not available on the L6474). |
|||
|
|||
**M918** - Increase speed until error or max feedrate achieved. |
@ -1,264 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* stepper/L64xx.cpp |
|||
* Stepper driver indirection for L64XX drivers |
|||
*/ |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
|
|||
#if HAS_L64XX |
|||
|
|||
#include "L64xx.h" |
|||
|
|||
#if AXIS_IS_L64XX(X) |
|||
L64XX_CLASS(X) stepperX(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
L64XX_CLASS(X2) stepperX2(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
L64XX_CLASS(Y) stepperY(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
L64XX_CLASS(Y2) stepperY2(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
L64XX_CLASS(Z) stepperZ(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
L64XX_CLASS(Z2) stepperZ2(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
L64XX_CLASS(Z3) stepperZ3(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
L64XX_CLASS(Z4) stepperZ4(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
L64XX_CLASS(I) stepperI(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
L64XX_CLASS(J) stepperJ(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
L64XX_CLASS(K) stepperK(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(U) |
|||
L64XX_CLASS(u) stepperU(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(V) |
|||
L64XX_CLASS(v) stepperV(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(W) |
|||
L64XX_CLASS(w) stepperW(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
L64XX_CLASS(E0) stepperE0(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
L64XX_CLASS(E1) stepperE1(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
L64XX_CLASS(E2) stepperE2(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
L64XX_CLASS(E3) stepperE3(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
L64XX_CLASS(E4) stepperE4(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
L64XX_CLASS(E5) stepperE5(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
L64XX_CLASS(E6) stepperE6(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
L64XX_CLASS(E7) stepperE7(L6470_CHAIN_SS_PIN); |
|||
#endif |
|||
|
|||
// Not using L64XX class init method because it
|
|||
// briefly sends power to the steppers
|
|||
|
|||
inline void L6470_init_chip(L64XX &st, const int ms, const int oc, const int sc, const int mv, const int slew_rate) { |
|||
st.set_handlers(L64xxManager.spi_init, L64xxManager.transfer_single, L64xxManager.transfer_chain); // specify which external SPI routines to use
|
|||
switch (st.L6470_status_layout) { |
|||
case L6470_STATUS_LAYOUT: { |
|||
st.resetDev(); |
|||
st.softFree(); |
|||
st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); |
|||
st.SetParam(L6470_KVAL_RUN, 0xFF); |
|||
st.SetParam(L6470_KVAL_ACC, 0xFF); |
|||
st.SetParam(L6470_KVAL_DEC, 0xFF); |
|||
st.setMicroSteps(ms); |
|||
st.setOverCurrent(oc); |
|||
st.setStallCurrent(sc); |
|||
st.SetParam(L6470_KVAL_HOLD, mv); |
|||
st.SetParam(L6470_ABS_POS, 0); |
|||
uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); |
|||
config_temp &= ~CONFIG_POW_SR; |
|||
switch (slew_rate) { |
|||
case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; |
|||
default: |
|||
case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; |
|||
case 3: |
|||
case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; |
|||
} |
|||
st.getStatus(); |
|||
st.getStatus(); |
|||
break; |
|||
} |
|||
|
|||
case L6474_STATUS_LAYOUT: { |
|||
st.free(); |
|||
//st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ);
|
|||
//st.SetParam(L6474_TVAL, 0xFF);
|
|||
st.setMicroSteps(ms); |
|||
st.setOverCurrent(oc); |
|||
st.setTVALCurrent(sc); |
|||
st.SetParam(L6470_ABS_POS, 0); |
|||
uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); |
|||
config_temp &= ~CONFIG_POW_SR & ~CONFIG_EN_TQREG; // clear out slew rate and set current to be controlled by TVAL register
|
|||
switch (slew_rate) { |
|||
case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; |
|||
default: |
|||
case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; |
|||
case 3: |
|||
case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; |
|||
//case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_75V_us); break;
|
|||
//default:
|
|||
//case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_110V_us); break;
|
|||
//case 3:
|
|||
//case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_260V_us); break;
|
|||
|
|||
//case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break;
|
|||
//default:
|
|||
//case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break;
|
|||
//case 3:
|
|||
//case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break;
|
|||
} |
|||
st.getStatus(); |
|||
st.getStatus(); |
|||
break; |
|||
} |
|||
|
|||
case L6480_STATUS_LAYOUT: { |
|||
st.resetDev(); |
|||
st.softFree(); |
|||
st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); |
|||
st.SetParam(L6470_KVAL_RUN, 0xFF); |
|||
st.SetParam(L6470_KVAL_ACC, 0xFF); |
|||
st.SetParam(L6470_KVAL_DEC, 0xFF); |
|||
st.setMicroSteps(ms); |
|||
st.setOverCurrent(oc); |
|||
st.setStallCurrent(sc); |
|||
st.SetParam(+-L6470_KVAL_HOLD, mv); |
|||
st.SetParam(L6470_ABS_POS, 0); |
|||
st.SetParam(st.L64XX_CONFIG,(st.GetParam(st.L64XX_CONFIG) | PWR_VCC_7_5V)); |
|||
st.getStatus(); // must clear out status bits before can set slew rate
|
|||
st.getStatus(); |
|||
switch (slew_rate) { |
|||
case 0: st.SetParam(L6470_GATECFG1, CONFIG1_SR_220V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_220V_us); break; |
|||
default: |
|||
case 1: st.SetParam(L6470_GATECFG1, CONFIG1_SR_400V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_400V_us); break; |
|||
case 2: st.SetParam(L6470_GATECFG1, CONFIG1_SR_520V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_520V_us); break; |
|||
case 3: st.SetParam(L6470_GATECFG1, CONFIG1_SR_980V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_980V_us); break; |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
#define L6470_INIT_CHIP(Q) L6470_init_chip(stepper##Q, Q##_MICROSTEPS, Q##_OVERCURRENT, Q##_STALLCURRENT, Q##_MAX_VOLTAGE, Q##_SLEW_RATE) |
|||
|
|||
void L64XX_Marlin::init_to_defaults() { |
|||
#if AXIS_IS_L64XX(X) |
|||
L6470_INIT_CHIP(X); |
|||
#endif |
|||
#if AXIS_IS_L64XX(X2) |
|||
L6470_INIT_CHIP(X2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y) |
|||
L6470_INIT_CHIP(Y); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Y2) |
|||
L6470_INIT_CHIP(Y2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z) |
|||
L6470_INIT_CHIP(Z); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z2) |
|||
L6470_INIT_CHIP(Z2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z3) |
|||
L6470_INIT_CHIP(Z3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(Z4) |
|||
L6470_INIT_CHIP(Z4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(I) |
|||
L6470_INIT_CHIP(I); |
|||
#endif |
|||
#if AXIS_IS_L64XX(J) |
|||
L6470_INIT_CHIP(J); |
|||
#endif |
|||
#if AXIS_IS_L64XX(K) |
|||
L6470_INIT_CHIP(K); |
|||
#endif |
|||
#if AXIS_IS_L64XX(U) |
|||
L6470_INIT_CHIP(U); |
|||
#endif |
|||
#if AXIS_IS_L64XX(V) |
|||
L6470_INIT_CHIP(V); |
|||
#endif |
|||
#if AXIS_IS_L64XX(W) |
|||
L6470_INIT_CHIP(W); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E0) |
|||
L6470_INIT_CHIP(E0); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E1) |
|||
L6470_INIT_CHIP(E1); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E2) |
|||
L6470_INIT_CHIP(E2); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E3) |
|||
L6470_INIT_CHIP(E3); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E4) |
|||
L6470_INIT_CHIP(E4); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E5) |
|||
L6470_INIT_CHIP(E5); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E6) |
|||
L6470_INIT_CHIP(E6); |
|||
#endif |
|||
#if AXIS_IS_L64XX(E7) |
|||
L6470_INIT_CHIP(E7); |
|||
#endif |
|||
} |
|||
|
|||
#endif // HAS_L64XX
|
@ -1,490 +0,0 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program 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. |
|||
* |
|||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
#pragma once |
|||
|
|||
/**
|
|||
* stepper/L64xx.h |
|||
* Stepper driver indirection for L64XX drivers |
|||
*/ |
|||
|
|||
#include "../../inc/MarlinConfig.h" |
|||
#include "../../libs/L64XX/L64XX_Marlin.h" |
|||
|
|||
// Convert option names to L64XX classes
|
|||
#define CLASS_L6470 L6470 |
|||
#define CLASS_L6474 L6474 |
|||
#define CLASS_POWERSTEP01 powerSTEP01 |
|||
|
|||
#define __L64XX_CLASS(TYPE) CLASS_##TYPE |
|||
#define _L64XX_CLASS(TYPE) __L64XX_CLASS(TYPE) |
|||
#define L64XX_CLASS(ST) _L64XX_CLASS(ST##_DRIVER_TYPE) |
|||
|
|||
#define L6474_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = dSPIN_L6474_ENABLE; WRITE(A##_DIR_PIN, STATE); }while(0) |
|||
#define L64XX_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = (STATE) ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD; }while(0) |
|||
|
|||
// X Stepper
|
|||
#if AXIS_IS_L64XX(X) |
|||
extern L64XX_CLASS(X) stepperX; |
|||
#define X_ENABLE_INIT() NOOP |
|||
#define X_ENABLE_WRITE(STATE) (STATE ? stepperX.hardStop() : stepperX.free()) |
|||
#define X_ENABLE_READ() (stepperX.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_X(L6474) |
|||
#define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN) |
|||
#define X_DIR_WRITE(STATE) L6474_DIR_WRITE(X, STATE) |
|||
#define X_DIR_READ() READ(X_DIR_PIN) |
|||
#else |
|||
#define X_DIR_INIT() NOOP |
|||
#define X_DIR_WRITE(STATE) L64XX_DIR_WRITE(X, STATE) |
|||
#define X_DIR_READ() (stepper##X.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_X(L6470) |
|||
#define DISABLE_STEPPER_X() stepperX.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// Y Stepper
|
|||
#if AXIS_IS_L64XX(Y) |
|||
extern L64XX_CLASS(Y) stepperY; |
|||
#define Y_ENABLE_INIT() NOOP |
|||
#define Y_ENABLE_WRITE(STATE) (STATE ? stepperY.hardStop() : stepperY.free()) |
|||
#define Y_ENABLE_READ() (stepperY.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Y(L6474) |
|||
#define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN) |
|||
#define Y_DIR_WRITE(STATE) L6474_DIR_WRITE(Y, STATE) |
|||
#define Y_DIR_READ() READ(Y_DIR_PIN) |
|||
#else |
|||
#define Y_DIR_INIT() NOOP |
|||
#define Y_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y, STATE) |
|||
#define Y_DIR_READ() (stepper##Y.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_Y(L6470) |
|||
#define DISABLE_STEPPER_Y() stepperY.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// Z Stepper
|
|||
#if AXIS_IS_L64XX(Z) |
|||
extern L64XX_CLASS(Z) stepperZ; |
|||
#define Z_ENABLE_INIT() NOOP |
|||
#define Z_ENABLE_WRITE(STATE) (STATE ? stepperZ.hardStop() : stepperZ.free()) |
|||
#define Z_ENABLE_READ() (stepperZ.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Z(L6474) |
|||
#define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN) |
|||
#define Z_DIR_WRITE(STATE) L6474_DIR_WRITE(Z, STATE) |
|||
#define Z_DIR_READ() READ(Z_DIR_PIN) |
|||
#else |
|||
#define Z_DIR_INIT() NOOP |
|||
#define Z_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z, STATE) |
|||
#define Z_DIR_READ() (stepper##Z.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_Z(L6470) |
|||
#define DISABLE_STEPPER_Z() stepperZ.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// X2 Stepper
|
|||
#if HAS_X2_ENABLE && AXIS_IS_L64XX(X2) |
|||
extern L64XX_CLASS(X2) stepperX2; |
|||
#define X2_ENABLE_INIT() NOOP |
|||
#define X2_ENABLE_WRITE(STATE) (STATE ? stepperX2.hardStop() : stepperX2.free()) |
|||
#define X2_ENABLE_READ() (stepperX2.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_X2(L6474) |
|||
#define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN) |
|||
#define X2_DIR_WRITE(STATE) L6474_DIR_WRITE(X2, STATE) |
|||
#define X2_DIR_READ() READ(X2_DIR_PIN) |
|||
#else |
|||
#define X2_DIR_INIT() NOOP |
|||
#define X2_DIR_WRITE(STATE) L64XX_DIR_WRITE(X2, STATE) |
|||
#define X2_DIR_READ() (stepper##X2.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
#if AXIS_DRIVER_TYPE_X2(L6470) |
|||
#define DISABLE_STEPPER_X2() stepperX2.free() |
|||
#endif |
|||
|
|||
// Y2 Stepper
|
|||
#if HAS_Y2_ENABLE && AXIS_IS_L64XX(Y2) |
|||
extern L64XX_CLASS(Y2) stepperY2; |
|||
#define Y2_ENABLE_INIT() NOOP |
|||
#define Y2_ENABLE_WRITE(STATE) (STATE ? stepperY2.hardStop() : stepperY2.free()) |
|||
#define Y2_ENABLE_READ() (stepperY2.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Y2(L6474) |
|||
#define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN) |
|||
#define Y2_DIR_WRITE(STATE) L6474_DIR_WRITE(Y2, STATE) |
|||
#define Y2_DIR_READ() READ(Y2_DIR_PIN) |
|||
#else |
|||
#define Y2_DIR_INIT() NOOP |
|||
#define Y2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y2, STATE) |
|||
#define Y2_DIR_READ() (stepper##Y2.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
#if AXIS_DRIVER_TYPE_Y2(L6470) |
|||
#define DISABLE_STEPPER_Y2() stepperY2.free() |
|||
#endif |
|||
|
|||
// Z2 Stepper
|
|||
#if HAS_Z2_ENABLE && AXIS_IS_L64XX(Z2) |
|||
extern L64XX_CLASS(Z2) stepperZ2; |
|||
#define Z2_ENABLE_INIT() NOOP |
|||
#define Z2_ENABLE_WRITE(STATE) (STATE ? stepperZ2.hardStop() : stepperZ2.free()) |
|||
#define Z2_ENABLE_READ() (stepperZ2.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Z2(L6474) |
|||
#define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN) |
|||
#define Z2_DIR_WRITE(STATE) L6474_DIR_WRITE(Z2, STATE) |
|||
#define Z2_DIR_READ() READ(Z2_DIR_PIN) |
|||
#else |
|||
#define Z2_DIR_INIT() NOOP |
|||
#define Z2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z2, STATE) |
|||
#define Z2_DIR_READ() (stepper##Z2.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
#if AXIS_DRIVER_TYPE_Z2(L6470) |
|||
#define DISABLE_STEPPER_Z2() stepperZ2.free() |
|||
#endif |
|||
|
|||
// Z3 Stepper
|
|||
#if HAS_Z3_ENABLE && AXIS_IS_L64XX(Z3) |
|||
extern L64XX_CLASS(Z3) stepperZ3; |
|||
#define Z3_ENABLE_INIT() NOOP |
|||
#define Z3_ENABLE_WRITE(STATE) (STATE ? stepperZ3.hardStop() : stepperZ3.free()) |
|||
#define Z3_ENABLE_READ() (stepperZ3.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Z3(L6474) |
|||
#define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN) |
|||
#define Z3_DIR_WRITE(STATE) L6474_DIR_WRITE(Z3, STATE) |
|||
#define Z3_DIR_READ() READ(Z3_DIR_PIN) |
|||
#else |
|||
#define Z3_DIR_INIT() NOOP |
|||
#define Z3_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z3, STATE) |
|||
#define Z3_DIR_READ() (stepper##Z3.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
#if AXIS_DRIVER_TYPE_Z3(L6470) |
|||
#define DISABLE_STEPPER_Z3() stepperZ3.free() |
|||
#endif |
|||
|
|||
// Z4 Stepper
|
|||
#if HAS_Z4_ENABLE && AXIS_IS_L64XX(Z4) |
|||
extern L64XX_CLASS(Z4) stepperZ4; |
|||
#define Z4_ENABLE_INIT() NOOP |
|||
#define Z4_ENABLE_WRITE(STATE) (STATE ? stepperZ4.hardStop() : stepperZ4.free()) |
|||
#define Z4_ENABLE_READ() (stepperZ4.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_Z4(L6474) |
|||
#define Z4_DIR_INIT() SET_OUTPUT(Z4_DIR_PIN) |
|||
#define Z4_DIR_WRITE(STATE) L6474_DIR_WRITE(Z4, STATE) |
|||
#define Z4_DIR_READ() READ(Z4_DIR_PIN) |
|||
#else |
|||
#define Z4_DIR_INIT() NOOP |
|||
#define Z4_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z4, STATE) |
|||
#define Z4_DIR_READ() (stepper##Z4.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
#if AXIS_DRIVER_TYPE_Z4(L6470) |
|||
#define DISABLE_STEPPER_Z4() stepperZ4.free() |
|||
#endif |
|||
|
|||
// I Stepper
|
|||
#if AXIS_IS_L64XX(I) |
|||
extern L64XX_CLASS(I) stepperI; |
|||
#define I_ENABLE_INIT() NOOP |
|||
#define I_ENABLE_WRITE(STATE) (STATE ? stepperI.hardStop() : stepperI.free()) |
|||
#define I_ENABLE_READ() (stepperI.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_I(L6474) |
|||
#define I_DIR_INIT() SET_OUTPUT(I_DIR_PIN) |
|||
#define I_DIR_WRITE(STATE) L6474_DIR_WRITE(I, STATE) |
|||
#define I_DIR_READ() READ(I_DIR_PIN) |
|||
#else |
|||
#define I_DIR_INIT() NOOP |
|||
#define I_DIR_WRITE(STATE) L64XX_DIR_WRITE(I, STATE) |
|||
#define I_DIR_READ() (stepper##I.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_I(L6470) |
|||
#define DISABLE_STEPPER_I() stepperI.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// J Stepper
|
|||
#if AXIS_IS_L64XX(J) |
|||
extern L64XX_CLASS(J) stepperJ; |
|||
#define J_ENABLE_INIT() NOOP |
|||
#define J_ENABLE_WRITE(STATE) (STATE ? stepperJ.hardStop() : stepperJ.free()) |
|||
#define J_ENABLE_READ() (stepperJ.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_J(L6474) |
|||
#define J_DIR_INIT() SET_OUTPUT(J_DIR_PIN) |
|||
#define J_DIR_WRITE(STATE) L6474_DIR_WRITE(J, STATE) |
|||
#define J_DIR_READ() READ(J_DIR_PIN) |
|||
#else |
|||
#define J_DIR_INIT() NOOP |
|||
#define J_DIR_WRITE(STATE) L64XX_DIR_WRITE(J, STATE) |
|||
#define J_DIR_READ() (stepper##J.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_J(L6470) |
|||
#define DISABLE_STEPPER_J() stepperJ.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// K Stepper
|
|||
#if AXIS_IS_L64XX(K) |
|||
extern L64XX_CLASS(K) stepperK; |
|||
#define K_ENABLE_INIT() NOOP |
|||
#define K_ENABLE_WRITE(STATE) (STATE ? stepperK.hardStop() : stepperK.free()) |
|||
#define K_ENABLE_READ() (stepperK.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_K(L6474) |
|||
#define K_DIR_INIT() SET_OUTPUT(K_DIR_PIN) |
|||
#define K_DIR_WRITE(STATE) L6474_DIR_WRITE(K, STATE) |
|||
#define K_DIR_READ() READ(K_DIR_PIN) |
|||
#else |
|||
#define K_DIR_INIT() NOOP |
|||
#define K_DIR_WRITE(STATE) L64XX_DIR_WRITE(K, STATE) |
|||
#define K_DIR_READ() (stepper##K.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_K(L6470) |
|||
#define DISABLE_STEPPER_K() stepperK.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// U Stepper
|
|||
#if HAS_U_AXIS |
|||
#if AXIS_IS_L64XX(U) |
|||
extern L64XX_CLASS(U) stepperU; |
|||
#define U_ENABLE_INIT() NOOP |
|||
#define U_ENABLE_WRITE(STATE) (STATE ? stepperU.hardStop() : stepperU.free()) |
|||
#define U_ENABLE_READ() (stepperU.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_U(L6474) |
|||
#define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) |
|||
#define U_DIR_WRITE(STATE) L6474_DIR_WRITE(U, STATE) |
|||
#define U_DIR_READ() READ(U_DIR_PIN) |
|||
#else |
|||
#define U_DIR_INIT() NOOP |
|||
#define U_DIR_WRITE(STATE) L64XX_DIR_WRITE(U, STATE) |
|||
#define U_DIR_READ() (stepper##U.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_U(L6470) |
|||
#define DISABLE_STEPPER_U() stepperU.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// V Stepper
|
|||
#if HAS_V_AXIS |
|||
#if AXIS_IS_L64XX(V) |
|||
extern L64XX_CLASS(V) stepperV; |
|||
#define V_ENABLE_INIT() NOOP |
|||
#define V_ENABLE_WRITE(STATE) (STATE ? stepperV.hardStop() : stepperV.free()) |
|||
#define V_ENABLE_READ() (stepperV.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_V(L6474) |
|||
#define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) |
|||
#define V_DIR_WRITE(STATE) L6474_DIR_WRITE(V, STATE) |
|||
#define V_DIR_READ() READ(V_DIR_PIN) |
|||
#else |
|||
#define V_DIR_INIT() NOOP |
|||
#define V_DIR_WRITE(STATE) L64XX_DIR_WRITE(V, STATE) |
|||
#define V_DIR_READ() (stepper##V.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_V(L6470) |
|||
#define DISABLE_STEPPER_V() stepperV.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// W Stepper
|
|||
#if HAS_W_AXIS |
|||
#if AXIS_IS_L64XX(W) |
|||
extern L64XX_CLASS(w) stepperW; |
|||
#define W_ENABLE_INIT() NOOP |
|||
#define W_ENABLE_WRITE(STATE) (STATE ? stepperW.hardStop() : stepperW.free()) |
|||
#define W_ENABLE_READ() (stepperW.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_W(L6474) |
|||
#define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) |
|||
#define W_DIR_WRITE(STATE) L6474_DIR_WRITE(W, STATE) |
|||
#define W_DIR_READ() READ(W_DIR_PIN) |
|||
#else |
|||
#define W_DIR_INIT() NOOP |
|||
#define W_DIR_WRITE(STATE) L64XX_DIR_WRITE(W, STATE) |
|||
#define W_DIR_READ() (stepper##W.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_W(L6470) |
|||
#define DISABLE_STEPPER_W() stepperW.free() |
|||
#endif |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E0 Stepper
|
|||
#if AXIS_IS_L64XX(E0) |
|||
extern L64XX_CLASS(E0) stepperE0; |
|||
#define E0_ENABLE_INIT() NOOP |
|||
#define E0_ENABLE_WRITE(STATE) (STATE ? stepperE0.hardStop() : stepperE0.free()) |
|||
#define E0_ENABLE_READ() (stepperE0.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E0(L6474) |
|||
#define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN) |
|||
#define E0_DIR_WRITE(STATE) L6474_DIR_WRITE(E0, STATE) |
|||
#define E0_DIR_READ() READ(E0_DIR_PIN) |
|||
#else |
|||
#define E0_DIR_INIT() NOOP |
|||
#define E0_DIR_WRITE(STATE) L64XX_DIR_WRITE(E0, STATE) |
|||
#define E0_DIR_READ() (stepper##E0.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E0(L6470) |
|||
#define DISABLE_STEPPER_E0() do{ stepperE0.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E1 Stepper
|
|||
#if AXIS_IS_L64XX(E1) |
|||
extern L64XX_CLASS(E1) stepperE1; |
|||
#define E1_ENABLE_INIT() NOOP |
|||
#define E1_ENABLE_WRITE(STATE) (STATE ? stepperE1.hardStop() : stepperE1.free()) |
|||
#define E1_ENABLE_READ() (stepperE1.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E1(L6474) |
|||
#define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN) |
|||
#define E1_DIR_WRITE(STATE) L6474_DIR_WRITE(E1, STATE) |
|||
#define E1_DIR_READ() READ(E1_DIR_PIN) |
|||
#else |
|||
#define E1_DIR_INIT() NOOP |
|||
#define E1_DIR_WRITE(STATE) L64XX_DIR_WRITE(E1, STATE) |
|||
#define E1_DIR_READ() (stepper##E1.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E1(L6470) |
|||
#define DISABLE_STEPPER_E1() do{ stepperE1.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E2 Stepper
|
|||
#if AXIS_IS_L64XX(E2) |
|||
extern L64XX_CLASS(E2) stepperE2; |
|||
#define E2_ENABLE_INIT() NOOP |
|||
#define E2_ENABLE_WRITE(STATE) (STATE ? stepperE2.hardStop() : stepperE2.free()) |
|||
#define E2_ENABLE_READ() (stepperE2.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E2(L6474) |
|||
#define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN) |
|||
#define E2_DIR_WRITE(STATE) L6474_DIR_WRITE(E2, STATE) |
|||
#define E2_DIR_READ() READ(E2_DIR_PIN) |
|||
#else |
|||
#define E2_DIR_INIT() NOOP |
|||
#define E2_DIR_WRITE(STATE) L64XX_DIR_WRITE(E2, STATE) |
|||
#define E2_DIR_READ() (stepper##E2.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E2(L6470) |
|||
#define DISABLE_STEPPER_E2() do{ stepperE2.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E3 Stepper
|
|||
#if AXIS_IS_L64XX(E3) |
|||
extern L64XX_CLASS(E3) stepperE3; |
|||
#define E3_ENABLE_INIT() NOOP |
|||
#define E3_ENABLE_WRITE(STATE) (STATE ? stepperE3.hardStop() : stepperE3.free()) |
|||
#define E3_ENABLE_READ() (stepperE3.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E3(L6474) |
|||
#define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN) |
|||
#define E3_DIR_WRITE(STATE) L6474_DIR_WRITE(E3, STATE) |
|||
#define E3_DIR_READ() READ(E3_DIR_PIN) |
|||
#else |
|||
#define E3_DIR_INIT() NOOP |
|||
#define E3_DIR_WRITE(STATE) L64XX_DIR_WRITE(E3, STATE) |
|||
#define E3_DIR_READ() (stepper##E3.getStatus() & STATUS_DIR); |
|||
#endif |
|||
#endif |
|||
|
|||
// E4 Stepper
|
|||
#if AXIS_IS_L64XX(E4) |
|||
extern L64XX_CLASS(E4) stepperE4; |
|||
#define E4_ENABLE_INIT() NOOP |
|||
#define E4_ENABLE_WRITE(STATE) (STATE ? stepperE4.hardStop() : stepperE4.free()) |
|||
#define E4_ENABLE_READ() (stepperE4.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E4(L6474) |
|||
#define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN) |
|||
#define E4_DIR_WRITE(STATE) L6474_DIR_WRITE(E4, STATE) |
|||
#define E4_DIR_READ() READ(E4_DIR_PIN) |
|||
#else |
|||
#define E4_DIR_INIT() NOOP |
|||
#define E4_DIR_WRITE(STATE) L64XX_DIR_WRITE(E4, STATE) |
|||
#define E4_DIR_READ() (stepper##E4.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E4(L6470) |
|||
#define DISABLE_STEPPER_E4() do{ stepperE4.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E5 Stepper
|
|||
#if AXIS_IS_L64XX(E5) |
|||
extern L64XX_CLASS(E5) stepperE5; |
|||
#define E5_ENABLE_INIT() NOOP |
|||
#define E5_ENABLE_WRITE(STATE) (STATE ? stepperE5.hardStop() : stepperE5.free()) |
|||
#define E5_ENABLE_READ() (stepperE5.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E5(L6474) |
|||
#define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN) |
|||
#define E5_DIR_WRITE(STATE) L6474_DIR_WRITE(E5, STATE) |
|||
#define E5_DIR_READ() READ(E5_DIR_PIN) |
|||
#else |
|||
#define E5_DIR_INIT() NOOP |
|||
#define E5_DIR_WRITE(STATE) L64XX_DIR_WRITE(E5, STATE) |
|||
#define E5_DIR_READ() (stepper##E5.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E5(L6470) |
|||
#define DISABLE_STEPPER_E5() do{ stepperE5.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E6 Stepper
|
|||
#if AXIS_IS_L64XX(E6) |
|||
extern L64XX_CLASS(E6) stepperE6; |
|||
#define E6_ENABLE_INIT() NOOP |
|||
#define E6_ENABLE_WRITE(STATE) (STATE ? stepperE6.hardStop() : stepperE6.free()) |
|||
#define E6_ENABLE_READ() (stepperE6.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E6(L6474) |
|||
#define E6_DIR_INIT() SET_OUTPUT(E6_DIR_PIN) |
|||
#define E6_DIR_WRITE(STATE) L6474_DIR_WRITE(E6, STATE) |
|||
#define E6_DIR_READ() READ(E6_DIR_PIN) |
|||
#else |
|||
#define E6_DIR_INIT() NOOP |
|||
#define E6_DIR_WRITE(STATE) L64XX_DIR_WRITE(E6, STATE) |
|||
#define E6_DIR_READ() (stepper##E6.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E6(L6470) |
|||
#define DISABLE_STEPPER_E6() do{ stepperE6.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
|||
|
|||
// E7 Stepper
|
|||
#if AXIS_IS_L64XX(E7) |
|||
extern L64XX_CLASS(E7) stepperE7; |
|||
#define E7_ENABLE_INIT() NOOP |
|||
#define E7_ENABLE_WRITE(STATE) (STATE ? stepperE7.hardStop() : stepperE7.free()) |
|||
#define E7_ENABLE_READ() (stepperE7.getStatus() & STATUS_HIZ) |
|||
#if AXIS_DRIVER_TYPE_E7(L6474) |
|||
#define E7_DIR_INIT() SET_OUTPUT(E7_DIR_PIN) |
|||
#define E7_DIR_WRITE(STATE) L6474_DIR_WRITE(E7, STATE) |
|||
#define E7_DIR_READ() READ(E7_DIR_PIN) |
|||
#else |
|||
#define E7_DIR_INIT() NOOP |
|||
#define E7_DIR_WRITE(STATE) L64XX_DIR_WRITE(E7, STATE) |
|||
#define E7_DIR_READ() (stepper##E7.getStatus() & STATUS_DIR); |
|||
#if AXIS_DRIVER_TYPE_E7(L6470) |
|||
#define DISABLE_STEPPER_E7() do{ stepperE7.free(); }while(0) |
|||
#endif |
|||
#endif |
|||
#endif |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue