Skip to content

Commit

Permalink
Split up stepper indirection (MarlinFirmware#15111)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored Sep 1, 2019
1 parent 87b16ed commit 586b334
Show file tree
Hide file tree
Showing 29 changed files with 1,391 additions and 1,088 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_STM32_F4_F7/STM32F7/TMC2660.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "../../../inc/MarlinConfig.h"
#include "../../../Marlin.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"
#include "../../../module/printcounter.h"
#include "../../../libs/duration_t.h"
#include "../../../libs/hex_print_routines.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include "HAL/shared/Delay.h"

#include "module/stepper_indirection.h"
#include "module/stepper/indirection.h"

#ifdef ARDUINO
#include <pins_arduino.h>
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/controllerfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#if ENABLED(USE_CONTROLLER_FAN)

#include "../module/stepper_indirection.h"
#include "../module/stepper/indirection.h"
#include "../module/temperature.h"

uint8_t controllerfan_speed;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "power.h"
#include "../module/temperature.h"
#include "../module/stepper_indirection.h"
#include "../module/stepper/indirection.h"
#include "../Marlin.h"

Power powerManager;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/prusa_MMU2/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ MMU2 mmu2;
#include "../../libs/nozzle.h"
#include "../../module/temperature.h"
#include "../../module/planner.h"
#include "../../module/stepper_indirection.h"
#include "../../module/stepper/indirection.h"
#include "../../Marlin.h"

#if ENABLED(HOST_PROMPT_SUPPORT)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/tmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "tmc_util.h"
#include "../Marlin.h"

#include "../module/stepper_indirection.h"
#include "../module/stepper/indirection.h"
#include "../module/printcounter.h"
#include "../libs/duration_t.h"
#include "../gcode/gcode.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/L6470/M122.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../gcode.h"
#include "../../../libs/L6470/L6470_Marlin.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"

inline void echo_yes_no(const bool yes) { serialprintPGM(yes ? PSTR(" YES") : PSTR(" NO ")); }

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/L6470/M906.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../gcode.h"
#include "../../../libs/L6470/L6470_Marlin.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"
#include "../../../module/planner.h"

#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/L6470/M916-918.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#if HAS_DRIVER(L6470)

#include "../../gcode.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"
#include "../../../module/planner.h"
#include "../../../libs/L6470/L6470_Marlin.h"

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/trinamic/M569.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../gcode.h"
#include "../../../feature/tmc_util.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"

template<typename TMC>
void tmc_say_stealth_status(TMC &st) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/trinamic/M906.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../gcode.h"
#include "../../../feature/tmc_util.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"

/**
* M906: Set motor current in milliamps.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/trinamic/M911-M914.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../gcode.h"
#include "../../../feature/tmc_util.h"
#include "../../../module/stepper_indirection.h"
#include "../../../module/stepper/indirection.h"
#include "../../../module/planner.h"
#include "../../queue.h"

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/host/M114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#if HAS_DRIVER(L6470)
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
#include "../../module/L6470/L6470_Marlin.h"
#include "../../libs/L6470/L6470_Marlin.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../core/debug_out.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extensible_ui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

#if HAS_TRINAMIC
#include "../../feature/tmc_util.h"
#include "../../module/stepper_indirection.h"
#include "../../module/stepper/indirection.h"
#endif

#include "ui_api.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_tmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#if HAS_TRINAMIC && HAS_LCD_MENU

#include "menu.h"
#include "../../module/stepper_indirection.h"
#include "../../module/stepper/indirection.h"
#include "../../feature/tmc_util.h"

#define TMC_EDIT_STORED_I_RMS(ST,MSG) MENU_ITEM_EDIT_CALLBACK(uint16_4, MSG, &stepper##ST.val_mA, 100, 3000, refresh_stepper_current_##ST)
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/libs/L6470/L6470_Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

/**
* The monitor_driver routines are a close copy of the TMC code
* The monitor_driver routines are a close copy of the TMC code
*/

#include "../../inc/MarlinConfig.h"
Expand All @@ -32,9 +32,9 @@

L6470_Marlin L6470;

#include "../stepper_indirection.h"
#include "../../module/stepper/indirection.h"
#include "../../module/planner.h"
#include "../../gcode/gcode.h"
#include "../planner.h"

#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../core/debug_out.h"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
#endif

#if HAS_TRINAMIC
#include "stepper_indirection.h"
#include "stepper/indirection.h"
#include "../feature/tmc_util.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/delta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#if ENABLED(SENSORLESS_HOMING)
#include "../feature/tmc_util.h"
#include "stepper_indirection.h"
#include "stepper/indirection.h"
#endif

#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ float zprobe_zoffset; // Initialized by settings.load()
#endif

#if QUIET_PROBING
#include "stepper_indirection.h"
#include "stepper/indirection.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
// Stepper class definition
//

#include "stepper_indirection.h"
#include "stepper/indirection.h"

#ifdef __AVR__
#include "speed_lookuptable.h"
Expand Down
143 changes: 143 additions & 0 deletions Marlin/src/module/stepper/L6470.cpp
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/>.
*
*/

/**
* stepper/L6470.cpp
* Stepper driver indirection for L6470 drivers
*/

#include "../../inc/MarlinConfig.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 // L6470
Loading

0 comments on commit 586b334

Please sign in to comment.