Fix compile error with DUE + MAX6675 (#13086)

This commit is contained in:
Scott Lahteine 2019-02-05 22:56:13 -06:00 committed by GitHub
parent ab6908a513
commit 3c49396370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 21 deletions

View file

@ -33,21 +33,22 @@ class SPIclass {
FORCE_INLINE static uint8_t receive() { return softSPI.receive(); } FORCE_INLINE static uint8_t receive() { return softSPI.receive(); }
}; };
// Hardware SPI // Hardware SPI
template<> template<>
class SPIclass<MISO_PIN, MOSI_PIN, SCK_PIN> { class SPIclass<MISO_PIN, MOSI_PIN, SCK_PIN> {
public: public:
FORCE_INLINE static void init() { FORCE_INLINE static void init() {
OUT_WRITE(SCK_PIN, LOW); OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH); OUT_WRITE(MOSI_PIN, HIGH);
SET_INPUT(MISO_PIN); SET_INPUT_PULLUP(MISO_PIN);
WRITE(MISO_PIN, HIGH);
} }
FORCE_INLINE static uint8_t receive() { FORCE_INLINE static uint8_t receive() {
SPDR = 0; #if defined(__AVR__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
for (;!TEST(SPSR, SPIF);); SPDR = 0;
return SPDR; for (;!TEST(SPSR, SPIF););
return SPDR;
#else
return spiRec();
#endif
} }
}; };

View file

@ -33,7 +33,9 @@
#include "../core/language.h" #include "../core/language.h"
#include "../HAL/shared/Delay.h" #include "../HAL/shared/Delay.h"
#if ENABLED(HEATER_0_USES_MAX6675) #define MAX6675_SEPARATE_SPI (ENABLED(HEATER_0_USES_MAX6675) || ENABLED(HEATER_1_USES_MAX6675)) && PIN_EXISTS(MAX6675_SCK) && PIN_EXISTS(MAX6675_DO)
#if MAX6675_SEPARATE_SPI
#include "../libs/private_spi.h" #include "../libs/private_spi.h"
#endif #endif
@ -1205,13 +1207,7 @@ void Temperature::updateTemperaturesFromRawValues() {
#endif #endif
#if ENABLED(HEATER_0_USES_MAX6675) #if MAX6675_SEPARATE_SPI
#ifndef MAX6675_SCK_PIN
#define MAX6675_SCK_PIN SCK_PIN
#endif
#ifndef MAX6675_DO_PIN
#define MAX6675_DO_PIN MISO_PIN
#endif
SPIclass<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi; SPIclass<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
#endif #endif
@ -1289,7 +1285,7 @@ void Temperature::init() {
#endif #endif
#endif #endif
#if ENABLED(HEATER_0_USES_MAX6675) #if MAX6675_SEPARATE_SPI
OUT_WRITE(SCK_PIN, LOW); OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH); OUT_WRITE(MOSI_PIN, HIGH);
@ -1300,7 +1296,7 @@ void Temperature::init() {
OUT_WRITE(SS_PIN, HIGH); OUT_WRITE(SS_PIN, HIGH);
OUT_WRITE(MAX6675_SS_PIN, HIGH); OUT_WRITE(MAX6675_SS_PIN, HIGH);
#endif // HEATER_0_USES_MAX6675 #endif
#if ENABLED(HEATER_1_USES_MAX6675) #if ENABLED(HEATER_1_USES_MAX6675)
OUT_WRITE(MAX6675_SS2_PIN, HIGH); OUT_WRITE(MAX6675_SS2_PIN, HIGH);
@ -1792,7 +1788,7 @@ void Temperature::disable_all_heaters() {
// //
// TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used.
// //
#if MB(MIGHTYBOARD_REVE) #if MAX6675_SEPARATE_SPI
spiBegin(); spiBegin();
spiInit(MAX6675_SPEED_BITS); spiInit(MAX6675_SPEED_BITS);
#endif #endif
@ -1813,7 +1809,7 @@ void Temperature::disable_all_heaters() {
max6675_temp = 0; max6675_temp = 0;
for (uint8_t i = sizeof(max6675_temp); i--;) { for (uint8_t i = sizeof(max6675_temp); i--;) {
max6675_temp |= ( max6675_temp |= (
#if MB(MIGHTYBOARD_REVE) #if MAX6675_SEPARATE_SPI
max6675_spi.receive() max6675_spi.receive()
#else #else
spiRec() spiRec()