diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 6e735974a9..48beca2c2d 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -9,51 +9,35 @@ assignees: ''
### Bug Description
-
+
-### Configuration Files
+### My Configurations
-**Required:** Include a ZIP file containing `Configuration.h` and `Configuration_adv.h`.
-
-If you've made any other modifications describe them in detail here.
+**Required:** Please include a ZIP file containing your `Configuration.h` and `Configuration_adv.h` files.
### Steps to Reproduce
-
+
1. [First Step]
2. [Second Step]
3. [and so on...]
-**Expected behavior:**
+**Expected behavior:** [What you expect to happen]
-
-
-**Actual behavior:**
-
-
+**Actual behavior:** [What actually happens]
#### Additional Information
* Provide pictures or links to videos that clearly demonstrate the issue.
-* See [Contributing to Marlin](https://github.com/MarlinFirmware/Marlin/blob/2.0.x/.github/contributing.md) for additional guidelines.
+* See [How Can I Contribute](#how-can-i-contribute) for additional guidelines.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 24de8d0141..ff3b6b06d8 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -2,7 +2,7 @@
name: Feature request
about: Request a Feature
title: "[FR] (feature request title)"
-labels: 'T: Feature Request'
+labels: ''
assignees: ''
---
diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml
index 89d5d65351..083e844e90 100644
--- a/.github/workflows/close-stale.yml
+++ b/.github/workflows/close-stale.yml
@@ -20,8 +20,8 @@ jobs:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- stale-issue-message: 'This issue has had no activity in the last 30 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 7 days.'
+ stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.'
days-before-stale: 30
- days-before-close: 7
+ days-before-close: 5
stale-issue-label: 'stale-closing-soon'
exempt-issue-labels: 'T: Feature Request'
diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml
index b228783799..fdb81fbdc9 100644
--- a/.github/workflows/test-builds.yml
+++ b/.github/workflows/test-builds.yml
@@ -41,7 +41,6 @@ jobs:
- mega2560
- teensy31
- teensy35
- - teensy41
- SAMD51_grandcentral_m4
# Extended AVR Environments
@@ -71,7 +70,6 @@ jobs:
- mks_robin_stm32
- ARMED
- FYSETC_S6
- - STM32F070CB_malyan
- STM32F070RB_malyan
- malyan_M300
- mks_robin_lite
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index db266b524b..8cd2faf7f8 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -34,8 +34,9 @@
* - Extra features
*
* Advanced settings can be found in Configuration_adv.h
+ *
*/
-#define CONFIGURATION_H_VERSION 020007
+#define CONFIGURATION_H_VERSION 020006
//===========================================================================
//============================= Getting Started =============================
@@ -346,10 +347,11 @@
#endif
#endif
+// @section temperature
+
//===========================================================================
//============================= Thermal Settings ============================
//===========================================================================
-// @section temperature
/**
* --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
@@ -388,7 +390,6 @@
* 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
* 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB)
* 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB)
- * 30 : Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K / B3950 (4.7k pullup)
* 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
* 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
* 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
@@ -431,12 +432,6 @@
#define DUMMY_THERMISTOR_998_VALUE 25
#define DUMMY_THERMISTOR_999_VALUE 100
-// Resistor values when using a MAX31865 (sensor -5)
-// Sensor value is typically 100 (PT100) or 1000 (PT1000)
-// Calibration value is typically 430 ohm for AdaFruit PT100 modules and 4300 ohm for AdaFruit PT1000 modules.
-//#define MAX31865_SENSOR_OHMS 100
-//#define MAX31865_CALIBRATION_OHMS 430
-
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
// from the two sensors differ too much the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT
@@ -492,17 +487,23 @@
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2]
- #if ENABLED(PID_PARAMS_PER_HOTEND)
- // Specify between 1 and HOTENDS values per array.
- // If fewer than EXTRUDER values are provided, the last element will be repeated.
- #define DEFAULT_Kp_LIST { 22.20, 22.20 }
- #define DEFAULT_Ki_LIST { 1.08, 1.08 }
- #define DEFAULT_Kd_LIST { 114.00, 114.00 }
- #else
- #define DEFAULT_Kp 22.20
- #define DEFAULT_Ki 1.08
- #define DEFAULT_Kd 114.00
- #endif
+ // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
+
+ // Ultimaker
+ #define DEFAULT_Kp 22.2
+ #define DEFAULT_Ki 1.08
+ #define DEFAULT_Kd 114
+
+ // MakerGear
+ //#define DEFAULT_Kp 7.0
+ //#define DEFAULT_Ki 0.1
+ //#define DEFAULT_Kd 12
+
+ // Mendel Parts V9 on 12V
+ //#define DEFAULT_Kp 63.0
+ //#define DEFAULT_Ki 2.25
+ //#define DEFAULT_Kd 440
+
#endif // PIDTEMP
//===========================================================================
@@ -538,12 +539,18 @@
//#define MIN_BED_POWER 0
//#define PID_BED_DEBUG // Sends debug data to the serial port.
- // 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
- // from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
+ //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+ //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4
+ //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
+ //from pidautotune
+ //#define DEFAULT_bedKp 97.1
+ //#define DEFAULT_bedKi 1.41
+ //#define DEFAULT_bedKd 1675.16
+
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED
@@ -601,7 +608,7 @@
// @section machine
-// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics,
+// Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics
// either in the usual order or reversed
//#define COREXY
//#define COREXZ
@@ -609,7 +616,6 @@
//#define COREYX
//#define COREZX
//#define COREZY
-//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
//===========================================================================
//============================== Endstop Settings ===========================
@@ -860,6 +866,7 @@
* - For simple switches connect...
* - normally-closed switches to GND and D32.
* - normally-open switches to 5V and D32.
+ *
*/
//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
@@ -1571,6 +1578,7 @@
*
* Caveats: The ending Z should be the same as starting Z.
* Attention: EXPERIMENTAL. G-code arguments may change.
+ *
*/
//#define NOZZLE_CLEAN_FEATURE
@@ -1723,6 +1731,7 @@
*
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
+ *
*/
//#define SDSUPPORT
@@ -1959,14 +1968,6 @@
//
//#define FF_INTERFACEBOARD
-//
-// TFT GLCD Panel with Marlin UI
-// Panel connected to main board by SPI or I2C interface.
-// See https://github.com/Serhiy-K/TFTGLCDAdapter
-//
-//#define TFTGLCD_PANEL_SPI
-//#define TFTGLCD_PANEL_I2C
-
//=============================================================================
//======================= LCD / Controller Selection =======================
//========================= (Graphical LCDs) ========================
@@ -2170,9 +2171,6 @@
// Touch-screen LCD for Malyan M200/M300 printers
//
//#define MALYAN_LCD
-#if ENABLED(MALYAN_LCD)
- #define LCD_SERIAL_PORT 1 // Default is 1 for Malyan M200
-#endif
//
// Touch UI for FTDI EVE (FT800/FT810) displays
@@ -2186,7 +2184,7 @@
//#define ANYCUBIC_LCD_I3MEGA
//#define ANYCUBIC_LCD_CHIRON
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
- #define LCD_SERIAL_PORT 3 // Default is 3 for Anycubic
+ #define ANYCUBIC_LCD_SERIAL_PORT 3
//#define ANYCUBIC_LCD_DEBUG
#endif
@@ -2204,47 +2202,43 @@
//=============================== Graphical TFTs ==============================
//=============================================================================
-/**
- * TFT Type - Select your Display type
- *
- * Available options are:
- * MKS_TS35_V2_0,
- * MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35,
- * MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R
- * TFT_TRONXY_X5SA, ANYCUBIC_TFT35, LONGER_LK_TFT28
- * TFT_GENERIC
- *
- * For TFT_GENERIC, you need to configure these 3 options:
- * Driver: TFT_DRIVER
- * Current Drivers are: AUTO, ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
- * Resolution: TFT_WIDTH and TFT_HEIGHT
- * Interface: TFT_INTERFACE_FSMC or TFT_INTERFACE_SPI
- */
-//#define TFT_GENERIC
+//
+// TFT display with optional touch screen
+// Color Marlin UI with standard menu system
+//
+//#define TFT_320x240
+//#define TFT_320x240_SPI
+//#define TFT_480x320
+//#define TFT_480x320_SPI
-/**
- * TFT UI - User Interface Selection. Enable one of the following options:
- *
- * TFT_CLASSIC_UI - Emulated DOGM - 128x64 Upscaled
- * TFT_COLOR_UI - Marlin Default Menus, Touch Friendly, using full TFT capabilities
- * TFT_LVGL_UI - A Modern UI using LVGL
- *
- * For LVGL_UI also copy the 'assets' folder from the build directory to the
- * root of your SD card, together with the compiled firmware.
- */
-//#define TFT_CLASSIC_UI
-//#define TFT_COLOR_UI
-//#define TFT_LVGL_UI
+//
+// Skip autodetect and force specific TFT driver
+// Mandatory for SPI screens with no MISO line
+// Available drivers are: ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
+//
+//#define TFT_DRIVER AUTO
-/**
- * TFT Rotation. Set to one of the following values:
- *
- * TFT_ROTATE_90, TFT_ROTATE_90_MIRROR_X, TFT_ROTATE_90_MIRROR_Y,
- * TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y,
- * TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
- * TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
- */
-//#define TFT_ROTATION TFT_NO_ROTATION
+//
+// SPI display (MKS Robin Nano V2.0, MKS Gen L V2.0)
+// Upscaled 128x64 Marlin UI
+//
+//#define SPI_GRAPHICAL_TFT
+
+//
+// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
+// Upscaled 128x64 Marlin UI
+//
+//#define FSMC_GRAPHICAL_TFT
+
+//
+// TFT LVGL UI
+//
+// Using default MKS icons and fonts from: https://git.io/JJvzK
+// Just copy the 'assets' folder from the build directory to the
+// root of your SD card, together with the compiled firmware.
+//
+//#define TFT_LVGL_UI_FSMC // Robin nano v1.2 uses FSMC
+//#define TFT_LVGL_UI_SPI // Robin nano v2.0 uses SPI
//=============================================================================
//============================ Other Controllers ============================
@@ -2314,6 +2308,9 @@
// then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
//#define TEMP_STAT_LEDS
+// SkeinForge sends the wrong arc G-codes when using Arc Point as fillet procedure
+//#define SF_ARC_FIX
+
// Support for the BariCUDA Paste Extruder
//#define BARICUDA
@@ -2346,6 +2343,7 @@
* *** CAUTION ***
*
* LED Type. Enable only one of the following two options.
+ *
*/
//#define RGB_LED
//#define RGBW_LED
@@ -2399,12 +2397,17 @@
#define PRINTER_EVENT_LEDS
#endif
+/**
+ * R/C SERVO support
+ * Sponsored by TrinityLabs, Reworked by codexmas
+ */
+
/**
* Number of servos
*
* For some servo-related options NUM_SERVOS will be set automatically.
* Set this manually if there are extra servos needing manual control.
- * Set to 0 to turn off servo support.
+ * Leave undefined or set to 0 to entirely disable the servo subsystem.
*/
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
@@ -2416,5 +2419,5 @@
// Only power servos during movement, otherwise leave off to prevent jitter
//#define DEACTIVATE_SERVOS_AFTER_MOVE
-// Edit servo angles with M281 and save to EEPROM with M500
+// Allow servo angle to be edited and saved to EEPROM
//#define EDITABLE_SERVO_ANGLES
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index bcacddd20d..e4b3fbf2ae 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -29,13 +29,15 @@
* Some of these settings can damage your printer if improperly set!
*
* Basic settings can be found in Configuration.h
+ *
*/
-#define CONFIGURATION_ADV_H_VERSION 020007
+#define CONFIGURATION_ADV_H_VERSION 020006
+
+// @section temperature
//===========================================================================
//============================= Thermal Settings ============================
//===========================================================================
-// @section temperature
/**
* Thermocouple sensors are quite sensitive to noise. Any noise induced in
@@ -124,19 +126,9 @@
#define HEATER_BED_INVERTING true
#endif
-//
-// Heated Bed Bang-Bang options
-//
-#if DISABLED(PIDTEMPBED)
- #define BED_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control
- #if ENABLED(BED_LIMIT_SWITCHING)
- #define BED_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > BED_HYSTERESIS
- #endif
-#endif
-
-//
-// Heated Chamber options
-//
+/**
+ * Heated Chamber settings
+ */
#if TEMP_SENSOR_CHAMBER
#define CHAMBER_MINTEMP 5
#define CHAMBER_MAXTEMP 60
@@ -144,28 +136,12 @@
//#define CHAMBER_LIMIT_SWITCHING
//#define HEATER_CHAMBER_PIN 44 // Chamber heater on/off pin
//#define HEATER_CHAMBER_INVERTING false
+#endif
- //#define CHAMBER_FAN // Enable a fan on the chamber
- #if ENABLED(CHAMBER_FAN)
- #define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve.
- #if CHAMBER_FAN_MODE == 0
- #define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255)
- #elif CHAMBER_FAN_MODE == 1
- #define CHAMBER_FAN_BASE 128 // Base chamber fan PWM (0-255); turns on when chamber temperature is above the target
- #define CHAMBER_FAN_FACTOR 25 // PWM increase per °C above target
- #elif CHAMBER_FAN_MODE == 2
- #define CHAMBER_FAN_BASE 128 // Minimum chamber fan PWM (0-255)
- #define CHAMBER_FAN_FACTOR 25 // PWM increase per °C difference from target
- #endif
- #endif
-
- //#define CHAMBER_VENT // Enable a servo-controlled vent on the chamber
- #if ENABLED(CHAMBER_VENT)
- #define CHAMBER_VENT_SERVO_NR 1 // Index of the vent servo
- #define HIGH_EXCESS_HEAT_LIMIT 5 // How much above target temp to consider there is excess heat in the chamber
- #define LOW_EXCESS_HEAT_LIMIT 3
- #define MIN_COOLING_SLOPE_TIME_CHAMBER_VENT 20
- #define MIN_COOLING_SLOPE_DEG_CHAMBER_VENT 1.5
+#if DISABLED(PIDTEMPBED)
+ #define BED_CHECK_INTERVAL 5000 // ms between checks in bang-bang control
+ #if ENABLED(BED_LIMIT_SWITCHING)
+ #define BED_HYSTERESIS 2 // Only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
#endif
#endif
@@ -762,6 +738,7 @@
* | 4 3 | 1 4 | 2 1 | 3 2 |
* | | | | |
* | 1 2 | 2 3 | 3 4 | 4 1 |
+ *
*/
#ifndef Z_STEPPER_ALIGN_XY
//#define Z_STEPPERS_ORIENTATION 0
@@ -806,9 +783,8 @@
#define TRAMMING_POINT_NAME_3 "Back-Right"
#define TRAMMING_POINT_NAME_4 "Back-Left"
- #define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation
- //#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first
- //#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item for Assisted Tramming
+ // Enable to restore leveling setup after operation
+ #define RESTORE_LEVELING_AFTER_G35
/**
* Screw thread:
@@ -1073,14 +1049,6 @@
#if HAS_LCD_MENU
- // Add Probe Z Offset calibration to the Z Probe Offsets menu
- #if HAS_BED_PROBE
- //#define PROBE_OFFSET_WIZARD
- #if ENABLED(PROBE_OFFSET_WIZARD)
- #define PROBE_OFFSET_START -4.0 // Estimated nozzle-to-probe Z offset, plus a little extra
- #endif
- #endif
-
// Include a page of printer information in the LCD Main Menu
//#define LCD_INFO_MENU
#if ENABLED(LCD_INFO_MENU)
@@ -1137,26 +1105,23 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif
-#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
- //#define SHOW_REMAINING_TIME // Display estimated time to completion
+#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
+ //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
+ //#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
- //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
- //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
+ //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
+ //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
#endif
+#endif
- #if HAS_MARLINUI_U8GLIB
- //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
- #endif
-
- #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
- //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
- #if ENABLED(LCD_PROGRESS_BAR)
- #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
- #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
- #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
- //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
- //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
- #endif
+#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
+ //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
+ #if ENABLED(LCD_PROGRESS_BAR)
+ #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
+ #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
+ #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
+ //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
+ //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
#endif
#endif
@@ -1199,7 +1164,6 @@
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
- //#define POWER_LOSS_RECOVER_ZHOME // Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
@@ -1360,7 +1324,7 @@
* controller events, as there is a trade-off between reliable
* printing performance versus fast display updates.
*/
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
// Show SD percentage next to the progress bar
//#define DOGM_SD_PERCENT
@@ -1375,7 +1339,7 @@
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_BIG_EDIT_FONT
- // A smaller font may be used on the Info Screen. Costs 2434 bytes of PROGMEM.
+ // A smaller font may be used on the Info Screen. Costs 2300 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_SMALL_INFOFONT
@@ -1430,18 +1394,18 @@
//#define MARLIN_SNAKE
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
//
// Additional options for DGUS / DWIN displays
//
#if HAS_DGUS_LCD
- #define LCD_SERIAL_PORT 3
- #define LCD_BAUDRATE 115200
+ #define DGUS_SERIAL_PORT 3
+ #define DGUS_BAUDRATE 115200
#define DGUS_RX_BUFFER_SIZE 128
#define DGUS_TX_BUFFER_SIZE 48
- //#define SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
+ //#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
@@ -1560,9 +1524,10 @@
#endif
//
-// Classic UI Options
+// FSMC / SPI Graphical TFT
//
#if TFT_SCALED_DOGLCD
+ //#define GRAPHICAL_TFT_ROTATE_180
//#define TFT_MARLINUI_COLOR 0xFFFF // White
//#define TFT_MARLINBG_COLOR 0x0000 // Black
//#define TFT_DISABLED_COLOR 0x0003 // Almost black
@@ -1607,7 +1572,6 @@
#if ENABLED(BABYSTEPPING)
//#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
//#define BABYSTEP_WITHOUT_HOMING
- //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
#define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
//#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps
@@ -1618,6 +1582,7 @@
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
// Note: Extra time may be added to mitigate controller latency.
+ //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle.
#if ENABLED(MOVE_Z_WHEN_IDLE)
#define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size.
@@ -1800,7 +1765,6 @@
#define N_ARC_CORRECTION 25 // Number of interpolated segments between corrections
//#define ARC_P_CIRCLES // Enable the 'P' parameter to specify complete circles
//#define CNC_WORKSPACE_PLANES // Allow G2/G3 to operate in XY, ZX, or YZ planes
- //#define SF_ARC_FIX // Enable only if using SkeinForge with "Arc Point" fillet procedure
#endif
// Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes.
@@ -1986,6 +1950,7 @@
* Be sure to turn off auto-retract during filament change.
*
* Note that M207 / M208 / M209 settings are saved to EEPROM.
+ *
*/
//#define FWRETRACT
#if ENABLED(FWRETRACT)
@@ -2011,7 +1976,7 @@
* Universal tool change settings.
* Applies to all types of extruders except where explicitly noted.
*/
-#if HAS_MULTI_EXTRUDER
+#if EXTRUDERS > 1
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 2 // (mm)
//#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
@@ -2075,7 +2040,7 @@
//#define TOOLCHANGE_PARK_X_ONLY // X axis only move
//#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move
#endif
-#endif // HAS_MULTI_EXTRUDER
+#endif // EXTRUDERS > 1
/**
* Advanced Pause
@@ -2522,7 +2487,7 @@
#define E7_HYBRID_THRESHOLD 30
/**
- * Use StallGuard to home / probe X, Y, Z.
+ * Use StallGuard2 to home / probe X, Y, Z.
*
* TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
* Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
@@ -2543,8 +2508,6 @@
*
* IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
* homing and adds a guard period for endstop triggering.
- *
- * Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis.
*/
//#define SENSORLESS_HOMING // StallGuard capable drivers only
@@ -3264,7 +3227,6 @@
//#define HOST_ACTION_COMMANDS
#if ENABLED(HOST_ACTION_COMMANDS)
//#define HOST_PROMPT_SUPPORT
- //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
#endif
/**
@@ -3372,26 +3334,6 @@
#define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max
#define JOY_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
- //#define JOYSTICK_DEBUG
-#endif
-
-/**
- * Mechanical Gantry Calibration
- * Modern replacement for the Prusa TMC_Z_CALIBRATION.
- * Adds capability to work with any adjustable current drivers.
- * Implemented as G34 because M915 is deprecated.
- */
-//#define MECHANICAL_GANTRY_CALIBRATION
-#if ENABLED(MECHANICAL_GANTRY_CALIBRATION)
- #define GANTRY_CALIBRATION_CURRENT 600 // Default calibration current in ma
- #define GANTRY_CALIBRATION_EXTRA_HEIGHT 15 // Extra distance in mm past Z_###_POS to move
- #define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move
- //#define GANTRY_CALIBRATION_TO_MIN // Enable to calibrate Z in the MIN direction
-
- //#define GANTRY_CALIBRATION_SAFE_POSITION { X_CENTER, Y_CENTER } // Safe position for nozzle
- //#define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM
- //#define GANTRY_CALIBRATION_COMMANDS_PRE ""
- #define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position
#endif
/**
@@ -3469,10 +3411,10 @@
#if ENABLED(PRUSA_MMU2)
// Serial port used for communication with MMU2.
- // For AVR enable the UART port used for the MMU. (e.g., mmuSerial)
+ // For AVR enable the UART port used for the MMU. (e.g., internalSerial)
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
- #define MMU2_SERIAL_PORT 2
- #define MMU2_SERIAL mmuSerial
+ #define INTERNAL_SERIAL_PORT 2
+ #define MMU2_SERIAL internalSerial
// Use hardware reset for MMU if a pin is defined for it
//#define MMU2_RST_PIN 23
@@ -3523,7 +3465,7 @@
*/
//#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU_EXTRUDER_SENSOR)
- #define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail
+ #define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail
#endif
/**
@@ -3575,11 +3517,6 @@
//
//#define M100_FREE_MEMORY_WATCHER
-//
-// M42 - Set pin states
-//
-//#define DIRECT_PIN_CONTROL
-
//
// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
//
diff --git a/Marlin/Makefile b/Marlin/Makefile
index 49cb960b92..95135ab594 100644
--- a/Marlin/Makefile
+++ b/Marlin/Makefile
@@ -22,10 +22,8 @@
# (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
# changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*).
#
-# 3. Set the line containing "MCU" to match your board's processor. Set
-# "PROG_MCU" as the AVR part name corresponding to "MCU". You can use the
-# following command to get a list of correspondences: `avrdude -c alf -p x`
-# Older boards are atmega8 based, newer ones like Arduino Mini, Bluetooth
+# 3. Set the line containing "MCU" to match your board's processor.
+# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
# change F_CPU to 8000000. If you are using Gen7 electronics, you
# probably need to use 20000000. Either way, you must regenerate
@@ -36,18 +34,18 @@
# 5. Type "make upload", reset your Arduino board, and press enter to
# upload your program to the Arduino board.
#
-# Note that all settings at the top of this file can be overridden from
+# Note that all settings at the top of this file can be overriden from
# the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
#
# To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
#
# make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
-# HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino
+# HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino
#
# To compile and upload simply add "upload" to the end of the line...
#
# make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
-# HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino upload
+# HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino upload
#
# If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
# start upload manually (using stk500) like so:
@@ -59,26 +57,7 @@
#
# This defines the board to compile for (see boards.h for your board's ID)
-HARDWARE_MOTHERBOARD ?= 1020
-
-ifeq ($(OS),Windows_NT)
- # Windows
- ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
- ARDUINO_USER_DIR ?= ${HOME}/Arduino
-else
- UNAME_S := $(shell uname -s)
- ifeq ($(UNAME_S),Linux)
- # Linux
- ARDUINO_INSTALL_DIR ?= /usr/share/arduino
- ARDUINO_USER_DIR ?= ${HOME}/Arduino
- endif
- ifeq ($(UNAME_S),Darwin)
- # Darwin (macOS)
- ARDUINO_INSTALL_DIR ?= /Applications/Arduino.app/Contents/Java
- ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
- AVR_TOOLS_PATH ?= /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/
- endif
-endif
+HARDWARE_MOTHERBOARD ?= 11
# Arduino source install directory, and version number
# On most linuxes this will be /usr/share/arduino
@@ -88,38 +67,32 @@ ARDUINO_VERSION ?= 106
# The installed Libraries are in the User folder
ARDUINO_USER_DIR ?= ${HOME}/Arduino
-# You can optionally set a path to the avr-gcc tools.
-# Requires a trailing slash. For example, /usr/local/avr-gcc/bin/
+# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
AVR_TOOLS_PATH ?=
-# Programmer configuration
+#Programmer configuration
UPLOAD_RATE ?= 57600
AVRDUDE_PROGRAMMER ?= arduino
-# On most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
+# on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
UPLOAD_PORT ?= /dev/ttyUSB0
-# Directory used to build files in, contains all the build files, from object
-# files to the final hex file on linux it is best to put an absolute path
-# like /home/username/tmp .
+#Directory used to build files in, contains all the build files, from object files to the final hex file
+#on linux it is best to put an absolute path like /home/username/tmp .
BUILD_DIR ?= applet
# This defines whether Liquid_TWI2 support will be built
LIQUID_TWI2 ?= 0
-# This defines if Wire is needed
+# this defines if Wire is needed
WIRE ?= 0
-# This defines if Tone is needed (i.e SPEAKER is defined in Configuration.h)
-# Disabling this (and SPEAKER) saves approximatively 350 bytes of memory.
-TONE ?= 1
+# this defines if U8GLIB is needed (may require RELOC_WORKAROUND)
+U8GLIB ?= 1
-# This defines if U8GLIB is needed (may require RELOC_WORKAROUND)
-U8GLIB ?= 0
+# this defines whether to include the Trinamic TMCStepper library
+TMC ?= 1
-# This defines whether to include the Trinamic TMCStepper library
-TMC ?= 0
-
-# This defines whether to include the AdaFruit NeoPixel library
+# this defines whether to include the AdaFruit NeoPixel library
NEOPIXEL ?= 0
############
@@ -197,115 +170,110 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1100)
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
# Velleman K8400 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
-# Velleman K8600 Controller (Vertex Nano)
+# Velleman K8600 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
-# Velleman K8800 Controller (Vertex Delta)
-else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# 2PrintBeta BAM&DICE with STK drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1105)
+else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# 2PrintBeta BAM&DICE Due with STK drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1106)
+else ifeq ($(HARDWARE_MOTHERBOARD),1105)
# MKS BASE v1.0
-else ifeq ($(HARDWARE_MOTHERBOARD),1107)
+else ifeq ($(HARDWARE_MOTHERBOARD),1106)
# MKS v1.4 with A4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1108)
+else ifeq ($(HARDWARE_MOTHERBOARD),1107)
# MKS v1.5 with Allegro A4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1109)
+else ifeq ($(HARDWARE_MOTHERBOARD),1108)
# MKS v1.6 with Allegro A4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1110)
+else ifeq ($(HARDWARE_MOTHERBOARD),1109)
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),1111)
+else ifeq ($(HARDWARE_MOTHERBOARD),1110)
# MKS GEN v1.3 or 1.4
-else ifeq ($(HARDWARE_MOTHERBOARD),1112)
+else ifeq ($(HARDWARE_MOTHERBOARD),1111)
# MKS GEN L
-else ifeq ($(HARDWARE_MOTHERBOARD),1113)
+else ifeq ($(HARDWARE_MOTHERBOARD),1112)
# zrib V2.0 control board (Chinese knock off RAMPS replica)
-else ifeq ($(HARDWARE_MOTHERBOARD),1114)
+else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# BigTreeTech or BIQU KFB2.0
-else ifeq ($(HARDWARE_MOTHERBOARD),1115)
+else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# Felix 2.0+ Electronics Board (RAMPS like)
-else ifeq ($(HARDWARE_MOTHERBOARD),1116)
+else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# Invent-A-Part RigidBoard
-else ifeq ($(HARDWARE_MOTHERBOARD),1117)
+else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Invent-A-Part RigidBoard V2
-else ifeq ($(HARDWARE_MOTHERBOARD),1118)
+else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Sainsmart 2-in-1 board
-else ifeq ($(HARDWARE_MOTHERBOARD),1119)
+else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Ultimaker
-else ifeq ($(HARDWARE_MOTHERBOARD),1120)
+else ifeq ($(HARDWARE_MOTHERBOARD),1119)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
-else ifeq ($(HARDWARE_MOTHERBOARD),1121)
- MCU ?= atmega1280
- PROG_MCU ?= m1280
+else ifeq ($(HARDWARE_MOTHERBOARD),1120)
+ MCU ?= atmega1280
# Azteeg X3
-else ifeq ($(HARDWARE_MOTHERBOARD),1122)
+else ifeq ($(HARDWARE_MOTHERBOARD),1121)
# Azteeg X3 Pro
-else ifeq ($(HARDWARE_MOTHERBOARD),1123)
+else ifeq ($(HARDWARE_MOTHERBOARD),1122)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
-else ifeq ($(HARDWARE_MOTHERBOARD),1124)
+else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Rumba
-else ifeq ($(HARDWARE_MOTHERBOARD),1125)
+else ifeq ($(HARDWARE_MOTHERBOARD),1124)
# Raise3D Rumba
-else ifeq ($(HARDWARE_MOTHERBOARD),1126)
+else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Rapide Lite RL200 Rumba
-else ifeq ($(HARDWARE_MOTHERBOARD),1127)
+else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Formbot T-Rex 2 Plus
-else ifeq ($(HARDWARE_MOTHERBOARD),1128)
+else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Formbot T-Rex 3
-else ifeq ($(HARDWARE_MOTHERBOARD),1129)
+else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot Raptor
-else ifeq ($(HARDWARE_MOTHERBOARD),1130)
+else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# Formbot Raptor 2
-else ifeq ($(HARDWARE_MOTHERBOARD),1131)
+else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# bq ZUM Mega 3D
-else ifeq ($(HARDWARE_MOTHERBOARD),1132)
+else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
-else ifeq ($(HARDWARE_MOTHERBOARD),1133)
+else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
-else ifeq ($(HARDWARE_MOTHERBOARD),1134)
+else ifeq ($(HARDWARE_MOTHERBOARD),1133)
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
-else ifeq ($(HARDWARE_MOTHERBOARD),1135)
+else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# TriGorilla Anycubic version 1.4 Rev 1.1
-else ifeq ($(HARDWARE_MOTHERBOARD),1136)
+else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# Creality: Ender-4, CR-8
-else ifeq ($(HARDWARE_MOTHERBOARD),1137)
+else ifeq ($(HARDWARE_MOTHERBOARD),1136)
# Creality: CR10S, CR20, CR-X
-else ifeq ($(HARDWARE_MOTHERBOARD),1138)
+else ifeq ($(HARDWARE_MOTHERBOARD),1137)
# Dagoma F5
-else ifeq ($(HARDWARE_MOTHERBOARD),1139)
+else ifeq ($(HARDWARE_MOTHERBOARD),1138)
# FYSETC F6 1.3
-else ifeq ($(HARDWARE_MOTHERBOARD),1140)
+else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# FYSETC F6 1.5
-else ifeq ($(HARDWARE_MOTHERBOARD),1141)
+else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# Duplicator i3 Plus
-else ifeq ($(HARDWARE_MOTHERBOARD),1142)
+else ifeq ($(HARDWARE_MOTHERBOARD),1141)
# VORON
-else ifeq ($(HARDWARE_MOTHERBOARD),1143)
+else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# TRONXY V3 1.0
-else ifeq ($(HARDWARE_MOTHERBOARD),1144)
+else ifeq ($(HARDWARE_MOTHERBOARD),1143)
# Z-Bolt X Series
-else ifeq ($(HARDWARE_MOTHERBOARD),1145)
+else ifeq ($(HARDWARE_MOTHERBOARD),1144)
# TT OSCAR
-else ifeq ($(HARDWARE_MOTHERBOARD),1146)
+else ifeq ($(HARDWARE_MOTHERBOARD),1145)
# Overlord/Overlord Pro
-else ifeq ($(HARDWARE_MOTHERBOARD),1147)
+else ifeq ($(HARDWARE_MOTHERBOARD),1146)
# ADIMLab Gantry v1
-else ifeq ($(HARDWARE_MOTHERBOARD),1148)
+else ifeq ($(HARDWARE_MOTHERBOARD),1147)
# ADIMLab Gantry v2
-else ifeq ($(HARDWARE_MOTHERBOARD),1149)
+else ifeq ($(HARDWARE_MOTHERBOARD),1148)
# BIQU Tango V1
-else ifeq ($(HARDWARE_MOTHERBOARD),1150)
+else ifeq ($(HARDWARE_MOTHERBOARD),1149)
# MKS GEN L V2
-else ifeq ($(HARDWARE_MOTHERBOARD),1151)
-# MKS GEN L V2.1
-else ifeq ($(HARDWARE_MOTHERBOARD),1152)
+else ifeq ($(HARDWARE_MOTHERBOARD),1150)
# Copymaster 3D
-else ifeq ($(HARDWARE_MOTHERBOARD),1153)
+else ifeq ($(HARDWARE_MOTHERBOARD),1151)
# Ortur 4
-else ifeq ($(HARDWARE_MOTHERBOARD),1154)
+else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# Tenlog D3 Hero
-else ifeq ($(HARDWARE_MOTHERBOARD),1155)
+else ifeq ($(HARDWARE_MOTHERBOARD),1153)
#
# RAMBo and derivatives
@@ -378,11 +346,9 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1320)
# Minitronics v1.0/1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1400)
MCU ?= atmega1281
- PROG_MCU ?= m1281
# Silvergate v1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1401)
MCU ?= atmega1281
- PROG_MCU ?= m1281
#
# Sanguinololu and Derivatives - ATmega644P, ATmega1284P
@@ -392,57 +358,46 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1401)
else ifeq ($(HARDWARE_MOTHERBOARD),1500)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Sanguinololu 1.2 and above
else ifeq ($(HARDWARE_MOTHERBOARD),1501)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Melzi
else ifeq ($(HARDWARE_MOTHERBOARD),1502)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Melzi V2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1503)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Melzi with ATmega1284 (MaKr3d version)
else ifeq ($(HARDWARE_MOTHERBOARD),1504)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Melzi Creality3D board (for CR-10 etc)
else ifeq ($(HARDWARE_MOTHERBOARD),1505)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Melzi Malyan M150 board
else ifeq ($(HARDWARE_MOTHERBOARD),1506)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Tronxy X5S
else ifeq ($(HARDWARE_MOTHERBOARD),1507)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# STB V1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1508)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Azteeg X1
else ifeq ($(HARDWARE_MOTHERBOARD),1509)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
# Anet 1.0 (Melzi clone)
else ifeq ($(HARDWARE_MOTHERBOARD),1510)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
#
# Other ATmega644P, ATmega644, ATmega1284P
@@ -452,61 +407,50 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1510)
else ifeq ($(HARDWARE_MOTHERBOARD),1600)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Gen3+
else ifeq ($(HARDWARE_MOTHERBOARD),1601)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Gen6
else ifeq ($(HARDWARE_MOTHERBOARD),1602)
HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Gen6 deluxe
else ifeq ($(HARDWARE_MOTHERBOARD),1603)
HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Gen7 custom (Alfons3 Version)
else ifeq ($(HARDWARE_MOTHERBOARD),1604)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644
- PROG_MCU ?= m644
F_CPU ?= 20000000
# Gen7 v1.1, v1.2
else ifeq ($(HARDWARE_MOTHERBOARD),1605)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p
- PROG_MCU ?= m644p
F_CPU ?= 20000000
# Gen7 v1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1606)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p
- PROG_MCU ?= m644p
F_CPU ?= 20000000
# Gen7 v1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1607)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega1284p
- PROG_MCU ?= m1284p
F_CPU ?= 20000000
# Alpha OMCA board
else ifeq ($(HARDWARE_MOTHERBOARD),1608)
HARDWARE_VARIANT ?= SanguinoA
MCU ?= atmega644
- PROG_MCU ?= m644
# Final OMCA board
else ifeq ($(HARDWARE_MOTHERBOARD),1609)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
# Sethi 3D_1
else ifeq ($(HARDWARE_MOTHERBOARD),1610)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
- PROG_MCU ?= m644p
#
# Teensyduino - AT90USB1286, AT90USB1286P
@@ -516,60 +460,51 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1610)
else ifeq ($(HARDWARE_MOTHERBOARD),1700)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# Printrboard (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1701)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# Printrboard Revision F (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1702)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# Brainwave (AT90USB646)
else ifeq ($(HARDWARE_MOTHERBOARD),1703)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb646
- PROG_MCU ?= usb646
# Brainwave Pro (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1704)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# SAV Mk-I (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1705)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# Teensy++2.0 (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1706)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# 5DPrint D8 Driver Board
else ifeq ($(HARDWARE_MOTHERBOARD),1707)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
- PROG_MCU ?= usb1286
# UltiMachine Archim1 (with DRV8825 drivers)
else ifeq ($(HARDWARE_MOTHERBOARD),3023)
HARDWARE_VARIANT ?= archim
MCPU = cortex-m3
- F_CPU = 84000000
+ F_CPU = 84000000L
IS_MCU = 0
# UltiMachine Archim2 (with TMC2130 drivers)
else ifeq ($(HARDWARE_MOTHERBOARD),3024)
HARDWARE_VARIANT ?= archim
MCPU = cortex-m3
- F_CPU = 84000000
+ F_CPU = 84000000L
IS_MCU = 0
endif
# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
# if you are setting this to something other than 16MHz
-# Do not put the UL suffix, it's done later on.
# Set to 16Mhz if not yet set.
F_CPU ?= 16000000
@@ -579,8 +514,7 @@ IS_MCU ?= 1
ifeq ($(IS_MCU),1)
# Set to arduino, ATmega2560 if not yet set.
HARDWARE_VARIANT ?= arduino
- MCU ?= atmega2560
- PROG_MCU ?= m2560
+ MCU ?= atmega2560
TOOL_PREFIX = avr
MCU_FLAGS = -mmcu=$(MCU)
@@ -611,36 +545,27 @@ VPATH += $(BUILD_DIR)
VPATH += $(HARDWARE_SRC)
ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
- # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
- # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
+VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src
+VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI
endif
ifeq ($(IS_MCU),1)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
- # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial
- # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src
endif
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
-
ifeq ($(LIQUID_TWI2), 1)
- WIRE = 1
- VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
endif
ifeq ($(WIRE), 1)
- # Old libraries (avr-core 1.6.21 / Arduino < 1.6.8)
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility
- # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src
- VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src/utility
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
+VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
endif
ifeq ($(NEOPIXEL), 1)
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
@@ -712,23 +637,13 @@ ifeq ($(WIRE), 1)
LIB_CXXSRC += Wire.cpp
endif
-ifeq ($(TONE), 1)
- LIB_CXXSRC += Tone.cpp
-endif
-
ifeq ($(U8GLIB), 1)
LIB_CXXSRC += U8glib.cpp
- LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c \
- u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c \
- u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
+ LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
endif
ifeq ($(TMC), 1)
- LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp \
- CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp \
- DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp \
- SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp \
- TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
+ LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
endif
ifeq ($(RELOC_WORKAROUND), 1)
@@ -770,23 +685,17 @@ REMOVE = rm -f
MV = mv -f
# Place -D or -U options here
-CDEFS = -DF_CPU=$(F_CPU)UL ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
+CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
CXXDEFS = $(CDEFS)
ifeq ($(HARDWARE_VARIANT), Teensy)
- CDEFS += -DUSB_SERIAL
+ CDEFS += -DUSB_SERIAL
LIB_SRC += usb.c pins_teensy.c
LIB_CXXSRC += usb_api.cpp
else ifeq ($(HARDWARE_VARIANT), archim)
- CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__
- CDEFS += -DUSB_VID=0x27B1 -DUSB_PID=0x0001 -DUSBCON
- CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
-
- LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp \
- UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp \
- PluggableUSB.cpp USBCore.cpp
-
+ CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
+ LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
ifeq ($(U8GLIB), 1)
@@ -812,20 +721,16 @@ CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
ifneq ($(HARDWARE_MOTHERBOARD),)
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
endif
-
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD)
CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
ASFLAGS := $(CDEFS)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
ifeq ($(HARDWARE_VARIANT), archim)
LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
LD_SUFFIX = $(LDLIBS)
-
- LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty
- LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
+ LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
else
LD_PREFIX = -Wl,--gc-sections,--relax
LDFLAGS = -lm
@@ -841,7 +746,7 @@ else
AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
endif
AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
- -p$(PROG_MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
+ -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
-b$(UPLOAD_RATE)
# Since Marlin 2.0, the source files may be distributed into several
@@ -942,7 +847,7 @@ extcoff: $(TARGET).elf
.elf.eep:
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
- --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
.elf.lss:
@@ -956,7 +861,7 @@ extcoff: $(TARGET).elf
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
$(Pecho) " CXX $@"
- $P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
+ $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
# Object files that were found in "src" will be stored in $(BUILD_DIR)
# in directories that mirror the structure of "src"
diff --git a/Marlin/Version.h b/Marlin/Version.h
index 60e068ba35..5ce04b2903 100644
--- a/Marlin/Version.h
+++ b/Marlin/Version.h
@@ -28,7 +28,7 @@
/**
* Marlin release version identifier
*/
-//#define SHORT_BUILD_VERSION "2.0.7.2"
+//#define SHORT_BUILD_VERSION "2.0.6.1"
/**
* Verbose version identifier which should contain a reference to the location
diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h
index 6e0afa8f10..609375e386 100644
--- a/Marlin/src/HAL/AVR/HAL.h
+++ b/Marlin/src/HAL/AVR/HAL.h
@@ -15,7 +15,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
*/
#pragma once
@@ -25,7 +24,7 @@
#include "watchdog.h"
#include "math.h"
-#ifdef IS_AT90USB
+#ifdef USBCON
#include
#else
#define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
@@ -81,30 +80,55 @@ typedef int8_t pin_t;
//extern uint8_t MCUSR;
// Serial ports
-#ifdef IS_AT90USB
- #define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial)
+#ifdef USBCON
+ #if ENABLED(BLUETOOTH)
+ #define MYSERIAL0 bluetoothSerial
+ #else
+ #define MYSERIAL0 Serial
+ #endif
+ #define NUM_SERIAL 1
#else
#if !WITHIN(SERIAL_PORT, -1, 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. Please update your configuration."
+ #elif SERIAL_PORT_2 == SERIAL_PORT
+ #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif
#define MYSERIAL1 customizedSerial2
+ #define NUM_SERIAL 2
+ #else
+ #define NUM_SERIAL 1
#endif
#endif
-#ifdef LCD_SERIAL_PORT
- #if !WITHIN(LCD_SERIAL_PORT, -1, 3)
- #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+#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 LCD_SERIAL lcdSerial
- #if HAS_DGUS_LCD
- #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
+ #define DGUS_SERIAL internalDgusSerial
+
+ #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
+#endif
+
+#ifdef ANYCUBIC_LCD_SERIAL_PORT
+ #if !WITHIN(ANYCUBIC_LCD_SERIAL_PORT, -1, 3)
+ #error "ANYCUBIC_LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT
+ #error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
+ #elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2
+ #error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif
+ #define ANYCUBIC_LCD_SERIAL anycubicLcdSerial
#endif
// ------------------------
@@ -120,8 +144,6 @@ void HAL_init();
inline void HAL_clear_reset_source() { MCUSR = 0; }
inline uint8_t HAL_get_reset_source() { return MCUSR; }
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
extern "C" {
diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp
index 8feac32aa7..3d44a3f59f 100644
--- a/Marlin/src/HAL/AVR/MarlinSerial.cpp
+++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp
@@ -38,372 +38,409 @@
#include "../../inc/MarlinConfig.h"
-#if !IS_AT90USB && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
+#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
-#include "MarlinSerial.h"
-#include "../../MarlinCore.h"
-
-#if ENABLED(DIRECT_STEPPING)
- #include "../../feature/direct_stepping.h"
-#endif
-
-template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } };
-template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 };
-template bool MarlinSerial::_written = false;
-template uint8_t MarlinSerial::xon_xoff_state = MarlinSerial::XON_XOFF_CHAR_SENT | MarlinSerial::XON_CHAR;
-template uint8_t MarlinSerial::rx_dropped_bytes = 0;
-template uint8_t MarlinSerial::rx_buffer_overruns = 0;
-template uint8_t MarlinSerial::rx_framing_errors = 0;
-template typename MarlinSerial::ring_buffer_pos_t MarlinSerial::rx_max_enqueued = 0;
-
-// A SW memory barrier, to ensure GCC does not overoptimize loops
-#define sw_barrier() asm volatile("": : :"memory");
-
-#include "../../feature/e_parser.h"
-
-// "Atomically" read the RX head index value without disabling interrupts:
-// This MUST be called with RX interrupts enabled, and CAN'T be called
-// from the RX ISR itself!
-template
-FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_head() {
- if (Cfg::RX_SIZE > 256) {
- // Keep reading until 2 consecutive reads return the same value,
- // meaning there was no update in-between caused by an interrupt.
- // This works because serial RX interrupts happen at a slower rate
- // than successive reads of a variable, so 2 consecutive reads with
- // the same value means no interrupt updated it.
- ring_buffer_pos_t vold, vnew = rx_buffer.head;
- sw_barrier();
- do {
- vold = vnew;
- vnew = rx_buffer.head;
- sw_barrier();
- } while (vold != vnew);
- return vnew;
- }
- else {
- // With an 8bit index, reads are always atomic. No need for special handling
- return rx_buffer.head;
- }
-}
-
-template
-volatile bool MarlinSerial::rx_tail_value_not_stable = false;
-template
-volatile uint16_t MarlinSerial::rx_tail_value_backup = 0;
-
-// Set RX tail index, taking into account the RX ISR could interrupt
-// the write to this variable in the middle - So a backup strategy
-// is used to ensure reads of the correct values.
-// -Must NOT be called from the RX ISR -
-template
-FORCE_INLINE void MarlinSerial::atomic_set_rx_tail(typename MarlinSerial::ring_buffer_pos_t value) {
- if (Cfg::RX_SIZE > 256) {
- // Store the new value in the backup
- rx_tail_value_backup = value;
- sw_barrier();
- // Flag we are about to change the true value
- rx_tail_value_not_stable = true;
- sw_barrier();
- // Store the new value
- rx_buffer.tail = value;
- sw_barrier();
- // Signal the new value is completely stored into the value
- rx_tail_value_not_stable = false;
- sw_barrier();
- }
- else
- rx_buffer.tail = value;
-}
-
-// Get the RX tail index, taking into account the read could be
-// interrupting in the middle of the update of that index value
-// -Called from the RX ISR -
-template
-FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_tail() {
- if (Cfg::RX_SIZE > 256) {
- // If the true index is being modified, return the backup value
- if (rx_tail_value_not_stable) return rx_tail_value_backup;
- }
- // The true index is stable, return it
- return rx_buffer.tail;
-}
-
-// (called with RX interrupts disabled)
-template
-FORCE_INLINE void MarlinSerial::store_rxd_char() {
-
- static EmergencyParser::State emergency_state; // = EP_RESET
-
- // This must read the R_UCSRA register before reading the received byte to detect error causes
- if (Cfg::DROPPED_RX && B_DOR && !++rx_dropped_bytes) --rx_dropped_bytes;
- if (Cfg::RX_OVERRUNS && B_DOR && !++rx_buffer_overruns) --rx_buffer_overruns;
- if (Cfg::RX_FRAMING_ERRORS && B_FE && !++rx_framing_errors) --rx_framing_errors;
-
- // Read the character from the USART
- uint8_t c = R_UDR;
+ #include "MarlinSerial.h"
+ #include "../../MarlinCore.h"
#if ENABLED(DIRECT_STEPPING)
- if (page_manager.maybe_store_rxd_char(c)) return;
+ #include "../../feature/direct_stepping.h"
#endif
- // Get the tail - Nothing can alter its value while this ISR is executing, but there's
- // a chance that this ISR interrupted the main process while it was updating the index.
- // The backup mechanism ensures the correct value is always returned.
- const ring_buffer_pos_t t = atomic_read_rx_tail();
+ template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } };
+ template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 };
+ template bool MarlinSerial::_written = false;
+ template uint8_t MarlinSerial::xon_xoff_state = MarlinSerial::XON_XOFF_CHAR_SENT | MarlinSerial::XON_CHAR;
+ template uint8_t MarlinSerial::rx_dropped_bytes = 0;
+ template uint8_t MarlinSerial::rx_buffer_overruns = 0;
+ template uint8_t MarlinSerial::rx_framing_errors = 0;
+ template typename MarlinSerial::ring_buffer_pos_t MarlinSerial::rx_max_enqueued = 0;
- // Get the head pointer - This ISR is the only one that modifies its value, so it's safe to read here
- ring_buffer_pos_t h = rx_buffer.head;
+ // A SW memory barrier, to ensure GCC does not overoptimize loops
+ #define sw_barrier() asm volatile("": : :"memory");
- // Get the next element
- ring_buffer_pos_t i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+ #include "../../feature/e_parser.h"
- if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c);
-
- // If the character is to be stored at the index just before the tail
- // (such that the head would advance to the current tail), the RX FIFO is
- // full, so don't write the character or advance the head.
- if (i != t) {
- rx_buffer.buffer[h] = c;
- h = i;
- }
- else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
- --rx_dropped_bytes;
-
- if (Cfg::MAX_RX_QUEUED) {
- // Calculate count of bytes stored into the RX buffer
- const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
-
- // Keep track of the maximum count of enqueued bytes
- NOLESS(rx_max_enqueued, rx_count);
- }
-
- if (Cfg::XONOFF) {
- // If the last char that was sent was an XON
- if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XON_CHAR) {
-
- // Bytes stored into the RX buffer
- const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
-
- // If over 12.5% of RX buffer capacity, send XOFF before running out of
- // RX buffer space .. 325 bytes @ 250kbits/s needed to let the host react
- // and stop sending bytes. This translates to 13mS propagation time.
- if (rx_count >= (Cfg::RX_SIZE) / 8) {
-
- // At this point, definitely no TX interrupt was executing, since the TX ISR can't be preempted.
- // Don't enable the TX interrupt here as a means to trigger the XOFF char, because if it happens
- // to be in the middle of trying to disable the RX interrupt in the main program, eventually the
- // enabling of the TX interrupt could be undone. The ONLY reliable thing this can do to ensure
- // the sending of the XOFF char is to send it HERE AND NOW.
-
- // About to send the XOFF char
- xon_xoff_state = XOFF_CHAR | XON_XOFF_CHAR_SENT;
-
- // Wait until the TX register becomes empty and send it - Here there could be a problem
- // - While waiting for the TX register to empty, the RX register could receive a new
- // character. This must also handle that situation!
- while (!B_UDRE) {
-
- if (B_RXC) {
- // A char arrived while waiting for the TX buffer to be empty - Receive and process it!
-
- i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
-
- // Read the character from the USART
- c = R_UDR;
-
- if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c);
-
- // If the character is to be stored at the index just before the tail
- // (such that the head would advance to the current tail), the FIFO is
- // full, so don't write the character or advance the head.
- if (i != t) {
- rx_buffer.buffer[h] = c;
- h = i;
- }
- else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
- --rx_dropped_bytes;
- }
- sw_barrier();
- }
-
- R_UDR = XOFF_CHAR;
-
- // Clear the TXC bit -- "can be cleared by writing a one to its bit
- // location". This makes sure flush() won't return until the bytes
- // actually got written
- B_TXC = 1;
-
- // At this point there could be a race condition between the write() function
- // and this sending of the XOFF char. This interrupt could happen between the
- // wait to be empty TX buffer loop and the actual write of the character. Since
- // the TX buffer is full because it's sending the XOFF char, the only way to be
- // sure the write() function will succeed is to wait for the XOFF char to be
- // completely sent. Since an extra character could be received during the wait
- // it must also be handled!
- while (!B_UDRE) {
-
- if (B_RXC) {
- // A char arrived while waiting for the TX buffer to be empty - Receive and process it!
-
- i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
-
- // Read the character from the USART
- c = R_UDR;
-
- if (Cfg::EMERGENCYPARSER)
- emergency_parser.update(emergency_state, c);
-
- // If the character is to be stored at the index just before the tail
- // (such that the head would advance to the current tail), the FIFO is
- // full, so don't write the character or advance the head.
- if (i != t) {
- rx_buffer.buffer[h] = c;
- h = i;
- }
- else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
- --rx_dropped_bytes;
- }
- sw_barrier();
- }
-
- // At this point everything is ready. The write() function won't
- // have any issues writing to the UART TX register if it needs to!
- }
+ // "Atomically" read the RX head index value without disabling interrupts:
+ // This MUST be called with RX interrupts enabled, and CAN'T be called
+ // from the RX ISR itself!
+ template
+ FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_head() {
+ if (Cfg::RX_SIZE > 256) {
+ // Keep reading until 2 consecutive reads return the same value,
+ // meaning there was no update in-between caused by an interrupt.
+ // This works because serial RX interrupts happen at a slower rate
+ // than successive reads of a variable, so 2 consecutive reads with
+ // the same value means no interrupt updated it.
+ ring_buffer_pos_t vold, vnew = rx_buffer.head;
+ sw_barrier();
+ do {
+ vold = vnew;
+ vnew = rx_buffer.head;
+ sw_barrier();
+ } while (vold != vnew);
+ return vnew;
+ }
+ else {
+ // With an 8bit index, reads are always atomic. No need for special handling
+ return rx_buffer.head;
}
}
- // Store the new head value - The main loop will retry until the value is stable
- rx_buffer.head = h;
-}
+ template
+ volatile bool MarlinSerial::rx_tail_value_not_stable = false;
+ template
+ volatile uint16_t MarlinSerial::rx_tail_value_backup = 0;
-// (called with TX irqs disabled)
-template
-FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq() {
- if (Cfg::TX_SIZE > 0) {
- // Read positions
- uint8_t t = tx_buffer.tail;
- const uint8_t h = tx_buffer.head;
+ // Set RX tail index, taking into account the RX ISR could interrupt
+ // the write to this variable in the middle - So a backup strategy
+ // is used to ensure reads of the correct values.
+ // -Must NOT be called from the RX ISR -
+ template
+ FORCE_INLINE void MarlinSerial::atomic_set_rx_tail(typename MarlinSerial::ring_buffer_pos_t value) {
+ if (Cfg::RX_SIZE > 256) {
+ // Store the new value in the backup
+ rx_tail_value_backup = value;
+ sw_barrier();
+ // Flag we are about to change the true value
+ rx_tail_value_not_stable = true;
+ sw_barrier();
+ // Store the new value
+ rx_buffer.tail = value;
+ sw_barrier();
+ // Signal the new value is completely stored into the value
+ rx_tail_value_not_stable = false;
+ sw_barrier();
+ }
+ else
+ rx_buffer.tail = value;
+ }
+
+ // Get the RX tail index, taking into account the read could be
+ // interrupting in the middle of the update of that index value
+ // -Called from the RX ISR -
+ template
+ FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_tail() {
+ if (Cfg::RX_SIZE > 256) {
+ // If the true index is being modified, return the backup value
+ if (rx_tail_value_not_stable) return rx_tail_value_backup;
+ }
+ // The true index is stable, return it
+ return rx_buffer.tail;
+ }
+
+ // (called with RX interrupts disabled)
+ template
+ FORCE_INLINE void MarlinSerial::store_rxd_char() {
+
+ static EmergencyParser::State emergency_state; // = EP_RESET
+
+ // This must read the R_UCSRA register before reading the received byte to detect error causes
+ if (Cfg::DROPPED_RX && B_DOR && !++rx_dropped_bytes) --rx_dropped_bytes;
+ if (Cfg::RX_OVERRUNS && B_DOR && !++rx_buffer_overruns) --rx_buffer_overruns;
+ if (Cfg::RX_FRAMING_ERRORS && B_FE && !++rx_framing_errors) --rx_framing_errors;
+
+ // Read the character from the USART
+ uint8_t c = R_UDR;
+
+ #if ENABLED(DIRECT_STEPPING)
+ if (page_manager.maybe_store_rxd_char(c)) return;
+ #endif
+
+ // Get the tail - Nothing can alter its value while this ISR is executing, but there's
+ // a chance that this ISR interrupted the main process while it was updating the index.
+ // The backup mechanism ensures the correct value is always returned.
+ const ring_buffer_pos_t t = atomic_read_rx_tail();
+
+ // Get the head pointer - This ISR is the only one that modifies its value, so it's safe to read here
+ ring_buffer_pos_t h = rx_buffer.head;
+
+ // Get the next element
+ ring_buffer_pos_t i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+
+ if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c);
+
+ // If the character is to be stored at the index just before the tail
+ // (such that the head would advance to the current tail), the RX FIFO is
+ // full, so don't write the character or advance the head.
+ if (i != t) {
+ rx_buffer.buffer[h] = c;
+ h = i;
+ }
+ else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
+ --rx_dropped_bytes;
+
+ if (Cfg::MAX_RX_QUEUED) {
+ // Calculate count of bytes stored into the RX buffer
+ const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+
+ // Keep track of the maximum count of enqueued bytes
+ NOLESS(rx_max_enqueued, rx_count);
+ }
if (Cfg::XONOFF) {
- // If an XON char is pending to be sent, do it now
- if (xon_xoff_state == XON_CHAR) {
+ // If the last char that was sent was an XON
+ if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XON_CHAR) {
- // Send the character
- R_UDR = XON_CHAR;
+ // Bytes stored into the RX buffer
+ const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
- // clear the TXC bit -- "can be cleared by writing a one to its bit
- // location". This makes sure flush() won't return until the bytes
- // actually got written
- B_TXC = 1;
+ // If over 12.5% of RX buffer capacity, send XOFF before running out of
+ // RX buffer space .. 325 bytes @ 250kbits/s needed to let the host react
+ // and stop sending bytes. This translates to 13mS propagation time.
+ if (rx_count >= (Cfg::RX_SIZE) / 8) {
- // Remember we sent it.
- xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT;
+ // At this point, definitely no TX interrupt was executing, since the TX ISR can't be preempted.
+ // Don't enable the TX interrupt here as a means to trigger the XOFF char, because if it happens
+ // to be in the middle of trying to disable the RX interrupt in the main program, eventually the
+ // enabling of the TX interrupt could be undone. The ONLY reliable thing this can do to ensure
+ // the sending of the XOFF char is to send it HERE AND NOW.
- // If nothing else to transmit, just disable TX interrupts.
- if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
+ // About to send the XOFF char
+ xon_xoff_state = XOFF_CHAR | XON_XOFF_CHAR_SENT;
- return;
+ // Wait until the TX register becomes empty and send it - Here there could be a problem
+ // - While waiting for the TX register to empty, the RX register could receive a new
+ // character. This must also handle that situation!
+ while (!B_UDRE) {
+
+ if (B_RXC) {
+ // A char arrived while waiting for the TX buffer to be empty - Receive and process it!
+
+ i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+
+ // Read the character from the USART
+ c = R_UDR;
+
+ if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c);
+
+ // If the character is to be stored at the index just before the tail
+ // (such that the head would advance to the current tail), the FIFO is
+ // full, so don't write the character or advance the head.
+ if (i != t) {
+ rx_buffer.buffer[h] = c;
+ h = i;
+ }
+ else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
+ --rx_dropped_bytes;
+ }
+ sw_barrier();
+ }
+
+ R_UDR = XOFF_CHAR;
+
+ // Clear the TXC bit -- "can be cleared by writing a one to its bit
+ // location". This makes sure flush() won't return until the bytes
+ // actually got written
+ B_TXC = 1;
+
+ // At this point there could be a race condition between the write() function
+ // and this sending of the XOFF char. This interrupt could happen between the
+ // wait to be empty TX buffer loop and the actual write of the character. Since
+ // the TX buffer is full because it's sending the XOFF char, the only way to be
+ // sure the write() function will succeed is to wait for the XOFF char to be
+ // completely sent. Since an extra character could be received during the wait
+ // it must also be handled!
+ while (!B_UDRE) {
+
+ if (B_RXC) {
+ // A char arrived while waiting for the TX buffer to be empty - Receive and process it!
+
+ i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+
+ // Read the character from the USART
+ c = R_UDR;
+
+ if (Cfg::EMERGENCYPARSER)
+ emergency_parser.update(emergency_state, c);
+
+ // If the character is to be stored at the index just before the tail
+ // (such that the head would advance to the current tail), the FIFO is
+ // full, so don't write the character or advance the head.
+ if (i != t) {
+ rx_buffer.buffer[h] = c;
+ h = i;
+ }
+ else if (Cfg::DROPPED_RX && !++rx_dropped_bytes)
+ --rx_dropped_bytes;
+ }
+ sw_barrier();
+ }
+
+ // At this point everything is ready. The write() function won't
+ // have any issues writing to the UART TX register if it needs to!
+ }
}
}
- // If nothing to transmit, just disable TX interrupts. This could
- // happen as the result of the non atomicity of the disabling of RX
- // interrupts that could end reenabling TX interrupts as a side effect.
- if (h == t) {
- B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
- return;
+ // Store the new head value - The main loop will retry until the value is stable
+ rx_buffer.head = h;
+ }
+
+ // (called with TX irqs disabled)
+ template
+ FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq() {
+ if (Cfg::TX_SIZE > 0) {
+ // Read positions
+ uint8_t t = tx_buffer.tail;
+ const uint8_t h = tx_buffer.head;
+
+ if (Cfg::XONOFF) {
+ // If an XON char is pending to be sent, do it now
+ if (xon_xoff_state == XON_CHAR) {
+
+ // Send the character
+ R_UDR = XON_CHAR;
+
+ // clear the TXC bit -- "can be cleared by writing a one to its bit
+ // location". This makes sure flush() won't return until the bytes
+ // actually got written
+ B_TXC = 1;
+
+ // Remember we sent it.
+ xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT;
+
+ // If nothing else to transmit, just disable TX interrupts.
+ if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
+
+ return;
+ }
+ }
+
+ // If nothing to transmit, just disable TX interrupts. This could
+ // happen as the result of the non atomicity of the disabling of RX
+ // interrupts that could end reenabling TX interrupts as a side effect.
+ if (h == t) {
+ B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
+ return;
+ }
+
+ // There is something to TX, Send the next byte
+ const uint8_t c = tx_buffer.buffer[t];
+ t = (t + 1) & (Cfg::TX_SIZE - 1);
+ R_UDR = c;
+ tx_buffer.tail = t;
+
+ // Clear the TXC bit (by writing a one to its bit location).
+ // Ensures flush() won't return until the bytes are actually written/
+ B_TXC = 1;
+
+ // Disable interrupts if there is nothing to transmit following this byte
+ if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
+ }
+ }
+
+ // Public Methods
+ template
+ void MarlinSerial::begin(const long baud) {
+ uint16_t baud_setting;
+ bool useU2X = true;
+
+ #if F_CPU == 16000000UL && SERIAL_PORT == 0
+ // Hard-coded exception for compatibility with the bootloader shipped
+ // with the Duemilanove and previous boards, and the firmware on the
+ // 8U2 on the Uno and Mega 2560.
+ if (baud == 57600) useU2X = false;
+ #endif
+
+ R_UCSRA = 0;
+ if (useU2X) {
+ B_U2X = 1;
+ baud_setting = (F_CPU / 4 / baud - 1) / 2;
+ }
+ else
+ baud_setting = (F_CPU / 8 / baud - 1) / 2;
+
+ // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
+ R_UBRRH = baud_setting >> 8;
+ R_UBRRL = baud_setting;
+
+ B_RXEN = 1;
+ B_TXEN = 1;
+ B_RXCIE = 1;
+ if (Cfg::TX_SIZE > 0) B_UDRIE = 0;
+ _written = false;
+ }
+
+ template
+ void MarlinSerial::end() {
+ B_RXEN = 0;
+ B_TXEN = 0;
+ B_RXCIE = 0;
+ B_UDRIE = 0;
+ }
+
+ template
+ int MarlinSerial::peek() {
+ const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
+ return h == t ? -1 : rx_buffer.buffer[t];
+ }
+
+ template
+ int MarlinSerial::read() {
+ const ring_buffer_pos_t h = atomic_read_rx_head();
+
+ // Read the tail. Main thread owns it, so it is safe to directly read it
+ ring_buffer_pos_t t = rx_buffer.tail;
+
+ // If nothing to read, return now
+ if (h == t) return -1;
+
+ // Get the next char
+ const int v = rx_buffer.buffer[t];
+ t = (ring_buffer_pos_t)(t + 1) & (Cfg::RX_SIZE - 1);
+
+ // Advance tail - Making sure the RX ISR will always get an stable value, even
+ // if it interrupts the writing of the value of that variable in the middle.
+ atomic_set_rx_tail(t);
+
+ if (Cfg::XONOFF) {
+ // If the XOFF char was sent, or about to be sent...
+ if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) {
+ // Get count of bytes in the RX buffer
+ const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
+ if (rx_count < (Cfg::RX_SIZE) / 10) {
+ if (Cfg::TX_SIZE > 0) {
+ // Signal we want an XON character to be sent.
+ xon_xoff_state = XON_CHAR;
+ // Enable TX ISR. Non atomic, but it will eventually enable them
+ B_UDRIE = 1;
+ }
+ else {
+ // If not using TX interrupts, we must send the XON char now
+ xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT;
+ while (!B_UDRE) sw_barrier();
+ R_UDR = XON_CHAR;
+ }
+ }
+ }
}
- // There is something to TX, Send the next byte
- const uint8_t c = tx_buffer.buffer[t];
- t = (t + 1) & (Cfg::TX_SIZE - 1);
- R_UDR = c;
- tx_buffer.tail = t;
-
- // Clear the TXC bit (by writing a one to its bit location).
- // Ensures flush() won't return until the bytes are actually written/
- B_TXC = 1;
-
- // Disable interrupts if there is nothing to transmit following this byte
- if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
+ return v;
}
-}
-// Public Methods
-template
-void MarlinSerial::begin(const long baud) {
- uint16_t baud_setting;
- bool useU2X = true;
-
- #if F_CPU == 16000000UL && SERIAL_PORT == 0
- // Hard-coded exception for compatibility with the bootloader shipped
- // with the Duemilanove and previous boards, and the firmware on the
- // 8U2 on the Uno and Mega 2560.
- if (baud == 57600) useU2X = false;
- #endif
-
- R_UCSRA = 0;
- if (useU2X) {
- B_U2X = 1;
- baud_setting = (F_CPU / 4 / baud - 1) / 2;
+ template
+ typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available() {
+ const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
+ return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1);
}
- else
- baud_setting = (F_CPU / 8 / baud - 1) / 2;
- // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
- R_UBRRH = baud_setting >> 8;
- R_UBRRL = baud_setting;
+ template
+ void MarlinSerial::flush() {
- B_RXEN = 1;
- B_TXEN = 1;
- B_RXCIE = 1;
- if (Cfg::TX_SIZE > 0) B_UDRIE = 0;
- _written = false;
-}
+ // Set the tail to the head:
+ // - Read the RX head index in a safe way. (See atomic_read_rx_head.)
+ // - Set the tail, making sure the RX ISR will always get a stable value, even
+ // if it interrupts the writing of the value of that variable in the middle.
+ atomic_set_rx_tail(atomic_read_rx_head());
-template
-void MarlinSerial::end() {
- B_RXEN = 0;
- B_TXEN = 0;
- B_RXCIE = 0;
- B_UDRIE = 0;
-}
-
-template
-int MarlinSerial::peek() {
- const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
- return h == t ? -1 : rx_buffer.buffer[t];
-}
-
-template
-int MarlinSerial::read() {
- const ring_buffer_pos_t h = atomic_read_rx_head();
-
- // Read the tail. Main thread owns it, so it is safe to directly read it
- ring_buffer_pos_t t = rx_buffer.tail;
-
- // If nothing to read, return now
- if (h == t) return -1;
-
- // Get the next char
- const int v = rx_buffer.buffer[t];
- t = (ring_buffer_pos_t)(t + 1) & (Cfg::RX_SIZE - 1);
-
- // Advance tail - Making sure the RX ISR will always get an stable value, even
- // if it interrupts the writing of the value of that variable in the middle.
- atomic_set_rx_tail(t);
-
- if (Cfg::XONOFF) {
- // If the XOFF char was sent, or about to be sent...
- if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) {
- // Get count of bytes in the RX buffer
- const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1);
- if (rx_count < (Cfg::RX_SIZE) / 10) {
+ if (Cfg::XONOFF) {
+ // If the XOFF char was sent, or about to be sent...
+ if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) {
if (Cfg::TX_SIZE > 0) {
// Signal we want an XON character to be sent.
xon_xoff_state = XON_CHAR;
- // Enable TX ISR. Non atomic, but it will eventually enable them
+ // Enable TX ISR. Non atomic, but it will eventually enable it.
B_UDRIE = 1;
}
else {
@@ -416,386 +453,365 @@ int MarlinSerial::read() {
}
}
- return v;
-}
+ template
+ void MarlinSerial::write(const uint8_t c) {
+ if (Cfg::TX_SIZE == 0) {
-template
-typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available() {
- const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
- return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1);
-}
-
-template
-void MarlinSerial::flush() {
-
- // Set the tail to the head:
- // - Read the RX head index in a safe way. (See atomic_read_rx_head.)
- // - Set the tail, making sure the RX ISR will always get a stable value, even
- // if it interrupts the writing of the value of that variable in the middle.
- atomic_set_rx_tail(atomic_read_rx_head());
-
- if (Cfg::XONOFF) {
- // If the XOFF char was sent, or about to be sent...
- if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) {
- if (Cfg::TX_SIZE > 0) {
- // Signal we want an XON character to be sent.
- xon_xoff_state = XON_CHAR;
- // Enable TX ISR. Non atomic, but it will eventually enable it.
- B_UDRIE = 1;
- }
- else {
- // If not using TX interrupts, we must send the XON char now
- xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT;
- while (!B_UDRE) sw_barrier();
- R_UDR = XON_CHAR;
- }
- }
- }
-}
-
-template
-void MarlinSerial::write(const uint8_t c) {
- if (Cfg::TX_SIZE == 0) {
-
- _written = true;
- while (!B_UDRE) sw_barrier();
- R_UDR = c;
-
- }
- else {
-
- _written = true;
-
- // If the TX interrupts are disabled and the data register
- // is empty, just write the byte to the data register and
- // be done. This shortcut helps significantly improve the
- // effective datarate at high (>500kbit/s) bitrates, where
- // interrupt overhead becomes a slowdown.
- // Yes, there is a race condition between the sending of the
- // XOFF char at the RX ISR, but it is properly handled there
- if (!B_UDRIE && B_UDRE) {
+ _written = true;
+ while (!B_UDRE) sw_barrier();
R_UDR = c;
- // clear the TXC bit -- "can be cleared by writing a one to its bit
- // location". This makes sure flush() won't return until the bytes
- // actually got written
- B_TXC = 1;
- return;
- }
-
- const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
-
- // If global interrupts are disabled (as the result of being called from an ISR)...
- if (!ISRS_ENABLED()) {
-
- // Make room by polling if it is possible to transmit, and do so!
- while (i == tx_buffer.tail) {
-
- // If we can transmit another byte, do it.
- if (B_UDRE) _tx_udr_empty_irq();
-
- // Make sure compiler rereads tx_buffer.tail
- sw_barrier();
- }
}
else {
- // Interrupts are enabled, just wait until there is space
- while (i == tx_buffer.tail) sw_barrier();
- }
- // Store new char. head is always safe to move
- tx_buffer.buffer[tx_buffer.head] = c;
- tx_buffer.head = i;
+ _written = true;
- // Enable TX ISR - Non atomic, but it will eventually enable TX ISR
- B_UDRIE = 1;
- }
-}
+ // If the TX interrupts are disabled and the data register
+ // is empty, just write the byte to the data register and
+ // be done. This shortcut helps significantly improve the
+ // effective datarate at high (>500kbit/s) bitrates, where
+ // interrupt overhead becomes a slowdown.
+ // Yes, there is a race condition between the sending of the
+ // XOFF char at the RX ISR, but it is properly handled there
+ if (!B_UDRIE && B_UDRE) {
+ R_UDR = c;
-template
-void MarlinSerial::flushTX() {
-
- if (Cfg::TX_SIZE == 0) {
- // No bytes written, no need to flush. This special case is needed since there's
- // no way to force the TXC (transmit complete) bit to 1 during initialization.
- if (!_written) return;
-
- // Wait until everything was transmitted
- while (!B_TXC) sw_barrier();
-
- // At this point nothing is queued anymore (DRIE is disabled) and
- // the hardware finished transmission (TXC is set).
-
- }
- else {
-
- // No bytes written, no need to flush. This special case is needed since there's
- // no way to force the TXC (transmit complete) bit to 1 during initialization.
- if (!_written) return;
-
- // If global interrupts are disabled (as the result of being called from an ISR)...
- if (!ISRS_ENABLED()) {
-
- // Wait until everything was transmitted - We must do polling, as interrupts are disabled
- while (tx_buffer.head != tx_buffer.tail || !B_TXC) {
-
- // If there is more space, send an extra character
- if (B_UDRE) _tx_udr_empty_irq();
-
- sw_barrier();
+ // clear the TXC bit -- "can be cleared by writing a one to its bit
+ // location". This makes sure flush() won't return until the bytes
+ // actually got written
+ B_TXC = 1;
+ return;
}
+ const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
+
+ // If global interrupts are disabled (as the result of being called from an ISR)...
+ if (!ISRS_ENABLED()) {
+
+ // Make room by polling if it is possible to transmit, and do so!
+ while (i == tx_buffer.tail) {
+
+ // If we can transmit another byte, do it.
+ if (B_UDRE) _tx_udr_empty_irq();
+
+ // Make sure compiler rereads tx_buffer.tail
+ sw_barrier();
+ }
+ }
+ else {
+ // Interrupts are enabled, just wait until there is space
+ while (i == tx_buffer.tail) sw_barrier();
+ }
+
+ // Store new char. head is always safe to move
+ tx_buffer.buffer[tx_buffer.head] = c;
+ tx_buffer.head = i;
+
+ // Enable TX ISR - Non atomic, but it will eventually enable TX ISR
+ B_UDRIE = 1;
}
- else {
+ }
+
+ template
+ void MarlinSerial::flushTX() {
+
+ if (Cfg::TX_SIZE == 0) {
+ // No bytes written, no need to flush. This special case is needed since there's
+ // no way to force the TXC (transmit complete) bit to 1 during initialization.
+ if (!_written) return;
+
// Wait until everything was transmitted
- while (tx_buffer.head != tx_buffer.tail || !B_TXC) sw_barrier();
+ while (!B_TXC) sw_barrier();
+
+ // At this point nothing is queued anymore (DRIE is disabled) and
+ // the hardware finished transmission (TXC is set).
+
}
+ else {
- // At this point nothing is queued anymore (DRIE is disabled) and
- // the hardware finished transmission (TXC is set).
- }
-}
+ // No bytes written, no need to flush. This special case is needed since there's
+ // no way to force the TXC (transmit complete) bit to 1 during initialization.
+ if (!_written) return;
-/**
- * Imports from print.h
- */
+ // If global interrupts are disabled (as the result of being called from an ISR)...
+ if (!ISRS_ENABLED()) {
-template
-void MarlinSerial::print(char c, int base) {
- print((long)c, base);
-}
+ // Wait until everything was transmitted - We must do polling, as interrupts are disabled
+ while (tx_buffer.head != tx_buffer.tail || !B_TXC) {
-template
-void MarlinSerial::print(unsigned char b, int base) {
- print((unsigned long)b, base);
-}
+ // If there is more space, send an extra character
+ if (B_UDRE) _tx_udr_empty_irq();
-template
-void MarlinSerial::print(int n, int base) {
- print((long)n, base);
-}
+ sw_barrier();
+ }
-template
-void MarlinSerial::print(unsigned int n, int base) {
- print((unsigned long)n, base);
-}
+ }
+ else {
+ // Wait until everything was transmitted
+ while (tx_buffer.head != tx_buffer.tail || !B_TXC) sw_barrier();
+ }
-template
-void MarlinSerial::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);
-}
-
-template
-void MarlinSerial::print(unsigned long n, int base) {
- if (base == 0) write(n);
- else printNumber(n, base);
-}
-
-template
-void MarlinSerial::print(double n, int digits) {
- printFloat(n, digits);
-}
-
-template
-void MarlinSerial::println() {
- print('\r');
- print('\n');
-}
-
-template
-void MarlinSerial::println(const String& s) {
- print(s);
- println();
-}
-
-template
-void MarlinSerial::println(const char c[]) {
- print(c);
- println();
-}
-
-template
-void MarlinSerial::println(char c, int base) {
- print(c, base);
- println();
-}
-
-template
-void MarlinSerial::println(unsigned char b, int base) {
- print(b, base);
- println();
-}
-
-template
-void MarlinSerial::println(int n, int base) {
- print(n, base);
- println();
-}
-
-template
-void MarlinSerial::println(unsigned int n, int base) {
- print(n, base);
- println();
-}
-
-template
-void MarlinSerial::println(long n, int base) {
- print(n, base);
- println();
-}
-
-template
-void MarlinSerial::println(unsigned long n, int base) {
- print(n, base);
- println();
-}
-
-template
-void MarlinSerial::println(double n, int digits) {
- print(n, digits);
- println();
-}
-
-// Private Methods
-
-template
-void MarlinSerial::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');
-}
-
-template
-void MarlinSerial::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"
- double rounding = 0.5;
- LOOP_L_N(i, digits) rounding *= 0.1;
- number += rounding;
-
- // Extract the integer part of the number and print it
- unsigned long int_part = (unsigned long)number;
- double remainder = number - (double)int_part;
- print(int_part);
-
- // Print the decimal point, but only if there are digits beyond
- if (digits) {
- print('.');
- // Extract digits from the remainder one at a time
- while (digits--) {
- remainder *= 10.0;
- int toPrint = int(remainder);
- print(toPrint);
- remainder -= toPrint;
+ // At this point nothing is queued anymore (DRIE is disabled) and
+ // the hardware finished transmission (TXC is set).
}
}
-}
-// Hookup ISR handlers
-ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) {
- MarlinSerial>::store_rxd_char();
-}
+ /**
+ * Imports from print.h
+ */
-ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) {
- MarlinSerial>::_tx_udr_empty_irq();
-}
+ template
+ void MarlinSerial::print(char c, int base) {
+ print((long)c, base);
+ }
-// Preinstantiate
-template class MarlinSerial>;
+ template
+ void MarlinSerial::print(unsigned char b, int base) {
+ print((unsigned long)b, base);
+ }
-// Instantiate
-MarlinSerial> customizedSerial1;
+ template
+ void MarlinSerial::print(int n, int base) {
+ print((long)n, base);
+ }
-#ifdef SERIAL_PORT_2
+ template
+ void MarlinSerial::print(unsigned int n, int base) {
+ print((unsigned long)n, base);
+ }
+
+ template
+ void MarlinSerial::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);
+ }
+
+ template
+ void MarlinSerial::print(unsigned long n, int base) {
+ if (base == 0) write(n);
+ else printNumber(n, base);
+ }
+
+ template
+ void MarlinSerial::print(double n, int digits) {
+ printFloat(n, digits);
+ }
+
+ template
+ void MarlinSerial::println() {
+ print('\r');
+ print('\n');
+ }
+
+ template
+ void MarlinSerial::println(const String& s) {
+ print(s);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(const char c[]) {
+ print(c);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(char c, int base) {
+ print(c, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(unsigned char b, int base) {
+ print(b, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(int n, int base) {
+ print(n, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(unsigned int n, int base) {
+ print(n, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(long n, int base) {
+ print(n, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(unsigned long n, int base) {
+ print(n, base);
+ println();
+ }
+
+ template
+ void MarlinSerial::println(double n, int digits) {
+ print(n, digits);
+ println();
+ }
+
+ // Private Methods
+
+ template
+ void MarlinSerial::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');
+ }
+
+ template
+ void MarlinSerial::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"
+ double rounding = 0.5;
+ LOOP_L_N(i, digits) rounding *= 0.1;
+ number += rounding;
+
+ // Extract the integer part of the number and print it
+ unsigned long int_part = (unsigned long)number;
+ double remainder = number - (double)int_part;
+ print(int_part);
+
+ // Print the decimal point, but only if there are digits beyond
+ if (digits) {
+ print('.');
+ // Extract digits from the remainder one at a time
+ while (digits--) {
+ remainder *= 10.0;
+ int toPrint = int(remainder);
+ print(toPrint);
+ remainder -= toPrint;
+ }
+ }
+ }
// Hookup ISR handlers
- ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _RX_vect)) {
- MarlinSerial>::store_rxd_char();
+ ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)) {
+ MarlinSerial>::store_rxd_char();
}
- ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _UDRE_vect)) {
- MarlinSerial>::_tx_udr_empty_irq();
+ ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_UDRE_vect)) {
+ MarlinSerial>::_tx_udr_empty_irq();
}
// Preinstantiate
- template class MarlinSerial>;
+ template class MarlinSerial>;
// Instantiate
- MarlinSerial> customizedSerial2;
+ MarlinSerial> customizedSerial1;
-#endif
+ #ifdef SERIAL_PORT_2
-#ifdef MMU2_SERIAL_PORT
-
- ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _RX_vect)) {
- MarlinSerial>::store_rxd_char();
- }
-
- ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _UDRE_vect)) {
- MarlinSerial>::_tx_udr_empty_irq();
- }
-
- // Preinstantiate
- template class MarlinSerial>;
-
- // Instantiate
- MarlinSerial> mmuSerial;
-
-#endif
-
-#ifdef LCD_SERIAL_PORT
-
- ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _RX_vect)) {
- MarlinSerial>::store_rxd_char();
- }
-
- ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _UDRE_vect)) {
- MarlinSerial>::_tx_udr_empty_irq();
- }
-
- // Preinstantiate
- template class MarlinSerial>;
-
- // Instantiate
- MarlinSerial> lcdSerial;
-
- #if HAS_DGUS_LCD
- template
- typename MarlinSerial::ring_buffer_pos_t MarlinSerial::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;
+ // Hookup ISR handlers
+ ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_RX_vect)) {
+ MarlinSerial>::store_rxd_char();
}
+
+ ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_UDRE_vect)) {
+ MarlinSerial>::_tx_udr_empty_irq();
+ }
+
+ // Preinstantiate
+ template class MarlinSerial>;
+
+ // Instantiate
+ MarlinSerial> customizedSerial2;
+
#endif
+#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
+
+#ifdef INTERNAL_SERIAL_PORT
+
+ ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) {
+ MarlinSerial>::store_rxd_char();
+ }
+
+ ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) {
+ MarlinSerial>::_tx_udr_empty_irq();
+ }
+
+ // Preinstantiate
+ template class MarlinSerial>;
+
+ // Instantiate
+ MarlinSerial> internalSerial;
+
#endif
-#endif // !IS_AT90USB && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
+#ifdef DGUS_SERIAL_PORT
+
+ template
+ typename MarlinSerial::ring_buffer_pos_t MarlinSerial::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>::store_rxd_char();
+ }
+
+ ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) {
+ MarlinSerial>::_tx_udr_empty_irq();
+ }
+
+ // Preinstantiate
+ template class MarlinSerial>;
+
+ // Instantiate
+ MarlinSerial> internalDgusSerial;
+
+#endif
+
+#ifdef ANYCUBIC_LCD_SERIAL_PORT
+
+ ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_RX_vect)) {
+ MarlinSerial>::store_rxd_char();
+ }
+
+ ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_UDRE_vect)) {
+ MarlinSerial>::_tx_udr_empty_irq();
+ }
+
+ // Preinstantiate
+ template class MarlinSerial>;
+
+ // Instantiate
+ MarlinSerial> anycubicLcdSerial;
+
+#endif
// For AT90USB targets use the UART for BT interfacing
-#if BOTH(IS_AT90USB, BLUETOOTH)
+#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
#endif
diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h
index 3850e2a47e..e8bfc5583a 100644
--- a/Marlin/src/HAL/AVR/MarlinSerial.h
+++ b/Marlin/src/HAL/AVR/MarlinSerial.h
@@ -48,11 +48,11 @@
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
- #define SERIAL_REGNAME(registerbase,number,suffix) _SERIAL_REGNAME(registerbase,number,suffix)
+ #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
- #define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##suffix
+ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else
- #define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##number##suffix
+ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
// Registers used by MarlinSerial class (expanded depending on selected serial port)
@@ -217,12 +217,10 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
- #if HAS_DGUS_LCD
+ #ifdef DGUS_SERIAL_PORT
static ring_buffer_pos_t get_tx_buffer_free();
#endif
- static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
-
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; }
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
@@ -280,53 +278,58 @@
#endif // !USBCON
-#ifdef MMU2_SERIAL_PORT
+#ifdef INTERNAL_SERIAL_PORT
template
- struct MMU2SerialCfg {
+ struct MarlinInternalSerialCfg {
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_OVERRUNS = 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;
};
- extern MarlinSerial> mmuSerial;
+ extern MarlinSerial> internalSerial;
#endif
-#ifdef LCD_SERIAL_PORT
-
+#ifdef DGUS_SERIAL_PORT
template
- 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
+ struct MarlinInternalSerialCfg {
+ static constexpr int PORT = serial;
+ static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
+ static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
+ static constexpr bool XONOFF = false;
+ static constexpr bool EMERGENCYPARSER = false;
+ static constexpr bool DROPPED_RX = false;
+ static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
+ static constexpr bool RX_FRAMING_ERRORS = false;
+ static constexpr bool MAX_RX_QUEUED = false;
};
- extern MarlinSerial> lcdSerial;
+ extern MarlinSerial> internalDgusSerial;
+#endif
+#ifdef ANYCUBIC_LCD_SERIAL_PORT
+ template
+ struct AnycubicLcdSerialCfg {
+ static constexpr int PORT = serial;
+ static constexpr unsigned int RX_SIZE = 64;
+ static constexpr unsigned int TX_SIZE = 128;
+ static constexpr bool XONOFF = false;
+ static constexpr bool EMERGENCYPARSER = false;
+ static constexpr bool DROPPED_RX = false;
+ static constexpr bool RX_OVERRUNS = false;
+ static constexpr bool RX_FRAMING_ERRORS = false;
+ static constexpr bool MAX_RX_QUEUED = false;
+ };
+
+ extern MarlinSerial> anycubicLcdSerial;
#endif
// Use the UART for Bluetooth in AT90USB configurations
-#if BOTH(IS_AT90USB, BLUETOOTH)
+#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
#endif
diff --git a/Marlin/src/HAL/AVR/Servo.cpp b/Marlin/src/HAL/AVR/Servo.cpp
index 526352b773..66ed993c6f 100644
--- a/Marlin/src/HAL/AVR/Servo.cpp
+++ b/Marlin/src/HAL/AVR/Servo.cpp
@@ -48,6 +48,7 @@
* readMicroseconds() - Get the last-written servo pulse width in microseconds.
* attached() - Return true if a servo is attached.
* detach() - Stop an attached servo from pulsing its i/o pin.
+ *
*/
#ifdef __AVR__
diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp
index 238c1124ad..29866bccf9 100644
--- a/Marlin/src/HAL/AVR/fast_pwm.cpp
+++ b/Marlin/src/HAL/AVR/fast_pwm.cpp
@@ -185,8 +185,8 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
res_temp_phase_correct = rtf / 2;
}
- LIMIT(res_temp_fast, 1U, size);
- LIMIT(res_temp_phase_correct, 1U, size);
+ 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),
diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h
index dd01634661..bd6935aaf0 100644
--- a/Marlin/src/HAL/AVR/fastio.h
+++ b/Marlin/src/HAL/AVR/fastio.h
@@ -29,17 +29,11 @@
#include
-#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)
- #define AVR_AT90USB1286_FAMILY 1
-#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
- #define AVR_ATmega1284_FAMILY 1
-#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
- #define AVR_ATmega2560_FAMILY 1
-#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
- #define AVR_ATmega2561_FAMILY 1
-#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
- #define AVR_ATmega328_FAMILY 1
-#endif
+#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
+#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
+#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
+#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
+#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__))
/**
* Include Ports and Functions
diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h
index dac6b1b150..d73f520d14 100644
--- a/Marlin/src/HAL/AVR/pinsDebug.h
+++ b/Marlin/src/HAL/AVR/pinsDebug.h
@@ -26,9 +26,7 @@
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
-#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
- #define AVR_ATmega2560_FAMILY_PLUS_70 1
-#endif
+#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H)
#if AVR_AT90USB1286_FAMILY
diff --git a/Marlin/src/HAL/AVR/pinsDebug_plus_70.h b/Marlin/src/HAL/AVR/pinsDebug_plus_70.h
index db3fdf1f76..46c03088d2 100644
--- a/Marlin/src/HAL/AVR/pinsDebug_plus_70.h
+++ b/Marlin/src/HAL/AVR/pinsDebug_plus_70.h
@@ -22,12 +22,15 @@
* Structures for 2560 family boards that use more than 70 pins
*/
-#if MB(BQ_ZUM_MEGA_3D, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
- #undef NUM_DIGITAL_PINS
+#undef NUM_DIGITAL_PINS
+#if MB(BQ_ZUM_MEGA_3D)
#define NUM_DIGITAL_PINS 85
#elif MB(MIGHTYBOARD_REVE)
- #undef NUM_DIGITAL_PINS
#define NUM_DIGITAL_PINS 80
+#elif MB(MINIRAMBO)
+ #define NUM_DIGITAL_PINS 85
+#elif MB(SCOOVO_X9H)
+ #define NUM_DIGITAL_PINS 85
#endif
#define PA 1
diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h
index 82eb8b14b1..6c40d32209 100644
--- a/Marlin/src/HAL/AVR/timers.h
+++ b/Marlin/src/HAL/AVR/timers.h
@@ -15,7 +15,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
*/
#pragma once
diff --git a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp b/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp
index cb95a48ccc..c29b195578 100644
--- a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp
+++ b/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp
@@ -57,7 +57,7 @@
#include "../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include "../shared/Marduino.h"
#include "../shared/Delay.h"
@@ -189,5 +189,5 @@ uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp
index 6ce85a4643..4b9260c359 100644
--- a/Marlin/src/HAL/DUE/HAL.cpp
+++ b/Marlin/src/HAL/DUE/HAL.cpp
@@ -19,7 +19,9 @@
*/
/**
- * HAL for Arduino Due and compatible (SAM3X8E)
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
*/
#ifdef ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h
index 88ace59575..31409c76dd 100644
--- a/Marlin/src/HAL/DUE/HAL.h
+++ b/Marlin/src/HAL/DUE/HAL.h
@@ -22,7 +22,9 @@
#pragma once
/**
- * HAL for Arduino Due and compatible (SAM3X8E)
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
*/
#define CPU_32_BIT
@@ -36,36 +38,59 @@
#include
-#define _MSERIAL(X) Serial##X
-#define MSERIAL(X) _MSERIAL(X)
-#define Serial0 Serial
-
// Define MYSERIAL0/1 before MarlinSerial includes!
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
#define MYSERIAL0 customizedSerial1
-#elif WITHIN(SERIAL_PORT, 0, 3)
- #define MYSERIAL0 MSERIAL(SERIAL_PORT)
+#elif SERIAL_PORT == 0
+ #define MYSERIAL0 Serial
+#elif SERIAL_PORT == 1
+ #define MYSERIAL0 Serial1
+#elif SERIAL_PORT == 2
+ #define MYSERIAL0 Serial2
+#elif SERIAL_PORT == 3
+ #define MYSERIAL0 Serial3
#else
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
- #if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
+ #if SERIAL_PORT_2 == SERIAL_PORT
+ #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
+ #elif SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
#define MYSERIAL1 customizedSerial2
- #elif WITHIN(SERIAL_PORT_2, 0, 3)
- #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
+ #elif SERIAL_PORT_2 == 0
+ #define MYSERIAL1 Serial
+ #elif SERIAL_PORT_2 == 1
+ #define MYSERIAL1 Serial1
+ #elif SERIAL_PORT_2 == 2
+ #define MYSERIAL1 Serial2
+ #elif SERIAL_PORT_2 == 3
+ #define MYSERIAL1 Serial3
#else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif
+ #define NUM_SERIAL 2
+#else
+ #define NUM_SERIAL 1
#endif
-#ifdef LCD_SERIAL_PORT
- #if LCD_SERIAL_PORT == -1
- #define LCD_SERIAL lcdSerial
- #elif WITHIN(LCD_SERIAL_PORT, 0, 3)
- #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
+#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 "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
@@ -105,15 +130,13 @@ void sei(); // Enable interrupts
void HAL_clear_reset_source(); // clear reset reason
uint8_t HAL_get_reset_source(); // get reset reason
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
//
// ADC
//
extern uint16_t HAL_adc_result; // result of last ADC conversion
#ifndef analogInputToDigitalPin
- #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
+ #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
#endif
#define HAL_ANALOG_SELECT(ch)
diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp
index 0451d8bcc4..6d8f7ef819 100644
--- a/Marlin/src/HAL/DUE/HAL_SPI.cpp
+++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp
@@ -30,7 +30,7 @@
*/
/**
- * HAL for Arduino Due and compatible (SAM3X8E)
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
*
* For ARDUINO_ARCH_SAM
*/
@@ -595,7 +595,7 @@
SPI_Enable(SPI0);
SET_OUTPUT(DAC0_SYNC);
- #if HAS_MULTI_EXTRUDER
+ #if EXTRUDERS > 1
SET_OUTPUT(DAC1_SYNC);
WRITE(DAC1_SYNC, HIGH);
#endif
@@ -759,6 +759,7 @@
*
* 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)
diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h
index a194eba2f3..dfafa15141 100644
--- a/Marlin/src/HAL/DUE/MarlinSerial.h
+++ b/Marlin/src/HAL/DUE/MarlinSerial.h
@@ -122,8 +122,6 @@ public:
static void write(const uint8_t c);
static void flushTX();
- static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
-
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; }
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
index be4b49c0f9..2ef7011b1c 100644
--- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
@@ -52,13 +52,14 @@
* 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.
+ *
*/
#ifdef __SAM3X8E__
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include
@@ -144,6 +145,6 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
-#endif // __SAM3X8E__
+#endif //__SAM3X8E__
diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
index ea7204fa36..54c244d4f6 100644
--- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
@@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
+#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
#undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz
@@ -144,5 +144,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
+#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp
index 615a386c35..960df1bd86 100644
--- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp
@@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include "../../shared/Delay.h"
@@ -108,5 +108,5 @@ void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
}
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp
index 6f38da0967..d98f06039f 100644
--- a/Marlin/src/HAL/DUE/eeprom_flash.cpp
+++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp
@@ -53,6 +53,7 @@
* per page. We can't emulate EE endurance with FLASH for all
* bytes, but we can emulate endurance for a given percent of
* bytes.
+ *
*/
//#define EE_EMU_DEBUG
@@ -60,7 +61,7 @@
#define EEPROMSize 4096
#define PagesPerGroup 128
#define GroupCount 2
-#define PageSize 256U
+#define PageSize 256u
/* Flash storage */
typedef struct FLASH_SECTOR {
diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp
index d9fbabce21..1682faea66 100644
--- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp
+++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp
@@ -154,7 +154,7 @@ void Stepper::digipot_init() {
NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals)
}
-void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) {
+void Stepper::digipot_current(const uint8_t driver, const int16_t current) {
if (!(PWM->PWM_CH_NUM[0].PWM_CPRD == PWM_PERIOD_US)) digipot_init(); // Init PWM system if needed
diff --git a/Marlin/src/HAL/DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h
index a99ca8ecce..28687ff267 100644
--- a/Marlin/src/HAL/DUE/pinsDebug.h
+++ b/Marlin/src/HAL/DUE/pinsDebug.h
@@ -179,4 +179,5 @@ void pwm_details(int32_t pin) {
* ----------------+--------
* ID | PB11
* VBOF | PB10
+ *
*/
diff --git a/Marlin/src/HAL/DUE/timers.cpp b/Marlin/src/HAL/DUE/timers.cpp
index 9b937d1a7c..795cdad66a 100644
--- a/Marlin/src/HAL/DUE/timers.cpp
+++ b/Marlin/src/HAL/DUE/timers.cpp
@@ -21,7 +21,9 @@
*/
/**
- * HAL Timers for Arduino Due and compatible (SAM3X8E)
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
*/
#ifdef ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h
index 0e1ea07cc2..9defe39a0a 100644
--- a/Marlin/src/HAL/DUE/timers.h
+++ b/Marlin/src/HAL/DUE/timers.h
@@ -21,7 +21,9 @@
#pragma once
/**
- * HAL Timers for Arduino Due and compatible (SAM3X8E)
+ * HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
*/
#include
diff --git a/Marlin/src/HAL/DUE/upload_extra_script.py b/Marlin/src/HAL/DUE/upload_extra_script.py
index d52a0a3642..06c2b914f5 100644
--- a/Marlin/src/HAL/DUE/upload_extra_script.py
+++ b/Marlin/src/HAL/DUE/upload_extra_script.py
@@ -14,5 +14,5 @@ if current_OS == 'Windows':
# Use bossac.exe on Windows
env.Replace(
- UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE"
+ UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot"
)
diff --git a/Marlin/src/HAL/DUE/usb/compiler.h b/Marlin/src/HAL/DUE/usb/compiler.h
index f89e554c45..7b746543c4 100644
--- a/Marlin/src/HAL/DUE/usb/compiler.h
+++ b/Marlin/src/HAL/DUE/usb/compiler.h
@@ -173,11 +173,11 @@
# define __always_inline __forceinline
#elif (defined __GNUC__)
#ifdef __always_inline
-# undef __always_inline
+# undef __always_inline
#endif
-# define __always_inline inline __attribute__((__always_inline__))
+# define __always_inline inline __attribute__((__always_inline__))
#elif (defined __ICCARM__)
-# define __always_inline _Pragma("inline=forced")
+# define __always_inline _Pragma("inline=forced")
#endif
/**
@@ -188,11 +188,11 @@
* heuristics and not inline the function.
*/
#ifdef __CC_ARM
-# define __no_inline __attribute__((noinline))
+# define __no_inline __attribute__((noinline))
#elif (defined __GNUC__)
-# define __no_inline __attribute__((__noinline__))
+# define __no_inline __attribute__((__noinline__))
#elif (defined __ICCARM__)
-# define __no_inline _Pragma("inline=never")
+# define __no_inline _Pragma("inline=never")
#endif
/*! \brief This macro is used to test fatal errors.
@@ -211,9 +211,9 @@
# else
#undef TEST_SUITE_DEFINE_ASSERT_MACRO
# define Assert(expr) \
- {\
- if (!(expr)) while (true);\
- }
+ {\
+ if (!(expr)) while (true);\
+ }
# endif
#else
# define Assert(expr) ((void) 0)
@@ -609,37 +609,37 @@ typedef struct
# define clz(u) ((u) ? __CLZ(u) : 32)
#else
# define clz(u) (((u) == 0) ? 32 : \
- ((u) & (1UL << 31)) ? 0 : \
- ((u) & (1UL << 30)) ? 1 : \
- ((u) & (1UL << 29)) ? 2 : \
- ((u) & (1UL << 28)) ? 3 : \
- ((u) & (1UL << 27)) ? 4 : \
- ((u) & (1UL << 26)) ? 5 : \
- ((u) & (1UL << 25)) ? 6 : \
- ((u) & (1UL << 24)) ? 7 : \
- ((u) & (1UL << 23)) ? 8 : \
- ((u) & (1UL << 22)) ? 9 : \
- ((u) & (1UL << 21)) ? 10 : \
- ((u) & (1UL << 20)) ? 11 : \
- ((u) & (1UL << 19)) ? 12 : \
- ((u) & (1UL << 18)) ? 13 : \
- ((u) & (1UL << 17)) ? 14 : \
- ((u) & (1UL << 16)) ? 15 : \
- ((u) & (1UL << 15)) ? 16 : \
- ((u) & (1UL << 14)) ? 17 : \
- ((u) & (1UL << 13)) ? 18 : \
- ((u) & (1UL << 12)) ? 19 : \
- ((u) & (1UL << 11)) ? 20 : \
- ((u) & (1UL << 10)) ? 21 : \
- ((u) & (1UL << 9)) ? 22 : \
- ((u) & (1UL << 8)) ? 23 : \
- ((u) & (1UL << 7)) ? 24 : \
- ((u) & (1UL << 6)) ? 25 : \
- ((u) & (1UL << 5)) ? 26 : \
- ((u) & (1UL << 4)) ? 27 : \
- ((u) & (1UL << 3)) ? 28 : \
- ((u) & (1UL << 2)) ? 29 : \
- ((u) & (1UL << 1)) ? 30 : \
+ ((u) & (1ul << 31)) ? 0 : \
+ ((u) & (1ul << 30)) ? 1 : \
+ ((u) & (1ul << 29)) ? 2 : \
+ ((u) & (1ul << 28)) ? 3 : \
+ ((u) & (1ul << 27)) ? 4 : \
+ ((u) & (1ul << 26)) ? 5 : \
+ ((u) & (1ul << 25)) ? 6 : \
+ ((u) & (1ul << 24)) ? 7 : \
+ ((u) & (1ul << 23)) ? 8 : \
+ ((u) & (1ul << 22)) ? 9 : \
+ ((u) & (1ul << 21)) ? 10 : \
+ ((u) & (1ul << 20)) ? 11 : \
+ ((u) & (1ul << 19)) ? 12 : \
+ ((u) & (1ul << 18)) ? 13 : \
+ ((u) & (1ul << 17)) ? 14 : \
+ ((u) & (1ul << 16)) ? 15 : \
+ ((u) & (1ul << 15)) ? 16 : \
+ ((u) & (1ul << 14)) ? 17 : \
+ ((u) & (1ul << 13)) ? 18 : \
+ ((u) & (1ul << 12)) ? 19 : \
+ ((u) & (1ul << 11)) ? 20 : \
+ ((u) & (1ul << 10)) ? 21 : \
+ ((u) & (1ul << 9)) ? 22 : \
+ ((u) & (1ul << 8)) ? 23 : \
+ ((u) & (1ul << 7)) ? 24 : \
+ ((u) & (1ul << 6)) ? 25 : \
+ ((u) & (1ul << 5)) ? 26 : \
+ ((u) & (1ul << 4)) ? 27 : \
+ ((u) & (1ul << 3)) ? 28 : \
+ ((u) & (1ul << 2)) ? 29 : \
+ ((u) & (1ul << 1)) ? 30 : \
31)
#endif
#endif
@@ -654,38 +654,38 @@ typedef struct
#if (defined __GNUC__) || (defined __CC_ARM)
# define ctz(u) ((u) ? __builtin_ctz(u) : 32)
#else
-# define ctz(u) ((u) & (1UL << 0) ? 0 : \
- (u) & (1UL << 1) ? 1 : \
- (u) & (1UL << 2) ? 2 : \
- (u) & (1UL << 3) ? 3 : \
- (u) & (1UL << 4) ? 4 : \
- (u) & (1UL << 5) ? 5 : \
- (u) & (1UL << 6) ? 6 : \
- (u) & (1UL << 7) ? 7 : \
- (u) & (1UL << 8) ? 8 : \
- (u) & (1UL << 9) ? 9 : \
- (u) & (1UL << 10) ? 10 : \
- (u) & (1UL << 11) ? 11 : \
- (u) & (1UL << 12) ? 12 : \
- (u) & (1UL << 13) ? 13 : \
- (u) & (1UL << 14) ? 14 : \
- (u) & (1UL << 15) ? 15 : \
- (u) & (1UL << 16) ? 16 : \
- (u) & (1UL << 17) ? 17 : \
- (u) & (1UL << 18) ? 18 : \
- (u) & (1UL << 19) ? 19 : \
- (u) & (1UL << 20) ? 20 : \
- (u) & (1UL << 21) ? 21 : \
- (u) & (1UL << 22) ? 22 : \
- (u) & (1UL << 23) ? 23 : \
- (u) & (1UL << 24) ? 24 : \
- (u) & (1UL << 25) ? 25 : \
- (u) & (1UL << 26) ? 26 : \
- (u) & (1UL << 27) ? 27 : \
- (u) & (1UL << 28) ? 28 : \
- (u) & (1UL << 29) ? 29 : \
- (u) & (1UL << 30) ? 30 : \
- (u) & (1UL << 31) ? 31 : \
+# define ctz(u) ((u) & (1ul << 0) ? 0 : \
+ (u) & (1ul << 1) ? 1 : \
+ (u) & (1ul << 2) ? 2 : \
+ (u) & (1ul << 3) ? 3 : \
+ (u) & (1ul << 4) ? 4 : \
+ (u) & (1ul << 5) ? 5 : \
+ (u) & (1ul << 6) ? 6 : \
+ (u) & (1ul << 7) ? 7 : \
+ (u) & (1ul << 8) ? 8 : \
+ (u) & (1ul << 9) ? 9 : \
+ (u) & (1ul << 10) ? 10 : \
+ (u) & (1ul << 11) ? 11 : \
+ (u) & (1ul << 12) ? 12 : \
+ (u) & (1ul << 13) ? 13 : \
+ (u) & (1ul << 14) ? 14 : \
+ (u) & (1ul << 15) ? 15 : \
+ (u) & (1ul << 16) ? 16 : \
+ (u) & (1ul << 17) ? 17 : \
+ (u) & (1ul << 18) ? 18 : \
+ (u) & (1ul << 19) ? 19 : \
+ (u) & (1ul << 20) ? 20 : \
+ (u) & (1ul << 21) ? 21 : \
+ (u) & (1ul << 22) ? 22 : \
+ (u) & (1ul << 23) ? 23 : \
+ (u) & (1ul << 24) ? 24 : \
+ (u) & (1ul << 25) ? 25 : \
+ (u) & (1ul << 26) ? 26 : \
+ (u) & (1ul << 27) ? 27 : \
+ (u) & (1ul << 28) ? 28 : \
+ (u) & (1ul << 29) ? 29 : \
+ (u) & (1ul << 30) ? 30 : \
+ (u) & (1ul << 31) ? 31 : \
32)
#endif
#endif
@@ -1106,16 +1106,17 @@ static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data)
/* Converts a 8 Byte array into a 32-Bit value */
static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
{
- union
- {
- uint32_t u32;
- uint8_t u8[8];
- }long_addr;
- uint8_t index;
- for (index = 0; index < 4; index++) {
- long_addr.u8[index] = *data++;
- }
- return long_addr.u32;
+ union
+ {
+ uint32_t u32;
+ uint8_t u8[8];
+ }long_addr;
+ uint8_t index;
+ for (index = 0; index < 4; index++)
+ {
+ long_addr.u8[index] = *data++;
+ }
+ return long_addr.u32;
}
/**
diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h
index ebc16c9525..c91f9efff0 100644
--- a/Marlin/src/HAL/ESP32/HAL.h
+++ b/Marlin/src/HAL/ESP32/HAL.h
@@ -15,12 +15,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
*/
#pragma once
/**
- * HAL for Espressif ESP32 WiFi
+ * Description: HAL for Espressif ESP32 WiFi
*/
#define CPU_32_BIT
@@ -59,6 +58,9 @@ extern portMUX_TYPE spinlock;
#else
#define MYSERIAL1 webSocketSerial
#endif
+ #define NUM_SERIAL 2
+#else
+ #define NUM_SERIAL 1
#endif
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
@@ -96,8 +98,6 @@ void HAL_clear_reset_source();
// reset reason
uint8_t HAL_get_reset_source();
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
void _delay_ms(int delay);
#pragma GCC diagnostic push
@@ -157,14 +157,14 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
if (stop >= start) {
// no overflow, so only loop while in between start and stop:
- // 0x00000000 -----------------start****stop-- 0xFFFFFFFF
+ // 0x00000000 -----------------start****stop-- 0xffffffff
while (ccount >= start && ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
}
}
else {
// stop did overflow, so only loop while outside of stop and start:
- // 0x00000000 **stop-------------------start** 0xFFFFFFFF
+ // 0x00000000 **stop-------------------start** 0xffffffff
while (ccount >= start || ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
}
diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp
index ca7f47a1f8..533f873e4f 100644
--- a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp
+++ b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp
@@ -86,7 +86,7 @@ int RingBuffer::read() {
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++) {
+ for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
buffer[i] = data[read_index];
read_index = NEXT_INDEX(read_index, size);
}
@@ -139,8 +139,9 @@ size_t WebSocketSerial::write(const uint8_t c) {
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
size_t written = 0;
- for (size_t i = 0; i < size; i++)
+ for(size_t i = 0; i < size; i++) {
written += write(buffer[i]);
+ }
return written;
}
diff --git a/Marlin/src/HAL/ESP32/ota.h b/Marlin/src/HAL/ESP32/ota.h
index 546ace82db..7f9b237aa6 100644
--- a/Marlin/src/HAL/ESP32/ota.h
+++ b/Marlin/src/HAL/ESP32/ota.h
@@ -15,7 +15,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
*/
#pragma once
diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h
index 5eca2f7eac..c7b7531442 100644
--- a/Marlin/src/HAL/HAL.h
+++ b/Marlin/src/HAL/HAL.h
@@ -25,16 +25,10 @@
#include HAL_PATH(.,HAL.h)
-#ifdef SERIAL_PORT_2
- #define NUM_SERIAL 2
-#else
- #define NUM_SERIAL 1
-#endif
-
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
#ifndef I2C_ADDRESS
- #define I2C_ADDRESS(A) uint8_t(A)
+ #define I2C_ADDRESS(A) (A)
#endif
// Needed for AVR sprintf_P PROGMEM extension
diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h
index 2e545e03d6..96e121d915 100644
--- a/Marlin/src/HAL/LINUX/HAL.h
+++ b/Marlin/src/HAL/LINUX/HAL.h
@@ -62,6 +62,7 @@ uint8_t _getc();
extern HalSerial usb_serial;
#define MYSERIAL0 usb_serial
+#define NUM_SERIAL 1
#define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750)
@@ -101,8 +102,6 @@ uint16_t HAL_adc_get_result();
inline void HAL_clear_reset_source(void) {}
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
/* ---------------- Delay in cycles */
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
Clock::delayCycles(x);
diff --git a/Marlin/src/HAL/LINUX/include/serial.h b/Marlin/src/HAL/LINUX/include/serial.h
index e916249389..154e95aec2 100644
--- a/Marlin/src/HAL/LINUX/include/serial.h
+++ b/Marlin/src/HAL/LINUX/include/serial.h
@@ -33,6 +33,7 @@
* Generic RingBuffer
* T type of the buffer array
* S size of the buffer (must be power of 2)
+ *
*/
template class RingBuffer {
public:
@@ -78,7 +79,6 @@ public:
#if ENABLED(EMERGENCY_PARSER)
EmergencyParser::State emergency_state;
- static inline bool emergency_parser_enabled() { return true; }
#endif
HalSerial() { host_connected = true; }
diff --git a/Marlin/src/HAL/LINUX/main.cpp b/Marlin/src/HAL/LINUX/main.cpp
index 481f059030..4eeef318e7 100644
--- a/Marlin/src/HAL/LINUX/main.cpp
+++ b/Marlin/src/HAL/LINUX/main.cpp
@@ -107,7 +107,7 @@ int main() {
std::thread write_serial (write_serial_thread);
std::thread read_serial (read_serial_thread);
- #ifdef MYSERIAL0
+ #if NUM_SERIAL > 0
MYSERIAL0.begin(BAUDRATE);
SERIAL_ECHOLNPGM("x86_64 Initialized");
SERIAL_FLUSHTX();
diff --git a/Marlin/src/HAL/LINUX/servo_private.h b/Marlin/src/HAL/LINUX/servo_private.h
index bcc8d2037f..122cfef3ea 100644
--- a/Marlin/src/HAL/LINUX/servo_private.h
+++ b/Marlin/src/HAL/LINUX/servo_private.h
@@ -45,6 +45,7 @@
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
*
* The only modification was to update/delete macros to match the LPC176x.
+ *
*/
#include
diff --git a/Marlin/src/HAL/LINUX/spi_pins.h b/Marlin/src/HAL/LINUX/spi_pins.h
index 01ba28e5b6..a444196f04 100644
--- a/Marlin/src/HAL/LINUX/spi_pins.h
+++ b/Marlin/src/HAL/LINUX/spi_pins.h
@@ -24,7 +24,7 @@
#include "../../core/macros.h"
#include "../../inc/MarlinConfigPre.h"
-#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
+#if BOTH(HAS_GRAPHICAL_LCD, SDSUPPORT) && (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 required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h
index cb637e715d..0153bacf42 100644
--- a/Marlin/src/HAL/LPC1768/HAL.h
+++ b/Marlin/src/HAL/LPC1768/HAL.h
@@ -63,35 +63,58 @@ extern "C" volatile uint32_t _millis;
#define ST7920_DELAY_3 DELAY_NS(750)
#endif
-#define _MSERIAL(X) MSerial##X
-#define MSERIAL(X) _MSERIAL(X)
-#define MSerial0 MSerial
-
#if SERIAL_PORT == -1
#define MYSERIAL0 UsbSerial
-#elif WITHIN(SERIAL_PORT, 0, 3)
- #define MYSERIAL0 MSERIAL(SERIAL_PORT)
+#elif SERIAL_PORT == 0
+ #define MYSERIAL0 MSerial
+#elif SERIAL_PORT == 1
+ #define MYSERIAL0 MSerial1
+#elif SERIAL_PORT == 2
+ #define MYSERIAL0 MSerial2
+#elif SERIAL_PORT == 3
+ #define MYSERIAL0 MSerial3
#else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
- #if SERIAL_PORT_2 == -1
+ #if SERIAL_PORT_2 == SERIAL_PORT
+ #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
+ #elif SERIAL_PORT_2 == -1
#define MYSERIAL1 UsbSerial
- #elif WITHIN(SERIAL_PORT_2, 0, 3)
- #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
+ #elif SERIAL_PORT_2 == 0
+ #define MYSERIAL1 MSerial
+ #elif SERIAL_PORT_2 == 1
+ #define MYSERIAL1 MSerial1
+ #elif SERIAL_PORT_2 == 2
+ #define MYSERIAL1 MSerial2
+ #elif SERIAL_PORT_2 == 3
+ #define MYSERIAL1 MSerial3
#else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif
+ #define NUM_SERIAL 2
+#else
+ #define NUM_SERIAL 1
#endif
-#ifdef LCD_SERIAL_PORT
- #if LCD_SERIAL_PORT == -1
- #define LCD_SERIAL UsbSerial
- #elif WITHIN(LCD_SERIAL_PORT, 0, 3)
- #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
+#ifdef DGUS_SERIAL_PORT
+ #if 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."
+ #elif DGUS_SERIAL_PORT == -1
+ #define DGUS_SERIAL UsbSerial
+ #elif DGUS_SERIAL_PORT == 0
+ #define DGUS_SERIAL MSerial
+ #elif DGUS_SERIAL_PORT == 1
+ #define DGUS_SERIAL MSerial1
+ #elif DGUS_SERIAL_PORT == 2
+ #define DGUS_SERIAL MSerial2
+ #elif DGUS_SERIAL_PORT == 3
+ #define DGUS_SERIAL MSerial3
#else
- #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
@@ -200,8 +223,6 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255,
void HAL_clear_reset_source(void);
uint8_t HAL_get_reset_source(void);
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
// Add strcmp_P if missing
#ifndef strcmp_P
#define strcmp_P(a, b) strcmp((a), (b))
diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
index b3d2908ac9..00b4310d1d 100644
--- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
+++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
@@ -39,10 +39,10 @@
* Some of the LCD interfaces/adapters result in the LCD SPI and the SD card
* SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
- * active. If any of these pins are shared then the software SPI must be used.
+ * active. If any of these pins are shared then the software SPI must be used.
*
- * A more sophisticated hardware SPI can be found at the following link.
- * This implementation has not been fully debugged.
+ * A more sophisticated hardware SPI can be found at the following link. This
+ * implementation has not been fully debugged.
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
*/
@@ -100,25 +100,72 @@
#else
+ // decide which HW SPI device to use
+ #ifndef LPC_HW_SPI_DEV
+ #if (SCK_PIN == P0_07 && MISO_PIN == P0_08 && MOSI_PIN == P0_09)
+ #define LPC_HW_SPI_DEV 1
+ #else
+ #if (SCK_PIN == P0_15 && MISO_PIN == P0_17 && MOSI_PIN == P0_18)
+ #define LPC_HW_SPI_DEV 0
+ #else
+ #error "Invalid pins selected for hardware SPI"
+ #endif
+ #endif
+ #endif
+ #if LPC_HW_SPI_DEV == 0
+ #define LPC_SSPn LPC_SSP0
+ #else
+ #define LPC_SSPn LPC_SSP1
+ #endif
+
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
- spiInit(SPI_SPEED);
+ PINSEL_CFG_Type PinCfg; // data structure to hold init values
+ PinCfg.Funcnum = 2;
+ PinCfg.OpenDrain = 0;
+ PinCfg.Pinmode = 0;
+ PinCfg.Pinnum = LPC176x::pin_bit(SCK_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(SCK_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(SCK_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(MISO_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(MISO_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_INPUT(MISO_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(MOSI_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(MOSI_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(MOSI_PIN);
+ // divide PCLK by 2 for SSP0
+ CLKPWR_SetPCLKDiv(LPC_HW_SPI_DEV == 0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
+ spiInit(0);
+ SSP_Cmd(LPC_SSPn, ENABLE); // start SSP running
}
void spiInit(uint8_t spiRate) {
- #if MISO_PIN == BOARD_SPI1_MISO_PIN
- SPI.setModule(1);
- #elif MISO_PIN == BOARD_SPI2_MISO_PIN
- SPI.setModule(2);
- #endif
- SPI.setDataSize(DATA_SIZE_8BIT);
- SPI.setDataMode(SPI_MODE0);
-
- SPI.setClock(SPISettings::spiRate2Clock(spiRate));
- SPI.begin();
+ // table to convert Marlin spiRates (0-5 plus default) into bit rates
+ uint32_t Marlin_speed[7]; // CPSR is always 2
+ Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
+ Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
+ Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
+ Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
+ Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
+ Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
+ Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
+ // setup for SPI mode
+ SSP_CFG_Type HW_SPI_init; // data structure to hold init values
+ SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
+ HW_SPI_init.ClockRate = Marlin_speed[_MIN(spiRate, 6)]; // put in the specified bit rate
+ HW_SPI_init.Mode |= SSP_CR1_SSP_EN;
+ SSP_Init(LPC_SSPn, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
}
static uint8_t doio(uint8_t b) {
- return SPI.transfer(b & 0x00FF) & 0x00FF;
+ /* send and receive a single byte */
+ SSP_SendData(LPC_SSPn, b & 0x00FF);
+ while (SSP_GetStatus(LPC_SSPn, SSP_STAT_BUSY)); // wait for it to finish
+ return SSP_ReceiveData(LPC_SSPn) & 0x00FF;
}
void spiSend(uint8_t b) { doio(b); }
@@ -170,74 +217,63 @@ static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
}
-// Retain the pin init state of the SPI, to avoid init more than once,
-// even if more instances of SPIClass exist
-static bool spiInitialised[BOARD_NR_SPI] = { false };
-
SPIClass::SPIClass(uint8_t device) {
// Init things specific to each SPI device
// clock divider setup is a bit of hack, and needs to be improved at a later date.
+ PINSEL_CFG_Type PinCfg; // data structure to hold init values
#if BOARD_NR_SPI >= 1
_settings[0].spi_d = LPC_SSP0;
- _settings[0].dataMode = SPI_MODE0;
- _settings[0].dataSize = DATA_SIZE_8BIT;
- _settings[0].clock = SPI_CLOCK_MAX;
- //_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
+ // _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
+ PinCfg.Funcnum = 2;
+ PinCfg.OpenDrain = 0;
+ PinCfg.Pinmode = 0;
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_SCK_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_SCK_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(BOARD_SPI1_SCK_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MISO_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MISO_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_INPUT(BOARD_SPI1_MISO_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MOSI_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MOSI_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(BOARD_SPI1_MOSI_PIN);
#endif
#if BOARD_NR_SPI >= 2
_settings[1].spi_d = LPC_SSP1;
- _settings[1].dataMode = SPI_MODE0;
- _settings[1].dataSize = DATA_SIZE_8BIT;
- _settings[1].clock = SPI_CLOCK_MAX;
- //_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
+ // _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
+ PinCfg.Funcnum = 2;
+ PinCfg.OpenDrain = 0;
+ PinCfg.Pinmode = 0;
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_SCK_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_SCK_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(BOARD_SPI2_SCK_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MISO_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MISO_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_INPUT(BOARD_SPI2_MISO_PIN);
+
+ PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MOSI_PIN);
+ PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MOSI_PIN);
+ PINSEL_ConfigPin(&PinCfg);
+ SET_OUTPUT(BOARD_SPI2_MOSI_PIN);
#endif
setModule(device);
- // Init the GPDMA controller
- // TODO: call once in the constructor? or each time?
+ /* Initialize GPDMA controller */
+ //TODO: call once in the constructor? or each time?
GPDMA_Init();
}
void SPIClass::begin() {
- // Init the SPI pins in the first begin call
- if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
- (_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) {
- pin_t sck, miso, mosi;
- if (_currentSetting->spi_d == LPC_SSP0) {
- sck = BOARD_SPI1_SCK_PIN;
- miso = BOARD_SPI1_MISO_PIN;
- mosi = BOARD_SPI1_MOSI_PIN;
- spiInitialised[0] = true;
- }
- else if (_currentSetting->spi_d == LPC_SSP1) {
- sck = BOARD_SPI2_SCK_PIN;
- miso = BOARD_SPI2_MISO_PIN;
- mosi = BOARD_SPI2_MOSI_PIN;
- spiInitialised[1] = true;
- }
- PINSEL_CFG_Type PinCfg; // data structure to hold init values
- PinCfg.Funcnum = 2;
- PinCfg.OpenDrain = 0;
- PinCfg.Pinmode = 0;
- PinCfg.Pinnum = LPC176x::pin_bit(sck);
- PinCfg.Portnum = LPC176x::pin_port(sck);
- PINSEL_ConfigPin(&PinCfg);
- SET_OUTPUT(sck);
-
- PinCfg.Pinnum = LPC176x::pin_bit(miso);
- PinCfg.Portnum = LPC176x::pin_port(miso);
- PINSEL_ConfigPin(&PinCfg);
- SET_INPUT(miso);
-
- PinCfg.Pinnum = LPC176x::pin_bit(mosi);
- PinCfg.Portnum = LPC176x::pin_port(mosi);
- PINSEL_ConfigPin(&PinCfg);
- SET_OUTPUT(mosi);
- }
-
updateSettings();
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
}
@@ -251,7 +287,7 @@ void SPIClass::beginTransaction(const SPISettings &cfg) {
}
uint8_t SPIClass::transfer(const uint16_t b) {
- // Send and receive a single byte
+ /* send and receive a single byte */
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
SSP_SendData(_currentSetting->spi_d, b);
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
@@ -259,7 +295,8 @@ uint8_t SPIClass::transfer(const uint16_t b) {
}
uint16_t SPIClass::transfer16(const uint16_t data) {
- return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
+ return (transfer((data >> 8) & 0xFF) << 8)
+ | (transfer(data & 0xFF) & 0xFF);
}
void SPIClass::end() {
@@ -283,7 +320,7 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
// Destination memory - Not used
GPDMACfg.DstMemAddr = 0;
// Transfer size
- GPDMACfg.TransferSize = length;
+ GPDMACfg.TransferSize = (minc ? length : 1);
// Transfer width
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
// Transfer type
@@ -298,24 +335,26 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
// Enable dma on SPI
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
- // Only increase memory if minc is true
- GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
+ // if minc=false, I'm repeating the same byte 'length' times, as I could not find yet how do GPDMA without memory increment
+ do {
+ // Setup channel with given parameter
+ GPDMA_Setup(&GPDMACfg);
- // Setup channel with given parameter
- GPDMA_Setup(&GPDMACfg);
+ // enabled dma
+ GPDMA_ChannelCmd(0, ENABLE);
- // Enable DMA
- GPDMA_ChannelCmd(0, ENABLE);
+ // wait data transfer
+ while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) { }
- // Wait for data transfer
- while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
+ // clear err and int
+ GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
+ GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
- // Clear err and int
- GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
- GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
+ // dma disable
+ GPDMA_ChannelCmd(0, DISABLE);
- // Disable DMA
- GPDMA_ChannelCmd(0, DISABLE);
+ --length;
+ } while (!minc && length > 0);
waitSpiTxEnd(_currentSetting->spi_d);
@@ -343,7 +382,7 @@ void SPIClass::setBitOrder(uint8_t bitOrder) {
}
void SPIClass::setDataMode(uint8_t dataMode) {
- _currentSetting->dataMode = dataMode;
+ _currentSetting->dataSize = dataMode;
}
void SPIClass::setDataSize(uint32_t ds) {
@@ -374,19 +413,19 @@ void SPIClass::updateSettings() {
switch (_currentSetting->dataMode) {
case SPI_MODE0:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
- HW_SPI_init.CPOL = SSP_CPOL_HI;
+ HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE1:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
- HW_SPI_init.CPOL = SSP_CPOL_HI;
+ HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE2:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
- HW_SPI_init.CPOL = SSP_CPOL_LO;
+ HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
case SPI_MODE3:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
- HW_SPI_init.CPOL = SSP_CPOL_LO;
+ HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
default:
break;
diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp
index 5374e005d3..c3fb3bd0e4 100644
--- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp
+++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp
@@ -24,28 +24,28 @@
#include "../../inc/MarlinConfigPre.h"
#include "MarlinSerial.h"
-#if USING_SERIAL_0
+#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
MarlinSerial MSerial(LPC_UART0);
extern "C" void UART0_IRQHandler() {
MSerial.IRQHandler();
}
#endif
-#if USING_SERIAL_1
+#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
extern "C" void UART1_IRQHandler() {
MSerial1.IRQHandler();
}
#endif
-#if USING_SERIAL_2
+#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
MarlinSerial MSerial2(LPC_UART2);
extern "C" void UART2_IRQHandler() {
MSerial2.IRQHandler();
}
#endif
-#if USING_SERIAL_3
+#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
MarlinSerial MSerial3(LPC_UART3);
extern "C" void UART3_IRQHandler() {
MSerial3.IRQHandler();
diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.h b/Marlin/src/HAL/LPC1768/MarlinSerial.h
index 8d6b64378a..98ce73d377 100644
--- a/Marlin/src/HAL/LPC1768/MarlinSerial.h
+++ b/Marlin/src/HAL/LPC1768/MarlinSerial.h
@@ -57,7 +57,6 @@ public:
}
EmergencyParser::State emergency_state;
- static inline bool emergency_parser_enabled() { return true; }
#endif
};
diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h
index eb12fd20f4..e953cb9204 100644
--- a/Marlin/src/HAL/LPC1768/Servo.h
+++ b/Marlin/src/HAL/LPC1768/Servo.h
@@ -46,6 +46,7 @@
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
*
* The only modification was to update/delete macros to match the LPC176x.
+ *
*/
#include
diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h
index 32ef908d63..b9bc0bf82e 100644
--- a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h
+++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h
@@ -24,3 +24,10 @@
#if HAS_FSMC_TFT
#error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768."
#endif
+
+// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
+#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
+ #undef TOUCH_SCREEN
+ #undef TOUCH_SCREEN_CALIBRATION
+ #define HAS_TOUCH_XPT2046 1
+#endif
diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h
index f5051d32a1..0a4e59c6c4 100644
--- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h
+++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h
@@ -24,7 +24,7 @@
#if PIO_PLATFORM_VERSION < 1001
#error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
#endif
-#if PIO_FRAMEWORK_VERSION < 2005
+#if PIO_FRAMEWORK_VERSION < 2002
#error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
#endif
@@ -89,10 +89,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
* Serial2 | P0_10 | P0_11 |
* Serial3 | P0_00 | P0_01 |
*/
-#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
-#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
-
-#if USING_SERIAL_0
+#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
#define IS_TX0(P) (P == P0_02)
#define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
@@ -106,67 +103,60 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#undef IS_RX0
#endif
-#if USING_SERIAL_1
+#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
#define IS_TX1(P) (P == P0_15)
#define IS_RX1(P) (P == P0_16)
- #define _IS_TX1_1 IS_TX1
- #define _IS_RX1_1 IS_RX1
#if IS_TX1(TMC_SW_SCK)
#error "Serial port pins (1) conflict with other pins!"
- #elif HAS_WIRED_LCD
+ #elif HAS_SPI_LCD
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
#error "Serial port pins (1) conflict with Encoder Buttons!"
- #elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
- || ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
+ #elif IS_TX1(SCK_PIN) || IS_TX1(LCD_PINS_D4) || IS_TX1(DOGLCD_SCK) || IS_TX1(LCD_RESET_PIN) || IS_TX1(LCD_PINS_RS) || IS_TX1(SHIFT_CLK) \
+ || IS_RX1(LCD_SDSS) || IS_RX1(LCD_PINS_RS) || IS_RX1(MISO_PIN) || IS_RX1(DOGLCD_A0) || IS_RX1(SS_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(DOGLCD_CS) || IS_RX1(LCD_RESET_PIN) || IS_RX1(LCD_BACKLIGHT_PIN)
#error "Serial port pins (1) conflict with LCD pins!"
#endif
#endif
#undef IS_TX1
#undef IS_RX1
- #undef _IS_TX1_1
- #undef _IS_RX1_1
#endif
-#if USING_SERIAL_2
+#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
#define IS_TX2(P) (P == P0_10)
#define IS_RX2(P) (P == P0_11)
- #define _IS_TX2_1 IS_TX2
- #define _IS_RX2_1 IS_RX2
- #if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
+ #if IS_TX2(X2_ENABLE_PIN) || IS_RX2(X2_DIR_PIN) || IS_RX2(X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
#error "Serial port pins (2) conflict with X2 pins!"
- #elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
+ #elif IS_TX2(Y2_ENABLE_PIN) || IS_RX2(Y2_DIR_PIN) || IS_RX2(Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
#error "Serial port pins (2) conflict with Y2 pins!"
- #elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
+ #elif IS_TX2(Z2_ENABLE_PIN) || IS_RX2(Z2_DIR_PIN) || IS_RX2(Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
#error "Serial port pins (2) conflict with Z2 pins!"
- #elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
+ #elif IS_TX2(Z3_ENABLE_PIN) || IS_RX2(Z3_DIR_PIN) || IS_RX2(Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
#error "Serial port pins (2) conflict with Z3 pins!"
- #elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
+ #elif IS_TX2(Z4_ENABLE_PIN) || IS_RX2(Z4_DIR_PIN) || IS_RX2(Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
#error "Serial port pins (2) conflict with Z4 pins!"
- #elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
+ #elif IS_RX2(X_DIR_PIN) || IS_RX2(Y_DIR_PIN)
#error "Serial port pins (2) conflict with other pins!"
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
#error "Serial port pins (2) conflict with Y endstop pin!"
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
#error "Serial port pins (2) conflict with probe pin!"
- #elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
+ #elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN)
#error "Serial port pins (2) conflict with X/Y stepper pins!"
- #elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
+ #elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
#error "Serial port pins (2) conflict with E1 stepper pins!"
- #elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN)
+ #elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN))
#error "Serial port pins (2) conflict with E stepper pins!"
#endif
#undef IS_TX2
#undef IS_RX2
- #undef _IS_TX2_1
- #undef _IS_RX2_1
#endif
-#if USING_SERIAL_3
+#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
#error "Serial port pins (3) conflict with X endstop pins!"
- #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
+ #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) \
+ || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
#error "Serial port pins (3) conflict with X/Y axis UART pins!"
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
#error "Serial port pins (3) conflict with X2 pins!"
@@ -178,20 +168,17 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "Serial port pins (3) conflict with Z3 pins!"
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
#error "Serial port pins (3) conflict with Z4 pins!"
- #elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
+ #elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
#error "Serial port pins (3) conflict with E1 pins!"
#endif
#undef PIN_IS_TX3
#undef PIN_IS_RX3
#endif
-#undef ANY_TX
-#undef ANY_RX
-
//
// Flag any i2c pin conflicts
//
-#if ANY(HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM)
+#if ANY(HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM)
#define USEDI2CDEV_M 1 // /Wire.cpp
#if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1)
@@ -227,7 +214,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
- #elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
+ #elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
#endif
#undef PIN_IS_SDA1
@@ -253,9 +240,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Z4_ENABLE)
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
- #elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE)
+ #elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE)
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
- #elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
+ #elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h
index 9da2a32556..e2645b9290 100644
--- a/Marlin/src/HAL/LPC1768/include/SPI.h
+++ b/Marlin/src/HAL/LPC1768/include/SPI.h
@@ -61,9 +61,7 @@
class SPISettings {
public:
- SPISettings(uint32_t spiRate, int inBitOrder, int inDataMode) {
- init_AlwaysInline(spiRate2Clock(spiRate), inBitOrder, inDataMode, DATA_SIZE_8BIT);
- }
+ SPISettings(uint32_t speed, int, int) : spi_speed(speed) {};
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
@@ -74,19 +72,7 @@ public:
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
}
- //uint32_t spiRate() const { return spi_speed; }
-
- static inline uint32_t spiRate2Clock(uint32_t spiRate) {
- uint32_t Marlin_speed[7]; // CPSR is always 2
- Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
- Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
- Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
- Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
- Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
- Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
- Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
- return Marlin_speed[spiRate > 6 ? 6 : spiRate];
- }
+ uint32_t spiRate() const { return spi_speed; }
private:
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
@@ -99,7 +85,7 @@ private:
dataSize = inDataSize;
}
- //uint32_t spi_speed;
+ uint32_t spi_speed;
uint32_t clock;
uint32_t dataSize;
//uint32_t clockDivider;
@@ -136,7 +122,7 @@ public:
void end();
void beginTransaction(const SPISettings&);
- void endTransaction() {}
+ void endTransaction() {};
// Transfer using 1 "Data Size"
uint8_t transfer(uint16_t data);
diff --git a/Marlin/src/HAL/LPC1768/spi_pins.h b/Marlin/src/HAL/LPC1768/spi_pins.h
index b4da5d4df2..2e6749bf57 100644
--- a/Marlin/src/HAL/LPC1768/spi_pins.h
+++ b/Marlin/src/HAL/LPC1768/spi_pins.h
@@ -23,7 +23,7 @@
#include "../../core/macros.h"
-#if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
+#if BOTH(SDSUPPORT, HAS_GRAPHICAL_LCD) && (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 required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.h b/Marlin/src/HAL/LPC1768/tft/tft_spi.h
index 4753fdbae9..8d3e3127bb 100644
--- a/Marlin/src/HAL/LPC1768/tft/tft_spi.h
+++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.h
@@ -36,7 +36,7 @@
#define DATASIZE_8BIT SSP_DATABIT_8
#define DATASIZE_16BIT SSP_DATABIT_16
-#define TFT_IO_DRIVER TFT_SPI
+#define TFT_IO TFT_SPI
#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp
index 5f96630043..c72e5f0eac 100644
--- a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp
+++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp
@@ -72,6 +72,7 @@ bool XPT2046::getRawPoint(int16_t *x, int16_t *y) {
if (!isTouched()) return false;
*x = getRawData(XPT2046_X);
*y = getRawData(XPT2046_Y);
+ SERIAL_ECHOLNPAIR("X: ", *x, ", Y: ", *y);
return isTouched();
}
diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h
index e6744fb005..23dc20e2eb 100644
--- a/Marlin/src/HAL/LPC1768/timers.h
+++ b/Marlin/src/HAL/LPC1768/timers.h
@@ -21,6 +21,7 @@
#pragma once
/**
+ *
* HAL For LPC1768
*/
diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp
index 057e10e0f5..befc348fab 100644
--- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp
+++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp
@@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include
#include "../../shared/HAL_SPI.h"
@@ -124,6 +124,6 @@ uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp
index 6f7efba4ae..f03be9ab34 100644
--- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp
+++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp
@@ -77,7 +77,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include
@@ -193,6 +193,6 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp
index 592e27f6c0..1500c22a0d 100644
--- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp
+++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp
@@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB
+#if HAS_GRAPHICAL_LCD
#include
#include "../../shared/HAL_SPI.h"
@@ -133,6 +133,6 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB
+#endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
index ca9d6ecfbe..4f52f7dd01 100644
--- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
+++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
@@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
+#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
#include
@@ -203,5 +203,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1;
}
-#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
+#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/LPC1768/usb_serial.cpp b/Marlin/src/HAL/LPC1768/usb_serial.cpp
index d225ce4188..63a570efdf 100644
--- a/Marlin/src/HAL/LPC1768/usb_serial.cpp
+++ b/Marlin/src/HAL/LPC1768/usb_serial.cpp
@@ -26,9 +26,7 @@
#if ENABLED(EMERGENCY_PARSER)
#include "../../feature/e_parser.h"
-
EmergencyParser::State emergency_state;
-
bool CDC_RecvCallback(const char buffer) {
emergency_parser.update(emergency_state, buffer);
return true;
diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h
index 7cb3635bd7..ea0f694cdc 100644
--- a/Marlin/src/HAL/SAMD51/HAL.h
+++ b/Marlin/src/HAL/SAMD51/HAL.h
@@ -35,35 +35,58 @@
// MYSERIAL0 required before MarlinSerial includes!
- #define __MSERIAL(X) Serial##X
- #define _MSERIAL(X) __MSERIAL(X)
- #define MSERIAL(X) _MSERIAL(INCREMENT(X))
-
#if SERIAL_PORT == -1
#define MYSERIAL0 Serial
- #elif WITHIN(SERIAL_PORT, 0, 3)
- #define MYSERIAL0 MSERIAL(SERIAL_PORT)
+ #elif SERIAL_PORT == 0
+ #define MYSERIAL0 Serial1
+ #elif SERIAL_PORT == 1
+ #define MYSERIAL0 Serial2
+ #elif SERIAL_PORT == 2
+ #define MYSERIAL0 Serial3
+ #elif SERIAL_PORT == 3
+ #define MYSERIAL0 Serial4
#else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
- #if SERIAL_PORT_2 == -1
+ #if SERIAL_PORT_2 == SERIAL_PORT
+ #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
+ #elif SERIAL_PORT_2 == -1
#define MYSERIAL1 Serial
- #elif WITHIN(SERIAL_PORT_2, 0, 3)
- #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
+ #elif SERIAL_PORT_2 == 0
+ #define MYSERIAL1 Serial1
+ #elif SERIAL_PORT_2 == 1
+ #define MYSERIAL1 Serial2
+ #elif SERIAL_PORT_2 == 2
+ #define MYSERIAL1 Serial3
+ #elif SERIAL_PORT_2 == 3
+ #define MYSERIAL1 Serial4
#else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif
+ #define NUM_SERIAL 2
+ #else
+ #define NUM_SERIAL 1
#endif
- #ifdef LCD_SERIAL_PORT
- #if LCD_SERIAL_PORT == -1
- #define LCD_SERIAL Serial
- #elif WITHIN(LCD_SERIAL_PORT, 0, 3)
- #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
+ #ifdef DGUS_SERIAL_PORT
+ #if 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."
+ #elif DGUS_SERIAL_PORT == -1
+ #define DGUS_SERIAL Serial
+ #elif DGUS_SERIAL_PORT == 0
+ #define DGUS_SERIAL Serial1
+ #elif DGUS_SERIAL_PORT == 1
+ #define DGUS_SERIAL Serial2
+ #elif DGUS_SERIAL_PORT == 2
+ #define DGUS_SERIAL Serial3
+ #elif DGUS_SERIAL_PORT == 2
+ #define DGUS_SERIAL Serial4
#else
- #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
@@ -89,8 +112,6 @@ typedef int8_t pin_t;
void HAL_clear_reset_source(); // clear reset reason
uint8_t HAL_get_reset_source(); // get reset reason
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
//
// ADC
//
diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.cpp b/Marlin/src/HAL/SAMD51/QSPIFlash.cpp
index 307eb3fd45..161c04084f 100644
--- a/Marlin/src/HAL/SAMD51/QSPIFlash.cpp
+++ b/Marlin/src/HAL/SAMD51/QSPIFlash.cpp
@@ -26,7 +26,7 @@
#include "QSPIFlash.h"
-#define INVALID_ADDR 0xFFFFFFFF
+#define INVALID_ADDR 0xffffffff
#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1))
#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1))
diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.h b/Marlin/src/HAL/SAMD51/QSPIFlash.h
index db4abec91c..b6f22769ff 100644
--- a/Marlin/src/HAL/SAMD51/QSPIFlash.h
+++ b/Marlin/src/HAL/SAMD51/QSPIFlash.h
@@ -24,6 +24,7 @@
* THE SOFTWARE.
*
* Derived from Adafruit_SPIFlash class with no SdFat references
+ *
*/
#pragma once
diff --git a/Marlin/src/HAL/SAMD51/pinsDebug.h b/Marlin/src/HAL/SAMD51/pinsDebug.h
index 81376db79a..c28937d6c6 100644
--- a/Marlin/src/HAL/SAMD51/pinsDebug.h
+++ b/Marlin/src/HAL/SAMD51/pinsDebug.h
@@ -150,4 +150,5 @@ void pwm_details(int32_t pin) {
* 93 | PA10 | QSPI: IO2
* 94 | PA11 | QSPI: IO3
* 95 | PB31 | SD: DETECT
+ *
*/
diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp
index 83604b1104..b1b727ce19 100644
--- a/Marlin/src/HAL/STM32/HAL.cpp
+++ b/Marlin/src/HAL/STM32/HAL.cpp
@@ -63,7 +63,7 @@ uint16_t HAL_adc_result;
void HAL_init() {
FastIO_init();
- #if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
+ #if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT)
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif
@@ -122,14 +122,9 @@ extern "C" {
// TODO: Make sure this doesn't cause any delay
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
+
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
-// Reset the system (to initiate a firmware flash)
void flashFirmware(const int16_t) { NVIC_SystemReset(); }
-// Maple Compatibility
-systickCallback_t systick_user_callback;
-void systick_attach_callback(systickCallback_t cb) { systick_user_callback = cb; }
-void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); }
-
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h
index a1f7515d6b..08081331b7 100644
--- a/Marlin/src/HAL/STM32/HAL.h
+++ b/Marlin/src/HAL/STM32/HAL.h
@@ -43,40 +43,83 @@
// ------------------------
// Defines
// ------------------------
-#define _MSERIAL(X) MSerial##X
-#define MSERIAL(X) _MSERIAL(X)
-#if SERIAL_PORT == -1
+#if SERIAL_PORT == 0
+ #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
+#elif SERIAL_PORT == -1
#define MYSERIAL0 SerialUSB
-#elif WITHIN(SERIAL_PORT, 1, 6)
- #define MYSERIAL0 MSERIAL(SERIAL_PORT)
+#elif SERIAL_PORT == 1
+ #define MYSERIAL0 MSerial1
+#elif SERIAL_PORT == 2
+ #define MYSERIAL0 MSerial2
+#elif SERIAL_PORT == 3
+ #define MYSERIAL0 MSerial3
+#elif SERIAL_PORT == 4
+ #define MYSERIAL0 MSerial4
+#elif SERIAL_PORT == 5
+ #define MYSERIAL0 MSerial5
+#elif SERIAL_PORT == 6
+ #define MYSERIAL0 MSerial6
#else
- #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
+ #error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
- #if SERIAL_PORT_2 == -1
+ #define NUM_SERIAL 2
+ #if SERIAL_PORT_2 == 0
+ #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
+ #elif SERIAL_PORT_2 == SERIAL_PORT
+ #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
+ #elif SERIAL_PORT_2 == -1
#define MYSERIAL1 SerialUSB
- #elif WITHIN(SERIAL_PORT_2, 1, 6)
- #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
+ #elif SERIAL_PORT_2 == 1
+ #define MYSERIAL1 MSerial1
+ #elif SERIAL_PORT_2 == 2
+ #define MYSERIAL1 MSerial2
+ #elif SERIAL_PORT_2 == 3
+ #define MYSERIAL1 MSerial3
+ #elif SERIAL_PORT_2 == 4
+ #define MYSERIAL1 MSerial4
+ #elif SERIAL_PORT_2 == 5
+ #define MYSERIAL1 MSerial5
+ #elif SERIAL_PORT_2 == 6
+ #define MYSERIAL1 MSerial6
#else
- #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration."
+ #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
#endif
+#else
+ #define NUM_SERIAL 1
#endif
-#ifdef LCD_SERIAL_PORT
- #if LCD_SERIAL_PORT == -1
- #define LCD_SERIAL SerialUSB
- #elif WITHIN(LCD_SERIAL_PORT, 1, 6)
- #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
+#if HAS_DGUS_LCD
+ #if DGUS_SERIAL_PORT == 0
+ #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) 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."
+ #elif DGUS_SERIAL_PORT == -1
+ #define DGUS_SERIAL SerialUSB
+ #elif DGUS_SERIAL_PORT == 1
+ #define DGUS_SERIAL MSerial1
+ #elif DGUS_SERIAL_PORT == 2
+ #define DGUS_SERIAL MSerial2
+ #elif DGUS_SERIAL_PORT == 3
+ #define DGUS_SERIAL MSerial3
+ #elif DGUS_SERIAL_PORT == 4
+ #define DGUS_SERIAL MSerial4
+ #elif DGUS_SERIAL_PORT == 5
+ #define DGUS_SERIAL MSerial5
+ #elif DGUS_SERIAL_PORT == 6
+ #define DGUS_SERIAL MSerial6
#else
- #error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
- #endif
- #if HAS_DGUS_LCD
- #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
+ #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
+
+ #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
#endif
+
/**
* TODO: review this to return 1 for pins that are not analog input
*/
@@ -134,8 +177,6 @@ void HAL_clear_reset_source();
// Reset reason
uint8_t HAL_get_reset_source();
-inline void HAL_reboot() {} // reboot the board or restart the bootloader
-
void _delay_ms(const int delay);
extern "C" char* _sbrk(int incr);
@@ -179,8 +220,3 @@ uint16_t HAL_adc_get_result();
#define PLATFORM_M997_SUPPORT
void flashFirmware(const int16_t);
-
-// Maple Compatibility
-typedef void (*systickCallback_t)(void);
-void systick_attach_callback(systickCallback_t cb);
-void HAL_SYSTICK_Callback();
diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp
index f947e6ef32..202442a71b 100644
--- a/Marlin/src/HAL/STM32/HAL_SPI.cpp
+++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp
@@ -132,9 +132,11 @@ static SPISettings spiConfig;
* @details Only configures SS pin since stm32duino creates and initialize the SPI object
*/
void spiBegin() {
- #if PIN_EXISTS(SS)
- OUT_WRITE(SS_PIN, HIGH);
+ #if !PIN_EXISTS(SS)
+ #error "SS_PIN not defined!"
#endif
+
+ OUT_WRITE(SS_PIN, HIGH);
}
// Configure SPI for specified SPI speed
@@ -171,7 +173,9 @@ static SPISettings spiConfig;
* @details
*/
uint8_t spiRec() {
+ SPI.beginTransaction(spiConfig);
uint8_t returnByte = SPI.transfer(0xFF);
+ SPI.endTransaction();
return returnByte;
}
@@ -187,7 +191,9 @@ static SPISettings spiConfig;
void spiRead(uint8_t* buf, uint16_t nbyte) {
if (nbyte == 0) return;
memset(buf, 0xFF, nbyte);
+ SPI.beginTransaction(spiConfig);
SPI.transfer(buf, nbyte);
+ SPI.endTransaction();
}
/**
@@ -198,7 +204,9 @@ static SPISettings spiConfig;
* @details
*/
void spiSend(uint8_t b) {
+ SPI.beginTransaction(spiConfig);
SPI.transfer(b);
+ SPI.endTransaction();
}
/**
@@ -211,8 +219,10 @@ static SPISettings spiConfig;
*/
void spiSendBlock(uint8_t token, const uint8_t* buf) {
uint8_t rxBuf[512];
+ SPI.beginTransaction(spiConfig);
SPI.transfer(token);
SPI.transfer((uint8_t*)buf, &rxBuf, 512);
+ SPI.endTransaction();
}
#endif // SOFTWARE_SPI
diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp
index a146664366..8d99ab7855 100644
--- a/Marlin/src/HAL/STM32/MarlinSerial.cpp
+++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp
@@ -49,14 +49,16 @@
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
#endif
-#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
- DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
+#if defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT >= 0
+ DECLARE_SERIAL_PORT_EXP(DGUS_SERIAL_PORT)
#endif
void MarlinSerial::begin(unsigned long baud, uint8_t config) {
HardwareSerial::begin(baud, config);
- // Replace the IRQ callback with the one we have defined
- TERN_(EMERGENCY_PARSER, _serial.rx_callback = _rx_callback);
+ // replace the IRQ callback with the one we have defined
+ #if ENABLED(EMERGENCY_PARSER)
+ _serial.rx_callback = _rx_callback;
+ #endif
}
// This function is Copyright (c) 2006 Nicholas Zambetti.
diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h
index 3611cc78d7..5ab97ff3a9 100644
--- a/Marlin/src/HAL/STM32/MarlinSerial.h
+++ b/Marlin/src/HAL/STM32/MarlinSerial.h
@@ -35,10 +35,6 @@ public:
#endif
{ }
- #if ENABLED(EMERGENCY_PARSER)
- static inline bool emergency_parser_enabled() { return true; }
- #endif
-
void begin(unsigned long baud, uint8_t config);
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
diff --git a/Marlin/src/HAL/STM32/SoftwareSerial.cpp b/Marlin/src/HAL/STM32/SoftwareSerial.cpp
new file mode 100644
index 0000000000..2228a177be
--- /dev/null
+++ b/Marlin/src/HAL/STM32/SoftwareSerial.cpp
@@ -0,0 +1,396 @@
+/*
+ * SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
+ *
+ * Multi-instance software serial library for Arduino/Wiring
+ * -- Interrupt-driven receive and other improvements by ladyada
+ *
+ * -- Tuning, circular buffer, derivation from class Print/Stream,
+ * multi-instance support, porting to 8MHz processors,
+ * various optimizations, PROGMEM delay tables, inverse logic and
+ * direct port writing by Mikal Hart
+ * -- Pin change interrupt macros by Paul Stoffregen
+ * -- 20MHz processor support by Garrett Mace
+ * -- ATmega1280/2560 support by Brett Hagman