Bump to head, another couple steps
This commit is contained in:
@@ -182,7 +182,7 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t freque
|
||||
#define TIMER_OCR_0 OCR0A
|
||||
#define TIMER_COUNTER_0 TCNT0
|
||||
|
||||
#define _CAT(a, ...) a ## __VA_ARGS__
|
||||
#define _CAT(a,V...) a##V
|
||||
#define HAL_timer_set_compare(timer, compare) (_CAT(TIMER_OCR_, timer) = compare)
|
||||
#define HAL_timer_get_compare(timer) _CAT(TIMER_OCR_, timer)
|
||||
#define HAL_timer_get_count(timer) _CAT(TIMER_COUNTER_, timer)
|
||||
@@ -372,3 +372,22 @@ inline void HAL_adc_init(void) {
|
||||
|
||||
// AVR compatibility
|
||||
#define strtof strtod
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Sets the frequency of the timer corresponding to the provided pin
|
||||
* as close as possible to the provided desired frequency. Internally
|
||||
* calculates the required waveform generation mode, prescaler and
|
||||
* resolution values required and sets the timer registers accordingly.
|
||||
* NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B)
|
||||
* NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings)
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired);
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Sets the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
@@ -739,24 +739,24 @@
|
||||
|
||||
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
||||
|
||||
#ifdef INTERNAL_SERIAL_PORT
|
||||
|
||||
#if defined(INTERNAL_SERIAL_PORT)
|
||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) {
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::store_rxd_char();
|
||||
}
|
||||
|
||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) {
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::store_rxd_char();
|
||||
}
|
||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) {
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||
}
|
||||
|
||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) {
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||
}
|
||||
// Preinstantiate
|
||||
template class MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>;
|
||||
|
||||
// Preinstantiate
|
||||
template class MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>;
|
||||
|
||||
// Instantiate
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
|
||||
// Instantiate
|
||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
|
||||
|
||||
#endif
|
||||
|
||||
// For AT90USB targets use the UART for BT interfacing
|
||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||
HardwareSerial bluetoothSerial;
|
||||
|
||||
@@ -276,7 +276,7 @@
|
||||
#endif // !USBCON
|
||||
|
||||
|
||||
#if defined(INTERNAL_SERIAL_PORT)
|
||||
#ifdef INTERNAL_SERIAL_PORT
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
* Sanity checks for Spindle / Laser
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
#ifdef __AVR__
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
/**
|
||||
* get_pwm_timer
|
||||
* Grabs timer information and registers of the provided pin
|
||||
* returns Timer struct containing this information
|
||||
* Used by set_pwm_frequency, set_pwm_duty
|
||||
*
|
||||
*/
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#include "HAL.h"
|
||||
|
||||
struct Timer {
|
||||
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
|
||||
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
|
||||
volatile uint16_t* ICRn; // max 1 ICR register per timer
|
||||
uint8_t n; // the timer number [0->5]
|
||||
uint8_t q; // the timer output [0->2] (A->C)
|
||||
};
|
||||
|
||||
Timer get_pwm_timer(pin_t pin) {
|
||||
uint8_t q = 0;
|
||||
switch (digitalPinToTimer(pin)) {
|
||||
// Protect reserved timers (TIMER0 & TIMER1)
|
||||
#ifdef TCCR0A
|
||||
#if !AVR_AT90USB1286_FAMILY
|
||||
case TIMER0A:
|
||||
#endif
|
||||
case TIMER0B:
|
||||
#endif
|
||||
#ifdef TCCR1A
|
||||
case TIMER1A: case TIMER1B:
|
||||
#endif
|
||||
break;
|
||||
#if defined(TCCR2) || defined(TCCR2A)
|
||||
#ifdef TCCR2
|
||||
case TIMER2: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR2, NULL, NULL},
|
||||
/*OCRnQ*/ { (uint16_t*)&OCR2, NULL, NULL},
|
||||
/*ICRn*/ NULL,
|
||||
/*n, q*/ 2, 0
|
||||
};
|
||||
}
|
||||
#elif defined TCCR2A
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
case TIMER2A: break; // protect TIMER2A
|
||||
case TIMER2B: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, NULL},
|
||||
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, NULL},
|
||||
/*ICRn*/ NULL,
|
||||
/*n, q*/ 2, 1
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
#else
|
||||
case TIMER2B: ++q;
|
||||
case TIMER2A: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR2A, &TCCR2B, NULL},
|
||||
/*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, NULL},
|
||||
/*ICRn*/ NULL,
|
||||
2, q
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef TCCR3A
|
||||
case TIMER3C: ++q;
|
||||
case TIMER3B: ++q;
|
||||
case TIMER3A: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C},
|
||||
/*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C},
|
||||
/*ICRn*/ &ICR3,
|
||||
/*n, q*/ 3, q
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
#endif
|
||||
#ifdef TCCR4A
|
||||
case TIMER4C: ++q;
|
||||
case TIMER4B: ++q;
|
||||
case TIMER4A: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C},
|
||||
/*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C},
|
||||
/*ICRn*/ &ICR4,
|
||||
/*n, q*/ 4, q
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
#endif
|
||||
#ifdef TCCR5A
|
||||
case TIMER5C: ++q;
|
||||
case TIMER5B: ++q;
|
||||
case TIMER5A: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C},
|
||||
/*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C },
|
||||
/*ICRn*/ &ICR5,
|
||||
/*n, q*/ 5, q
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { NULL, NULL, NULL},
|
||||
/*OCRnQ*/ { NULL, NULL, NULL},
|
||||
/*ICRn*/ NULL,
|
||||
0, 0
|
||||
};
|
||||
return timer;
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
Timer timer = get_pwm_timer(pin);
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
|
||||
uint16_t size;
|
||||
if (timer.n == 2) size = 255; else size = 65535;
|
||||
|
||||
uint16_t res = 255; // resolution (TOP value)
|
||||
uint8_t j = 0; // prescaler index
|
||||
uint8_t wgm = 1; // waveform generation mode
|
||||
|
||||
// Calculating the prescaler and resolution to use to achieve closest frequency
|
||||
if (f_desired != 0) {
|
||||
int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable
|
||||
uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
|
||||
|
||||
// loop over prescaler values
|
||||
for (uint8_t i = 1; i < 8; i++) {
|
||||
uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
|
||||
if (timer.n == 2) {
|
||||
// No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
|
||||
res_temp_fast = rtf - 1;
|
||||
res_temp_phase_correct = rtf / 2;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// Skip TIMER2 specific prescalers when not TIMER2
|
||||
if (i == 3 || i == 5) continue;
|
||||
const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
|
||||
res_temp_fast = rtf - 1;
|
||||
res_temp_phase_correct = rtf / 2;
|
||||
}
|
||||
|
||||
LIMIT(res_temp_fast, 1u, size);
|
||||
LIMIT(res_temp_phase_correct, 1u, size);
|
||||
// Calculate frequencies of test prescaler and resolution values
|
||||
const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)),
|
||||
f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),
|
||||
f_diff = ABS(f - f_desired),
|
||||
f_fast_diff = ABS(f_temp_fast - f_desired),
|
||||
f_phase_diff = ABS(f_temp_phase_correct - f_desired);
|
||||
|
||||
// If FAST values are closest to desired f
|
||||
if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) {
|
||||
// Remember this combination
|
||||
f = f_temp_fast;
|
||||
res = res_temp_fast;
|
||||
j = i;
|
||||
// Set the Wave Generation Mode to FAST PWM
|
||||
if (timer.n == 2) {
|
||||
wgm = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
WGM2_FAST_PWM_OCR2A
|
||||
#else
|
||||
WGM2_FAST_PWM
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else wgm = WGM_FAST_PWM_ICRn;
|
||||
}
|
||||
// If PHASE CORRECT values are closes to desired f
|
||||
else if (f_phase_diff < f_diff) {
|
||||
f = f_temp_phase_correct;
|
||||
res = res_temp_phase_correct;
|
||||
j = i;
|
||||
// Set the Wave Generation Mode to PWM PHASE CORRECT
|
||||
if (timer.n == 2) {
|
||||
wgm = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
WGM2_PWM_PC_OCR2A
|
||||
#else
|
||||
WGM2_PWM_PC
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else wgm = WGM_PWM_PC_ICRn;
|
||||
}
|
||||
}
|
||||
}
|
||||
_SET_WGMnQ(timer.TCCRnQ, wgm);
|
||||
_SET_CSn(timer.TCCRnQ, j);
|
||||
|
||||
if (timer.n == 2) {
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
_SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
|
||||
#endif
|
||||
}
|
||||
else
|
||||
_SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
|
||||
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
|
||||
if (v == 0)
|
||||
digitalWrite(pin, invert);
|
||||
else if (v == v_size)
|
||||
digitalWrite(pin, !invert);
|
||||
else {
|
||||
Timer timer = get_pwm_timer(pin);
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
|
||||
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
|
||||
_SET_COMnQ(timer.TCCRnQ, (timer.q
|
||||
#ifdef TCCR2
|
||||
+ (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
|
||||
#endif
|
||||
), COM_CLEAR_SET + invert
|
||||
);
|
||||
|
||||
uint16_t top;
|
||||
if (timer.n == 2) { // if TIMER2
|
||||
top = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
*timer.OCRnQ[0] // top = OCR2A
|
||||
#else
|
||||
255 // top = 0xFF (max)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
top = *timer.ICRn; // top = ICRn
|
||||
|
||||
_SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top / v_size)); // Scale 8/16-bit v to top value
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FAST_PWM_FAN
|
||||
#endif // __AVR__
|
||||
@@ -81,9 +81,9 @@
|
||||
#define _SET_INPUT(IO) CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
#define _SET_OUTPUT(IO) SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
|
||||
#define _GET_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
#define _GET_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
#define _GET_TIMER(IO) DIO ## IO ## _PWM
|
||||
#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
#define _IS_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||
#define _HAS_TIMER(IO) DIO ## IO ## _PWM
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
#ifdef FASTIO_EXT_START
|
||||
@@ -104,9 +104,9 @@
|
||||
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
#define GET_INPUT(IO) _GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define GET_TIMER(IO) _GET_TIMER(IO)
|
||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
||||
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
@@ -200,7 +200,7 @@ enum ClockSource2 : char {
|
||||
TCCR##T##B = (TCCR##T##B & ~(0x3 << WGM##T##2)) | (((int(V) >> 2) & 0x3) << WGM##T##2); \
|
||||
}while(0)
|
||||
#define SET_WGM(T,V) _SET_WGM(T,WGM_##V)
|
||||
// Runtime (see Temperature::set_pwm_frequency):
|
||||
// Runtime (see set_pwm_frequency):
|
||||
#define _SET_WGMnQ(TCCRnQ, V) do{ \
|
||||
*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << 0)) | (( int(V) & 0x3) << 0); \
|
||||
*(TCCRnQ)[1] = (*(TCCRnQ)[1] & ~(0x3 << 3)) | (((int(V) >> 2) & 0x3) << 3); \
|
||||
@@ -230,7 +230,7 @@ enum ClockSource2 : char {
|
||||
#define SET_CS4(V) _SET_CS4(CS_##V)
|
||||
#define SET_CS5(V) _SET_CS5(CS_##V)
|
||||
#define SET_CS(T,V) SET_CS##T(V)
|
||||
// Runtime (see Temperature::set_pwm_frequency)
|
||||
// Runtime (see set_pwm_frequency)
|
||||
#define _SET_CSn(TCCRnQ, V) do{ \
|
||||
(*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)); \
|
||||
}while(0)
|
||||
@@ -243,19 +243,19 @@ enum ClockSource2 : char {
|
||||
#define SET_COMB(T,V) SET_COM(T,B,V)
|
||||
#define SET_COMC(T,V) SET_COM(T,C,V)
|
||||
#define SET_COMS(T,V1,V2,V3) do{ SET_COMA(T,V1); SET_COMB(T,V2); SET_COMC(T,V3); }while(0)
|
||||
// Runtime (see Temperature::set_pwm_duty)
|
||||
// Runtime (see set_pwm_duty)
|
||||
#define _SET_COMnQ(TCCRnQ, Q, V) do{ \
|
||||
(*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))); \
|
||||
}while(0)
|
||||
|
||||
// Set OCRnQ register
|
||||
// Runtime (see Temperature::set_pwm_duty):
|
||||
// Runtime (see set_pwm_duty):
|
||||
#define _SET_OCRnQ(OCRnQ, Q, V) do{ \
|
||||
(*(OCRnQ)[(Q)] = (0x0000) | (int(V) & 0xFFFF)); \
|
||||
}while(0)
|
||||
|
||||
// Set ICRn register (one per timer)
|
||||
// Runtime (see Temperature::set_pwm_frequency)
|
||||
// Runtime (see set_pwm_frequency)
|
||||
#define _SET_ICRn(ICRn, V) do{ \
|
||||
(*(ICRn) = (0x0000) | (int(V) & 0xFFFF)); \
|
||||
}while(0)
|
||||
@@ -286,7 +286,7 @@ enum ClockSource2 : char {
|
||||
#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)
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(FAN) || PIN_EXISTS(FAN1) || PIN_EXISTS(FAN2)
|
||||
#if ANY_PIN(FAN, FAN1, FAN2)
|
||||
#if PIN_EXISTS(FAN2)
|
||||
#define PWM_CHK_FAN_A(P) (P == FAN_PIN || P == FAN1_PIN || P == FAN2_PIN)
|
||||
#elif PIN_EXISTS(FAN1)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) || ENABLED(SD_FIRMWARE_UPDATE)
|
||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "../shared/persistent_store_api.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM, SPI_EEPROM)
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -997,5 +997,5 @@ void eeprom_flush(void) {
|
||||
ee_Flush();
|
||||
}
|
||||
|
||||
#endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
|
||||
#endif // ARDUINO_ARCH_AVR
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#if ENABLED(DUE_SOFTWARE_SPI)
|
||||
#if EITHER(DUE_SOFTWARE_SPI, FORCE_SOFT_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// software SPI
|
||||
@@ -739,7 +739,42 @@
|
||||
#define SPI_MODE_2_DUE_HW 0
|
||||
#define SPI_MODE_3_DUE_HW 1
|
||||
|
||||
/**
|
||||
* The DUE SPI controller is set up so the upper word of the longword
|
||||
* written to the transmit data register selects which SPI Chip Select
|
||||
* Register is used. This allows different streams to have different SPI
|
||||
* settings.
|
||||
*
|
||||
* In practice it's spooky. Some combinations hang the system, while others
|
||||
* upset the peripheral device.
|
||||
*
|
||||
* SPI mode should be the same for all streams. The FYSETC_MINI_12864 gets
|
||||
* upset if the clock phase changes after chip select goes active.
|
||||
*
|
||||
* SPI_CSR_CSAAT should be set for all streams. If not the WHILE_TX(0)
|
||||
* macro returns immediately which can result in the SPI chip select going
|
||||
* inactive before all the data has been sent.
|
||||
*
|
||||
* The TMC2130 library uses SPI0->SPI_CSR[3].
|
||||
*
|
||||
* The U8G hardware SPI uses SPI0->SPI_CSR[0]. The system hangs and/or the
|
||||
* FYSETC_MINI_12864 gets upset if lower baud rates are used and the SD card
|
||||
* is inserted or removed.
|
||||
*
|
||||
* The SD card uses SPI0->SPI_CSR[3]. Efforts were made to use [1] and [2]
|
||||
* but they all resulted in hangs or garbage on the LCD.
|
||||
*
|
||||
* The SPI controlled chip selects are NOT enabled in the GPIO controller.
|
||||
* The application must control the chip select.
|
||||
*
|
||||
* All of the above can be avoided by defining FORCE_SOFT_SPI to force the
|
||||
* display to use software SPI.
|
||||
*
|
||||
*/
|
||||
|
||||
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)
|
||||
// Also sets U8G SPI rate to 4MHz and the SPI mode to 3
|
||||
|
||||
// 8.4 MHz, 4 MHz, 2 MHz, 1 MHz, 0.5 MHz, 0.329 MHz, 0.329 MHz
|
||||
constexpr int spiDivider[] = { 10, 21, 42, 84, 168, 255, 255 };
|
||||
if (spiRate > 6) spiRate = 1;
|
||||
@@ -760,15 +795,16 @@
|
||||
// TMC2103 compatible setup
|
||||
// Master mode, no fault detection, PCS bits in data written to TDR select CSR register
|
||||
SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS;
|
||||
// SPI mode 0, 8 Bit data transfer, baud rate
|
||||
SPI0->SPI_CSR[3] = SPI_CSR_SCBR(spiDivider[spiRate]) | SPI_CSR_CSAAT | SPI_MODE_0_DUE_HW; // use same CSR as TMC2130
|
||||
// SPI mode 3, 8 Bit data transfer, baud rate
|
||||
SPI0->SPI_CSR[3] = SPI_CSR_SCBR(spiDivider[spiRate]) | SPI_CSR_CSAAT | SPI_MODE_3_DUE_HW; // use same CSR as TMC2130
|
||||
SPI0->SPI_CSR[0] = SPI_CSR_SCBR(spiDivider[1]) | SPI_CSR_CSAAT | SPI_MODE_3_DUE_HW; // U8G default to 4MHz
|
||||
}
|
||||
|
||||
void spiBegin() { spiInit(); }
|
||||
|
||||
static uint8_t spiTransfer(uint8_t data) {
|
||||
WHILE_TX(0);
|
||||
SPI0->SPI_TDR = (uint32_t)data | 0x00070000UL; // Add TMC2130 PCS bits to every byte
|
||||
SPI0->SPI_TDR = (uint32_t)data | 0x00070000UL; // Add TMC2130 PCS bits to every byte (use SPI0->SPI_CSR[3])
|
||||
WHILE_TX(0);
|
||||
WHILE_RX(0);
|
||||
return SPI0->SPI_RDR;
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
|
||||
{ TC0, 1, TC1_IRQn, 0}, // 1
|
||||
{ TC0, 2, TC2_IRQn, 0}, // 2
|
||||
{ TC1, 0, TC3_IRQn, 2}, // 3 - stepper
|
||||
{ TC0, 2, TC2_IRQn, 2}, // 2 - stepper
|
||||
{ TC1, 0, TC3_IRQn, 0}, // 3
|
||||
{ TC1, 1, TC4_IRQn, 15}, // 4 - temperature
|
||||
{ TC1, 2, TC5_IRQn, 3}, // 5 - [servo timer3]
|
||||
{ TC2, 0, TC6_IRQn, 14}, // 6 - tone
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
|
||||
|
||||
#define STEP_TIMER_NUM 3 // index of timer to use for stepper
|
||||
#define STEP_TIMER_NUM 2 // index of timer to use for stepper
|
||||
#define TEMP_TIMER_NUM 4 // index of timer to use for temperature
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
|
||||
@@ -65,7 +65,7 @@ typedef uint32_t hal_timer_t;
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
|
||||
#define HAL_STEP_TIMER_ISR() void TC3_Handler()
|
||||
#define HAL_STEP_TIMER_ISR() void TC2_Handler()
|
||||
#define HAL_TEMP_TIMER_ISR() void TC4_Handler()
|
||||
#define HAL_TONE_TIMER_ISR() void TC6_Handler()
|
||||
|
||||
|
||||
@@ -50,3 +50,7 @@
|
||||
#error "DUE software SPI is required but is incompatible with TMC2130 hardware SPI. Enable TMC_USE_SW_SPI to fix."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -177,11 +177,11 @@
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
// Check if pin is an input
|
||||
#define GET_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
|
||||
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
|
||||
// Check if pin is an output
|
||||
#define GET_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
|
||||
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
|
||||
// Check if pin is a timer - Must be a constexpr
|
||||
#define GET_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
||||
#define HAS_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
||||
|
||||
// Shorthand
|
||||
#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#if DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#if DISABLED(I2C_EEPROM, SPI_EEPROM)
|
||||
#define E2END 0xFFF // Default to Flash emulated EEPROM size (EepromEmulation_Due.cpp)
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ extern void eeprom_flush(void);
|
||||
bool PersistentStore::access_start() { return true; }
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
#if DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#if DISABLED(I2C_EEPROM, SPI_EEPROM)
|
||||
eeprom_flush();
|
||||
#endif
|
||||
return true;
|
||||
|
||||
@@ -99,7 +99,7 @@ static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
|
||||
spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
|
||||
DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
|
||||
}
|
||||
spiSend_sw_DUE(val & 0x0F0);
|
||||
spiSend_sw_DUE(val & 0xF0);
|
||||
spiSend_sw_DUE(val << 4);
|
||||
}
|
||||
|
||||
@@ -168,6 +168,42 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#if ENABLED(LIGHTWEIGHT_UI)
|
||||
#include "../../lcd/ultralcd.h"
|
||||
#include "../shared/HAL_ST7920.h"
|
||||
|
||||
#define ST7920_CS_PIN LCD_PINS_RS
|
||||
|
||||
#if DOGM_SPI_DELAY_US > 0
|
||||
#define U8G_DELAY() DELAY_US(DOGM_SPI_DELAY_US)
|
||||
#else
|
||||
#define U8G_DELAY() DELAY_US(10)
|
||||
#endif
|
||||
|
||||
void ST7920_cs() {
|
||||
WRITE(ST7920_CS_PIN, HIGH);
|
||||
U8G_DELAY();
|
||||
}
|
||||
|
||||
void ST7920_ncs() {
|
||||
WRITE(ST7920_CS_PIN, LOW);
|
||||
}
|
||||
|
||||
void ST7920_set_cmd() {
|
||||
spiSend_sw_DUE(0xF8);
|
||||
DELAY_US(40);
|
||||
}
|
||||
|
||||
void ST7920_set_dat() {
|
||||
spiSend_sw_DUE(0xFA);
|
||||
DELAY_US(40);
|
||||
}
|
||||
|
||||
void ST7920_write_byte(const uint8_t val) {
|
||||
spiSend_sw_DUE(val & 0xF0);
|
||||
spiSend_sw_DUE(val << 4);
|
||||
}
|
||||
#endif // LIGHTWEIGHT_UI
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "FlushableHardwareSerial.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
FlushableHardwareSerial::FlushableHardwareSerial(int uart_nr)
|
||||
: HardwareSerial(uart_nr)
|
||||
{}
|
||||
|
||||
FlushableHardwareSerial flushableSerial(0);
|
||||
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
class FlushableHardwareSerial : public HardwareSerial {
|
||||
public:
|
||||
FlushableHardwareSerial(int uart_nr);
|
||||
|
||||
inline void flushTX(void) { /* No need to flush the hardware serial, but defined here for compatibility. */ }
|
||||
};
|
||||
|
||||
extern FlushableHardwareSerial flushableSerial;
|
||||
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
@@ -41,7 +41,10 @@
|
||||
#endif
|
||||
#if ENABLED(WEBSUPPORT)
|
||||
#include "web.h"
|
||||
#include "spiffs.h"
|
||||
#endif
|
||||
#elif ENABLED(EEPROM_SETTINGS)
|
||||
#include "spiffs.h"
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -95,9 +98,12 @@ void HAL_init(void) {
|
||||
OTA_init();
|
||||
#endif
|
||||
#if ENABLED(WEBSUPPORT)
|
||||
spiffs_init();
|
||||
web_init();
|
||||
#endif
|
||||
server.begin();
|
||||
#elif ENABLED(EEPROM_SETTINGS)
|
||||
spiffs_init();
|
||||
#endif
|
||||
|
||||
i2s_init();
|
||||
@@ -111,7 +117,7 @@ void HAL_idletask(void) {
|
||||
|
||||
void HAL_clear_reset_source(void) { }
|
||||
|
||||
uint8_t HAL_get_reset_source (void) {
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
return rtc_get_reset_reason(1);
|
||||
}
|
||||
|
||||
@@ -127,12 +133,16 @@ int freeMemory() {
|
||||
// --------------------------------------------------------------------------
|
||||
// ADC
|
||||
// --------------------------------------------------------------------------
|
||||
#define ADC1_CHANNEL(pin) ADC1_GPIO##pin_CHANNEL
|
||||
#define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL
|
||||
|
||||
adc1_channel_t get_channel(int pin) {
|
||||
switch (pin) {
|
||||
case 36: return ADC1_GPIO36_CHANNEL;
|
||||
case 39: return ADC1_GPIO39_CHANNEL;
|
||||
case 39: return ADC1_CHANNEL(39);
|
||||
case 36: return ADC1_CHANNEL(36);
|
||||
case 35: return ADC1_CHANNEL(35);
|
||||
case 34: return ADC1_CHANNEL(34);
|
||||
case 33: return ADC1_CHANNEL(33);
|
||||
case 32: return ADC1_CHANNEL(32);
|
||||
}
|
||||
|
||||
return ADC1_CHANNEL_MAX;
|
||||
@@ -141,14 +151,21 @@ adc1_channel_t get_channel(int pin) {
|
||||
void HAL_adc_init() {
|
||||
// Configure ADC
|
||||
adc1_config_width(ADC_WIDTH_12Bit);
|
||||
adc1_config_channel_atten(get_channel(36), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(39), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(36), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(35), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(34), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(33), ADC_ATTEN_11db);
|
||||
adc1_config_channel_atten(get_channel(32), ADC_ATTEN_11db);
|
||||
|
||||
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
|
||||
// That's why we're not setting it up here.
|
||||
|
||||
// Calculate ADC characteristics i.e. gain and offset factors
|
||||
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, V_REF, &characteristics);
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion (uint8_t adc_pin) {
|
||||
void HAL_adc_start_conversion(uint8_t adc_pin) {
|
||||
uint32_t mv;
|
||||
esp_adc_cal_get_voltage((adc_channel_t)get_channel(adc_pin), &characteristics, &mv);
|
||||
|
||||
|
||||
@@ -30,13 +30,18 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// these are going to be re-defined in Arduino.h
|
||||
#undef DISABLED
|
||||
#undef M_PI
|
||||
#undef _BV
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// revert back to the correct (old) definition
|
||||
#undef DISABLED
|
||||
#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
|
||||
#define DISABLED(V...) DO(DIS,&&,V)
|
||||
// re-define in case Arduino.h has been skipped due to earlier inclusion (i.e. in Marlin\src\HAL\HAL_ESP32\i2s.cpp)
|
||||
#define _BV(b) (1UL << (b))
|
||||
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
@@ -48,6 +53,7 @@
|
||||
#include "HAL_timers_ESP32.h"
|
||||
|
||||
#include "WebSocketSerial.h"
|
||||
#include "FlushableHardwareSerial.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Defines
|
||||
@@ -55,7 +61,7 @@
|
||||
|
||||
extern portMUX_TYPE spinlock;
|
||||
|
||||
#define MYSERIAL0 Serial
|
||||
#define MYSERIAL0 flushableSerial
|
||||
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
#define NUM_SERIAL 2
|
||||
@@ -96,7 +102,7 @@ extern uint16_t HAL_adc_result;
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
// reset reason
|
||||
uint8_t HAL_get_reset_source (void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
void _delay_ms(int delay);
|
||||
|
||||
@@ -119,7 +125,7 @@ void HAL_adc_init(void);
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion (uint8_t adc_pin);
|
||||
void HAL_adc_start_conversion(uint8_t adc_pin);
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
|
||||
@@ -44,6 +44,15 @@ static SPISettings spiConfig;
|
||||
// Public functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#if ENABLED(SOFTWARE_SPI)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Software SPI
|
||||
// --------------------------------------------------------------------------
|
||||
#error "Software SPI not supported for ESP32. Use Hardware SPI."
|
||||
|
||||
#else
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Hardware SPI
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -61,13 +70,14 @@ void spiInit(uint8_t spiRate) {
|
||||
uint32_t clock;
|
||||
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV2; break;
|
||||
case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4; break;
|
||||
case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8; break;
|
||||
case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
|
||||
case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
|
||||
case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
|
||||
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
|
||||
case SPI_FULL_SPEED: clock = 16000000; break;
|
||||
case SPI_HALF_SPEED: clock = 8000000; break;
|
||||
case SPI_QUARTER_SPEED: clock = 4000000; break;
|
||||
case SPI_EIGHTH_SPEED: clock = 2000000; break;
|
||||
case SPI_SIXTEENTH_SPEED: clock = 1000000; break;
|
||||
case SPI_SPEED_5: clock = 500000; break;
|
||||
case SPI_SPEED_6: clock = 250000; break;
|
||||
default: clock = 1000000; // Default from the SPI library
|
||||
}
|
||||
|
||||
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
||||
@@ -106,4 +116,6 @@ void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode)
|
||||
SPI.beginTransaction(spiConfig);
|
||||
}
|
||||
|
||||
#endif // !SOFTWARE_SPI
|
||||
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
|
||||
@@ -23,3 +23,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
@@ -21,213 +21,132 @@
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
|
||||
#include "WebSocketSerial.h"
|
||||
|
||||
extern WebSocketSerial webSocketSerial;
|
||||
|
||||
#include "wifi.h"
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
struct ring_buffer_r {
|
||||
unsigned char buffer[RX_BUFFER_SIZE];
|
||||
volatile ring_buffer_pos_t head, tail;
|
||||
};
|
||||
WebSocketSerial webSocketSerial;
|
||||
AsyncWebSocket ws("/ws"); // TODO Move inside the class.
|
||||
|
||||
struct ring_buffer_t {
|
||||
unsigned char buffer[256];
|
||||
volatile uint8_t head, tail;
|
||||
};
|
||||
// RingBuffer impl
|
||||
|
||||
ring_buffer_r rx_buffer = { { 0 }, 0, 0 };
|
||||
ring_buffer_t tx_buffer = { { 0 }, 0, 0 };
|
||||
#define NEXT_INDEX(I, SIZE) ((I + 1) & (ring_buffer_pos_t)(SIZE - 1))
|
||||
|
||||
static bool _written;
|
||||
RingBuffer::RingBuffer(ring_buffer_pos_t size)
|
||||
: data(new uint8_t[size]),
|
||||
read_index(0),
|
||||
write_index(0),
|
||||
size(size)
|
||||
{}
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
static EmergencyParser::State emergency_state; // = EP_RESET
|
||||
#endif
|
||||
RingBuffer::~RingBuffer() { delete[] data; }
|
||||
|
||||
AsyncWebSocket ws("/ws"); // access at ws://[esp ip]/ws
|
||||
ring_buffer_pos_t RingBuffer::write(const uint8_t c) {
|
||||
const ring_buffer_pos_t n = NEXT_INDEX(write_index, size);
|
||||
|
||||
FORCE_INLINE int next_rx_index(const int i) { return (ring_buffer_pos_t)(i + 1) & (ring_buffer_pos_t)(RX_BUFFER_SIZE - 1); }
|
||||
FORCE_INLINE int next_tx_index(const int i) { return (ring_buffer_pos_t)(i + 1) & (ring_buffer_pos_t)(TX_BUFFER_SIZE - 1); }
|
||||
|
||||
static void addToBuffer(uint8_t * const data, const size_t len) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
ring_buffer_pos_t h = rx_buffer.head;
|
||||
const ring_buffer_pos_t t = rx_buffer.tail, n = next_rx_index(h);
|
||||
|
||||
if (n != t) { rx_buffer.buffer[h] = data[i]; h = n; }
|
||||
|
||||
// TODO: buffer is full, handle?
|
||||
|
||||
rx_buffer.head = h;
|
||||
if (n != read_index) {
|
||||
this->data[write_index] = c;
|
||||
write_index = n;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO: buffer is full, handle?
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Handle WebSocket event
|
||||
static void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||
switch (type) {
|
||||
case WS_EVT_CONNECT: client->ping(); break; // client connected
|
||||
case WS_EVT_DISCONNECT: // client disconnected
|
||||
case WS_EVT_ERROR: // error was received from the other end
|
||||
case WS_EVT_PONG: break; // pong message was received (in response to a ping request maybe)
|
||||
case WS_EVT_DATA: { // data packet
|
||||
AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
||||
if (info->opcode == WS_TEXT || info->message_opcode == WS_TEXT)
|
||||
addToBuffer(data, len);
|
||||
}
|
||||
ring_buffer_pos_t RingBuffer::write(const uint8_t *buffer, ring_buffer_pos_t size) {
|
||||
ring_buffer_pos_t written = 0;
|
||||
for (ring_buffer_pos_t i = 0; i < size; i++) {
|
||||
written += write(buffer[i]);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
// Public Methods
|
||||
int RingBuffer::available(void) {
|
||||
return (size - read_index + write_index) & (size - 1);
|
||||
}
|
||||
|
||||
int RingBuffer::peek(void) {
|
||||
return available() ? data[read_index] : -1;
|
||||
}
|
||||
|
||||
int RingBuffer::read(void) {
|
||||
if (available()) {
|
||||
const int ret = data[read_index];
|
||||
read_index = NEXT_INDEX(read_index, size);
|
||||
return ret;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
|
||||
ring_buffer_pos_t len = available();
|
||||
|
||||
for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
|
||||
buffer[i] = data[read_index];
|
||||
read_index = NEXT_INDEX(read_index, size);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void RingBuffer::flush(void) { read_index = write_index; }
|
||||
|
||||
// WebSocketSerial impl
|
||||
WebSocketSerial::WebSocketSerial()
|
||||
: rx_buffer(RingBuffer(RX_BUFFER_SIZE)),
|
||||
tx_buffer(RingBuffer(TX_BUFFER_SIZE))
|
||||
{}
|
||||
|
||||
void WebSocketSerial::begin(const long baud_setting) {
|
||||
ws.onEvent(onEvent);
|
||||
server.addHandler(&ws); // attach AsyncWebSocket
|
||||
ws.onEvent([this](AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) {
|
||||
switch (type) {
|
||||
case WS_EVT_CONNECT: client->ping(); break; // client connected
|
||||
case WS_EVT_DISCONNECT: // client disconnected
|
||||
case WS_EVT_ERROR: // error was received from the other end
|
||||
case WS_EVT_PONG: break; // pong message was received (in response to a ping request maybe)
|
||||
case WS_EVT_DATA: { // data packet
|
||||
AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
||||
if (info->opcode == WS_TEXT || info->message_opcode == WS_TEXT)
|
||||
this->rx_buffer.write(data, len);
|
||||
}
|
||||
}
|
||||
});
|
||||
server.addHandler(&ws);
|
||||
}
|
||||
|
||||
void WebSocketSerial::end() { }
|
||||
int WebSocketSerial::peek(void) { return rx_buffer.peek(); }
|
||||
int WebSocketSerial::read(void) { return rx_buffer.read(); }
|
||||
int WebSocketSerial::available(void) { return rx_buffer.available(); }
|
||||
void WebSocketSerial::flush(void) { rx_buffer.flush(); }
|
||||
|
||||
int WebSocketSerial::peek(void) {
|
||||
const int v = rx_buffer.head == rx_buffer.tail ? -1 : rx_buffer.buffer[rx_buffer.tail];
|
||||
return v;
|
||||
}
|
||||
size_t WebSocketSerial::write(const uint8_t c) {
|
||||
size_t ret = tx_buffer.write(c);
|
||||
|
||||
int WebSocketSerial::read(void) {
|
||||
const ring_buffer_pos_t h = rx_buffer.head, t = rx_buffer.tail;
|
||||
if (h == t) return -1; // Nothing to read? Return now
|
||||
|
||||
const int v = rx_buffer.buffer[t];
|
||||
|
||||
rx_buffer.tail = (ring_buffer_pos_t)(t + 1) & (RX_BUFFER_SIZE - 1); // Advance tail
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
bool WebSocketSerial::available(void) {
|
||||
const ring_buffer_pos_t h = rx_buffer.head, t = rx_buffer.tail;
|
||||
return (ring_buffer_pos_t)(RX_BUFFER_SIZE + h - t) & (RX_BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
void WebSocketSerial::flush(void) {
|
||||
ws.textAll("flush");
|
||||
rx_buffer.tail = rx_buffer.head;
|
||||
}
|
||||
|
||||
#if TX_BUFFER_SIZE
|
||||
|
||||
void WebSocketSerial::write(const uint8_t c) {
|
||||
_written = true;
|
||||
|
||||
const uint8_t i = (tx_buffer.head + 1) & (TX_BUFFER_SIZE - 1);
|
||||
|
||||
// Store new char. head is always safe to move
|
||||
tx_buffer.buffer[tx_buffer.head] = c;
|
||||
tx_buffer.head = i;
|
||||
|
||||
if (c == '\n') {
|
||||
ws.textAll(tx_buffer.buffer, tx_buffer.head);
|
||||
tx_buffer.head = 0;
|
||||
}
|
||||
if (ret && c == '\n') {
|
||||
uint8_t tmp[TX_BUFFER_SIZE];
|
||||
ring_buffer_pos_t size = tx_buffer.read(tmp);
|
||||
ws.textAll(tmp, size);
|
||||
}
|
||||
|
||||
void WebSocketSerial::flushTx(void) {
|
||||
ws.textAll("flushTx");
|
||||
if (!_written) return;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//void WebSocketSerial::write(const uint8_t c) { _written = true; }
|
||||
//void WebSocketSerial::flushTx(void) { if (!_written) return; }
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Imports from print.h
|
||||
*/
|
||||
|
||||
void WebSocketSerial::print(char c, int base) { print((long)c, base); }
|
||||
void WebSocketSerial::print(unsigned char b, int base) { print((unsigned long)b, base); }
|
||||
void WebSocketSerial::print(int n, int base) { print((long)n, base); }
|
||||
void WebSocketSerial::print(unsigned int n, int base) { print((unsigned long)n, base); }
|
||||
void WebSocketSerial::print(long n, int base) {
|
||||
if (base == 0)
|
||||
write(n);
|
||||
else if (base == 10) {
|
||||
if (n < 0) { print('-'); n = -n; }
|
||||
printNumber(n, 10);
|
||||
}
|
||||
else
|
||||
printNumber(n, base);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WebSocketSerial::print(unsigned long n, int base) {
|
||||
if (base == 0) write(n); else printNumber(n, base);
|
||||
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
|
||||
size_t written = 0;
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
written += write(buffer[i]);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
void WebSocketSerial::print(double n, int digits) { printFloat(n, digits); }
|
||||
|
||||
void WebSocketSerial::println(void) { print('\r'); print('\n'); }
|
||||
void WebSocketSerial::println(const String& s) { print(s); println(); }
|
||||
void WebSocketSerial::println(const char c[]) { print(c); println(); }
|
||||
void WebSocketSerial::println(char c, int base) { print(c, base); println(); }
|
||||
void WebSocketSerial::println(unsigned char b, int base) { print(b, base); println(); }
|
||||
void WebSocketSerial::println(int n, int base) { print(n, base); println(); }
|
||||
void WebSocketSerial::println(unsigned int n, int base) { print(n, base); println(); }
|
||||
void WebSocketSerial::println(long n, int base) { print(n, base); println(); }
|
||||
void WebSocketSerial::println(unsigned long n, int base) { print(n, base); println(); }
|
||||
void WebSocketSerial::println(double n, int digits) { print(n, digits); println(); }
|
||||
|
||||
// Private Methods
|
||||
|
||||
void WebSocketSerial::printNumber(unsigned long n, uint8_t base) {
|
||||
if (n) {
|
||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
||||
int8_t i = 0;
|
||||
while (n) {
|
||||
buf[i++] = n % base;
|
||||
n /= base;
|
||||
}
|
||||
while (i--)
|
||||
print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
|
||||
}
|
||||
else
|
||||
print('0');
|
||||
}
|
||||
|
||||
void WebSocketSerial::printFloat(double number, uint8_t digits) {
|
||||
// Handle negative numbers
|
||||
if (number < 0.0) { print('-'); number = -number; }
|
||||
|
||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||
// Use a lookup table for performance
|
||||
constexpr double rounds[] = { 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005 };
|
||||
number += rounds[digits];
|
||||
|
||||
//number += pow(10, -(digits + 1)); // slower single-line equivalent
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
print(int_part);
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
double remainder = number - (double)int_part;
|
||||
if (digits) {
|
||||
print('.');
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits--) {
|
||||
remainder *= 10.0;
|
||||
const int toPrint = int(remainder);
|
||||
print(toPrint);
|
||||
remainder -= toPrint;
|
||||
}
|
||||
}
|
||||
void WebSocketSerial::flushTX(void) {
|
||||
// No need to do anything as there's no benefit to sending partial lines over the websocket connection.
|
||||
}
|
||||
|
||||
#endif // WIFISUPPORT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
@@ -23,12 +23,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
#include "Stream.h"
|
||||
|
||||
#ifndef RX_BUFFER_SIZE
|
||||
#define RX_BUFFER_SIZE 128
|
||||
@@ -40,60 +35,50 @@
|
||||
#error "TX_BUFFER_SIZE is required for the WebSocket."
|
||||
#endif
|
||||
|
||||
#if RX_BUFFER_SIZE > 256
|
||||
typedef uint16_t ring_buffer_pos_t;
|
||||
#else
|
||||
typedef uint8_t ring_buffer_pos_t;
|
||||
#endif
|
||||
typedef uint16_t ring_buffer_pos_t;
|
||||
|
||||
class RingBuffer {
|
||||
uint8_t *data;
|
||||
ring_buffer_pos_t size, read_index, write_index;
|
||||
|
||||
class WebSocketSerial {
|
||||
public:
|
||||
WebSocketSerial() {};
|
||||
static void begin(const long);
|
||||
static void end();
|
||||
static int peek(void);
|
||||
static int read(void);
|
||||
static void flush(void);
|
||||
static void flushTx(void);
|
||||
static bool available(void);
|
||||
static void write(const uint8_t c);
|
||||
RingBuffer(ring_buffer_pos_t size);
|
||||
~RingBuffer();
|
||||
|
||||
int available(void);
|
||||
int peek(void);
|
||||
int read(void);
|
||||
ring_buffer_pos_t read(uint8_t *buffer);
|
||||
void flush(void);
|
||||
ring_buffer_pos_t write(const uint8_t c);
|
||||
ring_buffer_pos_t write(const uint8_t* buffer, ring_buffer_pos_t size);
|
||||
};
|
||||
|
||||
class WebSocketSerial: public Stream {
|
||||
RingBuffer rx_buffer;
|
||||
RingBuffer tx_buffer;
|
||||
|
||||
public:
|
||||
WebSocketSerial();
|
||||
void begin(const long);
|
||||
void end();
|
||||
int available(void);
|
||||
int peek(void);
|
||||
int read(void);
|
||||
void flush(void);
|
||||
void flushTX(void);
|
||||
size_t write(const uint8_t c);
|
||||
size_t write(const uint8_t* buffer, size_t size);
|
||||
|
||||
operator bool() { return true; }
|
||||
|
||||
#if ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||
FORCE_INLINE static uint32_t dropped() { return 0; }
|
||||
FORCE_INLINE uint32_t dropped() { return 0; }
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||
FORCE_INLINE static int rxMaxEnqueued() { return 0; }
|
||||
FORCE_INLINE int rxMaxEnqueued() { return 0; }
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
|
||||
FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
|
||||
FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
|
||||
FORCE_INLINE static void print(const char* str) { write(str); }
|
||||
|
||||
static void print(char, int = 0);
|
||||
static void print(unsigned char, int = 0);
|
||||
static void print(int, int = DEC);
|
||||
static void print(unsigned int, int = DEC);
|
||||
static void print(long, int = DEC);
|
||||
static void print(unsigned long, int = DEC);
|
||||
static void print(double, int = 2);
|
||||
|
||||
static void println(const String& s);
|
||||
static void println(const char[]);
|
||||
static void println(char, int = 0);
|
||||
static void println(unsigned char, int = 0);
|
||||
static void println(int, int = DEC);
|
||||
static void println(unsigned int, int = DEC);
|
||||
static void println(long, int = DEC);
|
||||
static void println(unsigned long, int = DEC);
|
||||
static void println(double, int = 2);
|
||||
static void println(void);
|
||||
operator bool() { return true; }
|
||||
|
||||
private:
|
||||
static void printNumber(unsigned long, const uint8_t);
|
||||
static void printFloat(double, uint8_t);
|
||||
};
|
||||
|
||||
extern WebSocketSerial webSocketSerial;
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
* Utility functions
|
||||
*/
|
||||
|
||||
// I2S expander pin mapping.
|
||||
#define IS_I2S_EXPANDER_PIN(IO) TEST(IO, 7)
|
||||
#define I2S_EXPANDER_PIN_INDEX(IO) (IO & 0x7F)
|
||||
|
||||
// Set pin as input
|
||||
#define _SET_INPUT(IO) pinMode(IO, INPUT)
|
||||
|
||||
@@ -37,10 +41,10 @@
|
||||
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
|
||||
|
||||
// Read a pin wrapper
|
||||
#define READ(IO) digitalRead(IO)
|
||||
#define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
|
||||
|
||||
// Write to a pin wrapper
|
||||
#define WRITE(IO, v) (TEST(IO, 7) ? i2s_write(IO & 0x7F, v) : digitalWrite(IO, v))
|
||||
#define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
|
||||
|
||||
// Set pin as input wrapper
|
||||
#define SET_INPUT(IO) _SET_INPUT(IO)
|
||||
@@ -61,8 +65,12 @@
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||
|
||||
#define PWM_PIN(P) true
|
||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||
// PWM outputs
|
||||
#define PWM_PIN(P) (P < 34) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
|
||||
#define USEABLE_HARDWARE_PWM(P) (!IS_I2S_EXPANDER_PIN(P) && PWM_PIN(P))
|
||||
|
||||
// Toggle pin value
|
||||
#define TOGGLE(IO) WRITE(IO, !READ(IO))
|
||||
|
||||
//
|
||||
// Ports and functions
|
||||
|
||||
@@ -21,7 +21,12 @@
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include <Arduino.h> // replace that with the proper imports
|
||||
// replace that with the proper imports, then cleanup workarounds in Marlin\src\HAL\HAL_ESP32\HAL.h
|
||||
#include <Arduino.h>
|
||||
// revert back to the correct definition
|
||||
#undef DISABLED
|
||||
#define DISABLED(V...) DO(DIS,&&,V)
|
||||
|
||||
#include "i2s.h"
|
||||
#include "../../core/macros.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
@@ -303,9 +308,9 @@ int i2s_init() {
|
||||
xTaskCreate(stepperTask, "StepperTask", 10000, NULL, 1, NULL);
|
||||
|
||||
// Route the i2s pins to the appropriate GPIO
|
||||
gpio_matrix_out_check(22, I2S0O_DATA_OUT23_IDX, 0, 0);
|
||||
gpio_matrix_out_check(25, I2S0O_WS_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out_check(26, I2S0O_BCK_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0);
|
||||
gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0);
|
||||
|
||||
// Start the I2S peripheral
|
||||
return i2s_start(I2S_NUM_0);
|
||||
@@ -315,6 +320,10 @@ void i2s_write(uint8_t pin, uint8_t val) {
|
||||
SET_BIT_TO(i2s_port_data, pin, val);
|
||||
}
|
||||
|
||||
uint8_t i2s_state(uint8_t pin) {
|
||||
return TEST(i2s_port_data, pin);
|
||||
}
|
||||
|
||||
void i2s_push_sample() {
|
||||
dma.current[dma.rw_pos++] = i2s_port_data;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ extern uint32_t i2s_port_data;
|
||||
|
||||
int i2s_init();
|
||||
|
||||
uint8_t i2s_state(uint8_t pin);
|
||||
|
||||
void i2s_write(uint8_t pin, uint8_t val);
|
||||
|
||||
void i2s_push_sample();
|
||||
|
||||
// pin definitions
|
||||
|
||||
#define I2S_WS 25
|
||||
#define I2S_BCK 26
|
||||
#define I2S_DATA 27
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#include "SPIFFS.h"
|
||||
#include "FS.h"
|
||||
#include "spiffs.h"
|
||||
|
||||
#define HAL_ESP32_EEPROM_SIZE 4096
|
||||
|
||||
File eeprom_file;
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
if (spiffs_initialized) {
|
||||
eeprom_file = SPIFFS.open("/eeprom.dat", "r+");
|
||||
|
||||
size_t file_size = eeprom_file.size();
|
||||
if (file_size < HAL_ESP32_EEPROM_SIZE) {
|
||||
bool write_ok = eeprom_file.seek(file_size);
|
||||
|
||||
while (write_ok && file_size < HAL_ESP32_EEPROM_SIZE) {
|
||||
write_ok = eeprom_file.write(0xFF) == 1;
|
||||
file_size++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
eeprom_file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
if (!eeprom_file.seek(pos)) return true; // return true for any error
|
||||
if (eeprom_file.write(value, size) != size) return true;
|
||||
|
||||
crc16(crc, value, size);
|
||||
pos += size;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
if (!eeprom_file.seek(pos)) return true; // return true for any error
|
||||
|
||||
if (writing) {
|
||||
if (eeprom_file.read(value, size) != size) return true;
|
||||
crc16(crc, value, size);
|
||||
}
|
||||
else {
|
||||
uint8_t tmp[size];
|
||||
if (eeprom_file.read(tmp, size) != size) return true;
|
||||
crc16(crc, tmp, size);
|
||||
}
|
||||
|
||||
pos += size;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t PersistentStore::capacity() { return HAL_ESP32_EEPROM_SIZE; }
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define SS_PIN 5
|
||||
#define SS_PIN SDSS
|
||||
#define SCK_PIN 18
|
||||
#define MISO_PIN 19
|
||||
#define MOSI_PIN 23
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if EITHER(WEBSUPPORT, EEPROM_SETTINGS)
|
||||
|
||||
#include "../../core/serial.h"
|
||||
|
||||
#include "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
|
||||
bool spiffs_initialized;
|
||||
|
||||
void spiffs_init() {
|
||||
if (SPIFFS.begin())
|
||||
spiffs_initialized = true;
|
||||
else
|
||||
SERIAL_ECHO_MSG("SPIFFS mount failed");
|
||||
}
|
||||
|
||||
#endif // WEBSUPPORT
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
extern bool spiffs_initialized;
|
||||
|
||||
void spiffs_init();
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
@@ -23,9 +26,6 @@
|
||||
|
||||
#if ENABLED(WEBSUPPORT)
|
||||
|
||||
#include "../../core/serial.h"
|
||||
|
||||
#include "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
#include "wifi.h"
|
||||
|
||||
@@ -37,12 +37,8 @@ void onNotFound(AsyncWebServerRequest *request){
|
||||
|
||||
void web_init() {
|
||||
server.addHandler(&events); // attach AsyncEventSource
|
||||
if (SPIFFS.begin()) {
|
||||
server.serveStatic("/", SPIFFS, "/www").setDefaultFile("index.html");
|
||||
server.onNotFound(onNotFound);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHO_MSG("SPIFFS Mount Failed");
|
||||
server.serveStatic("/", SPIFFS, "/www").setDefaultFile("index.html");
|
||||
server.onNotFound(onNotFound);
|
||||
}
|
||||
|
||||
#endif // WEBSUPPORT
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -65,3 +65,7 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif // SPINDLE_LASER_ENABLE
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -75,19 +75,19 @@
|
||||
// hg42: currently not used, but was used by pinsDebug
|
||||
|
||||
/// check if pin is an input
|
||||
#define _GET_INPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
#define _IS_INPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
|
||||
/// check if pin is an output
|
||||
#define _GET_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
#define _IS_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
|
||||
// hg42: GET_TIMER is used only to check if it's a PWM pin
|
||||
// hg42: HAS_TIMER is used only to check if it's a PWM pin
|
||||
// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
|
||||
// hg42: instead use PWM bit from the #define
|
||||
|
||||
/// check if pin is a timer
|
||||
#define _GET_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
|
||||
#define _HAS_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
|
||||
// hg42: could be this:
|
||||
// #define _GET_TIMER(IO) LPC1768_PIN_PWM(IO)
|
||||
// #define _HAS_TIMER(IO) LPC1768_PIN_PWM(IO)
|
||||
// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
|
||||
|
||||
/// Read a pin wrapper
|
||||
@@ -112,12 +112,12 @@
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
/// check if pin is an input wrapper
|
||||
#define GET_INPUT(IO) _GET_INPUT(IO)
|
||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||
/// check if pin is an output wrapper
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||
|
||||
/// check if pin is a timer (wrapper)
|
||||
#define GET_TIMER(IO) _GET_TIMER(IO)
|
||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
||||
|
||||
// Shorthand
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "src/core/macros.h"
|
||||
|
||||
#if ENABLED(SDSUPPORT) && ENABLED(DOGLCD) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#if BOTH(SDSUPPORT, DOGLCD) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
||||
// needed due to the speed and mode requred for communicating with each device being different.
|
||||
// This requirement can be removed if the SPI access to these devices is updated to use
|
||||
|
||||
@@ -52,11 +52,13 @@ int freeMemory() {
|
||||
return result;
|
||||
}
|
||||
|
||||
// scan command line for code
|
||||
// return index into pin map array if found and the pin is valid.
|
||||
// return dval if not found or not a valid pin.
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||
const uint16_t val = (uint16_t)parser.intval(code), port = val / 100, pin = val % 100;
|
||||
const int16_t ind = (port < (NUM_DIGITAL_PINS >> 5) && (pin < 32))
|
||||
? GET_PIN_MAP_INDEX(port << 5 | pin) : -2;
|
||||
return ind > -2 ? ind : dval;
|
||||
const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
|
||||
const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? GET_PIN_MAP_INDEX((port << 5) | pin) : -2;
|
||||
return ind > -1 ? ind : dval;
|
||||
}
|
||||
|
||||
void flashFirmware(int16_t value) {
|
||||
|
||||
@@ -147,6 +147,9 @@ using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
|
||||
#define HAL_READ_ADC() FilteredADC::get_result()
|
||||
#define HAL_ADC_READY() FilteredADC::finished_conversion()
|
||||
|
||||
// A grace period for the ADC readings to stabilize before they start causing thermal protection errors.
|
||||
#define THERMAL_PROTECTION_GRACE_PERIOD 500
|
||||
|
||||
// Parse a G-code word into a pin index
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||
// P0.6 thru P0.9 are for the onboard SD card
|
||||
@@ -157,3 +160,19 @@ void HAL_idletask(void);
|
||||
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
void flashFirmware(int16_t value);
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Set the frequency of the timer corresponding to the provided pin
|
||||
* All Hardware PWM pins run at the same frequency and all
|
||||
* Software PWM pins run at the same frequency
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired);
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -66,12 +66,7 @@
|
||||
#endif
|
||||
#endif // SPINDLE_LASER_ENABLE
|
||||
|
||||
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI) \
|
||||
&& (MB(RAMPS_14_RE_ARM_EFB) \
|
||||
|| MB(RAMPS_14_RE_ARM_EEB) \
|
||||
|| MB(RAMPS_14_RE_ARM_EFF) \
|
||||
|| MB(RAMPS_14_RE_ARM_EEF) \
|
||||
|| MB(RAMPS_14_RE_ARM_SF))
|
||||
#if IS_RE_ARM_BOARD && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
|
||||
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
|
||||
#include <pwm.h>
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
pwm_set_frequency(pin, f_desired);
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
|
||||
}
|
||||
|
||||
#endif // FAST_PWM_FAN
|
||||
#endif // TARGET_LPC1768
|
||||
@@ -84,14 +84,14 @@
|
||||
#define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
|
||||
|
||||
/// check if pin is an input
|
||||
#define _GET_INPUT(IO) (!gpio_get_dir(IO))
|
||||
#define _IS_INPUT(IO) (!gpio_get_dir(IO))
|
||||
|
||||
/// check if pin is an output
|
||||
#define _GET_OUTPUT(IO) (gpio_get_dir(IO))
|
||||
#define _IS_OUTPUT(IO) (gpio_get_dir(IO))
|
||||
|
||||
/// check if pin is a timer
|
||||
/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
|
||||
#define _GET_TIMER(IO) true
|
||||
#define _HAS_TIMER(IO) true
|
||||
|
||||
/// Read a pin wrapper
|
||||
#define READ(IO) _READ(IO)
|
||||
@@ -115,12 +115,12 @@
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
/// check if pin is an input wrapper
|
||||
#define GET_INPUT(IO) _GET_INPUT(IO)
|
||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||
/// check if pin is an output wrapper
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||
|
||||
/// check if pin is a timer (wrapper)
|
||||
#define GET_TIMER(IO) _GET_TIMER(IO)
|
||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
||||
|
||||
// Shorthand
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include <usb/usb.h>
|
||||
@@ -98,7 +119,7 @@ void HAL_init() {
|
||||
|
||||
// HAL idle task
|
||||
void HAL_idletask(void) {
|
||||
#if ENABLED(SDSUPPORT) && ENABLED(SHARED_SD_CARD)
|
||||
#if BOTH(SDSUPPORT, SHARED_SD_CARD)
|
||||
// If Marlin is using the SD card we need to lock it to prevent access from
|
||||
// a PC via USB.
|
||||
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
|
||||
|
||||
@@ -74,7 +74,8 @@ bool PersistentStore::access_start() {
|
||||
// sector is blank so nothing stored yet
|
||||
for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE;
|
||||
current_slot = EEPROM_SLOTS;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// current slot is the first non blank one
|
||||
current_slot = first_nblank_loc / EEPROM_SIZE;
|
||||
uint8_t *eeprom_data = SLOT_ADDRESS(EEPROM_SECTOR, current_slot);
|
||||
|
||||
@@ -40,6 +40,12 @@
|
||||
#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
|
||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||
|
||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||
// uses pin index
|
||||
#ifndef M43_NEVER_TOUCH
|
||||
#define M43_NEVER_TOUCH(Q) ((Q) == 29 || (Q) == 30 || (Q) == 73) // USB pins
|
||||
#endif
|
||||
|
||||
// active ADC function/mode/code values for PINSEL registers
|
||||
constexpr int8_t ADC_pin_mode(pin_t pin) {
|
||||
return (LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 2 ? 2 :
|
||||
|
||||
@@ -137,8 +137,11 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
//if (u8g_com_arduino_ssd_start_sequence(u8g) == 0)
|
||||
// return u8g_i2c_stop(), 0;
|
||||
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0) {
|
||||
u8g_i2c_stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (u8g_i2c_send_byte(arg_val) == 0) {
|
||||
u8g_i2c_stop();
|
||||
return 0;
|
||||
@@ -186,9 +189,6 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
|
||||
|
||||
u8g_i2c_start(0); // send slave address and write bit
|
||||
u8g_i2c_send_byte(arg_val ? 0x40 : 0x80); // Write to ? Graphics DRAM mode : Command mode
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
||||
@@ -65,10 +65,76 @@
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 2 // About 2 MHz
|
||||
|
||||
#include <algorithm>
|
||||
#include <LPC17xx.h>
|
||||
#include <gpio.h>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
if (spi_speed == 0) {
|
||||
gpio_set(mosi_pin, !!(b & 0x80));
|
||||
gpio_set(sck_pin, HIGH);
|
||||
b <<= 1;
|
||||
if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
|
||||
gpio_set(sck_pin, LOW);
|
||||
}
|
||||
else {
|
||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||
for (uint8_t j = 0; j < spi_speed; j++)
|
||||
gpio_set(mosi_pin, state);
|
||||
|
||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
||||
gpio_set(sck_pin, HIGH);
|
||||
|
||||
b <<= 1;
|
||||
if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
|
||||
|
||||
for (uint8_t j = 0; j < spi_speed; j++)
|
||||
gpio_set(sck_pin, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||
if (spi_speed == 0) {
|
||||
gpio_set(sck_pin, LOW);
|
||||
gpio_set(mosi_pin, state);
|
||||
gpio_set(mosi_pin, state); // need some setup time
|
||||
gpio_set(sck_pin, HIGH);
|
||||
}
|
||||
else {
|
||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
||||
gpio_set(sck_pin, LOW);
|
||||
|
||||
for (uint8_t j = 0; j < spi_speed; j++)
|
||||
gpio_set(mosi_pin, state);
|
||||
|
||||
for (uint8_t j = 0; j < spi_speed; j++)
|
||||
gpio_set(sck_pin, HIGH);
|
||||
}
|
||||
b <<= 1;
|
||||
if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static uint8_t SPI_speed = 0;
|
||||
|
||||
static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
|
||||
swSpiTransfer(val, SPI_speed, clockPin, -1, dataPin);
|
||||
#if ENABLED(FYSETC_MINI_12864)
|
||||
swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
|
||||
#else
|
||||
swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
|
||||
@@ -74,8 +74,10 @@ void watchdog_reset() {
|
||||
|
||||
#else
|
||||
|
||||
void HAL_clear_reset_source(void) {}
|
||||
uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
void watchdog_init(void) {}
|
||||
void watchdog_reset(void) {}
|
||||
void HAL_clear_reset_source(void) {}
|
||||
uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
|
||||
#endif // USE_WATCHDOG
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@
|
||||
#if ENABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
#if STM32F7xx
|
||||
#include "stm32f7xx_ll_pwr.h"
|
||||
#elif STM32F4xx
|
||||
#include "stm32f4xx_ll_pwr.h"
|
||||
#else
|
||||
#error "EEPROM_EMULATED_WITH_SRAM is currently only supported for STM32F7xx"
|
||||
#error "EEPROM_EMULATED_WITH_SRAM is currently only supported for STM32F4xx and STM32F7xx"
|
||||
#endif
|
||||
#endif // EEPROM_EMULATED_WITH_SRAM
|
||||
|
||||
@@ -118,7 +120,7 @@ void HAL_init(void) {
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source (void) {
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
|
||||
|
||||
@@ -165,7 +165,7 @@ void HAL_init(void);
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
/** reset reason */
|
||||
uint8_t HAL_get_reset_source (void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
* Test Re-ARM specific configuration values for errors at compile-time.
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -69,3 +69,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -78,11 +78,11 @@ void FastIO_init(); // Must be called before using fast io macros
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
#define SET_PWM(IO) _SET_MODE(IO, PWM)
|
||||
|
||||
#define GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO)
|
||||
#define GET_TIMER(IO)
|
||||
#define IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO)
|
||||
#define HAS_TIMER(IO) digitalPinHasPWM(IO)
|
||||
|
||||
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||
#define PWM_PIN(P) HAS_TIMER(P)
|
||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
|
||||
@@ -28,20 +28,20 @@
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM) && DISABLED(SPI_EEPROM) && DISABLED(I2C_EEPROM)
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
#include <EEPROM.h>
|
||||
static bool eeprom_data_written = false;
|
||||
#endif
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM) && DISABLED(SPI_EEPROM) && DISABLED(I2C_EEPROM)
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_buffer_fill();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM) && DISABLED(SPI_EEPROM) && DISABLED(I2C_EEPROM)
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
if (eeprom_data_written) {
|
||||
eeprom_buffer_flush();
|
||||
eeprom_data_written = false;
|
||||
@@ -55,7 +55,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
uint8_t v = *value;
|
||||
|
||||
// Save to either external EEPROM, program flash or Backup SRAM
|
||||
#if ENABLED(SPI_EEPROM) || ENABLED(I2C_EEPROM)
|
||||
#if EITHER(SPI_EEPROM, I2C_EEPROM)
|
||||
// EEPROM has only ~100,000 write cycles,
|
||||
// so only write bytes that have changed!
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
@@ -76,7 +76,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
pos++;
|
||||
value++;
|
||||
};
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM) && DISABLED(SPI_EEPROM) && DISABLED(I2C_EEPROM)
|
||||
#if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_data_written = true;
|
||||
#endif
|
||||
|
||||
@@ -87,7 +87,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
do {
|
||||
// Read from either external EEPROM, program flash or Backup SRAM
|
||||
const uint8_t c = (
|
||||
#if ENABLED(SPI_EEPROM) || ENABLED(I2C_EEPROM)
|
||||
#if EITHER(SPI_EEPROM, I2C_EEPROM)
|
||||
eeprom_read_byte((uint8_t*)pos)
|
||||
#elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
eeprom_buffered_read_byte(pos)
|
||||
@@ -105,7 +105,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
}
|
||||
|
||||
size_t PersistentStore::capacity() {
|
||||
#if ENABLED(SPI_EEPROM) || ENABLED(I2C_EEPROM)
|
||||
#if EITHER(SPI_EEPROM, I2C_EEPROM)
|
||||
return E2END + 1;
|
||||
#elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
|
||||
return E2END + 1;
|
||||
|
||||
@@ -130,6 +130,10 @@ void HAL_init();
|
||||
#define analogInputToDigitalPin(p) (p)
|
||||
#endif
|
||||
|
||||
#ifndef digitalPinHasPWM
|
||||
#define digitalPinHasPWM(P) (PIN_MAP[P].timer_device != NULL)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START uint32_t primask = __get_primask(); (void)__iCliRetVal()
|
||||
#define CRITICAL_SECTION_END if (!primask) (void)__iSeiRetVal()
|
||||
#define ISRS_ENABLED() (!__get_primask())
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__STM32F1__) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
|
||||
#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
|
||||
|
||||
#include "HAL_sdio_STM32F1.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ bool SDIO_Init(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
|
||||
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
|
||||
if (blockAddress >= SdCard.LogBlockNbr) return false;
|
||||
if ((0x03 & (uint32_t)data)) return false; // misaligned data
|
||||
@@ -100,6 +100,12 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
|
||||
dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL);
|
||||
|
||||
if (SDIO->STA & SDIO_STA_RXDAVL) {
|
||||
while (SDIO->STA & SDIO_STA_RXDAVL) (void) SDIO->FIFO;
|
||||
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SDIO_GET_FLAG(SDIO_STA_TRX_ERROR_FLAGS)) {
|
||||
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
|
||||
return false;
|
||||
@@ -108,6 +114,12 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
uint32_t retries = 3;
|
||||
while (retries--) if (SDIO_ReadBlock_DMA(blockAddress, data)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
|
||||
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
|
||||
if (blockAddress >= SdCard.LogBlockNbr) return false;
|
||||
@@ -264,4 +276,4 @@ bool SDIO_GetCmdResp7(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // __STM32F1__ && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
|
||||
#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
* Test Re-ARM specific configuration values for errors at compile-time.
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -74,3 +74,7 @@
|
||||
#if ENABLED(SDIO_SUPPORT) && DISABLED(SDSUPPORT)
|
||||
#error "SDIO_SUPPORT requires SDSUPPORT. Enable SDSUPPORT to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -45,11 +45,11 @@
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
#define SET_PWM(IO) pinMode(IO, PWM) // do{ gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP); timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, TIMER_PWM); }while(0)
|
||||
|
||||
#define GET_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
||||
#define GET_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
|
||||
#define GET_TIMER(IO) (PIN_MAP[IO].timer_device != NULL)
|
||||
#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
||||
#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
|
||||
#define HAS_TIMER(IO) (PIN_MAP[IO].timer_device != NULL)
|
||||
|
||||
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||
#define PWM_PIN(P) HAS_TIMER(P)
|
||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
// This is for EEPROM emulation in flash
|
||||
#if ENABLED(EEPROM_SETTINGS) && ENABLED(FLASH_EEPROM_EMULATION)
|
||||
#if BOTH(EEPROM_SETTINGS, FLASH_EEPROM_EMULATION)
|
||||
|
||||
#include "../shared/persistent_store_api.h"
|
||||
|
||||
@@ -79,14 +79,15 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t si
|
||||
}
|
||||
|
||||
// Now, write any remaining single byte
|
||||
if (size & 1) {
|
||||
const uint16_t odd = size & 1;
|
||||
if (odd) {
|
||||
uint16_t temp = value[size - 1];
|
||||
status = FLASH_ProgramHalfWord(pageBase + pos + i, temp);
|
||||
if (status != FLASH_COMPLETE) return true;
|
||||
}
|
||||
|
||||
crc16(crc, value, size);
|
||||
pos += ((size + 1) & ~1);
|
||||
pos += size + odd;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
|
||||
if (writing) value[i] = c;
|
||||
crc16(crc, &c, 1);
|
||||
}
|
||||
pos += ((size + 1) & ~1);
|
||||
pos += ((size + 1) & ~1); // i.e., size+(size&1), round up odd values
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ bool PersistentStore::access_start() {
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
if (!card.isDetected()) return false;
|
||||
card.openFile(eeprom_filename, true);
|
||||
card.openFile(eeprom_filename, false);
|
||||
int16_t bytes_written = card.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
||||
card.closefile();
|
||||
return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* Communication interface for FSMC
|
||||
*/
|
||||
|
||||
#if (defined(STM32F1) || defined(STM32F1xx)) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
|
||||
#if defined(ARDUINO_ARCH_STM32F1) && (defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY))
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
@@ -267,4 +267,4 @@ uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
|
||||
|
||||
#endif // HAS_GRAPHICAL_LCD
|
||||
|
||||
#endif // (STM32F1 || STM32F1xx) && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
|
||||
#endif // ARDUINO_ARCH_STM32F1 && (STM32_HIGH_DENSITY || STM32_XL_DENSITY)
|
||||
|
||||
@@ -1,50 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file EEPROM/EEPROM_Emulation/inc/eeprom.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright � 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/******************************************************************************
|
||||
* @file eeprom_emul.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright � 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM, SPI_EEPROM)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Includes
|
||||
@@ -138,5 +138,5 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
|
||||
|
||||
}
|
||||
|
||||
#endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
|
||||
#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
|
||||
#endif // STM32GENERIC && STM32F4
|
||||
|
||||
@@ -79,7 +79,7 @@ void sei(void) { interrupts(); }
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source (void) {
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
|
||||
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
|
||||
|
||||
@@ -170,7 +170,7 @@ extern uint16_t HAL_adc_result;
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
/** reset reason */
|
||||
uint8_t HAL_get_reset_source (void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
* Test Re-ARM specific configuration values for errors at compile-time.
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -68,3 +68,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F4. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -48,11 +48,11 @@
|
||||
|
||||
#define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
|
||||
|
||||
#define GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO)
|
||||
#define GET_TIMER(IO)
|
||||
#define IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO)
|
||||
#define HAS_TIMER(IO) true
|
||||
|
||||
#define PWM_PIN(P) true
|
||||
#define PWM_PIN(P) HAS_TIMER(P)
|
||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
|
||||
@@ -1,50 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file EEPROM/EEPROM_Emulation/inc/eeprom.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/******************************************************************************
|
||||
* @file eeprom_emul.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.2.6
|
||||
* @date 04-November-2016
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -79,7 +79,7 @@ void sei(void) { interrupts(); }
|
||||
|
||||
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
uint8_t HAL_get_reset_source (void) {
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)
|
||||
return RST_WATCHDOG;
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ extern uint16_t HAL_adc_result;
|
||||
void HAL_clear_reset_source (void);
|
||||
|
||||
/** reset reason */
|
||||
uint8_t HAL_get_reset_source (void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
* Test Re-ARM specific configuration values for errors at compile-time.
|
||||
*/
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
|
||||
#if !PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENA_PIN."
|
||||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
|
||||
#error "SPINDLE_DIR_PIN not defined."
|
||||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
|
||||
@@ -70,3 +70,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F7. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -47,11 +47,11 @@
|
||||
|
||||
#define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
|
||||
|
||||
#define GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO)
|
||||
#define GET_TIMER(IO)
|
||||
#define IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO)
|
||||
#define HAS_TIMER(IO) true
|
||||
|
||||
#define PWM_PIN(P) true
|
||||
#define PWM_PIN(P) HAS_TIMER(P)
|
||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
|
||||
@@ -27,3 +27,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for Teensy 3.1/3.2. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _GET_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _GET_OUTPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _IS_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _IS_OUTPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
|
||||
#define READ(IO) _READ(IO)
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
#define GET_INPUT(IO) _GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "HAL_timers_Teensy.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <util/atomic.h>
|
||||
|
||||
#define ST7920_DELAY_1 DELAY_NS(600)
|
||||
#define ST7920_DELAY_2 DELAY_NS(750)
|
||||
@@ -58,9 +59,6 @@
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#undef MOTHERBOARD
|
||||
#define MOTHERBOARD BOARD_TEENSY35_36
|
||||
|
||||
#define IS_32BIT_TEENSY (defined(__MK64FX512__) || defined(__MK66FX1M0__))
|
||||
#define IS_TEENSY35 defined(__MK64FX512__)
|
||||
#define IS_TEENSY36 defined(__MK66FX1M0__)
|
||||
@@ -87,9 +85,9 @@ typedef int8_t pin_t;
|
||||
#define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_START uint32_t primask = __get_primask(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ISRS_ENABLED() (!__get_primask())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
|
||||
|
||||
@@ -27,3 +27,7 @@
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#error "EMERGENCY_PARSER is not yet implemented for Teensy 3.5/3.6. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not yet implemented for this platform."
|
||||
#endif
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _GET_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _GET_OUTPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _IS_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
#define _IS_OUTPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
|
||||
#define READ(IO) _READ(IO)
|
||||
|
||||
@@ -80,8 +80,8 @@
|
||||
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
||||
#define SET_PWM(IO) SET_OUTPUT(IO)
|
||||
|
||||
#define GET_INPUT(IO) _GET_INPUT(IO)
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
|
||||
@@ -19,22 +19,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* M49.cpp - Toggle the G26 debug flag
|
||||
* HAL/HAL_ST7920.h
|
||||
* For the HALs that provide direct access to the ST7920 display
|
||||
* (bypassing U8G), it will allow the LIGHTWEIGHT_UI to operate.
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(G26_MESH_VALIDATION)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
void GcodeSuite::M49() {
|
||||
g26_debug_flag ^= true;
|
||||
SERIAL_ECHOPGM("G26 Debug: ");
|
||||
serialprintPGM(g26_debug_flag ? PSTR("On\n") : PSTR("Off\n"));
|
||||
}
|
||||
|
||||
#endif // G26_MESH_VALIDATION
|
||||
#if HAS_GRAPHICAL_LCD && ENABLED(LIGHTWEIGHT_UI)
|
||||
void ST7920_cs();
|
||||
void ST7920_ncs();
|
||||
void ST7920_set_cmd();
|
||||
void ST7920_set_dat();
|
||||
void ST7920_write_byte(const uint8_t data);
|
||||
#endif
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) || ENABLED(SD_FIRMWARE_UPDATE)
|
||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
||||
|
||||
#include "persistent_store_api.h"
|
||||
PersistentStore persistentStore;
|
||||
|
||||
+24
-19
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
#include "core/utility.h"
|
||||
#include "lcd/ultralcd.h"
|
||||
#include "module/motion.h"
|
||||
#include "module/planner.h"
|
||||
@@ -84,6 +85,10 @@
|
||||
#include "feature/leds/leds.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
#include "feature/bltouch.h"
|
||||
#endif
|
||||
|
||||
#if HAS_SERVOS
|
||||
#include "module/servo.h"
|
||||
#endif
|
||||
@@ -128,7 +133,7 @@
|
||||
#include "feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#if BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#include "feature/pause.h"
|
||||
#endif
|
||||
|
||||
@@ -152,7 +157,7 @@
|
||||
#include "feature/fanmux.h"
|
||||
#endif
|
||||
|
||||
#if DO_SWITCH_EXTRUDER || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER) || ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
||||
#if DO_SWITCH_EXTRUDER || ANY(SWITCHING_NOZZLE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER)
|
||||
#include "module/tool_change.h"
|
||||
#endif
|
||||
|
||||
@@ -328,7 +333,7 @@ void disable_all_steppers() {
|
||||
ExtUI::onFilamentRunout(ExtUI::getActiveTool());
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT) || ENABLED(HOST_ACTION_COMMANDS)
|
||||
#if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
|
||||
const char tool = '0'
|
||||
#if NUM_RUNOUT_SENSORS > 1
|
||||
+ active_extruder
|
||||
@@ -443,7 +448,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
|
||||
}
|
||||
|
||||
// Prevent steppers timing-out in the middle of M600
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#if BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#define MOVE_AWAY_TEST !did_pause_print
|
||||
#else
|
||||
#define MOVE_AWAY_TEST true
|
||||
@@ -452,7 +457,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
|
||||
if (stepper_inactive_time) {
|
||||
static bool already_shutdown_steppers; // = false
|
||||
if (planner.has_blocks_queued())
|
||||
gcode.previous_move_ms = ms; // reset_stepper_timeout to keep steppers powered
|
||||
gcode.reset_stepper_timeout();
|
||||
else if (MOVE_AWAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
|
||||
if (!already_shutdown_steppers) {
|
||||
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this
|
||||
@@ -468,14 +473,11 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
|
||||
#if ENABLED(DISABLE_INACTIVE_E)
|
||||
disable_e_steppers();
|
||||
#endif
|
||||
#if HAS_LCD_MENU
|
||||
ui.status_screen();
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
if (ubl.lcd_map_control) {
|
||||
ubl.lcd_map_control = false;
|
||||
ui.defer_status_screen(false);
|
||||
}
|
||||
#endif
|
||||
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
if (ubl.lcd_map_control) {
|
||||
ubl.lcd_map_control = false;
|
||||
ui.defer_status_screen(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -612,7 +614,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
|
||||
}
|
||||
#endif // !SWITCHING_EXTRUDER
|
||||
|
||||
gcode.previous_move_ms = ms; // reset_stepper_timeout to keep steppers powered
|
||||
gcode.reset_stepper_timeout();
|
||||
}
|
||||
#endif // EXTRUDER_RUNOUT_PREVENT
|
||||
|
||||
@@ -718,7 +720,7 @@ void idle(
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRUSA_MMU2)
|
||||
mmu2.mmuLoop();
|
||||
mmu2.mmu_loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -970,7 +972,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(SPINDLE_LASER_ENABLE)
|
||||
OUT_WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT); // init spindle to off
|
||||
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ENABLE_INVERT); // init spindle to off
|
||||
#if SPINDLE_DIR_CHANGE
|
||||
OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // init rotation to clockwise (M3)
|
||||
#endif
|
||||
@@ -1000,7 +1002,7 @@ void setup() {
|
||||
dac_init();
|
||||
#endif
|
||||
|
||||
#if (ENABLED(Z_PROBE_SLED) || ENABLED(SOLENOID_PROBE)) && HAS_SOLENOID_1
|
||||
#if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
|
||||
OUT_WRITE(SOL1_PIN, LOW); // OFF
|
||||
#endif
|
||||
|
||||
@@ -1040,7 +1042,7 @@ void setup() {
|
||||
ui.init();
|
||||
ui.reset_status();
|
||||
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
#if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
|
||||
ui.show_bootscreen();
|
||||
#endif
|
||||
|
||||
@@ -1049,7 +1051,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
bltouch_init();
|
||||
bltouch.init();
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
@@ -1138,6 +1140,9 @@ void loop() {
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
card.removeJobRecoveryFile();
|
||||
#endif
|
||||
#ifdef EVENT_GCODE_SD_STOP
|
||||
enqueue_and_echo_commands_P(PSTR(EVENT_GCODE_SD_STOP));
|
||||
#endif
|
||||
}
|
||||
#endif // SDSUPPORT
|
||||
|
||||
|
||||
@@ -189,10 +189,12 @@
|
||||
#define BOARD_COHESION3D_REMIX 1755 // Cohesion3D ReMix
|
||||
#define BOARD_COHESION3D_MINI 1756 // Cohesion3D Mini
|
||||
#define BOARD_SMOOTHIEBOARD 1757 // Smoothieboard
|
||||
#define BOARD_AZTEEG_X5_MINI_WIFI 1758 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
|
||||
#define BOARD_AZTEEG_X5_MINI_WIFI 1758 // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
|
||||
#define BOARD_BIQU_SKR_V1_1 1759 // BIQU SKR_V1.1 (Power outputs: Hotend0,Hotend1, Fan, Bed)
|
||||
#define BOARD_BIQU_B300_V1_0 1760 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
|
||||
#define BOARD_BIGTREE_SKR_V1_3 1761 // BIGTREE SKR_V1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
|
||||
#define BOARD_AZTEEG_X5_MINI 1762 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
|
||||
#define BOARD_MKS_SGEN 1763 // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
|
||||
|
||||
//
|
||||
// SAM3X8E ARM Cortex M3
|
||||
@@ -253,6 +255,8 @@
|
||||
#define BOARD_STM32F4 1804 // STM32 STM32GENERIC based STM32F4 controller
|
||||
#define BOARD_ARMED 1807 // Arm'ed STM32F4 based controller
|
||||
#define BOARD_RUMBA32 1809 // RUMBA32 STM32F4 based controller
|
||||
#define BOARD_BLACK_STM32F407VE 1810 // BLACK_STM32F407VE
|
||||
#define BOARD_BLACK_STM32F407ZE 1811 // BLACK_STM32F407ZE
|
||||
#define BOARD_STEVAL 1866 // STEVAL-3DP001V1 3D PRINTER BOARD
|
||||
|
||||
//
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// Serial aliases for debugging.
|
||||
@@ -27,6 +26,7 @@
|
||||
// (or not) in a given .cpp file
|
||||
//
|
||||
|
||||
#undef DEBUG_PRINT_P
|
||||
#undef DEBUG_ECHO_START
|
||||
#undef DEBUG_ERROR_START
|
||||
#undef DEBUG_CHAR
|
||||
@@ -47,6 +47,7 @@
|
||||
#undef DEBUG_DELAY
|
||||
|
||||
#if DEBUG_OUT
|
||||
#define DEBUG_PRINT_P(P) serialprintPGM(P)
|
||||
#define DEBUG_ECHO_START SERIAL_ECHO_START
|
||||
#define DEBUG_ERROR_START SERIAL_ERROR_START
|
||||
#define DEBUG_CHAR SERIAL_CHAR
|
||||
@@ -66,6 +67,7 @@
|
||||
#define DEBUG_XYZ SERIAL_XYZ
|
||||
#define DEBUG_DELAY(ms) serial_delay(ms)
|
||||
#else
|
||||
#define DEBUG_PRINT_P(P) NOOP
|
||||
#define DEBUG_ECHO_START() NOOP
|
||||
#define DEBUG_ERROR_START() NOOP
|
||||
#define DEBUG_CHAR(...) NOOP
|
||||
|
||||
+39
-14
@@ -52,7 +52,7 @@
|
||||
#define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
|
||||
#define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
|
||||
#define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
|
||||
#define AXIS_DRIVER_TYPE_X2(T) ((ENABLED(X_DUAL_STEPPER_DRIVERS) || ENABLED(DUAL_X_CARRIAGE)) && _AXIS_DRIVER_TYPE(X2,T))
|
||||
#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
|
||||
#define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
|
||||
#define AXIS_DRIVER_TYPE_Z2(T) (Z_MULTI_STEPPER_DRIVERS && _AXIS_DRIVER_TYPE(Z2,T))
|
||||
#define AXIS_DRIVER_TYPE_Z3(T) (ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Z3,T))
|
||||
@@ -65,20 +65,45 @@
|
||||
|
||||
#define AXIS_DRIVER_TYPE(A,T) AXIS_DRIVER_TYPE_##A(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) || \
|
||||
AXIS_DRIVER_TYPE_Z(T) || AXIS_DRIVER_TYPE_Z2(T) || AXIS_DRIVER_TYPE_Z3(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) )
|
||||
#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_X2(T) \
|
||||
|| AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Y2(T) \
|
||||
|| AXIS_DRIVER_TYPE_Z(T) || AXIS_DRIVER_TYPE_Z2(T) || AXIS_DRIVER_TYPE_Z3(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) )
|
||||
|
||||
// Test for supported TMC drivers that require advanced configuration
|
||||
// Does not match standalone configurations
|
||||
#define HAS_TRINAMIC ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2660) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) )
|
||||
#define HAS_TRINAMIC ( HAS_DRIVER(TMC2130) \
|
||||
|| HAS_DRIVER(TMC2160) \
|
||||
|| HAS_DRIVER(TMC2208) \
|
||||
|| HAS_DRIVER(TMC2660) \
|
||||
|| HAS_DRIVER(TMC5130) \
|
||||
|| HAS_DRIVER(TMC5160) )
|
||||
|
||||
#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE_##A(TMC2130) || \
|
||||
AXIS_DRIVER_TYPE_##A(TMC2160) || \
|
||||
AXIS_DRIVER_TYPE_##A(TMC2208) || \
|
||||
AXIS_DRIVER_TYPE_##A(TMC2660) || \
|
||||
AXIS_DRIVER_TYPE_##A(TMC5130) || \
|
||||
AXIS_DRIVER_TYPE_##A(TMC5160))
|
||||
#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2208) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
// Test for a driver that uses SPI - this allows checking whether a _CS_ pin
|
||||
// is considered sensitive
|
||||
#define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_STALLGUARD(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_STEALTHCHOP(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2208) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
@@ -39,6 +39,12 @@ enum AxisEnum : unsigned char {
|
||||
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,
|
||||
ALL_AXES = 0xFE,
|
||||
NO_AXIS = 0xFF
|
||||
};
|
||||
|
||||
@@ -344,7 +344,6 @@
|
||||
#define MSG_LCD_N3 " 4"
|
||||
#define MSG_LCD_N4 " 5"
|
||||
#define MSG_LCD_N5 " 6"
|
||||
#define MSG_E0 "E0"
|
||||
#define MSG_E1 "E1"
|
||||
#define MSG_E2 "E2"
|
||||
#define MSG_E3 "E3"
|
||||
|
||||
+48
-17
@@ -133,8 +133,25 @@
|
||||
|
||||
#endif
|
||||
|
||||
// Macros to chain up to 12 conditions
|
||||
#define _DO_1(W,C,A) (_##W##_1(A))
|
||||
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
|
||||
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
|
||||
#define _DO_4(W,C,A,V...) (_##W##_1(A) C _DO_3(W,C,V))
|
||||
#define _DO_5(W,C,A,V...) (_##W##_1(A) C _DO_4(W,C,V))
|
||||
#define _DO_6(W,C,A,V...) (_##W##_1(A) C _DO_5(W,C,V))
|
||||
#define _DO_7(W,C,A,V...) (_##W##_1(A) C _DO_6(W,C,V))
|
||||
#define _DO_8(W,C,A,V...) (_##W##_1(A) C _DO_7(W,C,V))
|
||||
#define _DO_9(W,C,A,V...) (_##W##_1(A) C _DO_8(W,C,V))
|
||||
#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
|
||||
#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
|
||||
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
|
||||
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
|
||||
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
|
||||
#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V)
|
||||
|
||||
// Macros to support option testing
|
||||
#define _CAT(a, ...) a ## __VA_ARGS__
|
||||
#define _CAT(a,V...) a##V
|
||||
#define SWITCH_ENABLED_false 0
|
||||
#define SWITCH_ENABLED_true 1
|
||||
#define SWITCH_ENABLED_0 0
|
||||
@@ -142,16 +159,33 @@
|
||||
#define SWITCH_ENABLED_0x0 0
|
||||
#define SWITCH_ENABLED_0x1 1
|
||||
#define SWITCH_ENABLED_ 1
|
||||
#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
|
||||
#define DISABLED(b) !ENABLED(b)
|
||||
#define _ENA_1(O) _CAT(SWITCH_ENABLED_, O)
|
||||
#define _DIS_1(O) !_ENA_1(O)
|
||||
#define ENABLED(V...) DO(ENA,&&,V)
|
||||
#define DISABLED(V...) DO(DIS,&&,V)
|
||||
|
||||
#define WITHIN(V,L,H) ((V) >= (L) && (V) <= (H))
|
||||
#define NUMERIC(a) WITHIN(a, '0', '9')
|
||||
#define DECIMAL(a) (NUMERIC(a) || a == '.')
|
||||
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+')
|
||||
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
#define ZERO(a) memset(a,0,sizeof(a))
|
||||
#define ANY(V...) !DISABLED(V)
|
||||
#define NONE(V...) DISABLED(V)
|
||||
#define ALL(V...) ENABLED(V)
|
||||
#define BOTH(V1,V2) ALL(V1,V2)
|
||||
#define EITHER(V1,V2) ANY(V1,V2)
|
||||
|
||||
// Macros to support pins/buttons exist testing
|
||||
#define _PINEX_1(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
|
||||
#define PIN_EXISTS(V...) DO(PINEX,&&,V)
|
||||
#define ANY_PIN(V...) DO(PINEX,||,V)
|
||||
|
||||
#define _BTNEX_1(BN) (defined(BTN_##BN) && BTN_##BN >= 0)
|
||||
#define BUTTON_EXISTS(V...) DO(BTNEX,&&,V)
|
||||
#define ANY_BUTTON(V...) DO(BTNEX,||,V)
|
||||
|
||||
#define WITHIN(N,L,H) ((N) >= (L) && (N) <= (H))
|
||||
#define NUMERIC(a) WITHIN(a, '0', '9')
|
||||
#define DECIMAL(a) (NUMERIC(a) || a == '.')
|
||||
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+')
|
||||
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
#define ZERO(a) memset(a,0,sizeof(a))
|
||||
#define COPY(a,b) do{ \
|
||||
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
|
||||
memcpy(&a[0],&b[0],MIN(sizeof(a),sizeof(b))); \
|
||||
@@ -165,8 +199,8 @@
|
||||
#define ARRAY_2(v1, v2, ...) { v1, v2 }
|
||||
#define ARRAY_1(v1, ...) { v1 }
|
||||
|
||||
#define _ARRAY_N(N, ...) ARRAY_ ##N(__VA_ARGS__)
|
||||
#define ARRAY_N(N, ...) _ARRAY_N(N, __VA_ARGS__)
|
||||
#define _ARRAY_N(N,V...) ARRAY_##N(V)
|
||||
#define ARRAY_N(N,V...) _ARRAY_N(N,V)
|
||||
|
||||
// Macros for adding
|
||||
#define INC_0 1
|
||||
@@ -178,7 +212,7 @@
|
||||
#define INC_6 7
|
||||
#define INC_7 8
|
||||
#define INC_8 9
|
||||
#define INCREMENT_(n) INC_ ##n
|
||||
#define INCREMENT_(n) INC_##n
|
||||
#define INCREMENT(n) INCREMENT_(n)
|
||||
|
||||
// Macros for subtracting
|
||||
@@ -191,12 +225,9 @@
|
||||
#define DEC_7 6
|
||||
#define DEC_8 7
|
||||
#define DEC_9 8
|
||||
#define DECREMENT_(n) DEC_ ##n
|
||||
#define DECREMENT_(n) DEC_##n
|
||||
#define DECREMENT(n) DECREMENT_(n)
|
||||
|
||||
#define PIN_EXISTS(PN) (defined(PN ##_PIN) && PN ##_PIN >= 0)
|
||||
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
|
||||
|
||||
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
|
||||
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
|
||||
// Pass NUM_ARGS(__VA_ARGS__) to use the number of arguments
|
||||
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
|
||||
#define _NUM_ARGS(_0,_24_,_23,_22,_21,_20,_19,_18,_17,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,N,...) N
|
||||
#define NUM_ARGS(...) _NUM_ARGS(0, __VA_ARGS__ ,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
#define NUM_ARGS(V...) _NUM_ARGS(0,V,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
||||
+18
-17
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "serial.h"
|
||||
#include "language.h"
|
||||
#include "enum.h"
|
||||
|
||||
uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
|
||||
|
||||
@@ -49,8 +50,14 @@ void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P)
|
||||
|
||||
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
||||
|
||||
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=NULL*/) {
|
||||
if (pre) serialprintPGM(pre);
|
||||
serialprintPGM(onoff ? on : off);
|
||||
if (post) serialprintPGM(post);
|
||||
}
|
||||
void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(MSG_ON) : PSTR(MSG_OFF)); }
|
||||
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
|
||||
void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
|
||||
|
||||
void print_bin(const uint16_t val) {
|
||||
uint16_t mask = 0x8000;
|
||||
@@ -61,21 +68,15 @@ void print_bin(const uint16_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z) {
|
||||
serialprintPGM(prefix);
|
||||
SERIAL_CHAR('(');
|
||||
SERIAL_ECHO(x);
|
||||
SERIAL_ECHOPAIR(", ", y, ", ", z);
|
||||
SERIAL_CHAR(')');
|
||||
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
||||
#include "enum.h"
|
||||
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z) {
|
||||
serialprintPGM(prefix);
|
||||
SERIAL_CHAR('(');
|
||||
SERIAL_ECHO(x);
|
||||
SERIAL_ECHOPAIR(", ", y, ", ", z);
|
||||
SERIAL_CHAR(')');
|
||||
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]) {
|
||||
print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
|
||||
}
|
||||
|
||||
#endif
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]) {
|
||||
print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
|
||||
}
|
||||
|
||||
@@ -174,18 +174,15 @@ inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PG
|
||||
void serialprintPGM(PGM_P str);
|
||||
void serial_echo_start();
|
||||
void serial_error_start();
|
||||
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=NULL);
|
||||
void serialprint_onoff(const bool onoff);
|
||||
void serialprintln_onoff(const bool onoff);
|
||||
void serialprint_truefalse(const bool tf);
|
||||
void serial_spaces(uint8_t count);
|
||||
|
||||
void print_bin(const uint16_t val);
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
|
||||
#define SERIAL_XYZ(PREFIX,...) do { print_xyz(PSTR(PREFIX), NULL, __VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define SERIAL_POS(...) NOOP
|
||||
#define SERIAL_XYZ(...) NOOP
|
||||
#endif
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
|
||||
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
|
||||
#define SERIAL_XYZ(PREFIX,...) do { print_xyz(PSTR(PREFIX), NULL, __VA_ARGS__); } while(0)
|
||||
|
||||
@@ -35,7 +35,7 @@ void safe_delay(millis_t ms) {
|
||||
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
|
||||
}
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) || ENABLED(SD_FIRMWARE_UPDATE)
|
||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
||||
|
||||
void crc16(uint16_t *crc, const void * const data, uint16_t cnt) {
|
||||
uint8_t *ptr = (uint8_t *)data;
|
||||
@@ -48,7 +48,7 @@ void safe_delay(millis_t ms) {
|
||||
|
||||
#endif // EEPROM_SETTINGS || SD_FIRMWARE_UPDATE
|
||||
|
||||
#if ENABLED(ULTRA_LCD) || ENABLED(DEBUG_LEVELING_FEATURE) || ENABLED(EXTENSIBLE_UI)
|
||||
#if ANY(ULTRA_LCD, DEBUG_LEVELING_FEATURE, EXTENSIBLE_UI)
|
||||
|
||||
char conv[8] = { 0 };
|
||||
|
||||
@@ -57,6 +57,16 @@ void safe_delay(millis_t ms) {
|
||||
#define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
|
||||
#define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
|
||||
|
||||
// Convert a full-range unsigned 8bit int to a percentage
|
||||
char* ui8tostr4pct(const uint8_t i) {
|
||||
const uint8_t n = ui8_to_percent(i);
|
||||
conv[3] = RJDIGIT(n, 100);
|
||||
conv[4] = RJDIGIT(n, 10);
|
||||
conv[5] = DIGIMOD(n, 1);
|
||||
conv[6] = '%';
|
||||
return &conv[3];
|
||||
}
|
||||
|
||||
// Convert unsigned 8bit int to string 123 format
|
||||
char* ui8tostr3(const uint8_t i) {
|
||||
conv[4] = RJDIGIT(i, 100);
|
||||
@@ -204,6 +214,19 @@ void safe_delay(millis_t ms) {
|
||||
return &conv[1];
|
||||
}
|
||||
|
||||
// Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format
|
||||
char* ftostr54sign(const float &f, char plus/*=' '*/) {
|
||||
long i = (f * 100000 + (f < 0 ? -5: 5)) / 10;
|
||||
conv[0] = i ? MINUSOR(i, plus) : ' ';
|
||||
conv[1] = DIGIMOD(i, 10000);
|
||||
conv[2] = '.';
|
||||
conv[3] = DIGIMOD(i, 1000);
|
||||
conv[4] = DIGIMOD(i, 100);
|
||||
conv[5] = DIGIMOD(i, 10);
|
||||
conv[6] = DIGIMOD(i, 1);
|
||||
return &conv[0];
|
||||
}
|
||||
|
||||
// Convert unsigned float to rj string with 12345 format
|
||||
char* ftostr5rj(const float &f) {
|
||||
const long i = ((f < 0 ? -f : f) * 10 + 5) / 10;
|
||||
@@ -241,15 +264,15 @@ void safe_delay(millis_t ms) {
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert unsigned float to string with 1234.56 format omitting trailing zeros
|
||||
char* ftostr62rj(const float &f) {
|
||||
const long i = ((f < 0 ? -f : f) * 1000 + 5) / 10;
|
||||
conv[0] = RJDIGIT(i, 100000);
|
||||
// Convert unsigned float to string with 1234.5 format omitting trailing zeros
|
||||
char* ftostr51rj(const float &f) {
|
||||
const long i = ((f < 0 ? -f : f) * 100 + 5) / 10;
|
||||
conv[0] = ' ';
|
||||
conv[1] = RJDIGIT(i, 10000);
|
||||
conv[2] = RJDIGIT(i, 1000);
|
||||
conv[3] = DIGIMOD(i, 100);
|
||||
conv[4] = '.';
|
||||
conv[5] = DIGIMOD(i, 10);
|
||||
conv[3] = RJDIGIT(i, 100);
|
||||
conv[4] = DIGIMOD(i, 10);
|
||||
conv[5] = '.';
|
||||
conv[6] = DIGIMOD(i, 1);
|
||||
return conv;
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ inline void serial_delay(const millis_t ms) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) || ENABLED(SD_FIRMWARE_UPDATE)
|
||||
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
|
||||
void crc16(uint16_t *crc, const void * const data, uint16_t cnt);
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
||||
#if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
|
||||
/**
|
||||
* These support functions allow the use of large bit arrays of flags that take very
|
||||
* little RAM. Currently they are limited to being 16x16 in size. Changing the declaration
|
||||
@@ -53,7 +53,10 @@ inline void serial_delay(const millis_t ms) {
|
||||
FORCE_INLINE bool is_bitmap_set(uint16_t bits[16], const uint8_t x, const uint8_t y) { return TEST(bits[y], x); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(ULTRA_LCD) || ENABLED(DEBUG_LEVELING_FEATURE) || ENABLED(EXTENSIBLE_UI)
|
||||
#if ANY(ULTRA_LCD, DEBUG_LEVELING_FEATURE, EXTENSIBLE_UI)
|
||||
|
||||
// Convert a full-range unsigned 8bit int to a percentage
|
||||
char* ui8tostr4pct(const uint8_t i);
|
||||
|
||||
// Convert uint8_t to string with 123 format
|
||||
char* ui8tostr3(const uint8_t x);
|
||||
@@ -88,6 +91,9 @@ inline void serial_delay(const millis_t ms) {
|
||||
// Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
|
||||
char* ftostr43sign(const float &x, char plus=' ');
|
||||
|
||||
// Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format
|
||||
char* ftostr54sign(const float &x, char plus=' ');
|
||||
|
||||
// Convert unsigned float to rj string with 12345 format
|
||||
char* ftostr5rj(const float &x);
|
||||
|
||||
@@ -100,8 +106,8 @@ inline void serial_delay(const millis_t ms) {
|
||||
// Convert signed float to string with +123.45 format
|
||||
char* ftostr52sign(const float &x);
|
||||
|
||||
// Convert unsigned float to string with 1234.56 format omitting trailing zeros
|
||||
char* ftostr62rj(const float &x);
|
||||
// Convert unsigned float to string with 1234.5 format omitting trailing zeros
|
||||
char* ftostr51rj(const float &x);
|
||||
|
||||
// Convert float to rj string with 123 or -12 format
|
||||
FORCE_INLINE char* ftostr3(const float &x) { return i16tostr3(int16_t(x + (x < 0 ? -0.5f : 0.5f))); }
|
||||
@@ -135,3 +141,8 @@ public:
|
||||
|
||||
#define REMEMBER(N,X, ...) restorer<typeof(X)> restorer_##N(X, ##__VA_ARGS__)
|
||||
#define RESTORE(N) restorer_##N.restore()
|
||||
|
||||
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "../module/stepper.h"
|
||||
#include "../gcode/parser.h"
|
||||
|
||||
#include "../feature/babystep.h"
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) {
|
||||
@@ -169,7 +171,7 @@ void I2CPositionEncoder::update() {
|
||||
const int32_t errorP = int32_t(sumP * (1.0f / (I2CPE_ERR_PRST_ARRAY_SIZE)));
|
||||
SERIAL_ECHO(axis_codes[encoderAxis]);
|
||||
SERIAL_ECHOLNPAIR(" - err detected: ", errorP * planner.steps_to_mm[encoderAxis], "mm; correcting!");
|
||||
thermalManager.babystepsTodo[encoderAxis] = -LROUND(errorP);
|
||||
babystep.add_steps(encoderAxis, -LROUND(errorP));
|
||||
errPrstIdx = 0;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +182,7 @@ void I2CPositionEncoder::update() {
|
||||
if (ABS(error) > threshold * planner.settings.axis_steps_per_mm[encoderAxis]) {
|
||||
//SERIAL_ECHOLN(error);
|
||||
//SERIAL_ECHOLN(position);
|
||||
thermalManager.babystepsTodo[encoderAxis] = -LROUND(error / 2);
|
||||
babystep.add_steps(encoderAxis, -LROUND(error / 2));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -227,13 +229,11 @@ bool I2CPositionEncoder::passes_test(const bool report) {
|
||||
if (report) {
|
||||
if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
|
||||
SERIAL_ECHO(axis_codes[encoderAxis]);
|
||||
SERIAL_ECHOPGM(" axis ");
|
||||
serialprintPGM(H == I2CPE_MAG_SIG_BAD ? PSTR("magnetic strip ") : PSTR("encoder "));
|
||||
serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder "));
|
||||
switch (H) {
|
||||
case I2CPE_MAG_SIG_GOOD:
|
||||
case I2CPE_MAG_SIG_MID:
|
||||
SERIAL_ECHOLNPGM("passes test; field strength ");
|
||||
serialprintPGM(H == I2CPE_MAG_SIG_GOOD ? PSTR("good.\n") : PSTR("fair.\n"));
|
||||
serial_ternary(H == I2CPE_MAG_SIG_GOOD, PSTR("passes test; field strength "), PSTR("good"), PSTR("fair"), PSTR(".\n"));
|
||||
break;
|
||||
default:
|
||||
SERIAL_ECHOLNPGM("not detected!");
|
||||
|
||||
@@ -275,9 +275,8 @@ class I2CPositionEncodersMgr {
|
||||
static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
|
||||
CHECK_IDX();
|
||||
encoders[idx].set_ec_enabled(enabled);
|
||||
SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis], " axis is ");
|
||||
serialprintPGM(encoders[idx].get_ec_enabled() ? PSTR("en") : PSTR("dis"));
|
||||
SERIAL_ECHOLNPGM("abled.");
|
||||
SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis]);
|
||||
serial_ternary(encoders[idx].get_ec_enabled(), PSTR(" axis is "), PSTR("en"), PSTR("dis"), PSTR("abled.\n"));
|
||||
}
|
||||
|
||||
static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
|
||||
#include "babystep.h"
|
||||
#include "../Marlin.h"
|
||||
#include "../module/planner.h"
|
||||
#include "../module/stepper.h"
|
||||
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
#include "../gcode/gcode.h"
|
||||
#endif
|
||||
|
||||
Babystep babystep;
|
||||
|
||||
volatile int16_t Babystep::todo[BS_TODO_AXIS(Z_AXIS) + 1];
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
int16_t Babystep::accum;
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void Babystep::step_axis(const AxisEnum axis) {
|
||||
const int16_t curTodo = todo[BS_TODO_AXIS(axis)]; // get rid of volatile for performance
|
||||
if (curTodo) {
|
||||
stepper.babystep((AxisEnum)axis, curTodo > 0);
|
||||
if (curTodo > 0) todo[BS_TODO_AXIS(axis)]--; else todo[BS_TODO_AXIS(axis)]++;
|
||||
}
|
||||
}
|
||||
|
||||
void Babystep::task() {
|
||||
#if EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
|
||||
LOOP_XYZ(axis) step_axis((AxisEnum)axis);
|
||||
#else
|
||||
step_axis(Z_AXIS);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Babystep::add_mm(const AxisEnum axis, const float &mm) {
|
||||
add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]);
|
||||
}
|
||||
|
||||
void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
|
||||
|
||||
#if ENABLED(BABYSTEP_WITHOUT_HOMING)
|
||||
#define CAN_BABYSTEP(AXIS) true
|
||||
#else
|
||||
extern uint8_t axis_known_position;
|
||||
#define CAN_BABYSTEP(AXIS) TEST(axis_known_position, AXIS)
|
||||
#endif
|
||||
|
||||
if (!CAN_BABYSTEP(axis)) return;
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
accum += distance; // Count up babysteps for the UI
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
axis_total[BS_TOTAL_AXIS(axis)] += distance;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
#define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: enable_X(); break; case Y_AXIS: enable_Y(); break; case Z_AXIS: enable_Z(); } }while(0)
|
||||
#else
|
||||
#define BSA_ENABLE(AXIS) NOOP
|
||||
#endif
|
||||
|
||||
#if IS_CORE
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
switch (axis) {
|
||||
case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
|
||||
BSA_ENABLE(CORE_AXIS_1);
|
||||
BSA_ENABLE(CORE_AXIS_2);
|
||||
todo[CORE_AXIS_1] += distance * 2;
|
||||
todo[CORE_AXIS_2] += distance * 2;
|
||||
break;
|
||||
case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
|
||||
BSA_ENABLE(CORE_AXIS_1);
|
||||
BSA_ENABLE(CORE_AXIS_2);
|
||||
todo[CORE_AXIS_1] += CORESIGN(distance * 2);
|
||||
todo[CORE_AXIS_2] -= CORESIGN(distance * 2);
|
||||
break;
|
||||
case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
|
||||
default:
|
||||
BSA_ENABLE(NORMAL_AXIS);
|
||||
todo[NORMAL_AXIS] += distance;
|
||||
break;
|
||||
}
|
||||
#elif CORE_IS_XZ || CORE_IS_YZ
|
||||
// Only Z stepping needs to be handled here
|
||||
BSA_ENABLE(CORE_AXIS_1);
|
||||
BSA_ENABLE(CORE_AXIS_2);
|
||||
todo[CORE_AXIS_1] += CORESIGN(distance * 2);
|
||||
todo[CORE_AXIS_2] -= CORESIGN(distance * 2);
|
||||
#else
|
||||
BSA_ENABLE(Z_AXIS);
|
||||
todo[Z_AXIS] += distance;
|
||||
#endif
|
||||
#else
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
BSA_ENABLE(axis);
|
||||
#else
|
||||
BSA_ENABLE(Z_AXIS);
|
||||
#endif
|
||||
todo[BS_TODO_AXIS(axis)] += distance;
|
||||
#endif
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
gcode.reset_stepper_timeout();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // BABYSTEPPING
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
#include "../core/enum.h"
|
||||
|
||||
#if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
|
||||
#define BS_TODO_AXIS(A) A
|
||||
#else
|
||||
#define BS_TODO_AXIS(A) 0
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
#define BS_TOTAL_AXIS(A) A
|
||||
#else
|
||||
#define BS_TOTAL_AXIS(A) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class Babystep {
|
||||
public:
|
||||
static volatile int16_t todo[BS_TODO_AXIS(Z_AXIS) + 1];
|
||||
#if HAS_LCD_MENU
|
||||
static int16_t accum; // Total babysteps in current edit
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28
|
||||
static inline void reset_total(const AxisEnum axis) {
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
if (axis == Z_AXIS)
|
||||
#endif
|
||||
axis_total[BS_TOTAL_AXIS(axis)] = 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
static void add_steps(const AxisEnum axis, const int16_t distance);
|
||||
static void add_mm(const AxisEnum axis, const float &mm);
|
||||
static void task();
|
||||
private:
|
||||
static void step_axis(const AxisEnum axis);
|
||||
};
|
||||
|
||||
extern Babystep babystep;
|
||||
@@ -40,4 +40,6 @@ void refresh_bed_level();
|
||||
void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
|
||||
#endif
|
||||
|
||||
#define Z_VALUES(X,Y) z_values[X][Y]
|
||||
#define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS])
|
||||
#define _GET_MESH_Y(J) (bilinear_start[Y_AXIS] + (J) * bilinear_grid_spacing[Y_AXIS])
|
||||
#define Z_VALUES_ARR z_values
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "bedlevel.h"
|
||||
#include "../../module/planner.h"
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
|
||||
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
|
||||
#include "../../module/motion.h"
|
||||
#endif
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
#include "../../core/debug_out.h"
|
||||
|
||||
#if ENABLED(G26_MESH_VALIDATION)
|
||||
bool g26_debug_flag; // = false
|
||||
#endif
|
||||
|
||||
bool leveling_is_valid() {
|
||||
return
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
@@ -146,7 +142,7 @@ void reset_bed_level() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
|
||||
#if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING)
|
||||
|
||||
/**
|
||||
* Enable to produce output in JSON format suitable
|
||||
@@ -215,7 +211,7 @@ void reset_bed_level() {
|
||||
|
||||
#endif // AUTO_BED_LEVELING_BILINEAR || MESH_BED_LEVELING
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
|
||||
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
|
||||
|
||||
void _manual_goto_xy(const float &rx, const float &ry) {
|
||||
|
||||
|
||||
@@ -28,12 +28,6 @@ typedef struct {
|
||||
float distance; // When populated, the distance from the search location
|
||||
} mesh_index_pair;
|
||||
|
||||
#if ENABLED(G26_MESH_VALIDATION)
|
||||
extern bool g26_debug_flag;
|
||||
#else
|
||||
constexpr bool g26_debug_flag = false;
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
extern bool g29_in_progress;
|
||||
#else
|
||||
@@ -48,38 +42,35 @@ void reset_bed_level();
|
||||
void set_z_fade_height(const float zfh, const bool do_report=true);
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef float (*element_2d_fn)(const uint8_t, const uint8_t);
|
||||
|
||||
/**
|
||||
* Print calibration results for plotting or manual frame adjustment.
|
||||
*/
|
||||
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn);
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
|
||||
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
|
||||
void _manual_goto_xy(const float &x, const float &y);
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS])
|
||||
#define _GET_MESH_Y(J) (bilinear_start[Y_AXIS] + (J) * bilinear_grid_spacing[Y_AXIS])
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I)
|
||||
#define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J)
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
#define _GET_MESH_X(I) mbl.index_to_xpos[I]
|
||||
#define _GET_MESH_Y(J) mbl.index_to_ypos[J]
|
||||
#endif
|
||||
#if HAS_MESH
|
||||
|
||||
typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#include "abl/abl.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl/ubl.h"
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
#include "mbl/mesh_bed_leveling.h"
|
||||
#endif
|
||||
|
||||
#define Z_VALUES(X,Y) Z_VALUES_ARR[X][Y]
|
||||
|
||||
#if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef float (*element_2d_fn)(const uint8_t, const uint8_t);
|
||||
|
||||
/**
|
||||
* Print calibration results for plotting or manual frame adjustment.
|
||||
*/
|
||||
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn);
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
#include "mbl/mesh_bed_leveling.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl/ubl.h"
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#include "abl/abl.h"
|
||||
#endif
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
ZERO(z_values);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ enum MeshLevelingState : char {
|
||||
|
||||
#define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1))
|
||||
#define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_POINTS_Y - 1))
|
||||
#define _GET_MESH_X(I) mbl.index_to_xpos[I]
|
||||
#define _GET_MESH_Y(J) mbl.index_to_ypos[J]
|
||||
#define Z_VALUES_ARR mbl.z_values
|
||||
|
||||
class mesh_bed_leveling {
|
||||
public:
|
||||
@@ -118,5 +121,3 @@ public:
|
||||
};
|
||||
|
||||
extern mesh_bed_leveling mbl;
|
||||
|
||||
#define Z_VALUES(X,Y) mbl.z_values[X][Y]
|
||||
|
||||
@@ -58,54 +58,10 @@
|
||||
|
||||
void unified_bed_leveling::report_state() {
|
||||
echo_name();
|
||||
SERIAL_ECHOPGM(" System v" UBL_VERSION " ");
|
||||
if (!planner.leveling_active) SERIAL_ECHOPGM("in");
|
||||
SERIAL_ECHOLNPGM("active.");
|
||||
serial_ternary(planner.leveling_active, PSTR(" System v" UBL_VERSION " "), PSTR(""), PSTR("in"), PSTR("active\n"));
|
||||
serial_delay(50);
|
||||
}
|
||||
|
||||
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
||||
|
||||
static void debug_echo_axis(const AxisEnum axis) {
|
||||
if (current_position[axis] == destination[axis])
|
||||
SERIAL_ECHOPGM("-------------");
|
||||
else
|
||||
SERIAL_ECHO_F(destination[X_AXIS], 6);
|
||||
}
|
||||
|
||||
void debug_current_and_destination(PGM_P title) {
|
||||
|
||||
// if the title message starts with a '!' it is so important, we are going to
|
||||
// ignore the status of the g26_debug_flag
|
||||
if (*title != '!' && !g26_debug_flag) return;
|
||||
|
||||
const float de = destination[E_AXIS] - current_position[E_AXIS];
|
||||
|
||||
if (de == 0.0) return; // Printing moves only
|
||||
|
||||
const float dx = destination[X_AXIS] - current_position[X_AXIS],
|
||||
dy = destination[Y_AXIS] - current_position[Y_AXIS],
|
||||
xy_dist = HYPOT(dx, dy);
|
||||
|
||||
if (xy_dist == 0.0) return;
|
||||
|
||||
const float fpmm = de / xy_dist;
|
||||
SERIAL_ECHOPAIR_F(" fpmm=", fpmm, 6);
|
||||
SERIAL_ECHOPAIR_F(" current=( ", current_position[X_AXIS], 6);
|
||||
SERIAL_ECHOPAIR_F(", ", current_position[Y_AXIS], 6);
|
||||
SERIAL_ECHOPAIR_F(", ", current_position[Z_AXIS], 6);
|
||||
SERIAL_ECHOPAIR_F(", ", current_position[E_AXIS], 6);
|
||||
SERIAL_ECHOPGM(" ) destination=( "); debug_echo_axis(X_AXIS);
|
||||
SERIAL_ECHOPGM(", "); debug_echo_axis(Y_AXIS);
|
||||
SERIAL_ECHOPGM(", "); debug_echo_axis(Z_AXIS);
|
||||
SERIAL_ECHOPGM(", "); debug_echo_axis(E_AXIS);
|
||||
SERIAL_ECHOPGM(" ) ");
|
||||
serialprintPGM(title);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
#endif // UBL_DEVEL_DEBUGGING
|
||||
|
||||
int8_t unified_bed_leveling::storage_slot;
|
||||
|
||||
float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||
@@ -135,8 +91,8 @@
|
||||
ZERO(z_values);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
if (was_enabled) report_current_position();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user