Skip to content

Commit

Permalink
Fix MAX6675 SPI init, conflicts (MarlinFirmware#20086)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinFor authored and dpreed committed Feb 5, 2021
1 parent 63dded7 commit adc1c45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
8 changes: 8 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,14 @@ void setup() {

SETUP_RUN(HAL_init());

// Init and disable SPI thermocouples
#if HEATER_0_USES_MAX6675
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
#endif
#if HEATER_1_USES_MAX6675
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
#endif

#if HAS_L64XX
SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers
#endif
Expand Down
19 changes: 1 addition & 18 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,22 +1799,7 @@ void Temperature::init() {
INIT_FAN_PIN(CONTROLLER_FAN_PIN);
#endif

#if MAX6675_SEPARATE_SPI

OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH);
SET_INPUT_PULLUP(MISO_PIN);

max6675_spi.init();

OUT_WRITE(SS_PIN, HIGH);
OUT_WRITE(MAX6675_SS_PIN, HIGH);

#endif

#if HEATER_1_USES_MAX6675
OUT_WRITE(MAX6675_SS2_PIN, HIGH);
#endif
TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init());

HAL_adc_init();

Expand Down Expand Up @@ -2277,9 +2262,7 @@ void Temperature::disable_all_heaters() {
spiInit(MAX6675_SPEED_BITS);
#endif

MAX6675_SET_OUTPUT();
MAX6675_WRITE(LOW); // enable TT_MAX6675

DELAY_NS(100); // Ensure 100ns delay

// Read a big-endian temperature value
Expand Down

0 comments on commit adc1c45

Please sign in to comment.