Skip to content

Commit

Permalink
BigTreeTech GTR V1.0 / Support 8 extruders, heaters, temp sensors, fa…
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwenxiong authored and kurtnelle committed Jan 29, 2020
1 parent f1ca181 commit 7a671fc
Show file tree
Hide file tree
Showing 66 changed files with 2,081 additions and 212 deletions.
19 changes: 15 additions & 4 deletions Marlin/src/HAL/HAL_AVR/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,25 @@ enum ClockSource2 : char {
*/

// Determine which harware PWMs are already in use
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#if PIN_EXISTS(CONTROLLER_FAN)
#define PWM_CHK_FAN_B(P) (P == CONTROLLER_FAN_PIN || P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
#else
#define PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#define PWM_CHK_FAN_B(P) _PWM_CHK_FAN_B(P)
#endif

#if ANY_PIN(FAN, FAN1, FAN2)
#if PIN_EXISTS(FAN2)
#if ANY_PIN(FAN, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7)
#if PIN_EXISTS(FAN7)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN || P == FAN7_PIN)
#elif PIN_EXISTS(FAN6)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN)
#elif PIN_EXISTS(FAN5)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN)
#elif PIN_EXISTS(FAN4)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN)
#elif PIN_EXISTS(FAN3)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN)
#elif PIN_EXISTS(FAN2)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN)
#elif PIN_EXISTS(FAN1)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN)
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#error "TEMP_4_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_5)
#error "TEMP_5_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_6)
#error "TEMP_6_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_7)
#error "TEMP_7_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#endif
#undef _OLD_TEMP_PIN

Expand Down
50 changes: 43 additions & 7 deletions Marlin/src/HAL/HAL_SAMD51/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
#else
#define GET_TEMP_5_ADC() -1
#endif
#if HAS_TEMP_ADC_6
#define GET_TEMP_6_ADC() PIN_TO_ADC(TEMP_6_PIN)
#else
#define GET_TEMP_6_ADC() -1
#endif
#if HAS_TEMP_ADC_7
#define GET_TEMP_7_ADC() PIN_TO_ADC(TEMP_7_PIN)
#else
#define GET_TEMP_7_ADC() -1
#endif
#if HAS_TEMP_PROBE
#define GET_PROBE_ADC() PIN_TO_ADC(TEMP_PROBE_PIN)
#else
Expand All @@ -85,13 +95,15 @@
#define GET_BUTTONS_ADC() -1
#endif

#define IS_ADC_REQUIRED(n) (GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n \
|| GET_TEMP_3_ADC() == n || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_BED_ADC() == n \
|| GET_CHAMBER_ADC() == n \
|| GET_FILAMENT_WIDTH_ADC() == n \
|| GET_BUTTONS_ADC() == n)
#define IS_ADC_REQUIRED(n) ( \
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
|| GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_BED_ADC() == n \
|| GET_CHAMBER_ADC() == n \
|| GET_FILAMENT_WIDTH_ADC() == n \
|| GET_BUTTONS_ADC() == n \
)

#define ADC0_IS_REQUIRED IS_ADC_REQUIRED(0)
#define ADC1_IS_REQUIRED IS_ADC_REQUIRED(1)
Expand Down Expand Up @@ -151,6 +163,12 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 0
TEMP_5_PIN,
#endif
#if GET_TEMP_6_ADC() == 0
TEMP_6_PIN,
#endif
#if GET_TEMP_7_ADC() == 0
TEMP_7_PIN,
#endif
#if GET_PROBE_ADC() == 0
TEMP_PROBE_PIN,
#endif
Expand Down Expand Up @@ -185,6 +203,12 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 1
TEMP_5_PIN,
#endif
#if GET_TEMP_6_ADC() == 1
TEMP_6_PIN,
#endif
#if GET_TEMP_7_ADC() == 1
TEMP_7_PIN,
#endif
#if GET_PROBE_ADC() == 1
TEMP_PROBE_PIN,
#endif
Expand Down Expand Up @@ -227,6 +251,12 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_5_PIN) },
#endif
#if GET_TEMP_6_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_6_PIN) },
#endif
#if GET_TEMP_7_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif
#if GET_PROBE_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
Expand Down Expand Up @@ -270,6 +300,12 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_5_PIN) },
#endif
#if GET_TEMP_6_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_6_PIN) },
#endif
#if GET_TEMP_7_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif
#if GET_PROBE_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
Expand Down
18 changes: 18 additions & 0 deletions Marlin/src/HAL/HAL_STM32F1/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ const uint8_t adc_pins[] = {
#if HAS_TEMP_ADC_5
TEMP_5_PIN,
#endif
#if HAS_TEMP_ADC_6
TEMP_6_PIN,
#endif
#if HAS_TEMP_ADC_7
TEMP_7_PIN,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH_PIN,
#endif
Expand Down Expand Up @@ -160,6 +166,12 @@ enum TEMP_PINS : char {
#if HAS_TEMP_ADC_5
TEMP_5,
#endif
#if HAS_TEMP_ADC_6
TEMP_6,
#endif
#if HAS_TEMP_ADC_7
TEMP_7,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH,
#endif
Expand Down Expand Up @@ -346,6 +358,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
#if HAS_TEMP_ADC_5
case TEMP_5_PIN: pin_index = TEMP_5; break;
#endif
#if HAS_TEMP_ADC_6
case TEMP_6_PIN: pin_index = TEMP_6; break;
#endif
#if HAS_TEMP_ADC_7
case TEMP_7_PIN: pin_index = TEMP_7; break;
#endif
#if HAS_JOY_ADC_X
case JOY_X_PIN: pin_index = JOY_X; break;
#endif
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/core/drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@

#define HAS_E_DRIVER(T) ( AXIS_DRIVER_TYPE_E0(T) || AXIS_DRIVER_TYPE_E1(T) \
|| AXIS_DRIVER_TYPE_E2(T) || AXIS_DRIVER_TYPE_E3(T) \
|| AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) )
|| AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) \
|| AXIS_DRIVER_TYPE_E6(T) || AXIS_DRIVER_TYPE_E7(T) )

#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_X2(T) \
|| AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Y2(T) \
Expand Down Expand Up @@ -152,7 +153,8 @@
|| AXIS_HAS_##T(Z3) \
|| AXIS_HAS_##T(E0) || AXIS_HAS_##T(E1) \
|| AXIS_HAS_##T(E2) || AXIS_HAS_##T(E3) \
|| AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) )
|| AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) \
|| AXIS_HAS_##T(E6) || AXIS_HAS_##T(E7) )

#define HAS_STEALTHCHOP ANY_AXIS_HAS(STEALTHCHOP)
#define HAS_STALLGUARD ANY_AXIS_HAS(STALLGUARD)
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@
#define LCD_STR_N3 "3"
#define LCD_STR_N4 "4"
#define LCD_STR_N5 "5"
#define LCD_STR_N6 "6"
#define LCD_STR_N7 "7"
#else
#define LCD_FIRST_TOOL '1'
#define LCD_STR_N0 "1"
Expand All @@ -367,6 +369,8 @@
#define LCD_STR_N3 "4"
#define LCD_STR_N4 "5"
#define LCD_STR_N5 "6"
#define LCD_STR_N6 "7"
#define LCD_STR_N7 "8"
#endif

#define LCD_STR_E0 "E" LCD_STR_N0
Expand All @@ -375,6 +379,8 @@
#define LCD_STR_E3 "E" LCD_STR_N3
#define LCD_STR_E4 "E" LCD_STR_N4
#define LCD_STR_E5 "E" LCD_STR_N5
#define LCD_STR_E6 "E" LCD_STR_N6
#define LCD_STR_E7 "E" LCD_STR_N7

#include "multi_language.h" // Allow multiple languages

Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ enum AxisEnum : uint8_t {
E_AXIS = 3,
X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6,
E0_AXIS = 3,
E1_AXIS = 4,
E2_AXIS = 5,
E3_AXIS = 6,
E4_AXIS = 7,
E5_AXIS = 8,
E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS,
ALL_AXES = 0xFE, NO_AXIS = 0xFF
};

Expand Down
33 changes: 24 additions & 9 deletions Marlin/src/gcode/control/M42.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,38 @@ void GcodeSuite::M42() {

const pin_t pin = GET_PIN_MAP_PIN(pin_index);

if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();

pinMode(pin, OUTPUT);
extDigitalWrite(pin, pin_status);
analogWrite(pin, pin_status);

#if FAN_COUNT > 0
switch (pin) {
#if HAS_FAN0
case FAN0_PIN: thermalManager.fan_speed[0] = pin_status; break;
case FAN0_PIN: thermalManager.fan_speed[0] = pin_status; return;
#endif
#if HAS_FAN1
case FAN1_PIN: thermalManager.fan_speed[1] = pin_status; break;
case FAN1_PIN: thermalManager.fan_speed[1] = pin_status; return;
#endif
#if HAS_FAN2
case FAN2_PIN: thermalManager.fan_speed[2] = pin_status; break;
case FAN2_PIN: thermalManager.fan_speed[2] = pin_status; return;
#endif
#if HAS_FAN3
case FAN3_PIN: thermalManager.fan_speed[3] = pin_status; return;
#endif
#if HAS_FAN4
case FAN4_PIN: thermalManager.fan_speed[4] = pin_status; return;
#endif
#if HAS_FAN5
case FAN5_PIN: thermalManager.fan_speed[5] = pin_status; return;
#endif
#if HAS_FAN6
case FAN6_PIN: thermalManager.fan_speed[6] = pin_status; return;
#endif
#if HAS_FAN7
case FAN7_PIN: thermalManager.fan_speed[7] = pin_status; return;
#endif
}
#endif

if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();

pinMode(pin, OUTPUT);
extDigitalWrite(pin, pin_status);
analogWrite(pin, pin_status);
}
26 changes: 25 additions & 1 deletion Marlin/src/gcode/feature/trinamic/M911-M914.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define M91x_SOME_X (M91x_USE(X) || M91x_USE(X2))
#define M91x_SOME_Y (M91x_USE(Y) || M91x_USE(Y2))
#define M91x_SOME_Z (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4))
#define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5))
#define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7))

#if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_SOME_E
#error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160."
Expand Down Expand Up @@ -91,6 +91,12 @@
#if M91x_USE_E(5)
tmc_report_otpw(stepperE5);
#endif
#if M91x_USE_E(6)
tmc_report_otpw(stepperE6);
#endif
#if M91x_USE_E(7)
tmc_report_otpw(stepperE7);
#endif
}

/**
Expand Down Expand Up @@ -188,6 +194,12 @@
#if M91x_USE_E(5)
if (hasNone || eval == 5 || (hasE && eval < 0)) tmc_clear_otpw(stepperE5);
#endif
#if M91x_USE_E(6)
if (hasNone || eval == 6 || (hasE && eval < 0)) tmc_clear_otpw(stepperE6);
#endif
#if M91x_USE_E(7)
if (hasNone || eval == 7 || (hasE && eval < 0)) tmc_clear_otpw(stepperE7);
#endif
#endif
}

Expand Down Expand Up @@ -263,6 +275,12 @@
#if E_STEPPERS > 5 && AXIS_HAS_STEALTHCHOP(E5)
case 5: TMC_SET_PWMTHRS_E(5); break;
#endif
#if E_STEPPERS > 6 && AXIS_HAS_STEALTHCHOP(E6)
case 6: TMC_SET_PWMTHRS_E(6); break;
#endif
#if E_STEPPERS > 7 && AXIS_HAS_STEALTHCHOP(E7)
case 7: TMC_SET_PWMTHRS_E(7); break;
#endif
}
#endif // E_STEPPERS
} break;
Expand Down Expand Up @@ -312,6 +330,12 @@
#if E_STEPPERS > 5 && AXIS_HAS_STEALTHCHOP(E5)
TMC_SAY_PWMTHRS_E(5);
#endif
#if E_STEPPERS > 6 && AXIS_HAS_STEALTHCHOP(E6)
TMC_SAY_PWMTHRS_E(6);
#endif
#if E_STEPPERS > 7 && AXIS_HAS_STEALTHCHOP(E7)
TMC_SAY_PWMTHRS_E(7);
#endif
}
}
#endif // HYBRID_THRESHOLD
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#undef TEMP_SENSOR_3
#undef TEMP_SENSOR_4
#undef TEMP_SENSOR_5
#undef TEMP_SENSOR_6
#undef TEMP_SENSOR_7
#undef FWRETRACT
#undef PIDTEMP
#undef AUTOTEMP
Expand Down
Loading

0 comments on commit 7a671fc

Please sign in to comment.