Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into ender3v2_bu…
Browse files Browse the repository at this point in the history
…gfix

* upstream/bugfix-2.0.x: (125 commits)
  Suppress redundant serial errors
  [cron] Bump distribution date (2021-04-04)
  [cron] Bump distribution date (2021-04-03)
  Update u8g / AVR display timing defaults (MarlinFirmware#21518)
  GT2560 V3 followup (MarlinFirmware#21512)
  Remove extraneous 'extern' hints (MarlinFirmware#21516)
  Requiring PIO >= 5.0.3
  Split up platformio.ini (MarlinFirmware#21507)
  [cron] Bump distribution date (2021-04-02)
  Followup to Laser Flow Meter (MarlinFirmware#21498)
  MKS H43 fix, cleanup (MarlinFirmware#21500)
  G26 Hilbert Curve followup (MarlinFirmware#21480)
  Board IDs for G2560 Rev B, G2560 v4, GTM32 VD (MarlinFirmware#21499)
  Replace 'const float &' with 'const_float_t' (MarlinFirmware#21505)
  [cron] Bump distribution date (2021-04-01)
  MKS H43 fix, cleanup (MarlinFirmware#21485)
  Update UBL param
  Move apply_rotation_xyz into matrix_3x3
  Put ABL state into a class
  FTDI Touch UI fix and reorganize (MarlinFirmware#21487)
  ...

# Conflicts:
#	Marlin/Configuration.h
  • Loading branch information
Michael authored and Michael committed Apr 4, 2021
2 parents f0c8c35 + 895e401 commit 839bf7d
Show file tree
Hide file tree
Showing 498 changed files with 10,326 additions and 6,847 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
# Non-working environment tests
#- at90usb1286_cdc
#- STM32F103CB_malyan
#- STM32F103RE
#- mks_robin_mini

steps:
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1111)
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
# MKS GEN L
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# zrib V2.0 control board (Chinese knock off RAMPS replica)
# zrib V2.0 control board (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# BigTreeTech or BIQU KFB2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/AVR/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void spiBegin() {
}

/** SPI read data */
void spiRead(uint8_t* buf, uint16_t nbyte) {
void spiRead(uint8_t *buf, uint16_t nbyte) {
if (nbyte-- == 0) return;
SPDR = 0xFF;
for (uint16_t i = 0; i < nbyte; i++) {
Expand All @@ -107,7 +107,7 @@ void spiBegin() {
}

/** SPI send block */
void spiSendBlock(uint8_t token, const uint8_t* buf) {
void spiSendBlock(uint8_t token, const uint8_t *buf) {
SPDR = token;
for (uint16_t i = 0; i < 512; i += 2) {
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
Expand Down Expand Up @@ -215,7 +215,7 @@ void spiBegin() {
}

// Soft SPI read data
void spiRead(uint8_t* buf, uint16_t nbyte) {
void spiRead(uint8_t *buf, uint16_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++)
buf[i] = spiRec();
}
Expand All @@ -242,7 +242,7 @@ void spiBegin() {
}

// Soft SPI send block
void spiSendBlock(uint8_t token, const uint8_t* buf) {
void spiSendBlock(uint8_t token, const uint8_t *buf) {
spiSend(token);
for (uint16_t i = 0; i < 512; i++)
spiSend(buf[i]);
Expand Down
33 changes: 11 additions & 22 deletions Marlin/src/HAL/AVR/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@
template <uint8_t serial>
struct MMU2SerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = 32;
static constexpr unsigned int TX_SIZE = 32;
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
static constexpr unsigned int RX_SIZE = 32;
static constexpr unsigned int TX_SIZE = 32;
static constexpr bool RX_OVERRUNS = false;
};

Expand All @@ -270,28 +270,17 @@

template <uint8_t serial>
struct LCDSerialCfg {
static constexpr int PORT = serial;
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
#if HAS_DGUS_LCD
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
static constexpr unsigned int RX_SIZE = 64;
static constexpr unsigned int TX_SIZE = 128;
static constexpr bool RX_OVERRUNS = false;
#else
static constexpr unsigned int RX_SIZE = 64;
static constexpr unsigned int TX_SIZE = 128;
static constexpr bool RX_OVERRUNS = false
#endif
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = TERN(HAS_DGUS_LCD, DGUS_RX_BUFFER_SIZE, 64);
static constexpr unsigned int TX_SIZE = TERN(HAS_DGUS_LCD, DGUS_TX_BUFFER_SIZE, 128);
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS);
};


typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
extern MSerialT4 lcdSerial;
#endif
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/AVR/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
uint16_t written = 0;
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
eeprom_write_byte(p, v);
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
if (eeprom_read_byte(p) != v) {
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/AVR/fastio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ uint8_t extDigitalRead(const int8_t pin) {
*
* DC values -1.0 to 1.0. Negative duty cycle inverts the pulse.
*/
uint16_t set_pwm_frequency_hz(const float &hz, const float dca, const float dcb, const float dcc) {
uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb, const float dcc) {
float count = 0;
if (hz > 0 && (dca || dcb || dcc)) {
count = float(F_CPU) / hz; // 1x prescaler, TOP for 16MHz base freq.
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/DUE/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ uint16_t HAL_adc_get_result() {
}

// Forward the default serial ports
#if ANY_SERIAL_IS(0)
#if USING_HW_SERIAL0
DefaultSerial1 MSerial0(false, Serial);
#endif
#if ANY_SERIAL_IS(1)
#if USING_HW_SERIAL1
DefaultSerial2 MSerial1(false, Serial1);
#endif
#if ANY_SERIAL_IS(2)
#if USING_HW_SERIAL2
DefaultSerial3 MSerial2(false, Serial2);
#endif
#if ANY_SERIAL_IS(3)
#if USING_HW_SERIAL3
DefaultSerial4 MSerial3(false, Serial3);
#endif

Expand Down
30 changes: 15 additions & 15 deletions Marlin/src/HAL/DUE/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
#pragma GCC optimize (3)

typedef uint8_t (*pfnSpiTransfer)(uint8_t b);
typedef void (*pfnSpiRxBlock)(uint8_t* buf, uint32_t nbyte);
typedef void (*pfnSpiTxBlock)(const uint8_t* buf, uint32_t nbyte);
typedef void (*pfnSpiRxBlock)(uint8_t *buf, uint32_t nbyte);
typedef void (*pfnSpiTxBlock)(const uint8_t *buf, uint32_t nbyte);

/* ---------------- Macros to be able to access definitions from asm */
#define _PORT(IO) DIO ## IO ## _WPORT
Expand Down Expand Up @@ -270,7 +270,7 @@
static pfnSpiTransfer spiTransferTx = (pfnSpiTransfer)spiTransferX;

// Block transfers run at ~8 .. ~10Mhz - Tx version (Rx data discarded)
static void spiTxBlock0(const uint8_t* ptr, uint32_t todo) {
static void spiTxBlock0(const uint8_t *ptr, uint32_t todo) {
uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(SD_MOSI_PIN)) + 0x30; /* SODR of port */
uint32_t MOSI_MASK = PIN_MASK(SD_MOSI_PIN);
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
Expand Down Expand Up @@ -349,7 +349,7 @@
);
}

static void spiRxBlock0(uint8_t* ptr, uint32_t todo) {
static void spiRxBlock0(uint8_t *ptr, uint32_t todo) {
uint32_t bin = 0;
uint32_t work = 0;
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */
Expand Down Expand Up @@ -425,13 +425,13 @@
);
}

static void spiTxBlockX(const uint8_t* buf, uint32_t todo) {
static void spiTxBlockX(const uint8_t *buf, uint32_t todo) {
do {
(void)spiTransferTx(*buf++);
} while (--todo);
}

static void spiRxBlockX(uint8_t* buf, uint32_t todo) {
static void spiRxBlockX(uint8_t *buf, uint32_t todo) {
do {
*buf++ = spiTransferRx(0xFF);
} while (--todo);
Expand Down Expand Up @@ -463,7 +463,7 @@
return b;
}

void spiRead(uint8_t* buf, uint16_t nbyte) {
void spiRead(uint8_t *buf, uint16_t nbyte) {
if (nbyte) {
_SS_WRITE(LOW);
WRITE(SD_MOSI_PIN, HIGH); // Output 1s 1
Expand All @@ -478,7 +478,7 @@
_SS_WRITE(HIGH);
}

void spiSendBlock(uint8_t token, const uint8_t* buf) {
void spiSendBlock(uint8_t token, const uint8_t *buf) {
_SS_WRITE(LOW);
(void)spiTransferTx(token);
spiTxBlock(buf, 512);
Expand Down Expand Up @@ -645,7 +645,7 @@
}

// Read from SPI into buffer
void spiRead(uint8_t* buf, uint16_t nbyte) {
void spiRead(uint8_t *buf, uint16_t nbyte) {
if (!nbyte) return;
--nbyte;
for (int i = 0; i < nbyte; i++) {
Expand All @@ -668,7 +668,7 @@
//DELAY_US(1U);
}

void spiSend(const uint8_t* buf, size_t nbyte) {
void spiSend(const uint8_t *buf, size_t nbyte) {
if (!nbyte) return;
--nbyte;
for (size_t i = 0; i < nbyte; i++) {
Expand All @@ -689,7 +689,7 @@
FLUSH_RX();
}

void spiSend(uint32_t chan, const uint8_t* buf, size_t nbyte) {
void spiSend(uint32_t chan, const uint8_t *buf, size_t nbyte) {
if (!nbyte) return;
--nbyte;
for (size_t i = 0; i < nbyte; i++) {
Expand All @@ -702,7 +702,7 @@
}

// Write from buffer to SPI
void spiSendBlock(uint8_t token, const uint8_t* buf) {
void spiSendBlock(uint8_t token, const uint8_t *buf) {
SPI0->SPI_TDR = (uint32_t)token | SPI_PCS(SPI_CHAN);
WHILE_TX(0);
//WHILE_RX(0);
Expand Down Expand Up @@ -801,19 +801,19 @@

uint8_t spiRec() { return (uint8_t)spiTransfer(0xFF); }

void spiRead(uint8_t* buf, uint16_t nbyte) {
void spiRead(uint8_t *buf, uint16_t nbyte) {
for (int i = 0; i < nbyte; i++)
buf[i] = spiTransfer(0xFF);
}

void spiSend(uint8_t data) { spiTransfer(data); }

void spiSend(const uint8_t* buf, size_t nbyte) {
void spiSend(const uint8_t *buf, size_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++)
spiTransfer(buf[i]);
}

void spiSendBlock(uint8_t token, const uint8_t* buf) {
void spiSendBlock(uint8_t token, const uint8_t *buf) {
spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
spiTransfer(buf[i]);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void MarlinSerial<Cfg>::flushTX() {


// If not using the USB port as serial port
#if SERIAL_PORT >= 0
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct MarlinSerialCfg {
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};

#if SERIAL_PORT >= 0
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
extern MSerialT customizedSerial1;
#endif
Expand Down
21 changes: 10 additions & 11 deletions Marlin/src/HAL/DUE/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static void ee_Dump(const int page, const void* data) {

#ifdef EE_EMU_DEBUG

const uint8_t* c = (const uint8_t*) data;
const uint8_t *c = (const uint8_t*) data;
char buffer[80];

sprintf_P(buffer, PSTR("Page: %d (0x%04x)\n"), page, page);
Expand Down Expand Up @@ -293,8 +293,8 @@ static bool ee_PageWrite(uint16_t page, const void* data) {
ee_Dump(-page, data);

// Calculate count of changed bits
uint32_t* p1 = (uint32_t*)addrflash;
uint32_t* p2 = (uint32_t*)data;
uint32_t *p1 = (uint32_t*)addrflash;
uint32_t *p2 = (uint32_t*)data;
int count = 0;
for (i =0; i<PageSize >> 2; i++) {
if (p1[i] != p2[i]) {
Expand Down Expand Up @@ -470,7 +470,7 @@ static uint8_t ee_Read(uint32_t address, bool excludeRAMBuffer=false) {
for (int page = curPage - 1; page >= 0; --page) {

// Get a pointer to the flash page
uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
uint8_t *pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);

uint16_t i = 0;
while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
Expand Down Expand Up @@ -550,7 +550,7 @@ static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer=false) {
for (int page = curPage - 1; page >= 0; --page) {

// Get a pointer to the flash page
uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);
uint8_t *pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup);

uint16_t i = 0;
while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */
Expand Down Expand Up @@ -589,7 +589,7 @@ static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer=false) {
}

static bool ee_IsPageClean(int page) {
uint32_t* pflash = (uint32_t*) getFlashStorage(page);
uint32_t *pflash = (uint32_t*) getFlashStorage(page);
for (uint16_t i = 0; i < (PageSize >> 2); ++i)
if (*pflash++ != 0xFFFFFFFF) return false;
return true;
Expand All @@ -599,7 +599,7 @@ static bool ee_Flush(uint32_t overrideAddress = 0xFFFFFFFF, uint8_t overrideData

// Check if RAM buffer has something to be written
bool isEmpty = true;
uint32_t* p = (uint32_t*) &buffer[0];
uint32_t *p = (uint32_t*) &buffer[0];
for (uint16_t j = 0; j < (PageSize >> 2); j++) {
if (*p++ != 0xFFFFFFFF) {
isEmpty = false;
Expand Down Expand Up @@ -976,14 +976,13 @@ bool PersistentStore::access_start() { ee_Init(); return true; }
bool PersistentStore::access_finish() { ee_Flush(); return true; }

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
uint16_t written = 0;
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != ee_Read(uint32_t(p))) {
if (v != ee_Read(uint32_t(p))) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
ee_Write(uint32_t(p), v);
delay(2);
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
if (ee_Read(uint32_t(p)) != v) {
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
Expand Down
7 changes: 3 additions & 4 deletions Marlin/src/HAL/DUE/eeprom_wired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ bool PersistentStore::access_start() { eeprom_init(); return true; }
bool PersistentStore::access_finish() { return true; }

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
uint16_t written = 0;
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
eeprom_write_byte(p, v);
delay(2);
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
if (eeprom_read_byte(p) != v) {
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/usb/udi_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
* - \code // Waits and gets a value on CDC line
int udi_cdc_getc(void);
// Reads a RAM buffer on CDC line
iram_size_t udi_cdc_read_buf(int* buf, iram_size_t size);
iram_size_t udi_cdc_read_buf(int *buf, iram_size_t size);
// Puts a byte on CDC line
int udi_cdc_putc(int value);
// Writes a RAM buffer on CDC line
iram_size_t udi_cdc_write_buf(const int* buf, iram_size_t size); \endcode
iram_size_t udi_cdc_write_buf(const int *buf, iram_size_t size); \endcode
*
* \section udi_cdc_use_cases Advanced use cases
* For more advanced use of the UDI CDC module, see the following use cases:
Expand Down

0 comments on commit 839bf7d

Please sign in to comment.