From 0cb00f52d94773411e405ae10a463a4687b70658 Mon Sep 17 00:00:00 2001 From: Thomas Moore Date: Sat, 30 Sep 2017 16:06:43 -0500 Subject: [PATCH] Cleanup warnings --- .travis.yml | 6 +- Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp | 307 +++++++++--------- Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp | 4 +- Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp | 8 +- Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h | 6 +- Marlin/src/HAL/HAL_LPC1768/arduino.cpp | 6 +- Marlin/src/feature/mixing.cpp | 4 + Marlin/src/feature/pause.cpp | 28 +- Marlin/src/gcode/calibrate/M100.cpp | 24 +- Marlin/src/gcode/config/M43.cpp | 6 +- Marlin/src/gcode/feature/pause/M125.cpp | 1 + Marlin/src/gcode/gcode.cpp | 4 + Marlin/src/gcode/parser.cpp | 2 +- Marlin/src/lcd/ultralcd.cpp | 1 - Marlin/src/libs/hex_print_routines.cpp | 31 +- Marlin/src/libs/nozzle.cpp | 4 + Marlin/src/module/stepper.cpp | 8 +- Marlin/src/module/temperature.cpp | 6 +- Marlin/src/module/tool_change.cpp | 4 +- Marlin/src/sd/SdBaseFile.cpp | 2 +- .../CMSIS/LPC1768/driver/lpc17xx_nvic.c | 2 +- 22 files changed, 240 insertions(+), 226 deletions(-) diff --git a/.travis.yml b/.travis.yml index b462f1b2ae..213b799b20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -352,8 +352,8 @@ script: - opt_enable FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY - opt_enable FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE - opt_enable BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY - - opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER - - opt_enable_adv ADVANCED_PAUSE_FEATURE LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA + - opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER + - opt_enable_adv ADVANCED_PAUSE_FEATURE LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA PARK_HEAD_ON_PAUSE - opt_set_adv I2C_SLAVE_ADDRESS 63 - opt_set ABL_GRID_POINTS_X 16 - opt_set ABL_GRID_POINTS_Y 16 @@ -388,7 +388,7 @@ script: # Mixing Extruder # - restore_configs - - opt_enable MIXING_EXTRUDER + - opt_enable MIXING_EXTRUDER DIRECT_MIXING_IN_G1 - opt_set MIXING_STEPPERS 2 - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM} # diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp index 95ef5d242a..1d65a92034 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp @@ -171,7 +171,7 @@ UNUSED(response); } - static void spiSend(const uint8_t* buf, size_t n) { + void spiSend(const uint8_t* buf, size_t n) { uint8_t response; if (n == 0) return; for (uint16_t i = 0; i < n; i++) { diff --git a/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp index 69676eab91..6438acd228 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp @@ -346,7 +346,6 @@ extern "C" { void UART0_IRQHandler (void) { uint8_t IIRValue, LSRValue; - uint8_t Dummy = Dummy; IIRValue = LPC_UART0->IIR; @@ -354,59 +353,59 @@ void UART0_IRQHandler (void) IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if ( IIRValue == IIR_RLS ) /* Receive Line Status */ { - LSRValue = LPC_UART0->LSR; - /* Receive Line Status */ - if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) - { - /* There are errors or break interrupt */ - /* Read LSR will clear the interrupt */ - UART0Status = LSRValue; - Dummy = LPC_UART0->RBR; /* Dummy read on RX to clear - interrupt, then bail out */ - return; - } - if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ - { - /* If no error on RLS, normal ready, save into the data buffer. */ - /* Note: read RBR will clear the interrupt */ - if ((UART0RxQueueWritePos+1) % UARTRXQUEUESIZE != UART0RxQueueReadPos) - { - UART0Buffer[UART0RxQueueWritePos] = LPC_UART0->RBR; - UART0RxQueueWritePos = (UART0RxQueueWritePos+1) % UARTRXQUEUESIZE; - } - else - dummy = LPC_UART0->RBR;; - } + LSRValue = LPC_UART0->LSR; + /* Receive Line Status */ + if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) + { + /* There are errors or break interrupt */ + /* Read LSR will clear the interrupt */ + UART0Status = LSRValue; + dummy = LPC_UART0->RBR; /* Dummy read on RX to clear + interrupt, then bail out */ + return; + } + if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ + { + /* If no error on RLS, normal ready, save into the data buffer. */ + /* Note: read RBR will clear the interrupt */ + if ((UART0RxQueueWritePos+1) % UARTRXQUEUESIZE != UART0RxQueueReadPos) + { + UART0Buffer[UART0RxQueueWritePos] = LPC_UART0->RBR; + UART0RxQueueWritePos = (UART0RxQueueWritePos+1) % UARTRXQUEUESIZE; + } + else + dummy = LPC_UART0->RBR; + } } else if ( IIRValue == IIR_RDA ) /* Receive Data Available */ { - /* Receive Data Available */ + /* Receive Data Available */ if ((UART0RxQueueWritePos+1) % UARTRXQUEUESIZE != UART0RxQueueReadPos) { UART0Buffer[UART0RxQueueWritePos] = LPC_UART0->RBR; UART0RxQueueWritePos = (UART0RxQueueWritePos+1) % UARTRXQUEUESIZE; } else - dummy = LPC_UART1->RBR;; + dummy = LPC_UART1->RBR; } else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */ { - /* Character Time-out indicator */ - UART0Status |= 0x100; /* Bit 9 as the CTI error */ + /* Character Time-out indicator */ + UART0Status |= 0x100; /* Bit 9 as the CTI error */ } else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */ { - /* THRE interrupt */ - LSRValue = LPC_UART0->LSR; /* Check status in the LSR to see if - valid data in U0THR or not */ - if ( LSRValue & LSR_THRE ) - { - UART0TxEmpty = 1; - } - else - { - UART0TxEmpty = 0; - } + /* THRE interrupt */ + LSRValue = LPC_UART0->LSR; /* Check status in the LSR to see if + valid data in U0THR or not */ + if ( LSRValue & LSR_THRE ) + { + UART0TxEmpty = 1; + } + else + { + UART0TxEmpty = 0; + } } } @@ -422,7 +421,6 @@ void UART0_IRQHandler (void) void UART1_IRQHandler (void) { uint8_t IIRValue, LSRValue; - uint8_t Dummy = Dummy; IIRValue = LPC_UART1->IIR; @@ -430,61 +428,60 @@ void UART1_IRQHandler (void) IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if ( IIRValue == IIR_RLS ) /* Receive Line Status */ { - LSRValue = LPC_UART1->LSR; - /* Receive Line Status */ - if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) - { - /* There are errors or break interrupt */ - /* Read LSR will clear the interrupt */ - UART1Status = LSRValue; - Dummy = LPC_UART1->RBR; /* Dummy read on RX to clear - interrupt, then bail out */ - return; - } - if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ - { - /* If no error on RLS, normal ready, save into the data buffer. */ - /* Note: read RBR will clear the interrupt */ - if ((UART1RxQueueWritePos+1) % UARTRXQUEUESIZE != UART1RxQueueReadPos) - { - UART1Buffer[UART1RxQueueWritePos] = LPC_UART1->RBR; - UART1RxQueueWritePos =(UART1RxQueueWritePos+1) % UARTRXQUEUESIZE; - } - else - dummy = LPC_UART1->RBR;; - } + LSRValue = LPC_UART1->LSR; + /* Receive Line Status */ + if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) + { + /* There are errors or break interrupt */ + /* Read LSR will clear the interrupt */ + UART1Status = LSRValue; + dummy = LPC_UART1->RBR; /* Dummy read on RX to clear + interrupt, then bail out */ + return; + } + if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ + { + /* If no error on RLS, normal ready, save into the data buffer. */ + /* Note: read RBR will clear the interrupt */ + if ((UART1RxQueueWritePos+1) % UARTRXQUEUESIZE != UART1RxQueueReadPos) + { + UART1Buffer[UART1RxQueueWritePos] = LPC_UART1->RBR; + UART1RxQueueWritePos =(UART1RxQueueWritePos+1) % UARTRXQUEUESIZE; + } + else + dummy = LPC_UART1->RBR; + } } else if ( IIRValue == IIR_RDA ) /* Receive Data Available */ { - /* Receive Data Available */ + /* Receive Data Available */ if ((UART1RxQueueWritePos+1) % UARTRXQUEUESIZE != UART1RxQueueReadPos) { UART1Buffer[UART1RxQueueWritePos] = LPC_UART1->RBR; UART1RxQueueWritePos = (UART1RxQueueWritePos+1) % UARTRXQUEUESIZE; } else - dummy = LPC_UART1->RBR;; + dummy = LPC_UART1->RBR; } else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */ { - /* Character Time-out indicator */ - UART1Status |= 0x100; /* Bit 9 as the CTI error */ - } - else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */ - { - /* THRE interrupt */ - LSRValue = LPC_UART1->LSR; /* Check status in the LSR to see if - valid data in U0THR or not */ - if ( LSRValue & LSR_THRE ) - { - UART1TxEmpty = 1; - } - else - { - UART1TxEmpty = 0; - } + /* Character Time-out indicator */ + UART1Status |= 0x100; /* Bit 9 as the CTI error */ + } + else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */ + { + /* THRE interrupt */ + LSRValue = LPC_UART1->LSR; /* Check status in the LSR to see if + valid data in U0THR or not */ + if ( LSRValue & LSR_THRE ) + { + UART1TxEmpty = 1; + } + else + { + UART1TxEmpty = 0; + } } - } /***************************************************************************** ** Function name: UART2_IRQHandler @@ -498,7 +495,6 @@ void UART1_IRQHandler (void) void UART2_IRQHandler (void) { uint8_t IIRValue, LSRValue; - uint8_t Dummy = Dummy; IIRValue = LPC_UART2->IIR; @@ -506,57 +502,57 @@ void UART2_IRQHandler (void) IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if ( IIRValue == IIR_RLS ) /* Receive Line Status */ { - LSRValue = LPC_UART2->LSR; - /* Receive Line Status */ - if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) - { - /* There are errors or break interrupt */ - /* Read LSR will clear the interrupt */ - UART2Status = LSRValue; - Dummy = LPC_UART2->RBR; /* Dummy read on RX to clear - interrupt, then bail out */ - return; - } - if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ - { - /* If no error on RLS, normal ready, save into the data buffer. */ - /* Note: read RBR will clear the interrupt */ - if ((UART2RxQueueWritePos+1) % UARTRXQUEUESIZE != UART2RxQueueReadPos) - { - UART2Buffer[UART2RxQueueWritePos] = LPC_UART2->RBR; - UART2RxQueueWritePos = (UART2RxQueueWritePos+1) % UARTRXQUEUESIZE; - } - } + LSRValue = LPC_UART2->LSR; + /* Receive Line Status */ + if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) + { + /* There are errors or break interrupt */ + /* Read LSR will clear the interrupt */ + UART2Status = LSRValue; + dummy = LPC_UART2->RBR; /* Dummy read on RX to clear + interrupt, then bail out */ + return; + } + if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ + { + /* If no error on RLS, normal ready, save into the data buffer. */ + /* Note: read RBR will clear the interrupt */ + if ((UART2RxQueueWritePos+1) % UARTRXQUEUESIZE != UART2RxQueueReadPos) + { + UART2Buffer[UART2RxQueueWritePos] = LPC_UART2->RBR; + UART2RxQueueWritePos = (UART2RxQueueWritePos+1) % UARTRXQUEUESIZE; + } + } } else if ( IIRValue == IIR_RDA ) /* Receive Data Available */ { - /* Receive Data Available */ + /* Receive Data Available */ if ((UART2RxQueueWritePos+1) % UARTRXQUEUESIZE != UART2RxQueueReadPos) { UART2Buffer[UART2RxQueueWritePos] = LPC_UART2->RBR; UART2RxQueueWritePos = (UART2RxQueueWritePos+1) % UARTRXQUEUESIZE; } else - dummy = LPC_UART2->RBR;; + dummy = LPC_UART2->RBR; } else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */ { - /* Character Time-out indicator */ - UART2Status |= 0x100; /* Bit 9 as the CTI error */ + /* Character Time-out indicator */ + UART2Status |= 0x100; /* Bit 9 as the CTI error */ } else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */ { - /* THRE interrupt */ - LSRValue = LPC_UART2->LSR; /* Check status in the LSR to see if - valid data in U0THR or not */ - if ( LSRValue & LSR_THRE ) - { - UART2TxEmpty = 1; - } - else - { - UART2TxEmpty = 0; - } + /* THRE interrupt */ + LSRValue = LPC_UART2->LSR; /* Check status in the LSR to see if + valid data in U0THR or not */ + if ( LSRValue & LSR_THRE ) + { + UART2TxEmpty = 1; + } + else + { + UART2TxEmpty = 0; + } } } /***************************************************************************** @@ -571,7 +567,6 @@ void UART2_IRQHandler (void) void UART3_IRQHandler (void) { uint8_t IIRValue, LSRValue; - uint8_t Dummy = Dummy; IIRValue = LPC_UART3->IIR; @@ -579,57 +574,57 @@ void UART3_IRQHandler (void) IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if ( IIRValue == IIR_RLS ) /* Receive Line Status */ { - LSRValue = LPC_UART3->LSR; - /* Receive Line Status */ - if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) - { - /* There are errors or break interrupt */ - /* Read LSR will clear the interrupt */ - UART3Status = LSRValue; - Dummy = LPC_UART3->RBR; /* Dummy read on RX to clear - interrupt, then bail out */ - return; - } - if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ - { - /* If no error on RLS, normal ready, save into the data buffer. */ - /* Note: read RBR will clear the interrupt */ - if ((UART3RxQueueWritePos+1) % UARTRXQUEUESIZE != UART3RxQueueReadPos) - { - UART3Buffer[UART3RxQueueWritePos] = LPC_UART3->RBR; - UART3RxQueueWritePos = (UART3RxQueueWritePos+1) % UARTRXQUEUESIZE; - } - } + LSRValue = LPC_UART3->LSR; + /* Receive Line Status */ + if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) + { + /* There are errors or break interrupt */ + /* Read LSR will clear the interrupt */ + UART3Status = LSRValue; + dummy = LPC_UART3->RBR; /* Dummy read on RX to clear + interrupt, then bail out */ + return; + } + if ( LSRValue & LSR_RDR ) /* Receive Data Ready */ + { + /* If no error on RLS, normal ready, save into the data buffer. */ + /* Note: read RBR will clear the interrupt */ + if ((UART3RxQueueWritePos+1) % UARTRXQUEUESIZE != UART3RxQueueReadPos) + { + UART3Buffer[UART3RxQueueWritePos] = LPC_UART3->RBR; + UART3RxQueueWritePos = (UART3RxQueueWritePos+1) % UARTRXQUEUESIZE; + } + } } else if ( IIRValue == IIR_RDA ) /* Receive Data Available */ { - /* Receive Data Available */ + /* Receive Data Available */ if ((UART3RxQueueWritePos+1) % UARTRXQUEUESIZE != UART3RxQueueReadPos) { UART3Buffer[UART3RxQueueWritePos] = LPC_UART3->RBR; UART3RxQueueWritePos = (UART3RxQueueWritePos+1) % UARTRXQUEUESIZE; } else - dummy = LPC_UART3->RBR;; + dummy = LPC_UART3->RBR; } else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */ { - /* Character Time-out indicator */ - UART3Status |= 0x100; /* Bit 9 as the CTI error */ + /* Character Time-out indicator */ + UART3Status |= 0x100; /* Bit 9 as the CTI error */ } else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */ { - /* THRE interrupt */ - LSRValue = LPC_UART3->LSR; /* Check status in the LSR to see if - valid data in U0THR or not */ - if ( LSRValue & LSR_THRE ) - { - UART3TxEmpty = 1; - } - else - { - UART3TxEmpty = 0; - } + /* THRE interrupt */ + LSRValue = LPC_UART3->LSR; /* Check status in the LSR to see if + valid data in U0THR or not */ + if ( LSRValue & LSR_THRE ) + { + UART3TxEmpty = 1; + } + else + { + UART3TxEmpty = 0; + } } } diff --git a/Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp b/Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp index af37501774..c8120b82dd 100644 --- a/Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp @@ -147,9 +147,11 @@ bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; } void Servo::move(const int value) { + constexpr uint16_t servo_delay[] = SERVO_DELAY; + static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long."); if (this->attach(0) >= 0) { // notice the pin number is zero here this->write(value); - delay(SERVO_DELAY); + delay(servo_delay[this->servoIndex]); #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) this->detach(); LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp index 596fa2a98c..51883a4002 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp @@ -292,10 +292,10 @@ void SoftwareSerial::begin(long speed) void SoftwareSerial::setRxIntMsk(bool enable) { - if (enable) - GpioEnableInt(_receivePort,_receivePin,CHANGE); - else - GpioDisableInt(_receivePort,_receivePin); + if (enable) + GpioEnableInt(_receivePort,_receivePin,CHANGE); + else + GpioDisableInt(_receivePort,_receivePin); } void SoftwareSerial::end() diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h index 544c7c450a..f581882f33 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h +++ b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h @@ -71,12 +71,12 @@ private: static SoftwareSerial *active_object; // private methods - void recv() __attribute__((__always_inline__)); + void recv(); uint32_t rx_pin_read(); - void tx_pin_write(uint8_t pin_state) __attribute__((__always_inline__)); + void tx_pin_write(uint8_t pin_state); void setTX(uint8_t transmitPin); void setRX(uint8_t receivePin); - void setRxIntMsk(bool enable) __attribute__((__always_inline__)); + void setRxIntMsk(bool enable); // private static method for timing static inline void tunedDelay(uint32_t delay); diff --git a/Marlin/src/HAL/HAL_LPC1768/arduino.cpp b/Marlin/src/HAL/HAL_LPC1768/arduino.cpp index be3c08f464..b3191731aa 100644 --- a/Marlin/src/HAL/HAL_LPC1768/arduino.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/arduino.cpp @@ -62,9 +62,9 @@ void delayMicroseconds(uint32_t us) { while (loops > 0) --loops; } else { // poll systick, more accurate through interrupts - int32_t start = SysTick->VAL; - int32_t load = SysTick->LOAD; - int32_t end = start - (load / 1000) * us; + uint32_t start = SysTick->VAL; + uint32_t load = SysTick->LOAD; + uint32_t end = start - (load / 1000) * us; if (end >> 31) while (!(SysTick->VAL > start && SysTick->VAL < (load + end))) __NOP(); diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 7300c3e28a..ff4755b1d1 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -24,6 +24,10 @@ #if ENABLED(MIXING_EXTRUDER) +#if ENABLED(DIRECT_MIXING_IN_G1) + #include "../gcode/parser.h" +#endif + float mixing_factor[MIXING_STEPPERS]; // Reciprocal of mix proportion. 0.0 = off, otherwise >= 1.0. #if MIXING_VIRTUAL_TOOLS > 1 diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index ae538c65db..7c7f7c0067 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -52,21 +52,23 @@ static float resume_position[XYZE]; static bool sd_print_paused = false; #endif -static void filament_change_beep(const int8_t max_beep_count, const bool init=false) { - static millis_t next_buzz = 0; - static int8_t runout_beep = 0; - - if (init) next_buzz = runout_beep = 0; - - const millis_t ms = millis(); - if (ELAPSED(ms, next_buzz)) { - if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to - next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 2500 : 400); - BUZZ(300, 2000); - runout_beep++; +#if HAS_BUZZER + static void filament_change_beep(const int8_t max_beep_count, const bool init=false) { + static millis_t next_buzz = 0; + static int8_t runout_beep = 0; + + if (init) next_buzz = runout_beep = 0; + + const millis_t ms = millis(); + if (ELAPSED(ms, next_buzz)) { + if (max_beep_count < 0 || runout_beep < max_beep_count + 5) { // Only beep as long as we're supposed to + next_buzz = ms + ((max_beep_count < 0 || runout_beep < max_beep_count) ? 2500 : 400); + BUZZ(300, 2000); + runout_beep++; + } } } -} +#endif static void ensure_safe_temperature() { bool heaters_heating = true; diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index ea5937008f..94f591d72e 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -79,8 +79,8 @@ char* top_of_stack() { } // Count the number of test bytes at the specified location. -inline int16_t count_test_bytes(const char * const ptr) { - for (uint16_t i = 0; i < 32000; i++) +inline int32_t count_test_bytes(const char * const ptr) { + for (uint32_t i = 0; i < 32000; i++) if (((char) ptr[i]) != TEST_BYTE) return i - 1; @@ -180,7 +180,7 @@ inline int check_for_free_memory_corruption(const char * const title) { int block_cnt = 0; for (int i = 0; i < n; i++) { if (ptr[i] == TEST_BYTE) { - int16_t j = count_test_bytes(ptr + i); + int32_t j = count_test_bytes(ptr + i); if (j > 8) { // SERIAL_ECHOPAIR("Found ", j); // SERIAL_ECHOLNPAIR(" bytes free at ", hex_address(ptr + i)); @@ -215,14 +215,14 @@ inline int check_for_free_memory_corruption(const char * const title) { * Return the number of free bytes in the memory pool, * with other vital statistics defining the pool. */ -inline void free_memory_pool_report(char * const ptr, const int16_t size) { - int16_t max_cnt = -1, block_cnt = 0; +inline void free_memory_pool_report(char * const ptr, const int32_t size) { + int32_t max_cnt = -1, block_cnt = 0; char *max_addr = NULL; // Find the longest block of test bytes in the buffer - for (int16_t i = 0; i < size; i++) { + for (int32_t i = 0; i < size; i++) { char *addr = ptr + i; if (*addr == TEST_BYTE) { - const int16_t j = count_test_bytes(addr); + const int32_t j = count_test_bytes(addr); if (j > 8) { SERIAL_ECHOPAIR("Found ", j); SERIAL_ECHOLNPAIR(" bytes free at ", hex_address(addr)); @@ -249,13 +249,13 @@ inline void free_memory_pool_report(char * const ptr, const int16_t size) { * Corrupt locations in the free memory pool and report the corrupt addresses. * This is useful to check the correctness of the M100 D and the M100 F commands. */ - inline void corrupt_free_memory(char *ptr, const uint16_t size) { + inline void corrupt_free_memory(char *ptr, const uint32_t size) { ptr += 8; - const uint16_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack. + const uint32_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack. j = near_top / (size + 1); SERIAL_ECHOLNPGM("Corrupting free memory block.\n"); - for (uint16_t i = 1; i <= size; i++) { + for (uint32_t i = 1; i <= size; i++) { char * const addr = ptr + i * j; *addr = i; SERIAL_ECHOPAIR("\nCorrupting address: ", hex_address(addr)); @@ -268,7 +268,7 @@ inline void free_memory_pool_report(char * const ptr, const int16_t size) { * M100 I * Init memory for the M100 tests. (Automatically applied on the first M100.) */ -inline void init_free_memory(char *ptr, int16_t size) { +inline void init_free_memory(char *ptr, int32_t size) { SERIAL_ECHOLNPGM("Initializing free memory block.\n\n"); size -= 250; // -250 to avoid interrupt activity that's altered the stack. @@ -284,7 +284,7 @@ inline void init_free_memory(char *ptr, int16_t size) { SERIAL_ECHO(size); SERIAL_ECHOLNPGM(" bytes of memory initialized.\n"); - for (int16_t i = 0; i < size; i++) { + for (int32_t i = 0; i < size; i++) { if (ptr[i] != TEST_BYTE) { SERIAL_ECHOPAIR("? address : ", hex_address(ptr + i)); SERIAL_ECHOLNPAIR("=", hex_byte(ptr[i])); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index e64062e9ed..225843017e 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -141,15 +141,16 @@ inline void servo_probe_test() { SERIAL_PROTOCOLLNPGM(". deploy & stow 4 times"); SET_INPUT_PULLUP(PROBE_TEST_PIN); + uint8_t i = 0; bool deploy_state, stow_state; - for (uint8_t i = 0; i < 4; i++) { + do { MOVE_SERVO(probe_index, z_servo_angle[0]); //deploy safe_delay(500); deploy_state = READ(PROBE_TEST_PIN); MOVE_SERVO(probe_index, z_servo_angle[1]); //stow safe_delay(500); stow_state = READ(PROBE_TEST_PIN); - } + } while (++i < 4); if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards"); gcode.refresh_cmd_timeout(); @@ -167,7 +168,6 @@ inline void servo_probe_test() { #if ENABLED(BLTOUCH) SERIAL_PROTOCOLLNPGM("ERROR: BLTOUCH enabled - set this device up as a Z Servo Probe with inverting as true."); #endif - } else { // measure active signal length MOVE_SERVO(probe_index, z_servo_angle[0]); // deploy diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 347afa9375..06e3895e8d 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -27,6 +27,7 @@ #include "../../gcode.h" #include "../../parser.h" #include "../../../feature/pause.h" +#include "../../../module/motion.h" /** * M125: Store current position and move to filament change position. diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 1dccf74469..880cf1b059 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -36,6 +36,10 @@ GcodeSuite gcode; #include "../module/printcounter.h" #endif +#if ENABLED(DIRECT_MIXING_IN_G1) + #include "../feature/mixing.h" +#endif + #include "../Marlin.h" // for idle() uint8_t GcodeSuite::target_extruder; diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 373a1caceb..503b5681d5 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -29,7 +29,7 @@ #include "../Marlin.h" #if ENABLED(DEBUG_GCODE_PARSER) - #include "../../libs/hex_print_routines.h" + #include "../libs/hex_print_routines.h" #endif // Must be declared for allocation and to satisfy the linker diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 7c83a977a8..dbf021c49d 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -2693,7 +2693,6 @@ void kill_screen(const char* lcd_msg) { void lcd_delta_settings() { START_MENU(); MENU_BACK(MSG_DELTA_CALIBRATE); - float Tz = 0.00; MENU_ITEM_EDIT(float52, MSG_DELTA_DIAG_ROG, &delta_diagonal_rod, DELTA_DIAGONAL_ROD - 5.0, DELTA_DIAGONAL_ROD + 5.0); _delta_height = DELTA_HEIGHT + home_offset[Z_AXIS]; MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &_delta_height, _delta_height - 10.0, _delta_height + 10.0, _lcd_set_delta_height); diff --git a/Marlin/src/libs/hex_print_routines.cpp b/Marlin/src/libs/hex_print_routines.cpp index 9e8a2b702a..ebf8bca7ec 100644 --- a/Marlin/src/libs/hex_print_routines.cpp +++ b/Marlin/src/libs/hex_print_routines.cpp @@ -21,41 +21,46 @@ */ #include "../inc/MarlinConfig.h" +#include "../gcode/parser.h" #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER) #include "hex_print_routines.h" #ifdef CPU_32_BIT - constexpr int byte_start = 0; - static char _hex[] = "0x0000"; - #else constexpr int byte_start = 4; static char _hex[] = "0x00000000"; + #else + constexpr int byte_start = 0; + static char _hex[] = "0x0000"; #endif char* hex_byte(const uint8_t b) { _hex[byte_start + 4] = hex_nybble(b >> 4); _hex[byte_start + 5] = hex_nybble(b); - return &_hex[byte_start]; + return &_hex[byte_start + 4]; } - char* hex_word(const uint16_t w) { + inline void _hex_word(const uint16_t w) { _hex[byte_start + 2] = hex_nybble(w >> 12); _hex[byte_start + 3] = hex_nybble(w >> 8); _hex[byte_start + 4] = hex_nybble(w >> 4); _hex[byte_start + 5] = hex_nybble(w); - return &_hex[byte_start - 2]; + } + + char* hex_word(const uint16_t w) { + _hex_word(w); + return &_hex[byte_start + 2]; } #ifdef CPU_32_BIT - char* hex_long(const uint32_t w) { - _hex[byte_start - 2] = hex_nybble(w >> 28); - _hex[byte_start - 1] = hex_nybble(w >> 24); - _hex[byte_start + 0] = hex_nybble(w >> 20); - _hex[byte_start + 1] = hex_nybble(w >> 16); - (void)hex_word((uint16_t)(w & 0xFFFF)); - return &_hex[byte_start - 6]; + char* hex_long(const uint32_t l) { + _hex[2] = hex_nybble(l >> 28); + _hex[3] = hex_nybble(l >> 24); + _hex[4] = hex_nybble(l >> 20); + _hex[5] = hex_nybble(l >> 16); + _hex_word((uint16_t)(l & 0xFFFF)); + return &_hex[2]; } #endif diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 7b7006ee2c..d5039c4ea2 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -26,6 +26,10 @@ #include "../module/motion.h" #include "point_t.h" +#if ENABLED(DELTA) + #include "../module/delta.h" +#endif + /** * @brief Stroke clean pattern * @details Wipes the nozzle back and forth in a linear movement diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 7cfc0f630d..e71859f34e 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -135,9 +135,9 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even * This fix isn't perfect and may lose steps - but better than locking up completely * in future the planner should slow down if advance stepping rate would be too high */ - FORCE_INLINE uint16_t adv_rate(const int steps, const uint16_t timer, const uint8_t loops) { + FORCE_INLINE HAL_TIMER_TYPE adv_rate(const int steps, const HAL_TIMER_TYPE timer, const uint8_t loops) { if (steps) { - const uint16_t rate = (timer * loops) / abs(steps); + const HAL_TIMER_TYPE rate = (timer * loops) / abs(steps); //return constrain(rate, 1, ADV_NEVER - 1) return rate ? rate : 1; } @@ -806,8 +806,8 @@ void Stepper::isr() { #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE) #ifdef CPU_32_BIT // Make sure stepper interrupt does not monopolise CPU by adjusting count to give about 8 us room - uint32_t stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM), - stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US; + HAL_TIMER_TYPE stepper_timer_count = HAL_timer_get_count(STEP_TIMER_NUM), + stepper_timer_current_count = HAL_timer_get_current_count(STEP_TIMER_NUM) + 8 * HAL_TICKS_PER_US; HAL_timer_set_count(STEP_TIMER_NUM, max(stepper_timer_count, stepper_timer_current_count)); #else NOLESS(OCR1A, TCNT1 + 16); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e1c8154af3..7eec289903 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1744,8 +1744,8 @@ void Temperature::isr() { // Macros for Slow PWM timer logic #define _SLOW_PWM_ROUTINE(NR, src) \ - soft_pwm_ ##NR = src; \ - if (soft_pwm_ ##NR > 0) { \ + soft_pwm_count_ ##NR = src; \ + if (soft_pwm_count_ ##NR > 0) { \ if (state_timer_heater_ ##NR == 0) { \ if (state_heater_ ##NR == 0) state_timer_heater_ ##NR = MIN_STATE_TIME; \ state_heater_ ##NR = 1; \ @@ -1762,7 +1762,7 @@ void Temperature::isr() { #define SLOW_PWM_ROUTINE(n) _SLOW_PWM_ROUTINE(n, soft_pwm_amount[n]) #define PWM_OFF_ROUTINE(NR) \ - if (soft_pwm_ ##NR < slow_pwm_count) { \ + if (soft_pwm_count_ ##NR < slow_pwm_count) { \ if (state_timer_heater_ ##NR == 0) { \ if (state_heater_ ##NR == 1) state_timer_heater_ ##NR = MIN_STATE_TIME; \ state_heater_ ##NR = 0; \ diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index e5ea339721..758044292c 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -286,8 +286,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n #else // !DUAL_X_CARRIAGE #if ENABLED(PARKING_EXTRUDER) // Dual Parking extruder - const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder]; - float z_raise = 0; + float z_raise = PARKING_EXTRUDER_SECURITY_RAISE; if (!no_move) { const float parkingposx[] = PARKING_EXTRUDER_PARKING_X, @@ -310,7 +309,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n SERIAL_ECHOLNPGM("Starting Autopark"); if (DEBUGGING(LEVELING)) DEBUG_POS("current position:", current_position); #endif - z_raise = PARKING_EXTRUDER_SECURITY_RAISE; current_position[Z_AXIS] += z_raise; #if ENABLED(DEBUG_LEVELING_FEATURE) SERIAL_ECHOLNPGM("(1) Raise Z-Axis "); diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index d292cdb354..b5356c0674 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -1388,7 +1388,7 @@ bool SdBaseFile::rmdir() { * the value zero, false, is returned for failure. */ bool SdBaseFile::rmRfStar() { - uint16_t index; + uint32_t index; SdBaseFile f; rewind(); while (curPosition_ < fileSize_) { diff --git a/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c b/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c index 7cbe8e1d43..3e01e47902 100644 --- a/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c +++ b/frameworks/CMSIS/LPC1768/driver/lpc17xx_nvic.c @@ -115,7 +115,7 @@ void NVIC_SCBDeInit(void) SCB->SCR = 0x00000000; SCB->CCR = 0x00000000; - for (tmp = 0; tmp < 32; tmp++) { + for (tmp = 0; tmp < (sizeof(SCB->SHP) / sizeof(SCB->SHP[0])); tmp++) { SCB->SHP[tmp] = 0x00; }