2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-17 18:34:04 -05:00
|
|
|
#include "../../../inc/MarlinConfig.h"
|
|
|
|
|
2017-12-15 15:03:14 -06:00
|
|
|
#if HAS_TRINAMIC
|
2017-09-17 18:34:04 -05:00
|
|
|
|
|
|
|
#include "../../gcode.h"
|
2017-12-15 15:03:14 -06:00
|
|
|
#include "../../../feature/tmc_util.h"
|
2017-09-17 18:34:04 -05:00
|
|
|
#include "../../../module/stepper_indirection.h"
|
2017-09-06 06:28:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* M906: Set motor current in milliamps using axis codes X, Y, Z, E
|
|
|
|
* Report driver currents when no axis specified
|
|
|
|
*/
|
2017-12-29 13:38:08 -06:00
|
|
|
void GcodeSuite::M906() {
|
2017-09-06 06:28:31 -05:00
|
|
|
uint16_t values[XYZE];
|
2018-01-09 19:14:07 -06:00
|
|
|
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
|
|
|
|
|
|
|
|
#define TMC_SET_GET_CURRENT(P,Q) do { \
|
|
|
|
if (values[P##_AXIS]) tmc_set_current(stepper##Q, extended_axis_codes[TMC_##Q], values[P##_AXIS]); \
|
|
|
|
else tmc_get_current(stepper##Q, extended_axis_codes[TMC_##Q]); } while(0)
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2017-12-15 15:03:14 -06:00
|
|
|
#if X_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(X,X);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2017-12-15 15:03:14 -06:00
|
|
|
#if X2_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(X,X2);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2017-12-15 15:03:14 -06:00
|
|
|
#if Y_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(Y,Y);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2017-12-15 15:03:14 -06:00
|
|
|
#if Y2_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(Y,Y2);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2017-12-15 15:03:14 -06:00
|
|
|
#if Z_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(Z,Z);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
|
|
|
#if Z2_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(Z,Z2);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2017-12-15 15:03:14 -06:00
|
|
|
#if E0_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(E,E0);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
|
|
|
#if E1_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(E,E1);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
|
|
|
#if E2_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(E,E2);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
|
|
|
#if E3_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(E,E3);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
|
|
|
#if E4_IS_TRINAMIC
|
2018-01-09 19:14:07 -06:00
|
|
|
TMC_SET_GET_CURRENT(E,E4);
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-09-17 18:34:04 -05:00
|
|
|
|
2017-12-15 15:03:14 -06:00
|
|
|
#endif // HAS_TRINAMIC
|