Fix compile error with DUE + MAX6675 (#13086)
This commit is contained in:
parent
ab6908a513
commit
3c49396370
@ -33,7 +33,6 @@ 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> {
|
||||||
@ -41,13 +40,15 @@ class SPIclass<MISO_PIN, MOSI_PIN, SCK_PIN> {
|
|||||||
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() {
|
||||||
|
#if defined(__AVR__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||||
SPDR = 0;
|
SPDR = 0;
|
||||||
for (;!TEST(SPSR, SPIF););
|
for (;!TEST(SPSR, SPIF););
|
||||||
return SPDR;
|
return SPDR;
|
||||||
|
#else
|
||||||
|
return spiRec();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user