-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2aef83d
commit 4758db6
Showing
9 changed files
with
2,345 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* module/stepper/L6470.cpp | ||
* Stepper driver indirection for L6470 drivers | ||
*/ | ||
|
||
#include "../../inc/MarlinConfigPre.h" | ||
|
||
#if HAS_DRIVER(L6470) | ||
|
||
#include "L6470.h" | ||
|
||
#define _L6470_DEFINE(ST) L6470 stepper##ST((const int)L6470_CHAIN_SS_PIN) | ||
|
||
// L6470 Stepper objects | ||
#if AXIS_DRIVER_TYPE_X(L6470) | ||
_L6470_DEFINE(X); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_X2(L6470) | ||
_L6470_DEFINE(X2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Y(L6470) | ||
_L6470_DEFINE(Y); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Y2(L6470) | ||
_L6470_DEFINE(Y2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z(L6470) | ||
_L6470_DEFINE(Z); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z2(L6470) | ||
_L6470_DEFINE(Z2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z3(L6470) | ||
_L6470_DEFINE(Z3); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E0(L6470) | ||
_L6470_DEFINE(E0); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E1(L6470) | ||
_L6470_DEFINE(E1); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E2(L6470) | ||
_L6470_DEFINE(E2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E3(L6470) | ||
_L6470_DEFINE(E3); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E4(L6470) | ||
_L6470_DEFINE(E4); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E5(L6470) | ||
_L6470_DEFINE(E5); | ||
#endif | ||
|
||
// not using L6470 library's init command because it | ||
// briefly sends power to the steppers | ||
|
||
#define _L6470_INIT_CHIP(Q) do{ \ | ||
stepper##Q.resetDev(); \ | ||
stepper##Q.softFree(); \ | ||
stepper##Q.SetParam(L6470_CONFIG, CONFIG_PWM_DIV_1 \ | ||
| CONFIG_PWM_MUL_2 \ | ||
| CONFIG_SR_290V_us \ | ||
| CONFIG_OC_SD_DISABLE \ | ||
| CONFIG_VS_COMP_DISABLE \ | ||
| CONFIG_SW_HARD_STOP \ | ||
| CONFIG_INT_16MHZ); \ | ||
stepper##Q.SetParam(L6470_KVAL_RUN, 0xFF); \ | ||
stepper##Q.SetParam(L6470_KVAL_ACC, 0xFF); \ | ||
stepper##Q.SetParam(L6470_KVAL_DEC, 0xFF); \ | ||
stepper##Q.setMicroSteps(Q##_MICROSTEPS); \ | ||
stepper##Q.setOverCurrent(Q##_OVERCURRENT); \ | ||
stepper##Q.setStallCurrent(Q##_STALLCURRENT); \ | ||
stepper##Q.SetParam(L6470_KVAL_HOLD, Q##_MAX_VOLTAGE); \ | ||
stepper##Q.SetParam(L6470_ABS_POS, 0); \ | ||
stepper##Q.getStatus(); \ | ||
}while(0) | ||
|
||
void L6470_Marlin::init_to_defaults() { | ||
#if AXIS_DRIVER_TYPE_X(L6470) | ||
_L6470_INIT_CHIP(X); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_X2(L6470) | ||
_L6470_INIT_CHIP(X2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Y(L6470) | ||
_L6470_INIT_CHIP(Y); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Y2(L6470) | ||
_L6470_INIT_CHIP(Y2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z(L6470) | ||
_L6470_INIT_CHIP(Z); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z2(L6470) | ||
_L6470_INIT_CHIP(Z2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_Z3(L6470) | ||
_L6470_INIT_CHIP(Z3); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E0(L6470) | ||
_L6470_INIT_CHIP(E0); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E1(L6470) | ||
_L6470_INIT_CHIP(E1); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E2(L6470) | ||
_L6470_INIT_CHIP(E2); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E3(L6470) | ||
_L6470_INIT_CHIP(E3); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E4(L6470) | ||
_L6470_INIT_CHIP(E4); | ||
#endif | ||
#if AXIS_DRIVER_TYPE_E5(L6470) | ||
_L6470_INIT_CHIP(E5); | ||
#endif | ||
} | ||
|
||
#endif // HAS_DRIVER(L6470) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#pragma once | ||
|
||
/** | ||
* module/stepper/indirection.h | ||
* | ||
* Stepper motor driver indirection to allow some stepper functions to | ||
* be done via SPI/I2c instead of direct pin manipulation. | ||
* | ||
* Copyright (c) 2015 Dominik Wenger | ||
*/ | ||
|
||
#include "../../inc/MarlinConfig.h" | ||
#include "../../libs/L6470/L6470_Marlin.h" | ||
|
||
#define L6470_WRITE_DIR_COMMAND(STATE,Q) do{ L6470_dir_commands[Q] = (STATE ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD); }while(0) | ||
|
||
// X Stepper | ||
#if AXIS_DRIVER_TYPE_X(L6470) | ||
extern L6470 stepperX; | ||
#define X_ENABLE_INIT NOOP | ||
#define X_ENABLE_WRITE(STATE) NOOP | ||
#define X_ENABLE_READ() (stepperX.getStatus() & STATUS_HIZ) | ||
#define X_DIR_INIT NOOP | ||
#define X_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,X) | ||
#define X_DIR_READ() (stepperX.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// Y Stepper | ||
#if AXIS_DRIVER_TYPE_Y(L6470) | ||
extern L6470 stepperY; | ||
#define Y_ENABLE_INIT NOOP | ||
#define Y_ENABLE_WRITE(STATE) NOOP | ||
#define Y_ENABLE_READ() (stepperY.getStatus() & STATUS_HIZ) | ||
#define Y_DIR_INIT NOOP | ||
#define Y_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Y) | ||
#define Y_DIR_READ() (stepperY.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// Z Stepper | ||
#if AXIS_DRIVER_TYPE_Z(L6470) | ||
extern L6470 stepperZ; | ||
#define Z_ENABLE_INIT NOOP | ||
#define Z_ENABLE_WRITE(STATE) NOOP | ||
#define Z_ENABLE_READ() (stepperZ.getStatus() & STATUS_HIZ) | ||
#define Z_DIR_INIT NOOP | ||
#define Z_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z) | ||
#define Z_DIR_READ() (stepperZ.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// X2 Stepper | ||
#if HAS_X2_ENABLE && AXIS_DRIVER_TYPE_X2(L6470) | ||
extern L6470 stepperX2; | ||
#define X2_ENABLE_INIT NOOP | ||
#define X2_ENABLE_WRITE(STATE) NOOP | ||
#define X2_ENABLE_READ() (stepperX2.getStatus() & STATUS_HIZ) | ||
#define X2_DIR_INIT NOOP | ||
#define X2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,X2) | ||
#define X2_DIR_READ() (stepperX2.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// Y2 Stepper | ||
#if HAS_Y2_ENABLE && AXIS_DRIVER_TYPE_Y2(L6470) | ||
extern L6470 stepperY2; | ||
#define Y2_ENABLE_INIT NOOP | ||
#define Y2_ENABLE_WRITE(STATE) NOOP | ||
#define Y2_ENABLE_READ() (stepperY2.getStatus() & STATUS_HIZ) | ||
#define Y2_DIR_INIT NOOP | ||
#define Y2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Y2) | ||
#define Y2_DIR_READ() (stepperY2.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// Z2 Stepper | ||
#if HAS_Z2_ENABLE && AXIS_DRIVER_TYPE_Z2(L6470) | ||
extern L6470 stepperZ2; | ||
#define Z2_ENABLE_INIT NOOP | ||
#define Z2_ENABLE_WRITE(STATE) NOOP | ||
#define Z2_ENABLE_READ() (stepperZ2.getStatus() & STATUS_HIZ) | ||
#define Z2_DIR_INIT NOOP | ||
#define Z2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z2) | ||
#define Z2_DIR_READ() (stepperZ2.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// Z3 Stepper | ||
#if HAS_Z3_ENABLE && AXIS_DRIVER_TYPE_Z3(L6470) | ||
extern L6470 stepperZ3; | ||
#define Z3_ENABLE_INIT NOOP | ||
#define Z3_ENABLE_WRITE(STATE) NOOP | ||
#define Z3_ENABLE_READ() (stepperZ3.getStatus() & STATUS_HIZ) | ||
#define Z3_DIR_INIT NOOP | ||
#define Z3_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z3) | ||
#define Z3_DIR_READ() (stepperZ3.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E0 Stepper | ||
#if AXIS_DRIVER_TYPE_E0(L6470) | ||
extern L6470 stepperE0; | ||
#define E0_ENABLE_INIT NOOP | ||
#define E0_ENABLE_WRITE(STATE) NOOP | ||
#define E0_ENABLE_READ() (stepperE0.getStatus() & STATUS_HIZ) | ||
#define E0_DIR_INIT NOOP | ||
#define E0_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E0) | ||
#define E0_DIR_READ() (stepperE0.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E1 Stepper | ||
#if AXIS_DRIVER_TYPE_E1(L6470) | ||
extern L6470 stepperE1; | ||
#define E1_ENABLE_INIT NOOP | ||
#define E1_ENABLE_WRITE(STATE) NOOP | ||
#define E1_ENABLE_READ() (stepperE1.getStatus() & STATUS_HIZ) | ||
#define E1_DIR_INIT NOOP | ||
#define E1_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E1) | ||
#define E1_DIR_READ() (stepperE1.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E2 Stepper | ||
#if AXIS_DRIVER_TYPE_E2(L6470) | ||
extern L6470 stepperE2; | ||
#define E2_ENABLE_INIT NOOP | ||
#define E2_ENABLE_WRITE(STATE) NOOP | ||
#define E2_ENABLE_READ() (stepperE2.getStatus() & STATUS_HIZ) | ||
#define E2_DIR_INIT NOOP | ||
#define E2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E2) | ||
#define E2_DIR_READ() (stepperE2.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E3 Stepper | ||
#if AXIS_DRIVER_TYPE_E3(L6470) | ||
extern L6470 stepperE3; | ||
#define E3_ENABLE_INIT NOOP | ||
#define E3_ENABLE_WRITE(STATE) NOOP | ||
#define E3_ENABLE_READ() (stepperE3.getStatus() & STATUS_HIZ) | ||
#define E3_DIR_INIT NOOP | ||
#define E3_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E3) | ||
#define E3_DIR_READ() (stepperE3.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E4 Stepper | ||
#if AXIS_DRIVER_TYPE_E4(L6470) | ||
extern L6470 stepperE4; | ||
#define E4_ENABLE_INIT NOOP | ||
#define E4_ENABLE_WRITE(STATE) NOOP | ||
#define E4_ENABLE_READ() (stepperE4.getStatus() & STATUS_HIZ) | ||
#define E4_DIR_INIT NOOP | ||
#define E4_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E4) | ||
#define E4_DIR_READ() (stepperE4.getStatus() & STATUS_DIR) | ||
#endif | ||
|
||
// E5 Stepper | ||
#if AXIS_DRIVER_TYPE_E5(L6470) | ||
extern L6470 stepperE5; | ||
#define E5_ENABLE_INIT NOOP | ||
#define E5_ENABLE_WRITE(STATE) NOOP | ||
#define E5_ENABLE_READ() (stepperE5.getStatus() & STATUS_HIZ) | ||
#define E5_DIR_INIT NOOP | ||
#define E5_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E5) | ||
#define E5_DIR_READ() (stepperE5.getStatus() & STATUS_DIR) | ||
#endif |
Oops, something went wrong.
4758db6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get errors while compiling:
4758db6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related #15102