Skip to content

Commit

Permalink
Merge bugfix-2.0.x changes & revert original TFT upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
petrzmax committed Jan 20, 2020
2 parents d2aea39 + 97b5a5f commit 644bfb2
Show file tree
Hide file tree
Showing 726 changed files with 13,114 additions and 695,415 deletions.
4 changes: 3 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
custom: http://www.thinkyhead.com/donate-to-marlin
github: [thinkyhead]
patreon: thinkyhead
custom: ["http://www.thinkyhead.com/donate-to-marlin"]
25 changes: 0 additions & 25 deletions .github/workflows/bump-date.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- BIGTREE_SKR_PRO
- mks_robin
- ARMED
- FYSETC_S6

# Put lengthy tests last

Expand Down Expand Up @@ -94,6 +95,8 @@ jobs:

- name: Run ${{ matrix.test-platform }} Tests
run: |
# Inline tests script
[[ "$GITHUB_REPOSITORY" == "MarlinFirmware/Marlin" ]] || exit 0
chmod +x buildroot/bin/*
chmod +x buildroot/share/tests/*
export PATH=./buildroot/bin/:./buildroot/share/tests/:${PATH}
Expand Down
31 changes: 22 additions & 9 deletions Marlin/src/HAL/HAL_AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,37 @@ typedef int8_t pin_t;
#define NUM_SERIAL 1
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3"
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif

#define MYSERIAL0 customizedSerial1

#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3"
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif
#define NUM_SERIAL 2
#define MYSERIAL1 customizedSerial2
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#endif

#ifdef DGUS_SERIAL_PORT
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif
#define DGUS_SERIAL internalDgusSerial

#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
#endif

// ------------------------
// Public functions
// ------------------------
Expand Down Expand Up @@ -345,9 +358,9 @@ void TIMER0_COMPB_vect_bottom()

// ADC
#ifdef DIDR2
#define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0)
#define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
#else
#define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
#define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
#endif

inline void HAL_adc_init() {
Expand All @@ -358,11 +371,11 @@ inline void HAL_adc_init() {
#endif
}

#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
#ifdef MUX5
#define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
#define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#else
#define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
#define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#endif

#define HAL_ADC_RESOLUTION 10
Expand Down
29 changes: 28 additions & 1 deletion Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))

#include "MarlinSerial.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"

template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };
Expand Down Expand Up @@ -757,6 +757,33 @@

#endif

#ifdef DGUS_SERIAL_PORT

template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
h = tx_buffer.head; // next pos for queue.
int ret = t - h - 1;
if (ret < 0) ret += Cfg::TX_SIZE + 1;
return ret;
}

ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_RX_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::store_rxd_char();
}

ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::_tx_udr_empty_irq();
}

// Preinstantiate
template class MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>;

// Instantiate
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;

#endif

// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
Expand Down
20 changes: 20 additions & 0 deletions Marlin/src/HAL/HAL_AVR/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
#ifdef DGUS_SERIAL_PORT
static ring_buffer_pos_t get_tx_buffer_free();
#endif

FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
Expand Down Expand Up @@ -292,6 +295,23 @@
extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
#endif

#ifdef DGUS_SERIAL_PORT
template <uint8_t serial>
struct MarlinInternalSerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = 128;
static constexpr unsigned int TX_SIZE = 48;
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_OVERRUNS = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
};

extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
#endif

// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
Expand Down
16 changes: 16 additions & 0 deletions Marlin/src/HAL/HAL_AVR/endstop_interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@ void setup_endstop_interrupts() {
pciSetup(Z3_MIN_PIN);
#endif
#endif
#if HAS_Z4_MAX
#if (digitalPinToInterrupt(Z4_MAX_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z4_MAX_PIN);
#else
static_assert(digitalPinHasPCICR(Z4_MAX_PIN), "Z4_MAX_PIN is not interrupt-capable");
pciSetup(Z4_MAX_PIN);
#endif
#endif
#if HAS_Z4_MIN
#if (digitalPinToInterrupt(Z4_MIN_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z4_MIN_PIN);
#else
static_assert(digitalPinHasPCICR(Z4_MIN_PIN), "Z4_MIN_PIN is not interrupt-capable");
pciSetup(Z4_MIN_PIN);
#endif
#endif
#if HAS_Z_MIN_PROBE_PIN
#if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z_MIN_PROBE_PIN);
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/HAL_AVR/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@
#if HAS_TRINAMIC && ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
#error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif

#if TMC_HAS_SW_SERIAL && ENABLED(MONITOR_DRIVER_STATUS)
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
#endif
6 changes: 2 additions & 4 deletions Marlin/src/HAL/HAL_AVR/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");
void com_print(uint8_t N, uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPGM(" COM");
SERIAL_CHAR('0' + N);
SERIAL_CHAR('A' + Z);
SERIAL_CHAR('0' + N, 'A' + Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}

Expand All @@ -247,8 +246,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);

SERIAL_ECHOPGM(" TIMER");
SERIAL_CHAR(T + '0');
SERIAL_CHAR(L);
SERIAL_CHAR(T + '0', L);
SERIAL_ECHO_SP(3);

if (N == 3) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_AVR/watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "watchdog.h"

#include "../../Marlin.h"
#include "../../MarlinCore.h"

// Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
void watchdog_init() {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_DUE/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ int freeMemory() {
// ADC
// ------------------------

void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = analogRead(adc_pin);
void HAL_adc_start_conversion(const uint8_t ch) {
HAL_adc_result = analogRead(ch);
}

uint16_t HAL_adc_get_result() {
Expand Down
30 changes: 25 additions & 5 deletions Marlin/src/HAL/HAL_DUE/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
#endif
#if SERIAL_PORT_2 == -1
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 customizedSerial2
#elif SERIAL_PORT_2 == 0
#define MYSERIAL1 Serial
Expand All @@ -75,6 +74,27 @@
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL internalDgusSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL Serial3
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif


#include "MarlinSerial.h"
#include "MarlinSerialUSB.h"

Expand Down Expand Up @@ -128,16 +148,16 @@ extern uint16_t HAL_adc_result; // result of last ADC conversion
#define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
#endif

#define HAL_ANALOG_SELECT(pin)
#define HAL_ANALOG_SELECT(ch)

inline void HAL_adc_init() {}//todo

#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
#define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true

void HAL_adc_start_conversion(const uint8_t adc_pin);
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();

//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
}

// all the others
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4uS => 125khz
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz

static uint8_t spiTransferX(uint8_t b) { // using Mode 0
int bits = 8;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "MarlinSerial.h"
#include "InterruptVectors.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"

template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

#include <U8glib.h>

#include "../../../Marlin.h"
#include "../../../MarlinCore.h"

void spiBegin();
void spiInit(uint8_t spiRate);
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/HAL/HAL_DUE/endstop_interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif

#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ static void udd_ctrl_in_sent(void)
// The IN data don't must be written in endpoint 0 DPRAM during
// a next setup reception in same endpoint 0 DPRAM.
// Thereby, an OUT ZLP reception must check before IN data write
// and if no OUT ZLP is recevied the data must be written quickly (800us)
// and if no OUT ZLP is received the data must be written quickly (800µs)
// before an eventually ZLP OUT and SETUP reception
flags = cpu_irq_save();
if (Is_udd_out_received(0)) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifdef ARDUINO_ARCH_SAM

#include "../../inc/MarlinConfig.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
#include "watchdog.h"

// Override Arduino runtime to either config or disable the watchdog
Expand Down
Loading

0 comments on commit 644bfb2

Please sign in to comment.