Skip to content

Commit 84ed27b

Browse files
GadgetAngelthinkyhead
authored andcommitted
MAX Thermocouples rework (MarlinFirmware#20447)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
1 parent 236ffa7 commit 84ed27b

File tree

5 files changed

+266
-56
lines changed

5 files changed

+266
-56
lines changed

Marlin/src/HAL/LPC1768/inc/SanityCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Detect an old pins file by checking for old ADC pins values.
3333
*/
34-
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3
34+
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board
3535
#if _OLD_TEMP_PIN(TEMP_BED)
3636
#error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
3737
#elif _OLD_TEMP_PIN(TEMP_0)

Marlin/src/MarlinCore.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,11 @@ void setup() {
940940

941941
SETUP_RUN(HAL_init());
942942

943-
// Init and disable SPI thermocouples
944-
#if TEMP_SENSOR_0_IS_MAX6675
943+
// Init and disable SPI thermocouples; this is still needed
944+
#if TEMP_SENSOR_0_IS_MAX_TC
945945
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
946946
#endif
947-
#if TEMP_SENSOR_1_IS_MAX6675
947+
#if TEMP_SENSOR_1_IS_MAX_TC
948948
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
949949
#endif
950950

Marlin/src/inc/Conditionals_post.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,90 @@
490490
#define HAS_MAX6675 1
491491
#endif
492492

493+
//
494+
// Compatibility layer for MAX (SPI) temp boards
495+
//
496+
#if PIN_EXISTS(MAX6675_SS)
497+
#if TEMP_SENSOR_0_IS_MAX31855
498+
#define MAX31855_CS_PIN MAX6675_SS_PIN
499+
#elif TEMP_SENSOR_0_IS_MAX31865
500+
#define MAX31865_CS_PIN MAX6675_SS_PIN
501+
#elif TEMP_SENSOR_0_IS_MAX6675
502+
#define MAX6675_CS_PIN MAX6675_SS_PIN
503+
#endif
504+
#endif
505+
506+
#if PIN_EXISTS(MAX6675_SS2)
507+
#if TEMP_SENSOR_1_IS_MAX31855
508+
#define MAX31855_CS2_PIN MAX6675_SS2_PIN
509+
#elif TEMP_SENSOR_1_IS_MAX31865
510+
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
511+
#elif TEMP_SENSOR_1_IS_MAX6675
512+
#define MAX6675_CS2_PIN MAX6675_SS2_PIN
513+
#endif
514+
#endif
515+
516+
#if PIN_EXISTS(MAX6675_DO)
517+
#if HAS_MAX31855
518+
#define MAX31855_MISO_PIN MAX6675_DO_PIN
519+
#elif HAS_MAX31865
520+
#define MAX31865_MISO_PIN MAX6675_DO_PIN
521+
#elif HAS_MAX6675
522+
#define MAX6675_MISO_PIN MAX6675_DO_PIN
523+
#endif
524+
#endif
525+
526+
#if PIN_EXISTS(MAX6675_SCK)
527+
#if HAS_MAX31855
528+
#define MAX31855_SCK_PIN MAX6675_SCK_PIN
529+
#elif HAS_MAX31865
530+
#define MAX31865_SCK_PIN MAX6675_SCK_PIN
531+
#endif
532+
#endif
533+
534+
// Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675
535+
#if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS)
536+
#define MAX6675_SS_PIN MAX31855_CS_PIN
537+
#endif
538+
#if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2)
539+
#define MAX6675_SS2_PIN MAX31855_CS2_PIN
540+
#endif
541+
#if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS)
542+
#define MAX6675_SS_PIN MAX6675_CS_PIN
543+
#endif
544+
#if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2)
545+
#define MAX6675_SS2_PIN MAX6675_CS2_PIN
546+
#endif
547+
#if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO)
548+
#define MAX6675_DO_PIN MAX31855_MISO_PIN
549+
#endif
550+
#if PIN_EXISTS(MAX6675_MISO) && !PIN_EXISTS(MAX6675_DO)
551+
#define MAX6675_DO_PIN MAX6675_MISO_PIN
552+
#endif
553+
#if PIN_EXISTS(MAX31855_SCK) && !PIN_EXISTS(MAX6675_SCK)
554+
#define MAX6675_SCK_PIN MAX31855_SCK_PIN
555+
#endif
556+
557+
//
558+
// User-defined thermocouple libraries
559+
//
560+
// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags
561+
// to select a USER library for MAX6675, MAX31855, MAX31865
562+
//
563+
#if BOTH(HAS_MAX6675, LIB_MAX6675)
564+
#define LIB_USR_MAX6675 1
565+
#endif
566+
#if BOTH(HAS_MAX31855, LIB_MAX31855)
567+
#define LIB_USR_MAX31855 1
568+
#endif
569+
#if HAS_MAX31865
570+
#if ENABLED(LIB_MAX31865)
571+
#define LIB_USR_MAX31865 1
572+
#else
573+
#define LIB_ADAFRUIT_MAX31865 1
574+
#endif
575+
#endif
576+
493577
#if TEMP_SENSOR_2 == -4
494578
#define TEMP_SENSOR_2_IS_AD8495 1
495579
#elif TEMP_SENSOR_2 == -3

0 commit comments

Comments
 (0)