diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000..a0fa3eff17
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,19 @@
+# editorconfig.org
+root = true
+
+[{*.patch,syntax_test_*}]
+trim_trailing_whitespace = false
+
+[{*.c,*.cpp,*.h}]
+charset = utf-8
+
+[{*.c,*.cpp,*.h,Makefile}]
+trim_trailing_whitespace = true
+insert_final_newline = true
+end_of_line = lf
+indent_style = space
+indent_size = 2
+
+[{*.py,*.conf,*.sublime-project}]
+indent_style = tab
+indent_size = 4
diff --git a/.gitignore b/.gitignore
index 7a364bbd42..80c76ee1e4 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
#
# Marlin 3D Printer Firmware
-# Copyright (C) 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+# Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
#
# Based on Sprinter and grbl.
-# Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+# Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -146,6 +146,9 @@ Marlin/*/*/readme.txt
Marlin/*/*/*/readme.txt
Marlin/*/*/*/*/readme.txt
+# Secure Credentials
+Configuration_Secure.h
+
#Visual Studio
*.sln
*.vcxproj
@@ -171,3 +174,13 @@ CMakeListsPrivate.txt
#CLion
cmake-build-*
+
+#Eclipse
+.project
+.cproject
+.pydevproject
+.settings
+.classpath
+
+#Python
+__pycache__
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 25a0c51423..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-dist: trusty
-sudo: false
-
-language: python
-python:
- - "2.7"
-
-notifications:
- email: false
-
-# Cache PlatformIO packages using Travis CI container-based infrastructure
-sudo: false
-cache:
- pip: true
- directories:
- - "~/.platformio"
-
-env:
- - TEST_PLATFORM="megaatmega2560"
- - TEST_PLATFORM="DUE"
- - TEST_PLATFORM="LPC1768"
- - TEST_PLATFORM="STM32F1"
- - TEST_PLATFORM="teensy35"
-
-before_install:
- #
- # Fetch the tag information for the current branch
- - git fetch origin --tags
- #
- # Publish the buildroot script folder
- - chmod +x ${TRAVIS_BUILD_DIR}/buildroot/bin/*
- - chmod +x ${TRAVIS_BUILD_DIR}/buildroot/share/tests/*
- - export PATH=${TRAVIS_BUILD_DIR}/buildroot/bin/:${TRAVIS_BUILD_DIR}/buildroot/share/tests/:${PATH}
-
-install:
- #- pip install -U platformio
- - pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
-
-before_script:
- # Update PlatformIO packages
- - platformio update
- #
- # Change current working directory to the build dir
- - cd ${TRAVIS_BUILD_DIR}
- #
- # Generate custom version include
- - generate_version ${TRAVIS_BUILD_DIR}/Marlin/src/inc
- - cat ${TRAVIS_BUILD_DIR}/Marlin/src/inc/_Version.h
- #
-script:
- - run_tests ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
diff --git a/LICENSE b/LICENSE
index f27031ae85..7d917cf3d8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -3,7 +3,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (c) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -634,7 +634,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
- Copyright (C) {year} {name of author}
+ Copyright (c) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -654,7 +654,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
- {project} Copyright (C) {year} {fullname}
+ {project} Copyright (c) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 8f2c9620b0..2fbb0a9acd 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -1,15 +1,37 @@
//#define PetsfangMicroswiss
#define BondtechBMG
-#define E3DV6
-//#define FilamentSensorStd
-#define FilamentSensorLerdge
+//#define CR10SPro_GearedExtruder
+//#define E3DV6
+#define Mosquito
+//#define FilamentSensorStd
+//#define FilamentSensorLerdge
+#define FilamentEncoder
+
+//#define STOCK_2208 // V2 Stock Board with TMC2208 Drivers
+//#define SKR13 // 32 bit board - assumes 2208 drivers
+//#define SKR14
+#define SKR14Turbo
+#define SKR_2209
+//#define E_8825
+#define SKR_UART // Configure SKR board with drivers in UART mode
+
+//#define SX2 // Small formfactor 200mm machine
+
+#define DUAL_Z
+#define GRAPHICSLCD
+#define UBL
+
+
+#if ANY(SKR13, SKR14, SKR14Turbo)
+ #define SKRLPCBoard
+#endif
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,6 +49,9 @@
*/
#pragma once
+#if DISABLED(SKRLPCBoard)
+ #define Y_STOP_PIN 14
+#endif
/**
* Configuration.h
*
@@ -42,7 +67,7 @@
* Advanced settings can be found in Configuration_adv.h
*
*/
-#define CONFIGURATION_H_VERSION 020000
+#define CONFIGURATION_H_VERSION 020005
//===========================================================================
//============================= Getting Started =============================
@@ -76,13 +101,9 @@
// @section info
-// User-specified version info of this build to display in [Pronterface, etc] terminal window during
-// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
-// build by the user have been successfully uploaded into firmware.
-#define STRING_CONFIG_H_AUTHOR "(Tinymachines3D)" // Who made the changes.
-#define SHOW_BOOTSCREEN
-#define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION // will be shown during bootup in line 1
-#define STRING_SPLASH_LINE2 WEBSITE_URL // will be shown during bootup in line 2
+// Author info of this build printed to the host during boot and M115
+#define STRING_CONFIG_H_AUTHOR "Tinymachines3D" // Who made the changes.
+#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
/**
* *** VENDORS PLEASE READ ***
@@ -95,17 +116,22 @@
* respectfully request that you retain the unmodified Marlin boot screen.
*/
-// Enable to show the bitmap in Marlin/_Bootscreen.h on startup.
-//#define SHOW_CUSTOM_BOOTSCREEN
+// Show the Marlin bootscreen on startup. ** ENABLE FOR PRODUCTION **
+#define SHOW_BOOTSCREEN
-// Enable to show the bitmap in Marlin/_Statusscreen.h on the status screen.
-//#define CUSTOM_STATUS_SCREEN_IMAGE
+#if ENABLED(GRAPHICSLCD)
+// Show the bitmap in Marlin/_Bootscreen.h on startup.
+#define SHOW_CUSTOM_BOOTSCREEN
+// Show the bitmap in Marlin/_Statusscreen.h on the status screen.
+#define CUSTOM_STATUS_SCREEN_IMAGE
+#endif
// @section machine
/**
* Select the serial port on the board to use for communication with the host.
* This allows the connection of wireless adapters (for instance) to non-default port pins.
+ * Serial port -1 is the USB emulated serial port, if available.
* Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader.
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
@@ -114,13 +140,11 @@
/**
* Select a secondary serial port on the board to use for communication with the host.
- * This allows the connection of wireless adapters (for instance) to non-default port pins.
- * Serial port -1 is the USB emulated serial port, if available.
- *
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
-//#define SERIAL_PORT_2 -1
-
+#if ENABLED(SKRLPCBoard)
+ #define SERIAL_PORT_2 -1
+#endif
/**
* This setting determines the communication speed of the printer.
*
@@ -135,24 +159,35 @@
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
-// The following define selects which electronics board you have.
-// Please choose the name from boards.h that matches your setup
+// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
- #define MOTHERBOARD BOARD_RAMPS_14_EFB
+ #if ENABLED(SKR13)
+ #define MOTHERBOARD BOARD_BTT_SKR_V1_3
+ #elif ENABLED(SKR14)
+ #define MOTHERBOARD BOARD_BTT_SKR_V1_4
+ #elif ENABLED(SKR14Turbo)
+ #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO
+ #else
+ #define MOTHERBOARD BOARD_RAMPS_14_EFB
+ #endif
#endif
-// Optional custom name for your RepStrap or other custom machine
-// Displayed in the LCD "Ready" message
- #define CUSTOM_MACHINE_NAME "TM3D SX4"
+// Name displayed in the LCD "Ready" message and Info menu
+#if ENABLED(SX2)
+ #define CUSTOM_MACHINE_NAME "TM3D SX2"
+ #else
+ #define CUSTOM_MACHINE_NAME "TM3D SX4"
+#endif
-// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
-// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
+
+// Printer's unique ID, used by some programs to differentiate between machines.
+// Choose your own or use a service like http://www.uuidgenerator.net/version4
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
// @section extruder
// This defines the number of extruders
-// :[1, 2, 3, 4, 5, 6]
+// :[1, 2, 3, 4, 5, 6, 7, 8]
#define EXTRUDERS 1
// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
@@ -161,6 +196,13 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE
+// Save and restore temperature and fan speed on tool-change.
+// Set standby for the unselected tool with M104/106/109 T...
+#if ENABLED(SINGLENOZZLE)
+ //#define SINGLENOZZLE_STANDBY_TEMP
+ //#define SINGLENOZZLE_STANDBY_FAN
+#endif
+
/**
* Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants.
*
@@ -224,7 +266,7 @@
*/
//#define MAGNETIC_PARKING_EXTRUDER
-#if ENABLED(PARKING_EXTRUDER) || ENABLED(MAGNETIC_PARKING_EXTRUDER)
+#if EITHER(PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER)
#define PARKING_EXTRUDER_PARKING_X { -78, 184 } // X positions for parking the extruders
#define PARKING_EXTRUDER_GRAB_DISTANCE 1 // (mm) Distance to move beyond the parking point to grab the extruder
@@ -255,13 +297,45 @@
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
-#if ENABLED(SWITCHING_TOOLHEAD)
- #define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
- #define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
- #define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
- #define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
- #define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
- #define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
+
+/**
+ * Magnetic Switching Toolhead
+ *
+ * Support swappable and dockable toolheads with a magnetic
+ * docking mechanism using movement and no servo.
+ */
+//#define MAGNETIC_SWITCHING_TOOLHEAD
+
+/**
+ * Electromagnetic Switching Toolhead
+ *
+ * Parking for CoreXY / HBot kinematics.
+ * Toolheads are parked at one edge and held with an electromagnet.
+ * Supports more than 2 Toolheads. See https://youtu.be/JolbsAKTKf4
+ */
+//#define ELECTROMAGNETIC_SWITCHING_TOOLHEAD
+
+#if ANY(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
+ #define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
+ #define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
+ #define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
+ #define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
+ #if ENABLED(SWITCHING_TOOLHEAD)
+ #define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
+ #define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
+ #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
+ #define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
+ #define SWITCHING_TOOLHEAD_X_SECURITY { 90, 150 } // (mm) Security distance X axis (T0,T1)
+ //#define PRIME_BEFORE_REMOVE // Prime the nozzle before release from the dock
+ #if ENABLED(PRIME_BEFORE_REMOVE)
+ #define SWITCHING_TOOLHEAD_PRIME_MM 20 // (mm) Extruder prime length
+ #define SWITCHING_TOOLHEAD_RETRACT_MM 10 // (mm) Retract after priming length
+ #define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/m) Extruder prime feedrate
+ #define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/m) Extruder retract feedrate
+ #endif
+ #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
+ #define SWITCHING_TOOLHEAD_Z_HOP 2 // (mm) Z raise for switching
+ #endif
#endif
/**
@@ -286,36 +360,37 @@
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
-//#define HOTEND_OFFSET_X {0.0, 20.00} // (mm) relative X-offset for each nozzle
-//#define HOTEND_OFFSET_Y {0.0, 5.00} // (mm) relative Y-offset for each nozzle
-//#define HOTEND_OFFSET_Z {0.0, 0.00} // (mm) relative Z-offset for each nozzle
+//#define HOTEND_OFFSET_X { 0.0, 20.00 } // (mm) relative X-offset for each nozzle
+//#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle
+//#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle
// @section machine
/**
- * Select your power supply here. Use 0 if you haven't connected the PS_ON_PIN
+ * Power Supply Control
*
- * 0 = No Power Switch
- * 1 = ATX
- * 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC)
- *
- * :{ 0:'No power switch', 1:'ATX', 2:'X-Box 360' }
+ * Enable and connect the power supply to the PS_ON_PIN.
+ * Specify whether the power supply is active HIGH or active LOW.
*/
-#define POWER_SUPPLY 0
+//#define PSU_CONTROL
+//#define PSU_NAME "Power Supply"
-#if POWER_SUPPLY > 0
- // Enable this option to leave the PSU off at startup.
- // Power to steppers and heaters will need to be turned on with M80.
- //#define PS_DEFAULT_OFF
+#if ENABLED(PSU_CONTROL)
+ #define PSU_ACTIVE_HIGH false // Set 'false' for ATX, 'true' for X-Box
- //#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
+ //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
+ //#define PSU_POWERUP_DELAY 100 // (ms) Delay for the PSU to warm up to full power
+
+ //#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
- #define AUTO_POWER_FANS // Turn on PSU if fans need power
+ #define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
+ #define AUTO_POWER_CHAMBER_FAN
+ //#define AUTO_POWER_E_TEMP 50 // (°C) Turn on PSU over this temperature
+ //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) Turn on PSU over this temperature
#define POWER_TIMEOUT 30
#endif
-
#endif
// @section temperature
@@ -329,17 +404,22 @@
*
* Temperature sensors available:
*
+ * -5 : PT100 / PT1000 with MAX31865 (only for sensors 0-1)
+ * -3 : thermocouple with MAX31855 (only for sensors 0-1)
+ * -2 : thermocouple with MAX6675 (only for sensors 0-1)
* -4 : thermocouple with AD8495
- * -3 : thermocouple with MAX31855 (only for sensor 0)
- * -2 : thermocouple with MAX6675 (only for sensor 0)
* -1 : thermocouple with AD595
* 0 : not used
* 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
+ * 331 : (3.3V scaled thermistor 1 table for MEGA)
+ * 332 : (3.3V scaled thermistor 1 table for DUE)
* 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
+ * 202 : 200k thermistor - Copymaster 3D
* 3 : Mendel-parts thermistor (4.7k pullup)
* 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
* 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan & J-Head) (4.7k pullup)
* 501 : 100K Zonestar (Tronxy X3A) Thermistor
+ * 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup)
* 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
* 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
* 71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
@@ -350,12 +430,17 @@
* 12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
* 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
* 15 : 100k thermistor calibration for JGAurora A5 hotend
- * 20 : the PT100 circuit found in the Ultimainboard V2.x
+ * 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327
+ * 20 : Pt100 with circuit in the Ultimainboard V2.x with 5v excitation (AVR)
+ * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
+ * 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
* 66 : 4.7M High Temperature thermistor from Dyze Design
+ * 67 : 450C thermistor from SliceEngineering
* 70 : the 100K thermistor found in the bq Hephestos 2
* 75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
+ * 99 : 100k thermistor with a 10K pull-up resistor (found on some Wanhao i3 machines)
*
* 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k.
* (but gives greater accuracy and more stable PID)
@@ -368,13 +453,15 @@
* 147 : Pt100 with 4k7 pullup
* 110 : Pt100 with 1k pullup (non standard)
*
+ * 1000 : Custom - Specify parameters in Configuration_adv.h
+ *
* Use these for Testing or Development purposes. NEVER for production machine.
* 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below.
* 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below.
- *
- * :{ '0': "Not used", '1':"100k / 4.7k - EPCOS", '2':"200k / 4.7k - ATC Semitec 204GT-2", '3':"Mendel-parts / 4.7k", '4':"10k !! do not use for a hotend. Bad resolution at high temp. !!", '5':"100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '501':"100K Zonestar (Tronxy X3A)", '6':"100k / 4.7k EPCOS - Not as accurate as Table 1", '7':"100k / 4.7k Honeywell 135-104LAG-J01", '8':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9':"100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10':"100k / 4.7k RS 198-961", '11':"100k / 4.7k beta 3950 1%", '12':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13':"100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '20':"PT100 (Ultimainboard V2.x)", '51':"100k / 1k - EPCOS", '52':"200k / 1k - ATC Semitec 204GT-2", '55':"100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '60':"100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '61':"100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup", '66':"Dyze Design 4.7M High Temperature thermistor", '70':"the 100K thermistor found in the bq Hephestos 2", '71':"100k / 4.7k Honeywell 135-104LAF-J01", '147':"Pt100 / 4.7k", '1047':"Pt1000 / 4.7k", '110':"Pt100 / 1k (non-standard)", '1010':"Pt1000 / 1k (non standard)", '-4':"Thermocouple + AD8495", '-3':"Thermocouple + MAX31855 (only for sensor 0)", '-2':"Thermocouple + MAX6675 (only for sensor 0)", '-1':"Thermocouple + AD595",'998':"Dummy 1", '999':"Dummy 2" }
*/
-#if ENABLED(E3DV6)
+#if ENABLED(Mosquito)
+ #define TEMP_SENSOR_0 67
+#elif ENABLED(E3DV6)
#define TEMP_SENSOR_0 5
#else
#define TEMP_SENSOR_0 1
@@ -384,7 +471,10 @@
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
+#define TEMP_SENSOR_6 0
+#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 11
+#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
// Dummy thermistor constant temperature readings, for use with 998 and 999
@@ -396,37 +486,38 @@
//#define TEMP_SENSOR_1_AS_REDUNDANT
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
-// Extruder temperature must be close to target for this long before M109 returns success
-#define TEMP_RESIDENCY_TIME 9 // (seconds)
-#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
-#define TEMP_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
+#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
+#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
+#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
-// Bed temperature must be close to target for this long before M190 returns success
-#define TEMP_BED_RESIDENCY_TIME 10 // (seconds)
-#define TEMP_BED_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
-#define TEMP_BED_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
+#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190
+#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
+#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
-// The minimal temperature defines the temperature below which the heater will not be enabled It is used
-// to check that the wiring to the thermistor is not broken.
-// Otherwise this would lead to the heater being powered on all the time.
-#define HEATER_0_MINTEMP 5
-#define HEATER_1_MINTEMP 5
-#define HEATER_2_MINTEMP 5
-#define HEATER_3_MINTEMP 5
-#define HEATER_4_MINTEMP 5
-#define HEATER_5_MINTEMP 5
-#define BED_MINTEMP 5
+// Below this temperature the heater will be switched off
+// because it probably indicates a broken thermistor wire.
+#define HEATER_0_MINTEMP 5
+#define HEATER_1_MINTEMP 5
+#define HEATER_2_MINTEMP 5
+#define HEATER_3_MINTEMP 5
+#define HEATER_4_MINTEMP 5
+#define HEATER_5_MINTEMP 5
+#define HEATER_6_MINTEMP 5
+#define HEATER_7_MINTEMP 5
+#define BED_MINTEMP 5
-// When temperature exceeds max temp, your heater will be switched off.
-// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
-// You should use MINTEMP for thermistor short/failure protection.
+// Above this temperature the heater will be switched off.
+// This can protect components from overheating, but NOT from shorts and failures.
+// (Use MINTEMP for thermistor short/failure protection.)
#define HEATER_0_MAXTEMP 305
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
#define HEATER_4_MAXTEMP 275
#define HEATER_5_MAXTEMP 275
-#define BED_MAXTEMP 125
+#define HEATER_6_MAXTEMP 275
+#define HEATER_7_MAXTEMP 275
+#define BED_MAXTEMP 125
//===========================================================================
//============================= PID Settings ================================
@@ -474,7 +565,7 @@
#endif // PIDTEMP
//===========================================================================
-//============================= PID > Bed Temperature Control ===============
+//====================== PID > Bed Temperature Control ======================
//===========================================================================
/**
@@ -503,7 +594,7 @@
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
#if ENABLED(PIDTEMPBED)
-
+ //#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+)
@@ -559,6 +650,7 @@
#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed
+#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber
//===========================================================================
//============================= Mechanical Settings =========================
@@ -634,26 +726,78 @@
*
* A4988 is assumed for unspecified drivers.
*
- * Options: A4988, A5984, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100,
- * TMC2130, TMC2130_STANDALONE, TMC2208, TMC2208_STANDALONE,
+ * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01,
+ * TB6560, TB6600, TMC2100,
+ * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE,
+ * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE,
* TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE,
- * TMC2160, TMC2160_STANDALONE, TMC5130, TMC5130_STANDALONE,
- * TMC5160, TMC5160_STANDALONE
- * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
+ * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE
+ * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
*/
-//#define X_DRIVER_TYPE A4988
-//#define Y_DRIVER_TYPE A4988
-//#define Z_DRIVER_TYPE A4988
+
+#if ENABLED(SKRLPCBoard, E_8825)
+ #define E0_DRIVER_TYPE DRV8825
+ #define E1_DRIVER_TYPE DRV8825
+#endif
+
+#if ANY(SKRLPCBoard, STOCK_2208) && DISABLED(SKR_UART)
+ #if ENABLED(SKR_2209)
+ #define X_DRIVER_TYPE TMC2209_STANDALONE
+ #define Y_DRIVER_TYPE TMC2209_STANDALONE
+ #define Z_DRIVER_TYPE TMC2209_STANDALONE
+ #define Z2_DRIVER_TYPE TMC2209_STANDALONE
+ #if DISABLED(E_8825)
+ #define E0_DRIVER_TYPE TMC2209_STANDALONE
+ #define E1_DRIVER_TYPE TMC2209_STANDALONE
+ #endif
+ #else
+ #define X_DRIVER_TYPE TMC2208_STANDALONE
+ #define Y_DRIVER_TYPE TMC2208_STANDALONE
+ #define Z_DRIVER_TYPE TMC2208_STANDALONE
+ #define Z2_DRIVER_TYPE TMC2208_STANDALONE
+ #if DISABLED(E_8825)
+ #define E0_DRIVER_TYPE TMC2208_STANDALONE
+ #define E1_DRIVER_TYPE TMC2208_STANDALONE
+ #endif
+ #endif
+#elif ENABLED(SKRLPCBoard, SKR_UART)
+ #if ENABLED(SKR_2209)
+ #define X_DRIVER_TYPE TMC2209
+ #define Y_DRIVER_TYPE TMC2209
+ #define Z_DRIVER_TYPE TMC2209
+ #define Z2_DRIVER_TYPE TMC2209
+ #if DISABLED(E_8825)
+ #define E0_DRIVER_TYPE TMC2209
+ #define E1_DRIVER_TYPE TMC2209
+ #endif
+ #else
+ #define X_DRIVER_TYPE TMC2208
+ #define Y_DRIVER_TYPE TMC2208
+ #define Z_DRIVER_TYPE TMC2208
+ #define Z2_DRIVER_TYPE TMC2208
+ #if DISABLED(E_8825)
+ #define E0_DRIVER_TYPE TMC2208
+ #define E1_DRIVER_TYPE TMC2208
+ #endif
+ #endif
+#else
+ #define X_DRIVER_TYPE A4988
+ #define Y_DRIVER_TYPE A4988
+ #define Z_DRIVER_TYPE A4988
+ #define Z2_DRIVER_TYPE A4988
+ #define E0_DRIVER_TYPE A4988
+ #define E1_DRIVER_TYPE A4988
+#endif
//#define X2_DRIVER_TYPE A4988
//#define Y2_DRIVER_TYPE A4988
-//#define Z2_DRIVER_TYPE A4988
//#define Z3_DRIVER_TYPE A4988
-//#define E0_DRIVER_TYPE A4988
-//#define E1_DRIVER_TYPE A4988
+//#define Z4_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
//#define E4_DRIVER_TYPE A4988
//#define E5_DRIVER_TYPE A4988
+//#define E6_DRIVER_TYPE A4988
+//#define E7_DRIVER_TYPE A4988
// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
@@ -696,27 +840,42 @@
/**
* Default Axis Steps Per Unit (steps/mm)
* Override with M92
- * X, Y, Z, E0 [, E1[, E2[, E3[, E4[, E5]]]]]
+ * X, Y, Z, E0 [, E1[, E2...]]
*/
#if ENABLED(BondtechBMG)
- #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 415.0 }
+ #define EStepsmm 415
+#elif ENABLED(CR10SPro_GearedExtruder)
+ #define EStepsmm 140
#else
- #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 100.3 }
+ #define EStepsmm 100.3
#endif
+
+
+ #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, EStepsmm }
/**
* Default Max Feed Rate (mm/s)
* Override with M203
- * X, Y, Z, E0 [, E1[, E2[, E3[, E4[, E5]]]]]
+ * X, Y, Z, E0 [, E1[, E2...]]
*/
-#define DEFAULT_MAX_FEEDRATE { 500, 500, 5, 25 }
+#define DEFAULT_MAX_FEEDRATE { 500, 500, 5, 70 }
+
+#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2
+#if ENABLED(LIMITED_MAX_FR_EDITING)
+ #define MAX_FEEDRATE_EDIT_VALUES { 1000, 1000, 10, 150 } // ...or, set your own edit limits
+#endif
/**
* Default Max Acceleration (change/s) change = mm/s
* (Maximum start speed for accelerated moves)
* Override with M201
- * X, Y, Z, E0 [, E1[, E2[, E3[, E4[, E5]]]]]
+ * X, Y, Z, E0 [, E1[, E2...]]
*/
-#define DEFAULT_MAX_ACCELERATION { 2000, 2000, 100, 2000 }
+#define DEFAULT_MAX_ACCELERATION { 1500, 1500, 50, 2000 }
+
+#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
+#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
+ #define MAX_ACCEL_EDIT_VALUES { 2500, 2500, 125, 5000 } // ...or, set your own edit limits
+#endif
/**
* Default Acceleration (change/s) change = mm/s
@@ -726,34 +885,45 @@
* M204 R Retract Acceleration
* M204 T Travel Acceleration
*/
-#define DEFAULT_ACCELERATION 2000 // X, Y, Z and E acceleration for printing moves
-#define DEFAULT_RETRACT_ACCELERATION 2000 // E acceleration for retracts
-#define DEFAULT_TRAVEL_ACCELERATION 2000 // X, Y, Z acceleration for travel (non printing) moves
-
-//
-// Use Junction Deviation instead of traditional Jerk Limiting
-//
-#define JUNCTION_DEVIATION
-#if ENABLED(JUNCTION_DEVIATION)
- #define JUNCTION_DEVIATION_MM 0.06 // (mm) Distance from real junction edge
-#endif
+#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves
+#define DEFAULT_RETRACT_ACCELERATION 1500 // E acceleration for retracts
+#define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves
/**
- * Default Jerk (mm/s)
+ * Default Jerk limits (mm/s)
* Override with M205 X Y Z E
*
* "Jerk" specifies the minimum speed change that requires acceleration.
* When changing speed and direction, if the difference is less than the
* value set here, it may happen instantaneously.
*/
-#if DISABLED(JUNCTION_DEVIATION)
+#define CLASSIC_JERK
+#if ENABLED(CLASSIC_JERK)
#define DEFAULT_XJERK 10.0
#define DEFAULT_YJERK 10.0
#define DEFAULT_ZJERK 0.3
+
+ //#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves
+
+ //#define LIMITED_JERK_EDITING // Limit edit via M205 or LCD to DEFAULT_aJERK * 2
+ #if ENABLED(LIMITED_JERK_EDITING)
+ #define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10 } // ...or, set your own edit limits
+ #endif
#endif
#define DEFAULT_EJERK 5.0 // May be used by Linear Advance
+/**
+ * Junction Deviation Factor
+ *
+ * See:
+ * https://reprap.org/forum/read.php?1,739819
+ * http://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html
+ */
+#if DISABLED(CLASSIC_JERK)
+ #define JUNCTION_DEVIATION_MM 0.06 // (mm) Distance from real junction edge
+#endif
+
/**
* S-Curve Acceleration
*
@@ -762,7 +932,7 @@
*
* See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained
*/
-//#define S_CURVE_ACCELERATION
+#define S_CURVE_ACCELERATION
//===========================================================================
//============================= Z Probe Options =============================
@@ -781,11 +951,11 @@
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
/**
- * Z_MIN_PROBE_ENDSTOP
+ * Z_MIN_PROBE_PIN
*
- * Enable this option for a probe connected to any pin except Z-Min.
- * (By default Marlin assumes the Z-Max endstop pin.)
- * To use a custom Z Probe pin, set Z_MIN_PROBE_PIN below.
+ * Define this pin if the probe is not connected to Z_MIN_PIN.
+ * If not defined the default pin for the selected MOTHERBOARD
+ * will be used. Most of the time the default is what you want.
*
* - The simplest option is to use a free endstop connector.
* - Use 5V for powered (usually inductive) sensors.
@@ -795,11 +965,8 @@
* - normally-closed switches to GND and D32.
* - normally-open switches to 5V and D32.
*
- * WARNING: Setting the wrong pin may have unexpected and potentially
- * disastrous consequences. Use with caution and do your homework.
- *
*/
-//#define Z_MIN_PROBE_ENDSTOP
+//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
/**
* Probe Type
@@ -822,18 +989,38 @@
*/
//#define FIX_MOUNTED_PROBE
+/**
+ * Use the nozzle as the probe, as with a conductive
+ * nozzle system or a piezo-electric smart effector.
+ */
+//#define NOZZLE_AS_PROBE
+
/**
* Z Servo Probe, such as an endstop switch on a rotating arm.
*/
-//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector.
-//#define Z_SERVO_ANGLES {70,0} // Z Servo Deploy and Stow angles
+//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector.
+//#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles
/**
* The BLTouch probe uses a Hall effect sensor and emulates a servo.
*/
#define BLTOUCH
-#if ENABLED(BLTOUCH)
- //#define BLTOUCH_DELAY 375 // (ms) Enable and increase if needed
+
+/**
+ * Touch-MI Probe by hotends.fr
+ *
+ * This probe is deployed and activated by moving the X-axis to a magnet at the edge of the bed.
+ * By default, the magnet is assumed to be on the left and activated by a home. If the magnet is
+ * on the right, enable and set TOUCH_MI_DEPLOY_XPOS to the deploy position.
+ *
+ * Also requires: BABYSTEPPING, BABYSTEP_ZPROBE_OFFSET, Z_SAFE_HOMING,
+ * and a minimum Z_HOMING_HEIGHT of 10.
+ */
+//#define TOUCH_MI_PROBE
+#if ENABLED(TOUCH_MI_PROBE)
+ #define TOUCH_MI_RETRACT_Z 0.5 // Height at which the probe retracts
+ //#define TOUCH_MI_DEPLOY_XPOS (X_MAX_BED + 2) // For a magnet on the right side of the bed
+ //#define TOUCH_MI_MANUAL_DEPLOY // For manual deploy (LCD menu)
#endif
// A probe that is deployed and stowed with a solenoid pin (SOL1_PIN)
@@ -850,46 +1037,65 @@
#define Z_PROBE_RETRACT_X X_MAX_POS
#endif
+// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
+// When the pin is defined you can use M672 to set/reset the probe sensivity.
+//#define DUET_SMART_EFFECTOR
+#if ENABLED(DUET_SMART_EFFECTOR)
+ #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin
+#endif
+
+/**
+ * Use StallGuard2 to probe the bed with the nozzle.
+ * Requires stallGuard-capable Trinamic stepper drivers.
+ * CAUTION: This can damage machines with Z lead screws.
+ * Take extreme care when setting up this feature.
+ */
+//#define SENSORLESS_PROBING
+
//
// For Z_PROBE_ALLEN_KEY see the Delta example configurations.
//
/**
- * Z Probe to nozzle (X,Y) offset, relative to (0, 0).
- * X and Y offsets must be integers.
+ * Z Probe to nozzle (X,Y) offset, relative to (0, 0).
*
- * In the following example the X and Y offsets are both positive:
- * #define X_PROBE_OFFSET_FROM_EXTRUDER 10
- * #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
+ * In the following example the X and Y offsets are both positive:
*
- * +-- BACK ---+
- * | |
- * L | (+) P | R <-- probe (20,20)
- * E | | I
- * F | (-) N (+) | G <-- nozzle (10,10)
- * T | | H
- * | (-) | T
- * | |
- * O-- FRONT --+
- * (0,0)
+ * #define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
+ *
+ * +-- BACK ---+
+ * | |
+ * L | (+) P | R <-- probe (20,20)
+ * E | | I
+ * F | (-) N (+) | G <-- nozzle (10,10)
+ * T | | H
+ * | (-) | T
+ * | |
+ * O-- FRONT --+
+ * (0,0)
+ *
+ * Specify a Probe position as { X, Y, Z }
*/
#if ENABLED(PetsfangMicroswiss)
- #define X_PROBE_OFFSET_FROM_EXTRUDER -48 // X offset: -left +right [of the nozzle]
- #define Y_PROBE_OFFSET_FROM_EXTRUDER -10 // Y offset: -front +behind [the nozzle]
+ #define NOZZLE_TO_PROBE_OFFSET { -42, -5, 0 }
#elif ENABLED(E3DV6)
- #define X_PROBE_OFFSET_FROM_EXTRUDER 36 // X offset: -left +right [of the nozzle]
- #define Y_PROBE_OFFSET_FROM_EXTRUDER 15 // Y offset: -front +behind [the nozzle]
+ #define NOZZLE_TO_PROBE_OFFSET { 36, 15, 0 }
+#elif ENABLED(Mosquito)
+ #define NOZZLE_TO_PROBE_OFFSET { 0, 26, 0 }
#else
- #define X_PROBE_OFFSET_FROM_EXTRUDER 37 // X offset: -left +right [of the nozzle]
- #define Y_PROBE_OFFSET_FROM_EXTRUDER -10 // Y offset: -front +behind [the nozzle]
+ #define NOZZLE_TO_PROBE_OFFSET { 37, -10, 0 }
#endif
-#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle]
-// Certain types of probes need to stay away from edges
-#define MIN_PROBE_EDGE 10
+// Most probes should stay away from the edges of the bed, but
+// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
+#if ENABLED(Mosquito)
+ #define MIN_PROBE_EDGE 5
+#else
+ #define MIN_PROBE_EDGE 5
+#endif
// X and Y axis travel speed (mm/m) between probes
-#define XY_PROBE_SPEED 3000
+#define XY_PROBE_SPEED 5000
// Feedrate (mm/m) for the first approach when double-probing (MULTIPLE_PROBING == 2)
#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
@@ -897,10 +1103,17 @@
// Feedrate (mm/m) for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
-// The number of probes to perform at each point.
-// Set to 2 for a fast/slow probe, using the second probe result.
-// Set to 3 or more for slow probes, averaging the results.
-//#define MULTIPLE_PROBING 2
+/**
+ * Multiple Probing
+ *
+ * You may get improved results by probing 2 or more times.
+ * With EXTRA_PROBING the more atypical reading(s) will be disregarded.
+ *
+ * A total of 2 does fast/slow probes with a weighted average.
+ * A total of 3 or more adds more slow probes, taking the average.
+ */
+#define MULTIPLE_PROBING 2
+//#define EXTRA_PROBING 1
/**
* Z probes require clearance when deploying, stowing, and moving between
@@ -910,7 +1123,7 @@
*
* Use these settings to specify the distance (mm) to raise the probe (or
* lower the bed). The values set here apply over and above any (negative)
- * probe Z Offset set with Z_PROBE_OFFSET_FROM_EXTRUDER, M851, or the LCD.
+ * probe Z Offset set with NOZZLE_TO_PROBE_OFFSET, M851, or the LCD.
* Only integer values >= 1 are valid here.
*
* Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle.
@@ -921,17 +1134,20 @@
#define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes
//#define Z_AFTER_PROBING 5 // Z position after probing is done
-#define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping
+#define Z_PROBE_LOW_POINT -3 // Farthest distance below the trigger-point to go before stopping
// For M851 give a range for adjusting the Z probe offset
-#define Z_PROBE_OFFSET_RANGE_MIN -20
-#define Z_PROBE_OFFSET_RANGE_MAX 20
+#define Z_PROBE_OFFSET_RANGE_MIN -9
+#define Z_PROBE_OFFSET_RANGE_MAX 9
// Enable the M48 repeatability test to test probe accuracy
//#define Z_MIN_PROBE_REPEATABILITY_TEST
// Before deploy/stow pause for user confirmation
//#define PAUSE_BEFORE_DEPLOY_STOW
+#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
+ //#define PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED // For Manual Deploy Allenkey Probe
+#endif
/**
* Enable one or more of the following if probing seems unreliable.
@@ -972,32 +1188,42 @@
// @section machine
// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
-#define INVERT_X_DIR false
-#define INVERT_Y_DIR false
-#define INVERT_Z_DIR false
+#if ANY(SKRLPCBoard, STOCK_2208)
+ #define INVERT_X_DIR true
+ #define INVERT_Y_DIR true
+ #define INVERT_Z_DIR true
+#else
+ #define INVERT_X_DIR false
+ #define INVERT_Y_DIR false
+ #define INVERT_Z_DIR false
+#endif
// @section extruder
// For direct drive extruder v9 set to true, for geared extruder set to false.
-#if ENABLED(BondtechBMG)
+#if (ENABLED(BondtechBMG, CR10SPro_GearedExtruder) && DISABLED(SKRLPCBoard)) || (DISABLED(BondtechBM, CR10SPro_GearedExtruderG) && ANY(SKRLPCBoard, STOCK_2208))
#define INVERT_E0_DIR true
#else
- #define INVERT_E0_DIR true
+ #define INVERT_E0_DIR false
#endif
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
+#define INVERT_E6_DIR false
+#define INVERT_E7_DIR false
// @section homing
-//#define NO_MOTION_BEFORE_HOMING // Inhibit movement until all axes have been homed
+//#define NO_MOTION_BEFORE_HOMING // Inhibit movement until all axes have been homed
-//#define UNKNOWN_Z_NO_RAISE // Don't raise Z (lower the bed) if Z is "unknown." For beds that fall when Z is powered off.
+//#define UNKNOWN_Z_NO_RAISE // Don't raise Z (lower the bed) if Z is "unknown." For beds that fall when Z is powered off.
-//#define Z_HOMING_HEIGHT 4 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ...
- // Be sure you have this distance over your Z_MAX_POS in case.
+//#define Z_HOMING_HEIGHT 4 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ...
+ // Be sure to have this much clearance over your Z_MAX_POS to prevent grinding.
+
+//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z
// Direction of endstops when homing; 1=MAX, -1=MIN
// :[-1,1]
@@ -1008,9 +1234,24 @@
// @section machine
// The size of the print bed
-#define X_BED_SIZE 398
-#define Y_BED_SIZE 390
+ #if ENABLED(Mosquito)
+ #define XCarriageModifier 10
+ #define YCarriageModifier 35
+ #elif ENABLED(PetsfangMicroswiss)
+ #define XCarriageModifier 10
+ #define YCarriageModifier 10
+#else
+ #define XCarriageModifier 0
+ #define YCarriageModifier 0
+#endif
+#if ENABLED(SX2)
+ #define X_BED_SIZE 248 - XCarriageModifier
+ #define Y_BED_SIZE 238 - YCarriageModifier
+#else
+ #define X_BED_SIZE 398 - XCarriageModifier
+ #define Y_BED_SIZE 390 - YCarriageModifier
+#endif
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
@@ -1018,8 +1259,11 @@
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
-#define Z_MAX_POS 500
-
+#if DISABLED(SX2)
+ #define Z_MAX_POS 500
+#else
+ #define Z_MAX_POS 250
+#endif
/**
* Software Endstops
*
@@ -1045,7 +1289,7 @@
#define MAX_SOFTWARE_ENDSTOP_Z
#endif
-#if ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS)
+#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
//#define SOFT_ENDSTOPS_MENU_ITEM // Enable/Disable software endstops from the LCD
#endif
@@ -1057,7 +1301,7 @@
* For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc.
* By default the firmware assumes HIGH=FILAMENT PRESENT.
*/
- #if ENABLED(FilamentSensorStd) || ENABLED(FilamentSensorLerdge)
+ #if ANY(FilamentSensorStd, FilamentSensorLerdge, FilamentEncoder)
#define FILAMENT_RUNOUT_SENSOR
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
@@ -1071,7 +1315,9 @@
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
- #define FIL_RUNOUT_PIN 2
+ #if DISABLED(SKRLPCBoard)
+ #define FIL_RUNOUT_PIN 2
+ #endif
// Set one or more commands to execute on filament runout.
// (After 'M412 H' Marlin will ask the host to handle the process.)
#define FILAMENT_RUNOUT_SCRIPT "M600"
@@ -1079,13 +1325,19 @@
// After a runout is detected, continue printing this length of filament
// before executing the runout script. Useful for a sensor at the end of
// a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead.
- #define FILAMENT_RUNOUT_DISTANCE_MM 5
+ #if ENABLED(FilamentEncoder)
+ #define FILAMENT_RUNOUT_DISTANCE_MM 15
+ #else
+ #define FILAMENT_RUNOUT_DISTANCE_MM 5
+ #endif
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
// Enable this option to use an encoder disc that toggles the runout pin
// as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM
// large enough to avoid false positives.)
- //#define FILAMENT_MOTION_SENSOR
+ #if ENABLED(FilamentEncoder)
+ #define FILAMENT_MOTION_SENSOR
+ #endif
#endif
#endif
@@ -1129,8 +1381,11 @@
*/
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
-#define AUTO_BED_LEVELING_BILINEAR
-//#define AUTO_BED_LEVELING_UBL
+#if DISABLED(UBL)
+ #define AUTO_BED_LEVELING_BILINEAR
+#else
+ #define AUTO_BED_LEVELING_UBL
+#endif
//#define MESH_BED_LEVELING
/**
@@ -1146,7 +1401,7 @@
*/
//#define DEBUG_LEVELING_FEATURE
-#if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL)
+#if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL)
// Gradually reduce leveling correction until a set height is reached,
// at which point movement will be level to the machine's XY plane.
// The height can be set with M420 Z
@@ -1165,24 +1420,24 @@
#if ENABLED(G26_MESH_VALIDATION)
#define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle.
#define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool.
- #define MESH_TEST_HOTEND_TEMP 205.0 // (°C) Default nozzle temperature for the G26 Mesh Validation Tool.
- #define MESH_TEST_BED_TEMP 60.0 // (°C) Default bed temperature for the G26 Mesh Validation Tool.
+ #define MESH_TEST_HOTEND_TEMP 205 // (°C) Default nozzle temperature for the G26 Mesh Validation Tool.
+ #define MESH_TEST_BED_TEMP 60 // (°C) Default bed temperature for the G26 Mesh Validation Tool.
+ #define G26_XY_FEEDRATE 20 // (mm/s) Feedrate for XY Moves for the G26 Mesh Validation Tool.
+ #define G26_RETRACT_MULTIPLIER 1.0 // G26 Q (retraction) used by default between mesh test elements.
#endif
#endif
-#if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)
+#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
// Set the number of grid points per dimension.
- #define GRID_MAX_POINTS_X 4
+ #if ENABLED(SX2)
+ #define GRID_MAX_POINTS_X 5
+ #else
+ #define GRID_MAX_POINTS_X 10
+ #endif
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
- // Set the boundaries for probing (where the probe can reach).
- //#define LEFT_PROBE_BED_POSITION MIN_PROBE_EDGE
- //#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - (MIN_PROBE_EDGE))
- //#define FRONT_PROBE_BED_POSITION MIN_PROBE_EDGE
- //#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - (MIN_PROBE_EDGE))
-
// Probe along the Y axis, advancing X after each column
//#define PROBE_Y_FIRST
@@ -1236,38 +1491,26 @@
#endif // BED_LEVELING
-/**
- * Points to probe for all 3-point Leveling procedures.
- * Override if the automatically selected points are inadequate.
- */
-#if ENABLED(AUTO_BED_LEVELING_3POINT) || ENABLED(AUTO_BED_LEVELING_UBL)
- //#define PROBE_PT_1_X 15
- //#define PROBE_PT_1_Y 180
- //#define PROBE_PT_2_X 15
- //#define PROBE_PT_2_Y 20
- //#define PROBE_PT_3_X 170
- //#define PROBE_PT_3_Y 20
-#endif
-
/**
* Add a bed leveling sub-menu for ABL or MBL.
* Include a guided procedure if manual probing is enabled.
*/
-//#define LCD_BED_LEVELING
+#define LCD_BED_LEVELING
#if ENABLED(LCD_BED_LEVELING)
#define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis.
#define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment
- //#define MESH_EDIT_MENU // Add a menu to edit mesh points
+ #define MESH_EDIT_MENU // Add a menu to edit mesh points
#endif
// Add a menu item to move between bed corners for manual bed adjustment
//#define LEVEL_BED_CORNERS
#if ENABLED(LEVEL_BED_CORNERS)
- #define LEVEL_CORNERS_INSET 30 // (mm) An inset for corner leveling
- #define LEVEL_CORNERS_Z_HOP 4.0 // (mm) Move nozzle up before moving between corners
- //#define LEVEL_CENTER_TOO // Move to the center after the last corner
+ #define LEVEL_CORNERS_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
+ #define LEVEL_CORNERS_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points
+ #define LEVEL_CORNERS_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points
+ #define LEVEL_CENTER_TOO // Move to the center after the last corner
#endif
/**
@@ -1305,7 +1548,7 @@
#endif
// Homing speeds (mm/m)
-#define HOMING_FEEDRATE_XY 4500
+#define HOMING_FEEDRATE_XY 6000
#define HOMING_FEEDRATE_Z 360
// Validate that endstops are triggered on homing moves
@@ -1374,17 +1617,22 @@
// @section extras
-//
-// EEPROM
-//
-// The microcontroller can store settings in the EEPROM, e.g. max velocity...
-// M500 - stores parameters in EEPROM
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
-// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
-//
-#define EEPROM_SETTINGS // Enable for M500 and M501 commands
-//#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release!
-#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
+/**
+ * EEPROM
+ *
+ * Persistent storage to preserve configurable settings across reboots.
+ *
+ * M500 - Store settings to EEPROM.
+ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes)
+ * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.)
+ */
+#define EEPROM_SETTINGS // Persistent storage with M500 and M501
+//#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release!
+#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
+#define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load
+#if ENABLED(EEPROM_SETTINGS)
+ #define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
+#endif
//
// Host Keepalive
@@ -1396,11 +1644,6 @@
#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113.
#define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating
-//
-// M100 Free Memory Watcher
-//
-//#define M100_FREE_MEMORY_WATCHER // Add M100 (Free Memory Watcher) to debug memory usage
-
//
// G20/G21 Inch mode support
//
@@ -1438,10 +1681,13 @@
#define NOZZLE_PARK_FEATURE
#if ENABLED(NOZZLE_PARK_FEATURE)
- // Specify a park position as { X, Y, Z }
+ // Specify a park position as { X, Y, Z_raise }
#define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MIN_POS + 30), 10 }
- #define NOZZLE_PARK_XY_FEEDRATE 100 // X and Y axes feedrate in mm/s (also used for delta printers Z axis)
- #define NOZZLE_PARK_Z_FEEDRATE 5 // Z axis feedrate in mm/s (not used for delta printers)
+ //#define NOZZLE_PARK_X_ONLY // X move only is required to park
+ //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park
+ #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance
+ #define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis)
+ #define NOZZLE_PARK_Z_FEEDRATE 5 // (mm/s) Z axis feedrate (not used for delta printers)
#endif
/**
@@ -1491,9 +1737,10 @@
// Default number of triangles
#define NOZZLE_CLEAN_TRIANGLES 3
- // Specify positions as { X, Y, Z }
- #define NOZZLE_CLEAN_START_POINT { 30, 30, (Z_MIN_POS + 1)}
- #define NOZZLE_CLEAN_END_POINT {100, 60, (Z_MIN_POS + 1)}
+ // Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
+ // Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
+ #define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } }
+ #define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } }
// Circular pattern radius
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5
@@ -1502,8 +1749,11 @@
// Middle point of circle
#define NOZZLE_CLEAN_CIRCLE_MIDDLE NOZZLE_CLEAN_START_POINT
- // Moves the nozzle to the initial position
+ // Move the nozzle to the initial position after cleaning
#define NOZZLE_CLEAN_GOBACK
+
+ // Enable for a purge/clean station that's always at the gantry height (thus no Z move)
+ //#define NOZZLE_CLEAN_NO_Z
#endif
/**
@@ -1548,10 +1798,10 @@
*
* Select the language to display on the LCD. These languages are available:
*
- * en, an, bg, ca, cz, da, de, el, el-gr, es, eu, fi, fr, gl, hr, it,
- * jp-kana, ko_KR, nl, pl, pt, pt-br, ru, sk, tr, uk, zh_CN, zh_TW, test
+ * en, an, bg, ca, cz, da, de, el, el_gr, es, eu, fi, fr, gl, hr, it, jp_kana,
+ * ko_KR, nl, pl, pt, pt_br, ru, sk, tr, uk, vi, zh_CN, zh_TW, test
*
- * :{ 'en':'English', 'an':'Aragonese', 'bg':'Bulgarian', 'ca':'Catalan', 'cz':'Czech', 'da':'Danish', 'de':'German', 'el':'Greek', 'el-gr':'Greek (Greece)', 'es':'Spanish', 'eu':'Basque-Euskera', 'fi':'Finnish', 'fr':'French', 'gl':'Galician', 'hr':'Croatian', 'it':'Italian', 'jp-kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt-br':'Portuguese (Brazilian)', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'zh_CN':'Chinese (Simplified)', 'zh_TW':'Chinese (Traditional)', 'test':'TEST' }
+ * :{ 'en':'English', 'an':'Aragonese', 'bg':'Bulgarian', 'ca':'Catalan', 'cz':'Czech', 'da':'Danish', 'de':'German', 'el':'Greek', 'el_gr':'Greek (Greece)', 'es':'Spanish', 'eu':'Basque-Euskera', 'fi':'Finnish', 'fr':'French', 'gl':'Galician', 'hr':'Croatian', 'it':'Italian', 'jp_kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt_br':'Portuguese (Brazilian)', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'vi':'Vietnamese', 'zh_CN':'Chinese (Simplified)', 'zh_TW':'Chinese (Traditional)', 'test':'TEST' }
*/
#define LCD_LANGUAGE en
@@ -1601,8 +1851,8 @@
* Enable one of the following items for a slower SPI transfer speed.
* This may be required to resolve "volume init" errors.
*/
-#define SPI_SPEED SPI_HALF_SPEED
-//#define SPI_SPEED SPI_QUARTER_SPEED
+//#define SPI_SPEED SPI_HALF_SPEED
+#define SPI_SPEED SPI_QUARTER_SPEED
//#define SPI_SPEED SPI_EIGHTH_SPEED
/**
@@ -1610,7 +1860,7 @@
*
* Use CRC checks and retries on the SD communication.
*/
-#define SD_CHECK_AND_RETRY
+//#define SD_CHECK_AND_RETRY
/**
* LCD Menu Items
@@ -1660,6 +1910,14 @@
//
//#define REVERSE_MENU_DIRECTION
+//
+// This option reverses the encoder direction for Select Screen.
+//
+// If CLOCKWISE normally moves LEFT this makes it go RIGHT.
+// If CLOCKWISE normally moves RIGHT this makes it go LEFT.
+//
+//#define REVERSE_SELECT_DIRECTION
+
//
// Individual Axis Homing
//
@@ -1696,7 +1954,9 @@
//
// Note: Usually sold with a white PCB.
//
-#define REPRAP_DISCOUNT_SMART_CONTROLLER
+#if DISABLED(GRAPHICSLCD)
+ #define REPRAP_DISCOUNT_SMART_CONTROLLER
+#endif
//
// Original RADDS LCD Display+Encoder+SDCardReader
@@ -1736,7 +1996,7 @@
//
// Makeboard 3D Printer Parts 3D Printer Mini Display 1602 Mini Controller
-// https://www.aliexpress.com/item/Micromake-Makeboard-3D-Printer-Parts-3D-Printer-Mini-Display-1602-Mini-Controller-Compatible-with-Ramps-1/32765887917.html
+// https://www.aliexpress.com/item/32765887917.html
//
//#define MAKEBOARD_MINI_2_LINE_DISPLAY_1602
@@ -1836,7 +2096,9 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
-//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
+#if ENABLED(GRAPHICSLCD)
+ #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
+#endif
//
// ReprapWorld Graphical LCD
@@ -1887,46 +2149,42 @@
//
//#define LCD_FOR_MELZI
-//
-// SSD1306 OLED full graphics generic display
-//
-//#define U8GLIB_SSD1306
-
-//
-// SAV OLEd LCD module support using either SSD1306 or SH1106 based LCD modules
-//
-//#define SAV_3DGLCD
-#if ENABLED(SAV_3DGLCD)
- //#define U8GLIB_SSD1306
- #define U8GLIB_SH1106
-#endif
-
//
// Original Ulticontroller from Ultimaker 2 printer with SSD1309 I2C display and encoder
// https://github.com/Ultimaker/Ultimaker2/tree/master/1249_Ulticontroller_Board_(x1)
//
//#define ULTI_CONTROLLER
-//
-// TinyBoy2 128x64 OLED / Encoder Panel
-//
-//#define OLED_PANEL_TINYBOY2
-
//
// MKS MINI12864 with graphic controller and SD support
-// http://reprap.org/wiki/MKS_MINI_12864
+// https://reprap.org/wiki/MKS_MINI_12864
//
//#define MKS_MINI_12864
+//
+// FYSETC variant of the MINI12864 graphic controller with SD support
+// https://wiki.fysetc.com/Mini12864_Panel/
+//
+//#define FYSETC_MINI_12864_X_X // Type C/D/E/F. No tunable RGB Backlight by default
+//#define FYSETC_MINI_12864_1_2 // Type C/D/E/F. Simple RGB Backlight (always on)
+//#define FYSETC_MINI_12864_2_0 // Type A/B. Discreet RGB Backlight
+//#define FYSETC_MINI_12864_2_1 // Type A/B. Neopixel RGB Backlight
+//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
+
//
// Factory display for Creality CR-10
-// https://www.aliexpress.com/item/Universal-LCD-12864-3D-Printer-Display-Screen-With-Encoder-For-CR-10-CR-7-Model/32833148327.html
+// https://www.aliexpress.com/item/32833148327.html
//
// This is RAMPS-compatible using a single 10-pin connector.
// (For CR-10 owners who want to replace the Melzi Creality board but retain the display)
//
//#define CR10_STOCKDISPLAY
+//
+// Ender-2 OEM display, a variant of the MKS_MINI_12864
+//
+//#define ENDER2_STOCKDISPLAY
+
//
// ANET and Tronxy Graphical Controller
//
@@ -1936,18 +2194,9 @@
//
//#define ANET_FULL_GRAPHICS_LCD
-//
-// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
-// http://reprap.org/wiki/MKS_12864OLED
-//
-// Tiny, but very sharp OLED display
-//
-//#define MKS_12864OLED // Uses the SH1106 controller (default)
-//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
-
//
// AZSMZ 12864 LCD with SD
-// https://www.aliexpress.com/store/product/3D-printer-smart-controller-SMART-RAMPS-OR-RAMPS-1-4-LCD-12864-LCD-control-panel-green/2179173_32213636460.html
+// https://www.aliexpress.com/item/32837222770.html
//
//#define AZSMZ_12864
@@ -1957,12 +2206,73 @@
//
//#define SILVER_GATE_GLCD_CONTROLLER
+//=============================================================================
+//============================== OLED Displays ==============================
+//=============================================================================
+
//
-// Extensible UI
+// SSD1306 OLED full graphics generic display
//
-// Enable third-party or vendor customized user interfaces that aren't
-// packaged with Marlin. Source code for the user interface will need to
-// be placed in "src/lcd/extensible_ui/lib"
+//#define U8GLIB_SSD1306
+
+//
+// SAV OLEd LCD module support using either SSD1306 or SH1106 based LCD modules
+//
+//#define SAV_3DGLCD
+#if ENABLED(SAV_3DGLCD)
+ #define U8GLIB_SSD1306
+ //#define U8GLIB_SH1106
+#endif
+
+//
+// TinyBoy2 128x64 OLED / Encoder Panel
+//
+//#define OLED_PANEL_TINYBOY2
+
+//
+// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
+// http://reprap.org/wiki/MKS_12864OLED
+//
+// Tiny, but very sharp OLED display
+//
+//#define MKS_12864OLED // Uses the SH1106 controller (default)
+//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
+
+//
+// Einstart S OLED SSD1306
+//
+//#define U8GLIB_SH1106_EINSTART
+
+//
+// Overlord OLED display/controller with i2c buzzer and LEDs
+//
+//#define OVERLORD_OLED
+
+//=============================================================================
+//========================== Extensible UI Displays ===========================
+//=============================================================================
+
+//
+// DGUS Touch Display with DWIN OS. (Choose one.)
+//
+//#define DGUS_LCD_UI_ORIGIN
+//#define DGUS_LCD_UI_FYSETC
+//#define DGUS_LCD_UI_HIPRECY
+
+//
+// Touch-screen LCD for Malyan M200 printers
+//
+//#define MALYAN_LCD
+
+//
+// Touch UI for FTDI EVE (FT800/FT810) displays
+// See Configuration_adv.h for all configuration options.
+//
+//#define TOUCH_UI_FTDI_EVE
+
+//
+// Third-party or vendor-customized controller interfaces.
+// Sources should be installed in 'src/lcd/extensible_ui'.
//
//#define EXTENSIBLE_UI
@@ -1971,36 +2281,34 @@
//=============================================================================
//
-// MKS Robin 320x240 color display
+// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
//
-//#define MKS_ROBIN_TFT
+//#define FSMC_GRAPHICAL_TFT
//=============================================================================
//============================ Other Controllers ============================
//=============================================================================
//
-// CONTROLLER TYPE: Standalone / Serial
+// ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
//
+//#define TOUCH_BUTTONS
+#if ENABLED(TOUCH_BUTTONS)
+ #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
+ #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
-//
-// LCD for Malyan M200 printers.
-//
-//#define MALYAN_LCD
-
-//
-// CONTROLLER TYPE: Keypad / Add-on
-//
+ #define XPT2046_X_CALIBRATION 12316
+ #define XPT2046_Y_CALIBRATION -8981
+ #define XPT2046_X_OFFSET -43
+ #define XPT2046_Y_OFFSET 257
+#endif
//
// RepRapWorld REPRAPWORLD_KEYPAD v1.1
// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
//
-// REPRAPWORLD_KEYPAD_MOVE_STEP sets how much should the robot move when a key
-// is pressed, a value of 10.0 means 10mm per click.
-//
//#define REPRAPWORLD_KEYPAD
-//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0
+//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
//=============================================================================
//=============================== Extra Features ==============================
@@ -2020,6 +2328,7 @@
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
// However, control resolution will be halved for each increment;
// at zero value, there are 128 effective control positions.
+// :[0,1,2,3,4,5,6,7]
#define SOFT_PWM_SCALE 0
// If SOFT_PWM_SCALE is set to a value higher than 0, dithering can
@@ -2074,22 +2383,28 @@
//#define RGB_LED
//#define RGBW_LED
-#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
- #define RGB_LED_R_PIN 34
- #define RGB_LED_G_PIN 43
- #define RGB_LED_B_PIN 35
- #define RGB_LED_W_PIN -1
+#if EITHER(RGB_LED, RGBW_LED)
+ //#define RGB_LED_R_PIN 34
+ //#define RGB_LED_G_PIN 43
+ //#define RGB_LED_B_PIN 35
+ //#define RGB_LED_W_PIN -1
#endif
// Support for Adafruit Neopixel LED driver
//#define NEOPIXEL_LED
#if ENABLED(NEOPIXEL_LED)
#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
- #define NEOPIXEL_PIN 4 // LED driving pin on motherboard 4 => D4 (EXP2-5 on Printrboard) / 30 => PC7 (EXP3-13 on Rumba)
- #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip
+ #define NEOPIXEL_PIN 4 // LED driving pin
+ //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
+ //#define NEOPIXEL2_PIN 5
+ #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
#define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
#define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255)
//#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup
+
+ // Use a single Neopixel LED for static (background) lighting
+ //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
+ //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
#endif
/**
@@ -2103,7 +2418,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
-#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) || ENABLED(PCA9533)|| ENABLED(NEOPIXEL_LED)
+#if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
#define PRINTER_EVENT_LEDS
#endif
@@ -2121,7 +2436,7 @@
*/
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
-// Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle.
+// (ms) Delay before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY { 300 }
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index c6b6bed028..7a2575b5d9 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
* Basic settings can be found in Configuration.h
*
*/
-#define CONFIGURATION_ADV_H_VERSION 020000
+#define CONFIGURATION_ADV_H_VERSION 020005
// @section temperature
@@ -39,6 +39,69 @@
//=============================Thermal Settings ============================
//===========================================================================
+//
+// Custom Thermistor 1000 parameters
+//
+#if TEMP_SENSOR_0 == 1000
+ #define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND0_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_1 == 1000
+ #define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND1_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_2 == 1000
+ #define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND2_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_3 == 1000
+ #define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND3_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_4 == 1000
+ #define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND4_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_5 == 1000
+ #define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND5_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_6 == 1000
+ #define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND6_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_7 == 1000
+ #define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define HOTEND7_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_BED == 1000
+ #define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define BED_BETA 3950 // Beta value
+#endif
+
+#if TEMP_SENSOR_CHAMBER == 1000
+ #define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
+ #define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
+ #define CHAMBER_BETA 3950 // Beta value
+#endif
+
//
// Hephestos 2 24V heated bed upgrade kit.
// https://store.bq.com/en/heated-bed-kit-hephestos2
@@ -50,6 +113,18 @@
#define HEATER_BED_INVERTING true
#endif
+/**
+ * Heated Chamber settings
+ */
+#if TEMP_SENSOR_CHAMBER
+ #define CHAMBER_MINTEMP 5
+ #define CHAMBER_MAXTEMP 60
+ #define TEMP_CHAMBER_HYSTERESIS 1 // (°C) Temperature proximity considered "close enough" to the target
+ //#define CHAMBER_LIMIT_SWITCHING
+ //#define HEATER_CHAMBER_PIN 44 // Chamber heater on/off pin
+ //#define HEATER_CHAMBER_INVERTING false
+#endif
+
#if DISABLED(PIDTEMPBED)
#define BED_CHECK_INTERVAL 5000 // ms between checks in bang-bang control
#if ENABLED(BED_LIMIT_SWITCHING)
@@ -75,10 +150,10 @@
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 120 // Seconds
- #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius
+ #define THERMAL_PROTECTION_HYSTERESIS 10 // Degrees Celsius
#define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops
- #if ENABLED(ADAPTIVE_FAN_SLOWING) && ENABLED(PIDTEMP)
+ #if BOTH(ADAPTIVE_FAN_SLOWING, PIDTEMP)
#define NO_FAN_SLOWING_IN_PID_TUNING // Don't slow fan speed during M303
#endif
@@ -112,14 +187,78 @@
#define WATCH_BED_TEMP_INCREASE 4 // Degrees Celsius
#endif
+/**
+ * Thermal Protection parameters for the heated chamber.
+ */
+#if ENABLED(THERMAL_PROTECTION_CHAMBER)
+ #define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // Seconds
+ #define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // Degrees Celsius
+
+ /**
+ * Heated chamber watch settings (M141/M191).
+ */
+ #define WATCH_CHAMBER_TEMP_PERIOD 60 // Seconds
+ #define WATCH_CHAMBER_TEMP_INCREASE 2 // Degrees Celsius
+#endif
+
#if ENABLED(PIDTEMP)
- // this adds an experimental additional term to the heating power, proportional to the extrusion speed.
- // if Kc is chosen well, the additional required power due to increased melting should be compensated.
+ // Add an experimental additional term to the heater power, proportional to the extrusion speed.
+ // A well-chosen Kc value should add just enough power to melt the increased material volume.
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif
+
+ /**
+ * Add an experimental additional term to the heater power, proportional to the fan speed.
+ * A well-chosen Kf value should add just enough power to compensate for power-loss from the cooling fan.
+ * You can either just add a constant compensation with the DEFAULT_Kf value
+ * or follow the instruction below to get speed-dependent compensation.
+ *
+ * Constant compensation (use only with fanspeeds of 0% and 100%)
+ * ---------------------------------------------------------------------
+ * A good starting point for the Kf-value comes from the calculation:
+ * kf = (power_fan * eff_fan) / power_heater * 255
+ * where eff_fan is between 0.0 and 1.0, based on fan-efficiency and airflow to the nozzle / heater.
+ *
+ * Example:
+ * Heater: 40W, Fan: 0.1A * 24V = 2.4W, eff_fan = 0.8
+ * Kf = (2.4W * 0.8) / 40W * 255 = 12.24
+ *
+ * Fan-speed dependent compensation
+ * --------------------------------
+ * 1. To find a good Kf value, set the hotend temperature, wait for it to settle, and enable the fan (100%).
+ * Make sure PID_FAN_SCALING_LIN_FACTOR is 0 and PID_FAN_SCALING_ALTERNATIVE_DEFINITION is not enabled.
+ * If you see the temperature drop repeat the test, increasing the Kf value slowly, until the temperature
+ * drop goes away. If the temperature overshoots after enabling the fan, the Kf value is too big.
+ * 2. Note the Kf-value for fan-speed at 100%
+ * 3. Determine a good value for PID_FAN_SCALING_MIN_SPEED, which is around the speed, where the fan starts moving.
+ * 4. Repeat step 1. and 2. for this fan speed.
+ * 5. Enable PID_FAN_SCALING_ALTERNATIVE_DEFINITION and enter the two identified Kf-values in
+ * PID_FAN_SCALING_AT_FULL_SPEED and PID_FAN_SCALING_AT_MIN_SPEED. Enter the minimum speed in PID_FAN_SCALING_MIN_SPEED
+ */
+ //#define PID_FAN_SCALING
+ #if ENABLED(PID_FAN_SCALING)
+ //#define PID_FAN_SCALING_ALTERNATIVE_DEFINITION
+ #if ENABLED(PID_FAN_SCALING_ALTERNATIVE_DEFINITION)
+ // The alternative definition is used for an easier configuration.
+ // Just figure out Kf at fullspeed (255) and PID_FAN_SCALING_MIN_SPEED.
+ // DEFAULT_Kf and PID_FAN_SCALING_LIN_FACTOR are calculated accordingly.
+
+ #define PID_FAN_SCALING_AT_FULL_SPEED 13.0 //=PID_FAN_SCALING_LIN_FACTOR*255+DEFAULT_Kf
+ #define PID_FAN_SCALING_AT_MIN_SPEED 6.0 //=PID_FAN_SCALING_LIN_FACTOR*PID_FAN_SCALING_MIN_SPEED+DEFAULT_Kf
+ #define PID_FAN_SCALING_MIN_SPEED 10.0 // Minimum fan speed at which to enable PID_FAN_SCALING
+
+ #define DEFAULT_Kf (255.0*PID_FAN_SCALING_AT_MIN_SPEED-PID_FAN_SCALING_AT_FULL_SPEED*PID_FAN_SCALING_MIN_SPEED)/(255.0-PID_FAN_SCALING_MIN_SPEED)
+ #define PID_FAN_SCALING_LIN_FACTOR (PID_FAN_SCALING_AT_FULL_SPEED-DEFAULT_Kf)/255.0
+
+ #else
+ #define PID_FAN_SCALING_LIN_FACTOR (0) // Power loss due to cooling = Kf * (fan_speed)
+ #define DEFAULT_Kf 10 // A constant value added to the PID-tuner
+ #define PID_FAN_SCALING_MIN_SPEED 10 // Minimum fan speed at which to enable PID_FAN_SCALING
+ #endif
+ #endif
#endif
/**
@@ -137,8 +276,10 @@
#define AUTOTEMP_OLDWEIGHT 0.98
#endif
-// Show extra position information in M114
-//#define M114_DETAIL
+// Extra options for the M114 "Current Position" report
+//#define M114_DETAIL // Use 'M114` for details to check planner calculations
+//#define M114_REALTIME // Real current position based on forward kinematics
+//#define M114_LEGACY // M114 used to synchronize on every call. Enable if needed.
// Show Temperature ADC value
// Enable for M105 to include ADC values read from temperature sensors.
@@ -197,14 +338,22 @@
* Controller Fan
* To cool down the stepper drivers and MOSFETs.
*
- * The fan will turn on automatically whenever any stepper is enabled
- * and turn off after a set period after all steppers are turned off.
+ * The fan turns on automatically whenever any driver is enabled and turns
+ * off (or reduces to idle speed) shortly after drivers are turned off.
+ *
*/
//#define USE_CONTROLLER_FAN
#if ENABLED(USE_CONTROLLER_FAN)
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
- #define CONTROLLERFAN_SECS 60 // Duration in seconds for the fan to run after all motors are disabled
- #define CONTROLLERFAN_SPEED 255 // 255 == full speed
+ //#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
+ #define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
+ #define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
+ #define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
+ #define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors
+ //#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
+ #if ENABLED(CONTROLLER_FAN_EDITABLE)
+ #define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
+ #endif
#endif
// When first starting the main fan, run it at full speed for the
@@ -212,6 +361,9 @@
// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
//#define FAN_KICKSTART_TIME 100
+// Some coolers may require a non-zero "off" state.
+//#define FAN_OFF_PWM 1
+
/**
* PWM Fan Scaling
*
@@ -227,6 +379,33 @@
//#define FAN_MIN_PWM 50
//#define FAN_MAX_PWM 128
+/**
+ * FAST PWM FAN Settings
+ *
+ * Use to change the FAST FAN PWM frequency (if enabled in Configuration.h)
+ * Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a
+ * frequency as close as possible to the desired frequency.
+ *
+ * FAST_PWM_FAN_FREQUENCY [undefined by default]
+ * Set this to your desired frequency.
+ * If left undefined this defaults to F = F_CPU/(2*255*1)
+ * i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
+ * These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
+ * NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
+ *
+ * USE_OCR2A_AS_TOP [undefined by default]
+ * Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2:
+ * 16MHz MCUs: [62.5KHz, 31.4KHz (default), 7.8KHz, 3.92KHz, 1.95KHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz]
+ * 20MHz MCUs: [78.1KHz, 39.2KHz (default), 9.77KHz, 4.9KHz, 2.44KHz, 1.22KHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz]
+ * A greater range can be achieved by enabling USE_OCR2A_AS_TOP. But note that this option blocks the use of
+ * PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.)
+ * USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies.
+ */
+#if ENABLED(FAST_PWM_FAN)
+ //#define FAST_PWM_FAN_FREQUENCY 31400
+ //#define USE_OCR2A_AS_TOP
+#endif
+
// @section extruder
/**
@@ -248,8 +427,11 @@
#define E4_AUTO_FAN_PIN -1
#define E5_AUTO_FAN_PIN -1
#define CHAMBER_AUTO_FAN_PIN -1
+
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // 255 == full speed
+#define CHAMBER_AUTO_FAN_TEMPERATURE 30
+#define CHAMBER_AUTO_FAN_SPEED 255
/**
* Part-Cooling Fan Multiplexer
@@ -271,17 +453,15 @@
#define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW
#define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin)
- //#define MENU_ITEM_CASE_LIGHT // Add a Case Light option to the LCD main menu
+ //#define CASE_LIGHT_MAX_PWM 128 // Limit pwm
+ //#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu
+ //#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting.
//#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED.
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White }
#endif
#endif
-//===========================================================================
-//============================ Mechanical Settings ==========================
-//===========================================================================
-
// @section homing
// If you want endstops to stay on (by default) even when not homing
@@ -320,7 +500,7 @@
//#define X_DUAL_ENDSTOPS
#if ENABLED(X_DUAL_ENDSTOPS)
#define X2_USE_ENDSTOP _XMAX_
- #define X_DUAL_ENDSTOPS_ADJUSTMENT 0
+ #define X2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
@@ -330,27 +510,31 @@
//#define Y_DUAL_ENDSTOPS
#if ENABLED(Y_DUAL_ENDSTOPS)
#define Y2_USE_ENDSTOP _YMAX_
- #define Y_DUAL_ENDSTOPS_ADJUSTMENT 0
+ #define Y2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
-//#define Z_DUAL_STEPPER_DRIVERS
-#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
- //#define Z_DUAL_ENDSTOPS
- #if ENABLED(Z_DUAL_ENDSTOPS)
- #define Z2_USE_ENDSTOP _XMAX_
- #define Z_DUAL_ENDSTOPS_ADJUSTMENT 0
- #endif
+//
+// For Z set the number of stepper drivers
+//
+#if ENABLED(DUAL_Z)
+ #define NUM_Z_STEPPER_DRIVERS 2 // (1-4) Z options change based on how many
+#else
+ #define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many
#endif
-
-//#define Z_TRIPLE_STEPPER_DRIVERS
-#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
- //#define Z_TRIPLE_ENDSTOPS
- #if ENABLED(Z_TRIPLE_ENDSTOPS)
- #define Z2_USE_ENDSTOP _XMAX_
- #define Z3_USE_ENDSTOP _YMAX_
- #define Z_TRIPLE_ENDSTOPS_ADJUSTMENT2 0
- #define Z_TRIPLE_ENDSTOPS_ADJUSTMENT3 0
+#if NUM_Z_STEPPER_DRIVERS > 1
+ //#define Z_MULTI_ENDSTOPS
+ #if ENABLED(Z_MULTI_ENDSTOPS)
+ #define Z2_USE_ENDSTOP _XMAX_
+ #define Z2_ENDSTOP_ADJUSTMENT 0
+ #if NUM_Z_STEPPER_DRIVERS >= 3
+ #define Z3_USE_ENDSTOP _YMAX_
+ #define Z3_ENDSTOP_ADJUSTMENT 0
+ #endif
+ #if NUM_Z_STEPPER_DRIVERS >= 4
+ #define Z4_USE_ENDSTOP _ZMAX_
+ #define Z4_ENDSTOP_ADJUSTMENT 0
+ #endif
#endif
#endif
@@ -363,31 +547,40 @@
* The inactive carriage is parked automatically to prevent oozing.
* X1 is the left carriage, X2 the right. They park and home at opposite ends of the X axis.
* By default the X2 stepper is assigned to the first unused E plug on the board.
+ *
+ * The following Dual X Carriage modes can be selected with M605 S:
+ *
+ * 0 : (FULL_CONTROL) The slicer has full control over both X-carriages and can achieve optimal travel
+ * results as long as it supports dual X-carriages. (M605 S0)
+ *
+ * 1 : (AUTO_PARK) The firmware automatically parks and unparks the X-carriages on tool-change so
+ * that additional slicer support is not required. (M605 S1)
+ *
+ * 2 : (DUPLICATION) The firmware moves the second X-carriage and extruder in synchronization with
+ * the first X-carriage and extruder, to print 2 copies of the same object at the same time.
+ * Set the constant X-offset and temperature differential with M605 S2 X[offs] R[deg] and
+ * follow with M605 S2 to initiate duplicated movement.
+ *
+ * 3 : (MIRRORED) Formbot/Vivedino-inspired mirrored mode in which the second extruder duplicates
+ * the movement of the first except the second extruder is reversed in the X axis.
+ * Set the initial X offset and temperature differential with M605 S2 X[offs] R[deg] and
+ * follow with M605 S3 to initiate mirrored movement.
*/
//#define DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
- #define X1_MIN_POS X_MIN_POS // set minimum to ensure first x-carriage doesn't hit the parked second X-carriage
- #define X1_MAX_POS X_BED_SIZE // set maximum to ensure first x-carriage doesn't hit the parked second X-carriage
- #define X2_MIN_POS 80 // set minimum to ensure second x-carriage doesn't hit the parked first X-carriage
- #define X2_MAX_POS 353 // set maximum to the distance between toolheads when both heads are homed
- #define X2_HOME_DIR 1 // the second X-carriage always homes to the maximum endstop position
- #define X2_HOME_POS X2_MAX_POS // default home position is the maximum carriage position
- // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software
- // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops
- // without modifying the firmware (through the "M218 T1 X???" command).
- // Remember: you should set the second extruder x-offset to 0 in your slicer.
-
- // There are a few selectable movement modes for dual x-carriages using M605 S
- // Mode 0 (DXC_FULL_CONTROL_MODE): Full control. The slicer has full control over both x-carriages and can achieve optimal travel results
- // as long as it supports dual x-carriages. (M605 S0)
- // Mode 1 (DXC_AUTO_PARK_MODE) : Auto-park mode. The firmware will automatically park and unpark the x-carriages on tool changes so
- // that additional slicer support is not required. (M605 S1)
- // Mode 2 (DXC_DUPLICATION_MODE) : Duplication mode. The firmware will transparently make the second x-carriage and extruder copy all
- // actions of the first x-carriage. This allows the printer to print 2 arbitrary items at
- // once. (2nd extruder x offset and temp offset are set using: M605 S2 [Xnnn] [Rmmm])
+ #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS
+ #define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage
+ #define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage
+ #define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed
+ #define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position
+ #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS.
+ // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software
+ // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops
+ // without modifying the firmware (through the "M218 T1 X???" command).
+ // Remember: you should set the second extruder x-offset to 0 in your slicer.
// This is the default power-up mode which can be later using M605.
- #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_FULL_CONTROL_MODE
+ #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE
// Default x offset in duplication mode (typically set to half print bed width)
#define DEFAULT_DUPLICATION_X_OFFSET 100
@@ -400,46 +593,159 @@
// @section homing
-// Homing hits each endstop, retracts by these distances, then does a slower bump.
-#define X_HOME_BUMP_MM 5
-#define Y_HOME_BUMP_MM 5
-#define Z_HOME_BUMP_MM 5
-#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
-//#define QUICK_HOME // If homing includes X and Y, do a diagonal move initially
+/**
+ * Homing Procedure
+ * Homing (G28) does an indefinite move towards the endstops to establish
+ * the position of the toolhead relative to the workspace.
+ */
-// When G28 is called, this option will make Y home before X
-//#define HOME_Y_BEFORE_X
+//#define SENSORLESS_BACKOFF_MM { 2, 2 } // (mm) Backoff from endstops before sensorless homing
-// Enable this if X or Y can't home without homing the other axis first.
-//#define CODEPENDENT_XY_HOMING
+#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump
+#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
+
+#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing
+
+#define QUICK_HOME // If G28 contains XY do a diagonal move first
+//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
+//#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first
+
+// @section bltouch
+
+#if ENABLED(BLTOUCH)
+ /**
+ * Either: Use the defaults (recommended) or: For special purposes, use the following DEFINES
+ * Do not activate settings that the probe might not understand. Clones might misunderstand
+ * advanced commands.
+ *
+ * Note: If the probe is not deploying, check a "Cmd: Reset" and "Cmd: Self-Test" and then
+ * check the wiring of the BROWN, RED and ORANGE wires.
+ *
+ * Note: If the trigger signal of your probe is not being recognized, it has been very often
+ * because the BLACK and WHITE wires needed to be swapped. They are not "interchangeable"
+ * like they would be with a real switch. So please check the wiring first.
+ *
+ * Settings for all BLTouch and clone probes:
+ */
+
+ // Safety: The probe needs time to recognize the command.
+ // Minimum command delay (ms). Enable and increase if needed.
+ //#define BLTOUCH_DELAY 500
+
+ /**
+ * Settings for BLTOUCH Classic 1.2, 1.3 or BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1, and most clones:
+ */
+
+ // Feature: Switch into SW mode after a deploy. It makes the output pulse longer. Can be useful
+ // in special cases, like noisy or filtered input configurations.
+ //#define BLTOUCH_FORCE_SW_MODE
+
+ /**
+ * Settings for BLTouch Smart 3.0 and 3.1
+ * Summary:
+ * - Voltage modes: 5V and OD (open drain - "logic voltage free") output modes
+ * - High-Speed mode
+ * - Disable LCD voltage options
+ */
+
+ /**
+ * Danger: Don't activate 5V mode unless attached to a 5V-tolerant controller!
+ * V3.0 or 3.1: Set default mode to 5V mode at Marlin startup.
+ * If disabled, OD mode is the hard-coded default on 3.0
+ * On startup, Marlin will compare its eeprom to this vale. If the selected mode
+ * differs, a mode set eeprom write will be completed at initialization.
+ * Use the option below to force an eeprom write to a V3.1 probe regardless.
+ */
+ //#define BLTOUCH_SET_5V_MODE
+
+ /**
+ * Safety: Activate if connecting a probe with an unknown voltage mode.
+ * V3.0: Set a probe into mode selected above at Marlin startup. Required for 5V mode on 3.0
+ * V3.1: Force a probe with unknown mode into selected mode at Marlin startup ( = Probe EEPROM write )
+ * To preserve the life of the probe, use this once then turn it off and re-flash.
+ */
+ //#define BLTOUCH_FORCE_MODE_SET
+
+ /**
+ * Use "HIGH SPEED" mode for probing.
+ * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
+ * This feature was designed for Delta's with very fast Z moves however higher speed cartesians may function
+ * If the machine cannot raise the probe fast enough after a trigger, it may enter a fault state.
+ */
+ #define BLTOUCH_HS_MODE
+
+ // Safety: Enable voltage mode settings in the LCD menu.
+ //#define BLTOUCH_LCD_VOLTAGE_MENU
+
+#endif // BLTOUCH
/**
* Z Steppers Auto-Alignment
* Add the G34 command to align multiple Z steppers using a bed probe.
*/
-//#define Z_STEPPER_AUTO_ALIGN
+#if ENABLED(DUAL_Z)
+ #define Z_STEPPER_AUTO_ALIGN
+#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
- // Define probe X and Y positions for Z1, Z2 [, Z3]
- #define Z_STEPPER_ALIGN_X { 10, 150, 290 }
- #define Z_STEPPER_ALIGN_Y { 290, 10, 290 }
- // Set number of iterations to align
- #define Z_STEPPER_ALIGN_ITERATIONS 3
- // Enable to restore leveling setup after operation
- #define RESTORE_LEVELING_AFTER_G34
- // Use the amplification factor to de-/increase correction step.
- // In case the stepper (spindle) position is further out than the test point
- // Use a value > 1. NOTE: This may cause instability
- #define Z_STEPPER_ALIGN_AMP 1.0
- // Stop criterion. If the accuracy is better than this stop iterating early
- #define Z_STEPPER_ALIGN_ACC 0.02
+ // Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]]
+ // If not defined, probe limits will be used.
+ // Override with 'M422 S X Y'
+ //#define Z_STEPPER_ALIGN_XY { { 10, 190 }, { 100, 10 }, { 190, 190 } }
+
+ /**
+ * Orientation for the automatically-calculated probe positions.
+ * Override Z stepper align points with 'M422 S X Y'
+ *
+ * 2 Steppers: (0) (1)
+ * | | 2 |
+ * | 1 2 | |
+ * | | 1 |
+ *
+ * 3 Steppers: (0) (1) (2) (3)
+ * | 3 | 1 | 2 1 | 2 |
+ * | | 3 | | 3 |
+ * | 1 2 | 2 | 3 | 1 |
+ *
+ * 4 Steppers: (0) (1) (2) (3)
+ * | 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
+ #endif
+
+ // Provide Z stepper positions for more rapid convergence in bed alignment.
+ // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3)
+ //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS
+ #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
+ // Define Stepper XY positions for Z1, Z2, Z3 corresponding to
+ // the Z screw positions in the bed carriage.
+ // Define one position per Z stepper in stepper driver order.
+ #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
+ #else
+ // Amplification factor. Used to scale the correction step up or down in case
+ // the stepper (spindle) position is farther out than the test point.
+ #define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability!
+ #endif
+
+ // On a 300mm bed a 5% grade would give a misalignment of ~1.5cm
+ #define G34_MAX_GRADE 15 // (%) Maximum incline that G34 will handle
+ #define Z_STEPPER_ALIGN_ITERATIONS 8 // Number of iterations to apply during alignment
+ #define Z_STEPPER_ALIGN_ACC 0.02 // Stop iterating early if the accuracy is better than this
+ #define RESTORE_LEVELING_AFTER_G34 // Restore leveling after G34 is done?
+ // After G34, re-home Z (G28 Z) or just calculate it from the last probe heights?
+ // Re-homing might be more precise in reproducing the actual 'G28 Z' homing height, especially on an uneven bed.
+ #define HOME_AFTER_G34
#endif
-// @section machine
+// @section motion
-#define AXIS_RELATIVE_MODES {false, false, false, false}
+#define AXIS_RELATIVE_MODES { false, false, false, false }
-// Allow duplication mode with a basic dual-nozzle extruder
-//#define DUAL_NOZZLE_DUPLICATION_MODE
+// Add a Duplicate option for well-separated conjoined nozzles
+//#define MULTI_NOZZLE_DUPLICATION
// By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
@@ -453,7 +759,7 @@
#define DEFAULT_STEPPER_DEACTIVE_TIME 120
#define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true
-#define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished.
+#define DISABLE_INACTIVE_Z true // Set to false if the nozzle will fall down on your printed part when print has finished.
#define DISABLE_INACTIVE_E true
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
@@ -461,26 +767,26 @@
//#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated
-// @section lcd
+// Minimum time that a segment needs to take if the buffer is emptied
+#define DEFAULT_MINSEGMENTTIME 20000 // (ms)
-#if ENABLED(ULTIPANEL)
- #define MANUAL_FEEDRATE {50*60, 50*60, 4*60, 60} // Feedrates for manual moves along X, Y, Z, E from panel
- #define MANUAL_E_MOVES_RELATIVE // Show LCD extruder moves as relative rather than absolute positions
- #define ULTIPANEL_FEEDMULTIPLY // Comment to disable setting feedrate multiplier via encoder
+// Slow down the machine if the look ahead buffer is (by default) half full.
+// Increase the slowdown divisor for larger buffer sizes.
+#define SLOWDOWN
+#if ENABLED(SLOWDOWN)
+ #define SLOWDOWN_DIVISOR 2
#endif
-// @section extras
-
-// minimum time in microseconds that a movement needs to take if the buffer is emptied.
-#define DEFAULT_MINSEGMENTTIME 20000
-
-// If defined the movements slow down when the look ahead buffer is only half full
-#define SLOWDOWN
-
-// Frequency limit
-// See nophead's blog for more info
-// Not working O
-//#define XY_FREQUENCY_LIMIT 15
+/**
+ * XY Frequency limit
+ * Reduce resonance by limiting the frequency of small zigzag infill moves.
+ * See http://hydraraptor.blogspot.com/2010/12/frequency-limit.html
+ * Use M201 F G to change limits at runtime.
+ */
+//#define XY_FREQUENCY_LIMIT 10 // (Hz) Maximum frequency of small zigzag infill moves. Set with M201 F.
+#ifdef XY_FREQUENCY_LIMIT
+ #define XY_FREQUENCY_MIN_PERCENT 5 // (percent) Minimum FR percentage to apply. Set with M201 G.
+#endif
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
// of the buffer and all stops. This should not be much greater than zero and should only be changed
@@ -550,8 +856,8 @@
//#define CALIBRATION_REPORTING
// The true location and dimension the cube/bolt/washer on the bed.
- #define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0} // mm
- #define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0} // mm
+ #define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // mm
+ #define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // mm
// Comment out any sides which are unreachable by the probe. For best
// auto-calibration results, all sides must be reachable.
@@ -564,10 +870,10 @@
// probing on a screwhead or hollow washer, probe near the edges.
//#define CALIBRATION_MEASURE_AT_TOP_EDGES
- // Define pin which is read during calibration
+ // Define the pin to read during calibration
#ifndef CALIBRATION_PIN
- #define CALIBRATION_PIN -1 // Override in pins.h or set to -1 to use your Z endstop
- #define CALIBRATION_PIN_INVERTING false // set to true to invert the pin
+ //#define CALIBRATION_PIN -1 // Define here to override the default pin
+ #define CALIBRATION_PIN_INVERTING false // Set to true to invert the custom pin
//#define CALIBRATION_PIN_PULLDOWN
#define CALIBRATION_PIN_PULLUP
#endif
@@ -579,8 +885,9 @@
* vibration and surface artifacts. The algorithm adapts to provide the best possible step smoothing at the
* lowest stepping frequencies.
*/
-//#define ADAPTIVE_STEP_SMOOTHING
-
+#if ENABLED(SKRLPCBoard)
+ #define ADAPTIVE_STEP_SMOOTHING
+#endif
/**
* Custom Microstepping
* Override as-needed for your setup. Up to 3 MS pins are supported.
@@ -619,34 +926,49 @@
//#define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
//#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis
-// Use an I2C based DIGIPOT (e.g., Azteeg X3 Pro)
-//#define DIGIPOT_I2C
-#if ENABLED(DIGIPOT_I2C) && !defined(DIGIPOT_I2C_ADDRESS_A)
+/**
+ * I2C-based DIGIPOTs (e.g., Azteeg X3 Pro)
+ */
+//#define DIGIPOT_MCP4018 // Requires https://github.com/stawel/SlowSoftI2CMaster
+//#define DIGIPOT_MCP4451
+#if EITHER(DIGIPOT_MCP4018, DIGIPOT_MCP4451)
+ #define DIGIPOT_I2C_NUM_CHANNELS 8 // 5DPRINT:4 AZTEEG_X3_PRO:8 MKS_SBASE:5 MIGHTYBOARD_REVE:5
+
+ // Actual motor currents in Amps. The number of entries must match DIGIPOT_I2C_NUM_CHANNELS.
+ // These correspond to the physical drivers, so be mindful if the order is changed.
+ #define DIGIPOT_I2C_MOTOR_CURRENTS { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 } // AZTEEG_X3_PRO
+
+ //#define DIGIPOT_USE_RAW_VALUES // Use DIGIPOT_MOTOR_CURRENT raw wiper values (instead of A4988 motor currents)
+
/**
* Common slave addresses:
*
* A (A shifted) B (B shifted) IC
* Smoothie 0x2C (0x58) 0x2D (0x5A) MCP4451
* AZTEEG_X3_PRO 0x2C (0x58) 0x2E (0x5C) MCP4451
+ * AZTEEG_X5_MINI 0x2C (0x58) 0x2E (0x5C) MCP4451
* AZTEEG_X5_MINI_WIFI 0x58 0x5C MCP4451
* MIGHTYBOARD_REVE 0x2F (0x5E) MCP4018
*/
- #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT
- #define DIGIPOT_I2C_ADDRESS_B 0x2D // unshifted slave address for second DIGIPOT
+ //#define DIGIPOT_I2C_ADDRESS_A 0x2C // Unshifted slave address for first DIGIPOT
+ //#define DIGIPOT_I2C_ADDRESS_B 0x2D // Unshifted slave address for second DIGIPOT
#endif
-//#define DIGIPOT_MCP4018 // Requires library from https://github.com/stawel/SlowSoftI2CMaster
-#define DIGIPOT_I2C_NUM_CHANNELS 8 // 5DPRINT: 4 AZTEEG_X3_PRO: 8 MKS SBASE: 5
-// Actual motor currents in Amps. The number of entries must match DIGIPOT_I2C_NUM_CHANNELS.
-// These correspond to the physical drivers, so be mindful if the order is changed.
-#define DIGIPOT_I2C_MOTOR_CURRENTS { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 } // AZTEEG_X3_PRO
-
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// @section lcd
+#if EITHER(ULTIPANEL, EXTENSIBLE_UI)
+ #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 60 } // Feedrates for manual moves along X, Y, Z, E from panel
+ #define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm)
+ #if ENABLED(ULTIPANEL)
+ #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position"
+ #define ULTIPANEL_FEEDMULTIPLY // Encoder sets the feedrate multiplier on the Status Screen
+ #endif
+#endif
+
// Change values more rapidly when the encoder is rotated faster
#define ENCODER_RATE_MULTIPLIER
#if ENABLED(ENCODER_RATE_MULTIPLIER)
@@ -661,8 +983,35 @@
#define FEEDRATE_CHANGE_BEEP_FREQUENCY 440
#endif
-// Include a page of printer information in the LCD Main Menu
-#define LCD_INFO_MENU
+#if HAS_LCD_MENU
+
+ // Include a page of printer information in the LCD Main Menu
+ #define LCD_INFO_MENU
+ #if ENABLED(LCD_INFO_MENU)
+ //#define LCD_PRINTER_INFO_IS_BOOTSCREEN // Show bootscreen(s) instead of Printer Info pages
+ #endif
+
+ // BACK menu items keep the highlight at the top
+ //#define TURBO_BACK_MENU_ITEM
+
+ /**
+ * LED Control Menu
+ * Add LED Control to the LCD menu
+ */
+ //#define LED_CONTROL_MENU
+ #if ENABLED(LED_CONTROL_MENU)
+ #define LED_COLOR_PRESETS // Enable the Preset Color menu option
+ #if ENABLED(LED_COLOR_PRESETS)
+ #define LED_USER_PRESET_RED 255 // User defined RED value
+ #define LED_USER_PRESET_GREEN 128 // User defined GREEN value
+ #define LED_USER_PRESET_BLUE 0 // User defined BLUE value
+ #define LED_USER_PRESET_WHITE 255 // User defined WHITE value
+ #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
+ //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
+ #endif
+ #endif
+
+#endif // HAS_LCD_MENU
// Scroll a longer status message into view
#define STATUS_MESSAGE_SCROLLING
@@ -671,10 +1020,28 @@
//#define LCD_DECIMAL_SMALL_XY
// The timeout (in ms) to return to the status screen from sub-menus
-//#define LCD_TIMEOUT_TO_STATUS 15000
+#define LCD_TIMEOUT_TO_STATUS 15000
// Add an 'M73' G-code to set the current percentage
-//#define LCD_SET_PROGRESS_MANUALLY
+#if ENABLED(GRAPHICSLCD)
+ #define LCD_SET_PROGRESS_MANUALLY
+#endif
+
+// Show the E position (filament used) during printing
+//#define LCD_SHOW_E_TOTAL
+
+#if ENABLED(SHOW_BOOTSCREEN)
+ #define BOOTSCREEN_TIMEOUT 2000 // (ms) Total Duration to display the boot screen(s)
+#endif
+
+#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
+ #endif
+#endif
#if HAS_CHARACTER_LCD && HAS_PRINT_PROGRESS
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
@@ -687,31 +1054,13 @@
#endif
#endif
-/**
- * LED Control Menu
- * Enable this feature to add LED Control to the LCD menu
- */
-//#define LED_CONTROL_MENU
-#if ENABLED(LED_CONTROL_MENU)
- #define LED_COLOR_PRESETS // Enable the Preset Color menu option
- #if ENABLED(LED_COLOR_PRESETS)
- #define LED_USER_PRESET_RED 255 // User defined RED value
- #define LED_USER_PRESET_GREEN 128 // User defined GREEN value
- #define LED_USER_PRESET_BLUE 0 // User defined BLUE value
- #define LED_USER_PRESET_WHITE 255 // User defined WHITE value
- #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
- //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
- #endif
-#endif // LED_CONTROL_MENU
-
#if ENABLED(SDSUPPORT)
- // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
- // around this by connecting a push button or single throw switch to the pin defined
- // as SD_DETECT_PIN in your board's pins definitions.
- // This setting should be disabled unless you are using a push button, pulling the pin to ground.
- // Note: This is always disabled for ULTIPANEL (except ELB_FULL_GRAPHIC_CONTROLLER).
- #define SD_DETECT_INVERTED
+ // The standard SD detect circuit reads LOW when media is inserted and HIGH when empty.
+ // Enable this option and set to HIGH if your SD cards are incorrectly detected.
+ #define SD_DETECT_STATE HIGH
+
+ #define SD_PROCEDURE_DEPTH 1 // Increase if you need more nested M32 calls
#define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the Z enabled so your bed stays in place.
@@ -720,8 +1069,15 @@
// Since the FAT gets out of order with usage, SDCARD_SORT_ALPHA is recommended.
#define SDCARD_RATHERRECENTFIRST
- // Add an option in the menu to run all auto#.g files
- //#define MENU_ADDAUTOSTART
+ #define SD_MENU_CONFIRM_START // Confirm the selected SD file before printing
+
+ //#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files
+
+ #define EVENT_GCODE_SD_STOP "G28XY" // G-code to run on Stop Print (e.g., "G28XY" or "G27")
+
+ #if ENABLED(PRINTER_EVENT_LEDS)
+ #define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination
+ #endif
/**
* Continue after Power-Loss (Creality3D)
@@ -730,11 +1086,26 @@
* during SD printing. If the recovery file is found at boot time, present
* an option on the LCD screen to continue the print from the last-known
* point in the file.
+ *
+ * If the machine reboots when resuming a print you may need to replace or
+ * reformat the SD card. (Bad sectors delay startup triggering the watchdog.)
*/
- //#define POWER_LOSS_RECOVERY
+ #if ENABLED(SKRLPCBoard)
+ #define POWER_LOSS_RECOVERY
+ #endif
#if ENABLED(POWER_LOSS_RECOVERY)
- //#define POWER_LOSS_PIN 44 // Pin to detect power loss
- //#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
+ #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_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
+ //#define POWER_LOSS_PULL // Set pullup / pulldown as appropriate
+ //#define POWER_LOSS_PURGE_LEN 20 // (mm) Length of filament to purge on resume
+ //#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail. Requires backup power.
+
+ // Without a POWER_LOSS_PIN the following option helps reduce wear on the SD card,
+ // especially with "vase mode" printing. Set too high and vases cannot be continued.
+ #define POWER_LOSS_MIN_Z_CHANGE 0.05 // (mm) Minimum Z change before saving power-loss data
#endif
/**
@@ -776,17 +1147,20 @@
#endif
// This allows hosts to request long names for files and folders with M33
- //#define LONG_FILENAME_HOST_SUPPORT
+ #define LONG_FILENAME_HOST_SUPPORT
// Enable this option to scroll long filenames in the SD card menu
- //#define SCROLL_LONG_FILENAMES
+ #define SCROLL_LONG_FILENAMES
+
+ // Leave the heaters on after Stop Print (not recommended!)
+ //#define SD_ABORT_NO_COOLDOWN
/**
* This option allows you to abort SD printing when any endstop is triggered.
* This feature must be enabled with "M540 S1" or from the LCD menu.
* To have any effect, endstops must be enabled during SD printing.
*/
- //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
+ //#define SD_ABORT_ON_ENDSTOP_HIT
/**
* This option makes it easier to print the same SD Card file again.
@@ -798,24 +1172,38 @@
/**
* Auto-report SdCard status with M27 S
*/
- //#define AUTO_REPORT_SD_STATUS
+ #define AUTO_REPORT_SD_STATUS
/**
* Support for USB thumb drives using an Arduino USB Host Shield or
* equivalent MAX3421E breakout board. The USB thumb drive will appear
* to Marlin as an SD card.
*
- * The MAX3421E must be assigned the same pins as the SD card reader, with
+ * The MAX3421E can be assigned the same pins as the SD card reader, with
* the following pin mapping:
*
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
- * INT --> SD_DETECT_PIN
+ * INT --> SD_DETECT_PIN [1]
* SS --> SDSS
+ *
+ * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
*/
//#define USB_FLASH_DRIVE_SUPPORT
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
- #define USB_CS_PIN SDSS
- #define USB_INTR_PIN SD_DETECT_PIN
+ #define USB_CS_PIN SDSS
+ #define USB_INTR_PIN SD_DETECT_PIN
+
+ /**
+ * USB Host Shield Library
+ *
+ * - UHS2 uses no interrupts and has been production-tested
+ * on a LulzBot TAZ Pro with a 32-bit Archim board.
+ *
+ * - UHS3 is newer code with better USB compatibility. But it
+ * is less tested and is known to interfere with Servos.
+ * [1] This requires USB_INTR_PIN to be interrupt-capable.
+ */
+ //#define USE_UHS3_USB
#endif
/**
@@ -835,10 +1223,27 @@
#endif
// Add an optimized binary file transfer mode, initiated with 'M28 B1'
- //#define FAST_FILE_TRANSFER
+ //#define BINARY_FILE_TRANSFER
+
+ /**
+ * Set this option to one of the following (or the board's defaults apply):
+ *
+ * LCD - Use the SD drive in the external LCD controller.
+ * ONBOARD - Use the SD drive on the control board. (No SD_DETECT_PIN. M21 to init.)
+ * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file).
+ *
+ * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ]
+ */
+ //#define SDCARD_CONNECTION LCD
#endif // SDSUPPORT
+/**
+ * By default an onboard SD card reader may be shared as a USB mass-
+ * storage device. This option hides the SD card from the host PC.
+ */
+//#define NO_SD_HOST_DRIVE // Disable SD Card access over USB (for security).
+
/**
* Additional options for Graphical Displays
*
@@ -853,7 +1258,7 @@
*/
#if HAS_GRAPHICAL_LCD
// Show SD percentage next to the progress bar
- //#define DOGM_SD_PERCENT
+ #define DOGM_SD_PERCENT
// Enable to save many cycles by drawing a hollow frame on the Info Screen
#define XYZ_HOLLOW_FRAME
@@ -863,16 +1268,12 @@
// A bigger font is available for edit items. Costs 3120 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
- //#define USE_BIG_EDIT_FONT
+ #define USE_BIG_EDIT_FONT
// 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
- // Enable this option and reduce the value to optimize screen updates.
- // The normal delay is 10µs. Use the lowest value that still gives a reliable display.
- //#define DOGM_SPI_DELAY_US 5
-
// Swap the CW/CCW indicators in the graphics overlay
//#define OVERLAY_GFX_REVERSE
@@ -889,6 +1290,10 @@
* This will prevent position updates from being displayed.
*/
#if ENABLED(U8GLIB_ST7920)
+ // Enable this option and reduce the value to optimize screen updates.
+ // The normal delay is 10µs. Use the lowest value that still gives a reliable display.
+ //#define DOGM_SPI_DELAY_US 5
+
//#define LIGHTWEIGHT_UI
#if ENABLED(LIGHTWEIGHT_UI)
#define STATUS_EXPIRE_SECONDS 20
@@ -905,23 +1310,184 @@
#define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM)
#define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating
#define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating
+ #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating
+ //#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active
//#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
+ #if DISABLED(SKRLPCBoard)
+ #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash)
+ #else
+ #define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
+ #endif
+
+ // Frivolous Game Options
+ #if ENABLED(SKRLPCBoard)
+ #define MARLIN_BRICKOUT
+ #define MARLIN_INVADERS
+ #define MARLIN_SNAKE
+ #endif
#endif // HAS_GRAPHICAL_LCD
+//
+// Additional options for DGUS / DWIN displays
+//
+#if HAS_DGUS_LCD
+ #define DGUS_SERIAL_PORT 3
+ #define DGUS_BAUDRATE 115200
+
+ #define DGUS_RX_BUFFER_SIZE 128
+ #define DGUS_TX_BUFFER_SIZE 48
+ //#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
+
+ #if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
+ #define DGUS_PRINT_FILENAME // Display the filename during printing
+ #define DGUS_PREHEAT_UI // Display a preheat screen during heatup
+
+ #if ENABLED(DGUS_LCD_UI_FYSETC)
+ //#define DGUS_UI_MOVE_DIS_OPTION // Disabled by default for UI_FYSETC
+ #else
+ #define DGUS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY
+ #endif
+
+ #define DGUS_FILAMENT_LOADUNLOAD
+ #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
+ #define DGUS_FILAMENT_PURGE_LENGTH 10
+ #define DGUS_FILAMENT_LOAD_LENGTH_PER_TIME 0.5 // (mm) Adjust in proportion to DGUS_UPDATE_INTERVAL_MS
+ #endif
+
+ #define DGUS_UI_WAITING // Show a "waiting" screen between some screens
+ #if ENABLED(DGUS_UI_WAITING)
+ #define DGUS_UI_WAITING_STATUS 10
+ #define DGUS_UI_WAITING_STATUS_PERIOD 8 // Increase to slower waiting status looping
+ #endif
+ #endif
+#endif // HAS_DGUS_LCD
+
+//
+// Touch UI for the FTDI Embedded Video Engine (EVE)
+//
+#if ENABLED(TOUCH_UI_FTDI_EVE)
+ // Display board used
+ //#define LCD_FTDI_VM800B35A // FTDI 3.5" with FT800 (320x240)
+ //#define LCD_4DSYSTEMS_4DLCD_FT843 // 4D Systems 4.3" (480x272)
+ //#define LCD_HAOYU_FT800CB // Haoyu with 4.3" or 5" (480x272)
+ //#define LCD_HAOYU_FT810CB // Haoyu with 5" (800x480)
+ //#define LCD_ALEPHOBJECTS_CLCD_UI // Aleph Objects Color LCD UI
+
+ // Correct the resolution if not using the stock TFT panel.
+ //#define TOUCH_UI_320x240
+ //#define TOUCH_UI_480x272
+ //#define TOUCH_UI_800x480
+
+ // Mappings for boards with a standard RepRapDiscount Display connector
+ //#define AO_EXP1_PINMAP // AlephObjects CLCD UI EXP1 mapping
+ //#define AO_EXP2_PINMAP // AlephObjects CLCD UI EXP2 mapping
+ //#define CR10_TFT_PINMAP // Rudolph Riedel's CR10 pin mapping
+ //#define S6_TFT_PINMAP // FYSETC S6 pin mapping
+
+ //#define OTHER_PIN_LAYOUT // Define pins manually below
+ #if ENABLED(OTHER_PIN_LAYOUT)
+ // Pins for CS and MOD_RESET (PD) must be chosen
+ #define CLCD_MOD_RESET 9
+ #define CLCD_SPI_CS 10
+
+ // If using software SPI, specify pins for SCLK, MOSI, MISO
+ //#define CLCD_USE_SOFT_SPI
+ #if ENABLED(CLCD_USE_SOFT_SPI)
+ #define CLCD_SOFT_SPI_MOSI 11
+ #define CLCD_SOFT_SPI_MISO 12
+ #define CLCD_SOFT_SPI_SCLK 13
+ #endif
+ #endif
+
+ // Display Orientation. An inverted (i.e. upside-down) display
+ // is supported on the FT800. The FT810 and beyond also support
+ // portrait and mirrored orientations.
+ //#define TOUCH_UI_INVERTED
+ //#define TOUCH_UI_PORTRAIT
+ //#define TOUCH_UI_MIRRORED
+
+ // UTF8 processing and rendering.
+ // Unsupported characters are shown as '?'.
+ //#define TOUCH_UI_USE_UTF8
+ #if ENABLED(TOUCH_UI_USE_UTF8)
+ // Western accents support. These accented characters use
+ // combined bitmaps and require relatively little storage.
+ #define TOUCH_UI_UTF8_WESTERN_CHARSET
+ #if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
+ // Additional character groups. These characters require
+ // full bitmaps and take up considerable storage:
+ //#define TOUCH_UI_UTF8_SUPERSCRIPTS // ¹ ² ³
+ //#define TOUCH_UI_UTF8_COPYRIGHT // © ®
+ //#define TOUCH_UI_UTF8_GERMANIC // ß
+ //#define TOUCH_UI_UTF8_SCANDINAVIAN // Æ Ð Ø Þ æ ð ø þ
+ //#define TOUCH_UI_UTF8_PUNCTUATION // « » ¿ ¡
+ //#define TOUCH_UI_UTF8_CURRENCY // ¢ £ ¤ ¥
+ //#define TOUCH_UI_UTF8_ORDINALS // º ª
+ //#define TOUCH_UI_UTF8_MATHEMATICS // ± × ÷
+ //#define TOUCH_UI_UTF8_FRACTIONS // ¼ ½ ¾
+ //#define TOUCH_UI_UTF8_SYMBOLS // µ ¶ ¦ § ¬
+ #endif
+ #endif
+
+ // Use a smaller font when labels don't fit buttons
+ #define TOUCH_UI_FIT_TEXT
+
+ // Allow language selection from menu at run-time (otherwise use LCD_LANGUAGE)
+ //#define LCD_LANGUAGE_1 en
+ //#define LCD_LANGUAGE_2 fr
+ //#define LCD_LANGUAGE_3 de
+ //#define LCD_LANGUAGE_4 es
+ //#define LCD_LANGUAGE_5 it
+
+ // Use a numeric passcode for "Screen lock" keypad.
+ // (recommended for smaller displays)
+ //#define TOUCH_UI_PASSCODE
+
+ // Output extra debug info for Touch UI events
+ //#define TOUCH_UI_DEBUG
+
+ // Developer menu (accessed by touching "About Printer" copyright text)
+ //#define TOUCH_UI_DEVELOPER_MENU
+#endif
+
+//
+// FSMC Graphical TFT
+//
+#if ENABLED(FSMC_GRAPHICAL_TFT)
+ //#define TFT_MARLINUI_COLOR 0xFFFF // White
+ //#define TFT_MARLINBG_COLOR 0x0000 // Black
+ //#define TFT_DISABLED_COLOR 0x0003 // Almost black
+ //#define TFT_BTCANCEL_COLOR 0xF800 // Red
+ //#define TFT_BTARROWS_COLOR 0xDEE6 // 11011 110111 00110 Yellow
+ //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
+#endif
+
+//
+// ADC Button Debounce
+//
+#if HAS_ADC_BUTTONS
+ #define ADC_BUTTON_DEBOUNCE_DELAY 16 // (ms) Increase if buttons bounce or repeat too fast
+#endif
+
// @section safety
-// The hardware watchdog should reset the microcontroller disabling all outputs,
-// in case the firmware gets stuck and doesn't do temperature regulation.
+/**
+ * The watchdog hardware timer will do a reset and disable all outputs
+ * if the firmware gets too overloaded to read the temperature sensors.
+ *
+ * If you find that watchdog reboot causes your AVR board to hang forever,
+ * enable WATCHDOG_RESET_MANUAL to use a custom timer instead of WDTO.
+ * NOTE: This method is less reliable as it can only catch hangups while
+ * interrupts are enabled.
+ */
#define USE_WATCHDOG
-
#if ENABLED(USE_WATCHDOG)
- // If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
- // The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
- // However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
//#define WATCHDOG_RESET_MANUAL
#endif
@@ -936,25 +1502,32 @@
*/
#define BABYSTEPPING
#if ENABLED(BABYSTEPPING)
+ #define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
+ //#define BABYSTEP_WITHOUT_HOMING
//#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_MULTIPLICATOR 10 // Babysteps are very small. Increase for faster motion.
+ #define BABYSTEP_MULTIPLICATOR_Z 10 // Babysteps are very small. Increase for faster motion.
+ #define BABYSTEP_MULTIPLICATOR_XY 1
#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
#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.
+ #endif
#endif
- //#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.
- #endif
+ //#define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28
#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
//#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets
- //#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
+ #if ENABLED(GRAPHICSLCD)
+ #define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
+ #endif
#endif
#endif
@@ -976,15 +1549,55 @@
* See http://marlinfw.org/docs/features/lin_advance.html for full instructions.
* Mention @Sebastianv650 on GitHub to alert the author of any issues.
*/
-//#define LIN_ADVANCE
+#if E0_DRIVER_TYPE != TMC2208_STANDALONE
+ #define LIN_ADVANCE
+#endif
#if ENABLED(LIN_ADVANCE)
- #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed
- //#define LA_DEBUG // If enabled, this will generate debug information output over USB.
+ //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants
+ #define LIN_ADVANCE_K 0.0 // Unit: mm compression per 1mm/s extruder speed
+ //#define LA_DEBUG // If enabled, this will generate debug information output over USB.
#endif
// @section leveling
-#if ENABLED(MESH_BED_LEVELING) || ENABLED(AUTO_BED_LEVELING_UBL)
+/**
+ * Points to probe for all 3-point Leveling procedures.
+ * Override if the automatically selected points are inadequate.
+ */
+#if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
+ //#define PROBE_PT_1_X 15
+ //#define PROBE_PT_1_Y 180
+ //#define PROBE_PT_2_X 15
+ //#define PROBE_PT_2_Y 20
+ //#define PROBE_PT_3_X 170
+ //#define PROBE_PT_3_Y 20
+#endif
+
+/**
+ * Override MIN_PROBE_EDGE for each side of the build plate
+ * Useful to get probe points to exact positions on targets or
+ * to allow leveling to avoid plate clamps on only specific
+ * sides of the bed. With NOZZLE_AS_PROBE negative values are
+ * allowed, to permit probing outside the bed.
+ *
+ * If you are replacing the prior *_PROBE_BED_POSITION options,
+ * LEFT and FRONT values in most cases will map directly over
+ * RIGHT and REAR would be the inverse such as
+ * (X/Y_BED_SIZE - RIGHT/BACK_PROBE_BED_POSITION)
+ *
+ * This will allow all positions to match at compilation, however
+ * should the probe position be modified with M851XY then the
+ * probe points will follow. This prevents any change from causing
+ * the probe to be unable to reach any points.
+ */
+#if PROBE_SELECTED && !IS_KINEMATIC
+ //#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
+ //#define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
+ //#define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
+ //#define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
+#endif
+
+#if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
// Override the mesh area if the automatic (max) area is too large
//#define MESH_MIN_X MESH_INSET
//#define MESH_MIN_Y MESH_INSET
@@ -996,7 +1609,9 @@
* Repeatedly attempt G29 leveling until it succeeds.
* Stop after G29_MAX_RETRIES attempts.
*/
-//#define G29_RETRY_AND_RECOVER
+#if DISABLED(UBL)
+ #define G29_RETRY_AND_RECOVER
+#endif
#if ENABLED(G29_RETRY_AND_RECOVER)
#define G29_MAX_RETRIES 3
#define G29_HALT_ON_FAILURE
@@ -1005,39 +1620,78 @@
* between attempts, and after the maximum number of retries have been tried.
*/
#define G29_SUCCESS_COMMANDS "M117 Bed leveling done."
- #define G29_RECOVER_COMMANDS "M117 Probe failed. Rewiping.\nG28\nG12 P0 S12 T0"
+ #define G29_RECOVER_COMMANDS "M117 Probe failed.\nG28\n"
#define G29_FAILURE_COMMANDS "M117 Bed leveling failed.\nG0 Z10\nM300 P25 S880\nM300 P50 S0\nM300 P25 S880\nM300 P50 S0\nM300 P25 S880\nM300 P50 S0\nG4 S1"
#endif
+/**
+ * Thermal Probe Compensation
+ * Probe measurements are adjusted to compensate for temperature distortion.
+ * Use G76 to calibrate this feature. Use M871 to set values manually.
+ * For a more detailed explanation of the process see G76_M871.cpp.
+ */
+#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
+ // Enable thermal first layer compensation using bed and probe temperatures
+ #define PROBE_TEMP_COMPENSATION
+
+ // Add additional compensation depending on hotend temperature
+ // Note: this values cannot be calibrated and have to be set manually
+ #if ENABLED(PROBE_TEMP_COMPENSATION)
+ // Park position to wait for probe cooldown
+ #define PTC_PARK_POS { 0, 0, 100 }
+
+ // Probe position to probe and wait for probe to reach target temperature
+ #define PTC_PROBE_POS { 90, 100 }
+
+ // Enable additional compensation using hotend temperature
+ // Note: this values cannot be calibrated automatically but have to be set manually
+ //#define USE_TEMP_EXT_COMPENSATION
+ #endif
+#endif
+
// @section extras
+//
+// G60/G61 Position Save and Return
+//
+//#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes
+
//
// G2/G3 Arc Support
//
-#define ARC_SUPPORT // Disable this feature to save ~3226 bytes
+#define ARC_SUPPORT // Disable this feature to save ~3226 bytes
#if ENABLED(ARC_SUPPORT)
- #define MM_PER_ARC_SEGMENT 1 // Length of each arc segment
- #define N_ARC_CORRECTION 25 // Number of intertpolated 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 MM_PER_ARC_SEGMENT 1 // (mm) Length (or minimum length) of each arc segment
+ //#define ARC_SEGMENTS_PER_R 1 // Max segment length, MM_PER = Min
+ #define MIN_ARC_SEGMENTS 24 // Minimum number of segments in a complete circle
+ //#define ARC_SEGMENTS_PER_SEC 50 // Use feedrate to choose segment length (with MM_PER_ARC_SEGMENT as the minimum)
+ #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
#endif
// Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes.
-//#define BEZIER_CURVE_SUPPORT
+#define BEZIER_CURVE_SUPPORT
-// G38.2 and G38.3 Probe Target
-// Set MULTIPLE_PROBING if you want G38 to double touch
+/**
+ * G38 Probe Target
+ *
+ * This option adds G38.2 and G38.3 (probe towards target)
+ * and optionally G38.4 and G38.5 (probe away from target).
+ * Set MULTIPLE_PROBING for G38 to probe more than once.
+ */
//#define G38_PROBE_TARGET
#if ENABLED(G38_PROBE_TARGET)
- #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)
+ //#define G38_PROBE_AWAY // Include G38.4 and G38.5 to probe away from target
+ #define G38_MINIMUM_MOVE 0.0275 // (mm) Minimum distance that will produce a move.
#endif
// Moves (or segments) with fewer steps than this will be joined with the next move
#define MIN_STEPS_PER_SEGMENT 6
/**
- * Minimum delay after setting the stepper DIR (in ns)
+ * Minimum delay before and after setting the stepper DIR (in ns)
* 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire)
* 20 : Minimum for TMC2xxx drivers
* 200 : Minimum for A4988 drivers
@@ -1049,12 +1703,14 @@
*
* Override the default value based on the driver type set in Configuration.h.
*/
-//#define MINIMUM_STEPPER_DIR_DELAY 650
+//#define MINIMUM_STEPPER_POST_DIR_DELAY 650
+//#define MINIMUM_STEPPER_PRE_DIR_DELAY 650
/**
* Minimum stepper driver pulse width (in µs)
* 0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers
- * 1 : Minimum for A4988, A5984, and LV8729 stepper drivers
+ * 0 : Minimum 500ns for LV8729, adjusted in stepper.h
+ * 1 : Minimum for A4988 and A5984 stepper drivers
* 2 : Minimum for DRV8825 stepper drivers
* 3 : Minimum for TB6600 stepper drivers
* 30 : Minimum for TB6560 stepper drivers
@@ -1066,12 +1722,12 @@
/**
* Maximum stepping rate (in Hz) the stepper driver allows
* If undefined, defaults to 1MHz / (2 * MINIMUM_STEPPER_PULSE)
- * 500000 : Maximum for A4988 stepper driver
- * 400000 : Maximum for TMC2xxx stepper drivers
- * 250000 : Maximum for DRV8825 stepper driver
- * 150000 : Maximum for TB6600 stepper driver
- * 130000 : Maximum for LV8729 stepper driver
- * 15000 : Maximum for TB6560 stepper driver
+ * 5000000 : Maximum for TMC2xxx stepper drivers
+ * 1000000 : Maximum for LV8729 stepper driver
+ * 500000 : Maximum for A4988 stepper driver
+ * 250000 : Maximum for DRV8825 stepper driver
+ * 150000 : Maximum for TB6600 stepper driver
+ * 15000 : Maximum for TB6560 stepper driver
*
* Override the default value based on the driver type set in Configuration.h.
*/
@@ -1090,8 +1746,8 @@
// The number of linear motions that can be in the plan at any give time.
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2 (e.g. 8, 16, 32) because shifts and ors are used to do the ring-buffering.
-#if ENABLED(SDSUPPORT)
- #define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
+#if ENABLED(SKRLPCBoard)
+ #define BLOCK_BUFFER_SIZE 64 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
#else
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif
@@ -1100,7 +1756,13 @@
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
-#define BUFSIZE 4
+#if ENABLED(SKRLPCBoard)
+ #define BUFSIZE 32
+#elif BOTH(GRAPHICSLCD, UBL)
+ #define BUFSIZE 12
+#else
+ #define BUFSIZE 16
+#endif
// Transmission to Host Buffer Size
// To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
@@ -1123,6 +1785,9 @@
//#define SERIAL_XON_XOFF
#endif
+// Add M575 G-code to change the baud rate
+//#define BAUD_RATE_GCODE
+
#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
@@ -1143,7 +1808,7 @@
// Therefore some clients abort after 30 seconds in a timeout.
// Some other clients start sending commands while receiving a 'wait'.
// This "wait" is only sent when the buffer is empty. 1 second is a good value here.
-//#define NO_TIMEOUTS 1000 // Milliseconds
+#define NO_TIMEOUTS 1000 // Milliseconds
// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary.
#define ADVANCED_OK
@@ -1180,19 +1845,19 @@
*/
#define FWRETRACT
#if ENABLED(FWRETRACT)
- #define FWRETRACT_AUTORETRACT // costs ~500 bytes of PROGMEM
+ #define FWRETRACT_AUTORETRACT // Override slicer retractions
#if ENABLED(FWRETRACT_AUTORETRACT)
- #define MIN_AUTORETRACT 0.1 // When auto-retract is on, convert E moves of this length and over
- #define MAX_AUTORETRACT 10.0 // Upper limit for auto-retract conversion
+ #define MIN_AUTORETRACT 0.1 // (mm) Don't convert E moves under this length
+ #define MAX_AUTORETRACT 10.0 // (mm) Don't convert E moves over this length
#endif
- #define RETRACT_LENGTH 3 // Default retract length (positive mm)
- #define RETRACT_LENGTH_SWAP 13 // Default swap retract length (positive mm), for extruder change
- #define RETRACT_FEEDRATE 45 // Default feedrate for retracting (mm/s)
- #define RETRACT_ZRAISE 0 // Default retract Z-raise (mm)
- #define RETRACT_RECOVER_LENGTH 0 // Default additional recover length (mm, added to retract length when recovering)
- #define RETRACT_RECOVER_LENGTH_SWAP 0 // Default additional swap recover length (mm, added to retract length when recovering from extruder change)
- #define RETRACT_RECOVER_FEEDRATE 8 // Default feedrate for recovering from retraction (mm/s)
- #define RETRACT_RECOVER_FEEDRATE_SWAP 8 // Default feedrate for recovering from swap retraction (mm/s)
+ #define RETRACT_LENGTH 3 // (mm) Default retract length (positive value)
+ #define RETRACT_LENGTH_SWAP 13 // (mm) Default swap retract length (positive value)
+ #define RETRACT_FEEDRATE 45 // (mm/s) Default feedrate for retracting
+ #define RETRACT_ZRAISE 0 // (mm) Default retract Z-raise
+ #define RETRACT_RECOVER_LENGTH 0 // (mm) Default additional recover length (added to retract length on recover)
+ #define RETRACT_RECOVER_LENGTH_SWAP 0 // (mm) Default additional swap recover length (added to retract length on recover from toolchange)
+ #define RETRACT_RECOVER_FEEDRATE 8 // (mm/s) Default feedrate for recovering from retraction
+ #define RETRACT_RECOVER_FEEDRATE_SWAP 8 // (mm/s) Default feedrate for recovering from swap retraction
#if ENABLED(MIXING_EXTRUDER)
//#define RETRACT_SYNC_MIXING // Retract and restore all mixing steppers simultaneously
#endif
@@ -1204,15 +1869,55 @@
*/
#if EXTRUDERS > 1
// Z raise distance for tool-change, as needed for some extruders
- #define TOOLCHANGE_ZRAISE 2 // (mm)
+ #define TOOLCHANGE_ZRAISE 2 // (mm)
+ //#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
+ //#define TOOLCHANGE_NO_RETURN // Never return to previous position on tool-change
+ #if ENABLED(TOOLCHANGE_NO_RETURN)
+ //#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change
+ #endif
- // Retract and prime filament on tool-change
+ /**
+ * Retract and prime filament on tool-change to reduce
+ * ooze and stringing and to get cleaner transitions.
+ */
//#define TOOLCHANGE_FILAMENT_SWAP
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
- #define TOOLCHANGE_FIL_SWAP_LENGTH 12 // (mm)
- #define TOOLCHANGE_FIL_EXTRA_PRIME 2 // (mm)
- #define TOOLCHANGE_FIL_SWAP_RETRACT_SPEED 3600 // (mm/m)
- #define TOOLCHANGE_FIL_SWAP_PRIME_SPEED 3600 // (mm/m)
+ // Load / Unload
+ #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length
+ #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode)
+ #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/m) (Unloading)
+ #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/m) (On SINGLENOZZLE or Bowden loading must be slowed down)
+
+ // Longer prime to clean out a SINGLENOZZLE
+ #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length
+ #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/m) Extra priming feedrate
+ #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/m) Retract before cooling for less stringing, better wipe, etc.
+
+ // Cool after prime to reduce stringing
+ #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip
+ #define TOOLCHANGE_FS_FAN_SPEED 255 // 0-255
+ #define TOOLCHANGE_FS_FAN_TIME 10 // (seconds)
+
+ // Swap uninitialized extruder with TOOLCHANGE_FS_PRIME_SPEED for all lengths (recover + prime)
+ // (May break filament if not retracted beforehand.)
+ //#define TOOLCHANGE_FS_INIT_BEFORE_SWAP
+
+ // Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied)
+ // Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect
+ //#define TOOLCHANGE_FS_PRIME_FIRST_USED
+
+ /**
+ * Tool Change Migration
+ * This feature provides G-code and LCD options to switch tools mid-print.
+ * All applicable tool properties are migrated so the print can continue.
+ * Tools must be closely matching and other restrictions may apply.
+ * Useful to:
+ * - Change filament color without interruption
+ * - Switch spools automatically on filament runout
+ * - Switch to a different nozzle on an extruder jam
+ */
+ #define TOOLCHANGE_MIGRATION_FEATURE
+
#endif
/**
@@ -1223,8 +1928,10 @@
#if ENABLED(TOOLCHANGE_PARK)
#define TOOLCHANGE_PARK_XY { X_MIN_POS + 10, Y_MIN_POS + 10 }
#define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/m)
+ //#define TOOLCHANGE_PARK_X_ONLY // X axis only move
+ //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move
#endif
-#endif
+#endif // EXTRUDERS > 1
/**
* Advanced Pause
@@ -1261,15 +1968,17 @@
// Set to 0 for manual extrusion.
// Filament can be extruded repeatedly from the Filament Change menu
// until extrusion is consistent, and to purge old filament.
- #define ADVANCED_PAUSE_RESUME_PRIME 1 // (mm) Extra distance to prime nozzle after returning from park.
+ #define ADVANCED_PAUSE_RESUME_PRIME 0 // (mm) Extra distance to prime nozzle after returning from park.
+ #define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused.
// Filament Unload does a Retract, Delay, and Purge first:
- #define FILAMENT_UNLOAD_RETRACT_LENGTH 13 // (mm) Unload initial retract length.
- #define FILAMENT_UNLOAD_DELAY 5000 // (ms) Delay for the filament to cool after retract.
+ #define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length.
+ #define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.
+ #define FILAMENT_UNLOAD_PURGE_FEEDRATE 25 // (mm/s) feedrate to purge before unload
#define PAUSE_PARK_NOZZLE_TIMEOUT 45 // (seconds) Time limit before the nozzle is turned off for safety.
- #define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed.
+ #define FILAMENT_CHANGE_ALERT_BEEPS 2 // Number of alert beeps to play when a response is needed.
#define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable for XYZ steppers to stay powered on during filament change.
#define PARK_HEAD_ON_PAUSE // Park the nozzle during pause and filament change.
@@ -1331,6 +2040,12 @@
#define Z3_MICROSTEPS 16
#endif
+ #if AXIS_DRIVER_TYPE_Z4(TMC26X)
+ #define Z4_MAX_CURRENT 1000
+ #define Z4_SENSE_RESISTOR 91
+ #define Z4_MICROSTEPS 16
+ #endif
+
#if AXIS_DRIVER_TYPE_E0(TMC26X)
#define E0_MAX_CURRENT 1000
#define E0_SENSE_RESISTOR 91
@@ -1367,6 +2082,18 @@
#define E5_MICROSTEPS 16
#endif
+ #if AXIS_DRIVER_TYPE_E6(TMC26X)
+ #define E6_MAX_CURRENT 1000
+ #define E6_SENSE_RESISTOR 91
+ #define E6_MICROSTEPS 16
+ #endif
+
+ #if AXIS_DRIVER_TYPE_E7(TMC26X)
+ #define E7_MAX_CURRENT 1000
+ #define E7_SENSE_RESISTOR 91
+ #define E7_MICROSTEPS 16
+ #endif
+
#endif // TMC26X
// @section tmc_smart
@@ -1387,87 +2114,129 @@
* TMCStepper library is required to use TMC stepper drivers.
* https://github.com/teemuatlut/TMCStepper
*/
-#if HAS_TRINAMIC
+#if HAS_TRINAMIC_CONFIG
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
#define INTERPOLATE true // Interpolate X/Y/Z_MICROSTEPS to 256
#if AXIS_IS_TMC(X)
- #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
- #define X_MICROSTEPS 16 // 0..256
- #define X_RSENSE 0.11
+ #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
+ #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing
+ #define X_MICROSTEPS 16 // 0..256
+ #define X_RSENSE 0.11
+ #define X_CHAIN_POS -1 // <=0 : Not chained. 1 : MCU MOSI connected. 2 : Next in chain, ...
#endif
#if AXIS_IS_TMC(X2)
- #define X2_CURRENT 800
- #define X2_MICROSTEPS 16
- #define X2_RSENSE 0.11
+ #define X2_CURRENT 800
+ #define X2_CURRENT_HOME X2_CURRENT
+ #define X2_MICROSTEPS 16
+ #define X2_RSENSE 0.11
+ #define X2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y)
- #define Y_CURRENT 800
- #define Y_MICROSTEPS 16
- #define Y_RSENSE 0.11
+ #define Y_CURRENT 800
+ #define Y_CURRENT_HOME Y_CURRENT
+ #define Y_MICROSTEPS 16
+ #define Y_RSENSE 0.11
+ #define Y_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y2)
- #define Y2_CURRENT 800
- #define Y2_MICROSTEPS 16
- #define Y2_RSENSE 0.11
+ #define Y2_CURRENT 800
+ #define Y2_CURRENT_HOME Y2_CURRENT
+ #define Y2_MICROSTEPS 16
+ #define Y2_RSENSE 0.11
+ #define Y2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z)
- #define Z_CURRENT 800
- #define Z_MICROSTEPS 16
- #define Z_RSENSE 0.11
+ #define Z_CURRENT 800
+ #define Z_CURRENT_HOME Z_CURRENT
+ #define Z_MICROSTEPS 16
+ #define Z_RSENSE 0.11
+ #define Z_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z2)
- #define Z2_CURRENT 800
- #define Z2_MICROSTEPS 16
- #define Z2_RSENSE 0.11
+ #define Z2_CURRENT 800
+ #define Z2_CURRENT_HOME Z2_CURRENT
+ #define Z2_MICROSTEPS 16
+ #define Z2_RSENSE 0.11
+ #define Z2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z3)
- #define Z3_CURRENT 800
- #define Z3_MICROSTEPS 16
- #define Z3_RSENSE 0.11
+ #define Z3_CURRENT 800
+ #define Z3_CURRENT_HOME Z3_CURRENT
+ #define Z3_MICROSTEPS 16
+ #define Z3_RSENSE 0.11
+ #define Z3_CHAIN_POS -1
+ #endif
+
+ #if AXIS_IS_TMC(Z4)
+ #define Z4_CURRENT 800
+ #define Z4_CURRENT_HOME Z4_CURRENT
+ #define Z4_MICROSTEPS 16
+ #define Z4_RSENSE 0.11
+ #define Z4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E0)
- #define E0_CURRENT 800
- #define E0_MICROSTEPS 16
- #define E0_RSENSE 0.11
+ #define E0_CURRENT 800
+ #define E0_MICROSTEPS 16
+ #define E0_RSENSE 0.11
+ #define E0_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E1)
- #define E1_CURRENT 800
- #define E1_MICROSTEPS 16
- #define E1_RSENSE 0.11
+ #define E1_CURRENT 800
+ #define E1_MICROSTEPS 16
+ #define E1_RSENSE 0.11
+ #define E1_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E2)
- #define E2_CURRENT 800
- #define E2_MICROSTEPS 16
- #define E2_RSENSE 0.11
+ #define E2_CURRENT 800
+ #define E2_MICROSTEPS 16
+ #define E2_RSENSE 0.11
+ #define E2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E3)
- #define E3_CURRENT 800
- #define E3_MICROSTEPS 16
- #define E3_RSENSE 0.11
+ #define E3_CURRENT 800
+ #define E3_MICROSTEPS 16
+ #define E3_RSENSE 0.11
+ #define E3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E4)
- #define E4_CURRENT 800
- #define E4_MICROSTEPS 16
- #define E4_RSENSE 0.11
+ #define E4_CURRENT 800
+ #define E4_MICROSTEPS 16
+ #define E4_RSENSE 0.11
+ #define E4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E5)
- #define E5_CURRENT 800
- #define E5_MICROSTEPS 16
- #define E5_RSENSE 0.11
+ #define E5_CURRENT 800
+ #define E5_MICROSTEPS 16
+ #define E5_RSENSE 0.11
+ #define E5_CHAIN_POS -1
+ #endif
+
+ #if AXIS_IS_TMC(E6)
+ #define E6_CURRENT 800
+ #define E6_MICROSTEPS 16
+ #define E6_RSENSE 0.11
+ #define E6_CHAIN_POS -1
+ #endif
+
+ #if AXIS_IS_TMC(E7)
+ #define E7_CURRENT 800
+ #define E7_MICROSTEPS 16
+ #define E7_RSENSE 0.11
+ #define E7_CHAIN_POS -1
#endif
/**
@@ -1487,9 +2256,10 @@
//#define E3_CS_PIN -1
//#define E4_CS_PIN -1
//#define E5_CS_PIN -1
+ //#define E6_CS_PIN -1
+ //#define E7_CS_PIN -1
/**
- * Use software SPI for TMC2130.
* Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160).
* The default SW SPI pins are defined the respective pins files,
* but you can override or define them here.
@@ -1499,6 +2269,35 @@
//#define TMC_SW_MISO -1
//#define TMC_SW_SCK -1
+ /**
+ * Four TMC2209 drivers can use the same HW/SW serial port with hardware configured addresses.
+ * Set the address using jumpers on pins MS1 and MS2.
+ * Address | MS1 | MS2
+ * 0 | LOW | LOW
+ * 1 | HIGH | LOW
+ * 2 | LOW | HIGH
+ * 3 | HIGH | HIGH
+ *
+ * Set *_SERIAL_TX_PIN and *_SERIAL_RX_PIN to match for all drivers
+ * on the same serial port, either here or in your board's pins file.
+ */
+ #define X_SLAVE_ADDRESS 0
+ #define Y_SLAVE_ADDRESS 0
+ #define Z_SLAVE_ADDRESS 0
+ #define X2_SLAVE_ADDRESS 0
+ #define Y2_SLAVE_ADDRESS 0
+ #define Z2_SLAVE_ADDRESS 0
+ #define Z3_SLAVE_ADDRESS 0
+ #define Z4_SLAVE_ADDRESS 0
+ #define E0_SLAVE_ADDRESS 0
+ #define E1_SLAVE_ADDRESS 0
+ #define E2_SLAVE_ADDRESS 0
+ #define E3_SLAVE_ADDRESS 0
+ #define E4_SLAVE_ADDRESS 0
+ #define E5_SLAVE_ADDRESS 0
+ #define E6_SLAVE_ADDRESS 0
+ #define E7_SLAVE_ADDRESS 0
+
/**
* Software enable
*
@@ -1508,7 +2307,7 @@
//#define SOFTWARE_DRIVER_ENABLE
/**
- * TMC2130, TMC2160, TMC2208, TMC5130 and TMC5160 only
+ * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only
* Use Trinamic's ultra quiet stepping mode.
* When disabled, Marlin will use spreadCycle stepping mode.
*/
@@ -1530,11 +2329,11 @@
* Define you own with
* { , , hysteresis_start[1..8] }
*/
- #define CHOPPER_TIMING CHOPPER_DEFAULT_12V
+ #define CHOPPER_TIMING CHOPPER_DEFAULT_24V
/**
* Monitor Trinamic drivers for error conditions,
- * like overtemperature and short to ground. TMC2208 requires hardware serial.
+ * like overtemperature and short to ground.
* In the case of overtemperature Marlin can decrease the driver current until error condition clears.
* Other detected conditions can be used to stop the current print.
* Relevant g-codes:
@@ -1552,13 +2351,13 @@
#endif
/**
- * TMC2130, TMC2160, TMC2208, TMC5130 and TMC5160 only
+ * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only
* The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD.
* This mode allows for faster movements at the expense of higher noise levels.
* STEALTHCHOP_(XY|Z|E) must be enabled to use HYBRID_THRESHOLD.
* M913 X/Y/Z/E to live tune the setting
*/
- //#define HYBRID_THRESHOLD
+ #define HYBRID_THRESHOLD
#define X_HYBRID_THRESHOLD 100 // [mm/s]
#define X2_HYBRID_THRESHOLD 100
@@ -1567,42 +2366,57 @@
#define Z_HYBRID_THRESHOLD 3
#define Z2_HYBRID_THRESHOLD 3
#define Z3_HYBRID_THRESHOLD 3
+ #define Z4_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
#define E1_HYBRID_THRESHOLD 30
#define E2_HYBRID_THRESHOLD 30
#define E3_HYBRID_THRESHOLD 30
#define E4_HYBRID_THRESHOLD 30
#define E5_HYBRID_THRESHOLD 30
+ #define E6_HYBRID_THRESHOLD 30
+ #define E7_HYBRID_THRESHOLD 30
/**
- * TMC2130, TMC2160, TMC2660, TMC5130, and TMC5160 only
- * Use StallGuard2 to sense an obstacle and trigger an endstop.
+ * 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.
* X, Y, and Z homing will always be done in spreadCycle mode.
*
- * X/Y/Z_STALL_SENSITIVITY is used for tuning the trigger sensitivity.
- * Higher values make the system LESS sensitive.
- * Lower value make the system MORE sensitive.
- * Too low values can lead to false positives, while too high values will collide the axis without triggering.
- * It is advised to set X/Y/Z_HOME_BUMP_MM to 0.
- * M914 X/Y/Z to live tune the setting
- */
- //#define SENSORLESS_HOMING // TMC2130 only
-
- /**
- * Use StallGuard2 to probe the bed with the nozzle.
+ * X/Y/Z_STALL_SENSITIVITY is the default stall threshold.
+ * Use M914 X Y Z to set the stall threshold at runtime:
*
- * CAUTION: This could cause damage to machines that use a lead screw or threaded rod
- * to move the Z axis. Take extreme care when attempting to enable this feature.
+ * Sensitivity TMC2209 Others
+ * HIGHEST 255 -64 (Too sensitive => False positive)
+ * LOWEST 0 63 (Too insensitive => No trigger)
+ *
+ * It is recommended to set [XYZ]_HOME_BUMP_MM to 0.
+ *
+ * SPI_ENDSTOPS *** Beta feature! *** TMC2130 Only ***
+ * Poll the driver through SPI to determine load when homing.
+ * Removes the need for a wire from DIAG1 to an endstop pin.
+ *
+ * IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
+ * homing and adds a guard period for endstop triggering.
*/
- //#define SENSORLESS_PROBING // TMC2130 only
+ //#define SENSORLESS_HOMING // StallGuard capable drivers only
- #if ENABLED(SENSORLESS_HOMING) || ENABLED(SENSORLESS_PROBING)
+ #if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
+ // TMC2209: 0...255. TMC2130: -64...63
#define X_STALL_SENSITIVITY 8
+ #define X2_STALL_SENSITIVITY X_STALL_SENSITIVITY
#define Y_STALL_SENSITIVITY 8
//#define Z_STALL_SENSITIVITY 8
+ //#define SPI_ENDSTOPS // TMC2130 only
+ //#define IMPROVE_HOMING_RELIABILITY
#endif
+ /**
+ * Beta feature!
+ * Create a 50/50 square wave step pulse optimal for stepper drivers.
+ */
+ //#define SQUARE_WAVE_STEPPING
+
/**
* Enable M122 debugging command for TMC stepper drivers.
* M122 S0/1 will enable continous reporting.
@@ -1612,25 +2426,24 @@
/**
* You can set your own advanced settings by filling in predefined functions.
* A list of available functions can be found on the library github page
- * https://github.com/teemuatlut/TMC2130Stepper
- * https://github.com/teemuatlut/TMC2208Stepper
+ * https://github.com/teemuatlut/TMCStepper
*
* Example:
* #define TMC_ADV() { \
- * stepperX.diag0_temp_prewarn(1); \
- * stepperY.interpolate(0); \
+ * stepperX.diag0_otpw(1); \
+ * stepperY.intpol(0); \
* }
*/
#define TMC_ADV() { }
-#endif // HAS_TRINAMIC
+#endif // HAS_TRINAMIC_CONFIG
-// @section L6470
+// @section L64XX
/**
- * L6470 Stepper Driver options
+ * L64XX Stepper Driver options
*
- * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver.
+ * Arduino-L6470 library (0.8.0 or higher) is required.
* https://github.com/ameyer/Arduino-L6470
*
* Requires the following to be defined in your pins_YOUR_BOARD file
@@ -1638,114 +2451,160 @@
* L6470_CHAIN_MISO_PIN
* L6470_CHAIN_MOSI_PIN
* L6470_CHAIN_SS_PIN
- * L6470_RESET_CHAIN_PIN (optional)
+ * ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset
*/
-#if HAS_DRIVER(L6470)
+
+#if HAS_L64XX
//#define L6470_CHITCHAT // Display additional status info
- #if AXIS_DRIVER_TYPE_X(L6470)
- #define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128)
- #define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current (VALID: 375 x (1 - 16) - 6A max - rounds down)
- #define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down)
- #define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper
- #define X_CHAIN_POS 0 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
+ #if AXIS_IS_L64XX(X)
+ #define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16
+ #define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current
+ // L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down
+ // POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down
+ #define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down)
+ // L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down
+ // POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down
+ // L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current
+ #define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474
+ #define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
+ #define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest
#endif
- #if AXIS_DRIVER_TYPE_X2(L6470)
+ #if AXIS_IS_L64XX(X2)
#define X2_MICROSTEPS 128
#define X2_OVERCURRENT 2000
#define X2_STALLCURRENT 1500
#define X2_MAX_VOLTAGE 127
- #define X2_CHAIN_POS 0
+ #define X2_CHAIN_POS -1
+ #define X2_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_Y(L6470)
+ #if AXIS_IS_L64XX(Y)
#define Y_MICROSTEPS 128
#define Y_OVERCURRENT 2000
#define Y_STALLCURRENT 1500
#define Y_MAX_VOLTAGE 127
- #define Y_CHAIN_POS 0
+ #define Y_CHAIN_POS -1
+ #define Y_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_Y2(L6470)
+ #if AXIS_IS_L64XX(Y2)
#define Y2_MICROSTEPS 128
#define Y2_OVERCURRENT 2000
#define Y2_STALLCURRENT 1500
#define Y2_MAX_VOLTAGE 127
- #define Y2_CHAIN_POS 0
+ #define Y2_CHAIN_POS -1
+ #define Y2_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_Z(L6470)
+ #if AXIS_IS_L64XX(Z)
#define Z_MICROSTEPS 128
#define Z_OVERCURRENT 2000
#define Z_STALLCURRENT 1500
#define Z_MAX_VOLTAGE 127
- #define Z_CHAIN_POS 0
+ #define Z_CHAIN_POS -1
+ #define Z_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_Z2(L6470)
+ #if AXIS_IS_L64XX(Z2)
#define Z2_MICROSTEPS 128
#define Z2_OVERCURRENT 2000
#define Z2_STALLCURRENT 1500
#define Z2_MAX_VOLTAGE 127
- #define Z2_CHAIN_POS 0
+ #define Z2_CHAIN_POS -1
+ #define Z2_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_Z3(L6470)
+ #if AXIS_IS_L64XX(Z3)
#define Z3_MICROSTEPS 128
#define Z3_OVERCURRENT 2000
#define Z3_STALLCURRENT 1500
#define Z3_MAX_VOLTAGE 127
- #define Z3_CHAIN_POS 0
+ #define Z3_CHAIN_POS -1
+ #define Z3_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E0(L6470)
+ #if AXIS_IS_L64XX(Z4)
+ #define Z4_MICROSTEPS 128
+ #define Z4_OVERCURRENT 2000
+ #define Z4_STALLCURRENT 1500
+ #define Z4_MAX_VOLTAGE 127
+ #define Z4_CHAIN_POS -1
+ #define Z4_SLEW_RATE 1
+ #endif
+
+ #if AXIS_IS_L64XX(E0)
#define E0_MICROSTEPS 128
#define E0_OVERCURRENT 2000
#define E0_STALLCURRENT 1500
#define E0_MAX_VOLTAGE 127
- #define E0_CHAIN_POS 0
+ #define E0_CHAIN_POS -1
+ #define E0_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E1(L6470)
+ #if AXIS_IS_L64XX(E1)
#define E1_MICROSTEPS 128
#define E1_OVERCURRENT 2000
#define E1_STALLCURRENT 1500
#define E1_MAX_VOLTAGE 127
- #define E1_CHAIN_POS 0
+ #define E1_CHAIN_POS -1
+ #define E1_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E2(L6470)
+ #if AXIS_IS_L64XX(E2)
#define E2_MICROSTEPS 128
#define E2_OVERCURRENT 2000
#define E2_STALLCURRENT 1500
#define E2_MAX_VOLTAGE 127
- #define E2_CHAIN_POS 0
+ #define E2_CHAIN_POS -1
+ #define E2_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E3(L6470)
+ #if AXIS_IS_L64XX(E3)
#define E3_MICROSTEPS 128
#define E3_OVERCURRENT 2000
#define E3_STALLCURRENT 1500
#define E3_MAX_VOLTAGE 127
- #define E3_CHAIN_POS 0
+ #define E3_CHAIN_POS -1
+ #define E3_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E4(L6470)
+ #if AXIS_IS_L64XX(E4)
#define E4_MICROSTEPS 128
#define E4_OVERCURRENT 2000
#define E4_STALLCURRENT 1500
#define E4_MAX_VOLTAGE 127
- #define E4_CHAIN_POS 0
+ #define E4_CHAIN_POS -1
+ #define E4_SLEW_RATE 1
#endif
- #if AXIS_DRIVER_TYPE_E5(L6470)
+ #if AXIS_IS_L64XX(E5)
#define E5_MICROSTEPS 128
#define E5_OVERCURRENT 2000
#define E5_STALLCURRENT 1500
#define E5_MAX_VOLTAGE 127
- #define E5_CHAIN_POS 0
+ #define E5_CHAIN_POS -1
+ #define E5_SLEW_RATE 1
+ #endif
+
+ #if AXIS_IS_L64XX(E6)
+ #define E6_MICROSTEPS 128
+ #define E6_OVERCURRENT 2000
+ #define E6_STALLCURRENT 1500
+ #define E6_MAX_VOLTAGE 127
+ #define E6_CHAIN_POS -1
+ #define E6_SLEW_RATE 1
+ #endif
+
+ #if AXIS_IS_L64XX(E7)
+ #define E7_MICROSTEPS 128
+ #define E7_OVERCURRENT 2000
+ #define E7_STALLCURRENT 1500
+ #define E7_MAX_VOLTAGE 127
+ #define E7_CHAIN_POS -1
+ #define E7_SLEW_RATE 1
#endif
/**
@@ -1757,7 +2616,7 @@
* I not present or I0 or I1 - X, Y, Z or E0
* I2 - X2, Y2, Z2 or E1
* I3 - Z3 or E3
- * I4 - E4
+ * I4 - Z4 or E4
* I5 - E5
* M916 - Increase drive level until get thermal warning
* M917 - Find minimum current thresholds
@@ -1771,7 +2630,15 @@
//#define L6470_STOP_ON_ERROR
#endif
-#endif // L6470
+#endif // HAS_L64XX
+
+// @section i2cbus
+
+//
+// I2C Master ID for LPC176x LCD and Digital Current control
+// Does not apply to other peripherals based on the Wire library.
+//
+//#define I2C_MASTER_ID 1 // Set a value from 0 to 2
/**
* TWI/I2C BUS
@@ -1801,10 +2668,10 @@
* echo:i2c-reply: from:99 bytes:5 data:hello
*/
-// @section i2cbus
-
//#define EXPERIMENTAL_I2CBUS
-#define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave
+#if ENABLED(EXPERIMENTAL_I2CBUS)
+ #define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave
+#endif
// @section extras
@@ -1833,6 +2700,20 @@
// Duration to hold the switch or keep CHDK_PIN high
//#define PHOTO_SWITCH_MS 50 // (ms) (M240 D)
+
+ /**
+ * PHOTO_PULSES_US may need adjustment depending on board and camera model.
+ * Pin must be running at 48.4kHz.
+ * Be sure to use a PHOTOGRAPH_PIN which can rise and fall quick enough.
+ * (e.g., MKS SBase temp sensor pin was too slow, so used P1.23 on J8.)
+ *
+ * Example pulse data for Nikon: https://bit.ly/2FKD0Aq
+ * IR Wiring: https://git.io/JvJf7
+ */
+ //#define PHOTO_PULSES_US { 2000, 27850, 400, 1580, 400, 3580, 400 } // (µs) Durations for each 48.4kHz oscillation
+ #ifdef PHOTO_PULSES_US
+ #define PHOTO_PULSE_DELAY_US 13 // (µs) Approximate duration of each HIGH and LOW pulse in the oscillation
+ #endif
#endif
/**
@@ -1850,36 +2731,145 @@
*
* See http://marlinfw.org/docs/configuration/laser_spindle.html for more config details.
*/
-//#define SPINDLE_LASER_ENABLE
-#if ENABLED(SPINDLE_LASER_ENABLE)
+//#define SPINDLE_FEATURE
+//#define LASER_FEATURE
+#if EITHER(SPINDLE_FEATURE, LASER_FEATURE)
+ #define SPINDLE_LASER_ACTIVE_HIGH false // Set to "true" if the on/off function is active HIGH
+ #define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power
+ #define SPINDLE_LASER_PWM_INVERT true // Set to "true" if the speed/power goes up when you want it to go slower
- #define SPINDLE_LASER_ENABLE_INVERT false // set to "true" if the on/off function is reversed
- #define SPINDLE_LASER_PWM true // set to true if your controller supports setting the speed/power
- #define SPINDLE_LASER_PWM_INVERT true // set to "true" if the speed/power goes up when you want it to go slower
- #define SPINDLE_LASER_POWERUP_DELAY 5000 // delay in milliseconds to allow the spindle/laser to come up to speed/power
- #define SPINDLE_LASER_POWERDOWN_DELAY 5000 // delay in milliseconds to allow the spindle to stop
- #define SPINDLE_DIR_CHANGE true // set to true if your spindle controller supports changing spindle direction
- #define SPINDLE_INVERT_DIR false
- #define SPINDLE_STOP_ON_DIR_CHANGE true // set to true if Marlin should stop the spindle before changing rotation direction
+ #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)
/**
- * The M3 & M4 commands use the following equation to convert PWM duty cycle to speed/power
- *
- * SPEED/POWER = PWM duty cycle * SPEED_POWER_SLOPE + SPEED_POWER_INTERCEPT
- * where PWM duty cycle varies from 0 to 255
- *
- * set the following for your controller (ALL MUST BE SET)
+ * Speed / Power can be set ('M3 S') and displayed in terms of:
+ * - PWM (S0 - S255)
+ * - PERCENT (S0 - S100)
+ * - RPM (S0 - S50000) Best for use with a spindle
*/
+ #define CUTTER_POWER_DISPLAY PWM
- #define SPEED_POWER_SLOPE 118.4
- #define SPEED_POWER_INTERCEPT 0
- #define SPEED_POWER_MIN 5000
- #define SPEED_POWER_MAX 30000 // SuperPID router controller 0 - 30,000 RPM
+ /**
+ * Relative mode uses relative range (SPEED_POWER_MIN to SPEED_POWER_MAX) instead of normal range (0 to SPEED_POWER_MAX)
+ * Best use with SuperPID router controller where for example S0 = 5,000 RPM and S255 = 30,000 RPM
+ */
+ //#define CUTTER_POWER_RELATIVE // Set speed proportional to [SPEED_POWER_MIN...SPEED_POWER_MAX] instead of directly
- //#define SPEED_POWER_SLOPE 0.3922
- //#define SPEED_POWER_INTERCEPT 0
- //#define SPEED_POWER_MIN 10
- //#define SPEED_POWER_MAX 100 // 0-100%
+ #if ENABLED(SPINDLE_FEATURE)
+ //#define SPINDLE_CHANGE_DIR // Enable if your spindle controller can change spindle direction
+ #define SPINDLE_CHANGE_DIR_STOP // Enable if the spindle should stop before changing spin direction
+ #define SPINDLE_INVERT_DIR false // Set to "true" if the spin direction is reversed
+
+ #define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power
+ #define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop
+
+ /**
+ * M3/M4 uses the following equation to convert speed/power to PWM duty cycle
+ * Power = ((DC / 255 * 100) - SPEED_POWER_INTERCEPT)) * (1 / SPEED_POWER_SLOPE)
+ * where PWM DC varies from 0 to 255
+ *
+ * Set these required parameters for your controller
+ */
+ #define SPEED_POWER_SLOPE 118.4 // SPEED_POWER_SLOPE = SPEED_POWER_MAX / 255
+ #define SPEED_POWER_INTERCEPT 0
+ #define SPEED_POWER_MIN 5000
+ #define SPEED_POWER_MAX 30000 // SuperPID router controller 0 - 30,000 RPM
+ #define SPEED_POWER_STARTUP 25000 // The default value for speed power when M3 is called without arguments
+
+ #else
+
+ #define SPEED_POWER_SLOPE 0.3922 // SPEED_POWER_SLOPE = SPEED_POWER_MAX / 255
+ #define SPEED_POWER_INTERCEPT 0
+ #define SPEED_POWER_MIN 0
+ #define SPEED_POWER_MAX 100 // 0-100%
+ #define SPEED_POWER_STARTUP 80 // The default value for speed power when M3 is called without arguments
+
+ /**
+ * Enable inline laser power to be handled in the planner / stepper routines.
+ * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)
+ * or by the 'S' parameter in G0/G1/G2/G3 moves (see LASER_MOVE_POWER).
+ *
+ * This allows the laser to keep in perfect sync with the planner and removes
+ * the powerup/down delay since lasers require negligible time.
+ */
+ #define LASER_POWER_INLINE
+
+ #if ENABLED(LASER_POWER_INLINE)
+ /**
+ * Scale the laser's power in proportion to the movement rate.
+ *
+ * - Sets the entry power proportional to the entry speed over the nominal speed.
+ * - Ramps the power up every N steps to approximate the speed trapezoid.
+ * - Due to the limited power resolution this is only approximate.
+ */
+ #define LASER_POWER_INLINE_TRAPEZOID
+
+ /**
+ * Continuously calculate the current power (nominal_power * current_rate / nominal_rate).
+ * Required for accurate power with non-trapezoidal acceleration (e.g., S_CURVE_ACCELERATION).
+ * This is a costly calculation so this option is discouraged on 8-bit AVR boards.
+ *
+ * LASER_POWER_INLINE_TRAPEZOID_CONT_PER defines how many step cycles there are between power updates. If your
+ * board isn't able to generate steps fast enough (and you are using LASER_POWER_INLINE_TRAPEZOID_CONT), increase this.
+ * Note that when this is zero it means it occurs every cycle; 1 means a delay wait one cycle then run, etc.
+ */
+ //#define LASER_POWER_INLINE_TRAPEZOID_CONT
+
+ /**
+ * Stepper iterations between power updates. Increase this value if the board
+ * can't keep up with the processing demands of LASER_POWER_INLINE_TRAPEZOID_CONT.
+ * Disable (or set to 0) to recalculate power on every stepper iteration.
+ */
+ //#define LASER_POWER_INLINE_TRAPEZOID_CONT_PER 10
+
+ /**
+ * Include laser power in G0/G1/G2/G3/G5 commands with the 'S' parameter
+ */
+ //#define LASER_MOVE_POWER
+
+ #if ENABLED(LASER_MOVE_POWER)
+ // Turn off the laser on G0 moves with no power parameter.
+ // If a power parameter is provided, use that instead.
+ //#define LASER_MOVE_G0_OFF
+ #endif
+
+ /**
+ * Inline flag inverted
+ *
+ * WARNING: M5 will NOT turn off the laser unless another move
+ * is done (so G-code files must end with 'M5 I').
+ */
+ //#define LASER_POWER_INLINE_INVERT
+
+ /**
+ * Continuously apply inline power. ('M3 S3' == 'G1 S3' == 'M3 S3 I')
+ *
+ * The laser might do some weird things, so only enable this
+ * feature if you understand the implications.
+ */
+ //#define LASER_POWER_INLINE_CONTINUOUS
+
+ #else
+
+ #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power
+ #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop
+
+ #endif
+ #endif
+#endif
+
+/**
+ * Coolant Control
+ *
+ * Add the M7, M8, and M9 commands to turn mist or flood coolant on and off.
+ *
+ * Note: COOLANT_MIST_PIN and/or COOLANT_FLOOD_PIN must also be defined.
+ */
+//#define COOLANT_CONTROL
+#if ENABLED(COOLANT_CONTROL)
+ #define COOLANT_MIST // Enable if mist coolant is present
+ #define COOLANT_FLOOD // Enable if flood coolant is present
+ #define COOLANT_MIST_INVERT false // Set "true" if the on/off function is reversed
+ #define COOLANT_FLOOD_INVERT false // Set "true" if the on/off function is reversed
#endif
/**
@@ -1933,6 +2923,13 @@
*/
#define EXTENDED_CAPABILITIES_REPORT
+/**
+ * Expected Printer Check
+ * Add the M16 G-code to compare a string to the MACHINE_NAME.
+ * M16 with a non-matching string causes the printer to halt.
+ */
+//#define EXPECTED_PRINTER_CHECK
+
/**
* Disable all Volumetric extrusion options
*/
@@ -1972,6 +2969,12 @@
*/
#define FASTER_GCODE_PARSER
+#if ENABLED(FASTER_GCODE_PARSER)
+ //#define GCODE_QUOTED_STRINGS // Support for quoted string parameters
+#endif
+
+//#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase
+
/**
* CNC G-code options
* Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc.
@@ -1987,6 +2990,13 @@
//#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode
#endif
+/**
+ * Startup commands
+ *
+ * Execute certain G-code commands immediately after power-on.
+ */
+//#define STARTUP_COMMANDS "M17 Z"
+
/**
* G-code Macros
*
@@ -1999,27 +3009,37 @@
#define GCODE_MACROS_SLOT_SIZE 50 // Maximum length of a single macro
#endif
-
+/**
+ * User-defined menu items that execute custom GCode
+ */
#define CUSTOM_USER_MENUS
-
#if ENABLED(CUSTOM_USER_MENUS)
//#define USER_SCRIPT_DONE "M117 User Script Done"
#define USER_SCRIPT_AUDIBLE_FEEDBACK
#define USER_SCRIPT_RETURN // Return to status screen after a script
- #define CUSTOM_USER_MENU_TITLE "Commissioning"
+ #define CUSTOM_USER_MENU_TITLE "Leveling Tools"
- #define USER_DESC_1 "Mesh Commission"
+ #define CommBedTmp "65"
+ #if ENABLED(DUAL_Z)
+ #define ALIGN_CMD "G34RI20\n"
+ #else
+ #define ALIGN_CMD ""
+ #endif
+ #define USER_DESC_1 "Setup"
+ #if (ENABLED(UBL))
+ #define USER_GCODE_1 "M190S" CommBedTmp"\nG28\n" ALIGN_CMD "G29P1\nG29S1\nG29S0\n G29F0.0\nG29A\nG28\nM109S225\nG1X150Y150\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
+ #else
+ #define USER_GCODE_1 "M190S" CommBedTmp"\n M117 Probing....\nM104S225\nG28\n" ALIGN_CMD "G29\nM400\nG28\nM420S1\nM109S225\nG1X100Y100\nG1Z0\nM500\nM400\nM77\nM117 Set Z Offset"
+ #endif
- #define USER_GCODE_1 "M117 \n M502 \n M500 \n M501 \n M190 S65 \n M117 Probing.... \n M104 S225 \n G28 \n G29 \n M500 \n G28 \n M420 S \n M109 S225 \n G1 X100 Y 100 \n G1 Z0 \n M77 \n M117 Set Z Offset"
-
#define USER_DESC_2 "PID Tune"
- #define USER_GCODE_2 "M106 S128 \n M303 C8 S225 E1 U \n M500 \n M117 PID Tune Done"
+ #define USER_GCODE_2 "M106 S128\nM303C8S225E0\nM500\nM117 PID Tune Done"
#define USER_DESC_3 "Prep for Z Adjust"
- #define USER_GCODE_3 "M190 S65\n M104 235 \n G28 \n G29 L1 \n G1 X100 Y 100 \n G1 Z0"
+ #define USER_GCODE_3 "M190S" CommBedTmp"\nM104S235\nG28\nG29L1\nG1X100Y100\nG1Z0"
#define USER_DESC_4 "Store Settings"
- #define USER_GCODE_4 "M500"
+ #define USER_GCODE_4 "M500\nM117 Settings Stored"
//#define USER_DESC_5 "Run Mesh Validation"
//#define USER_GCODE_5 "G26"
@@ -2044,9 +3064,12 @@
#define HOST_PROMPT_SUPPORT
#endif
-//===========================================================================
-//====================== I2C Position Encoder Settings ======================
-//===========================================================================
+/**
+ * Cancel Objects
+ *
+ * Implement M486 to allow Marlin to skip objects
+ */
+#define CANCEL_OBJECTS
/**
* I2C position encoders for closed loop control.
@@ -2110,7 +3133,7 @@
//#define I2CPE_ERR_THRESH_ABORT 100.0 // Threshold size for error (in mm) error on any given
// axis after which the printer will abort. Comment out to
- // disable abort behaviour.
+ // disable abort behavior.
#define I2CPE_TIME_TRUSTED 10000 // After an encoder fault, there must be no further fault
// for this amount of time (in ms) before the encoder
@@ -2128,6 +3151,26 @@
#endif // I2C_POSITION_ENCODERS
+/**
+ * Analog Joystick(s)
+ */
+//#define JOYSTICK
+#if ENABLED(JOYSTICK)
+ #define JOY_X_PIN 5 // RAMPS: Suggested pin A5 on AUX2
+ #define JOY_Y_PIN 10 // RAMPS: Suggested pin A10 on AUX2
+ #define JOY_Z_PIN 12 // RAMPS: Suggested pin A12 on AUX2
+ #define JOY_EN_PIN 44 // RAMPS: Suggested pin D44 on AUX2
+
+ //#define INVERT_JOY_X // Enable if X direction is reversed
+ //#define INVERT_JOY_Y // Enable if Y direction is reversed
+ //#define INVERT_JOY_Z // Enable if Z direction is reversed
+
+ // Use M119 with JOYSTICK_DEBUG to find reasonable values after connecting:
+ #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 }
+#endif
+
/**
* MAX7219 Debug Matrix
*
@@ -2141,11 +3184,12 @@
#define MAX7219_LOAD_PIN 44
//#define MAX7219_GCODE // Add the M7219 G-code to control the LED matrix
- #define MAX7219_INIT_TEST 2 // Do a test pattern at initialization (Set to 2 for spiral)
+ #define MAX7219_INIT_TEST 2 // Test pattern at startup: 0=none, 1=sweep, 2=spiral
#define MAX7219_NUMBER_UNITS 1 // Number of Max7219 units in chain.
#define MAX7219_ROTATE 0 // Rotate the display clockwise (in multiples of +/- 90°)
// connector at: right=0 bottom=-90 top=90 left=180
//#define MAX7219_REVERSE_ORDER // The individual LED matrix units may be in reversed order
+ //#define MAX7219_SIDE_BY_SIDE // Big chip+matrix boards can be chained side-by-side
/**
* Sample debug features
@@ -2170,16 +3214,29 @@
//#define NANODLP_Z_SYNC
#if ENABLED(NANODLP_Z_SYNC)
//#define NANODLP_ALL_AXIS // Enables "Z_move_comp" output on any axis move.
- // Default behaviour is limited to Z axis only.
+ // Default behavior is limited to Z axis only.
#endif
/**
* WiFi Support (Espressif ESP32 WiFi)
*/
-//#define WIFISUPPORT
-#if ENABLED(WIFISUPPORT)
- #define WIFI_SSID "Wifi SSID"
- #define WIFI_PWD "Wifi Password"
+//#define WIFISUPPORT // Marlin embedded WiFi managenent
+//#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)
+
+#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
+ //#define WEBSUPPORT // Start a webserver (which may include auto-discovery)
+ //#define OTASUPPORT // Support over-the-air firmware updates
+ //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
+
+ /**
+ * To set a default WiFi SSID / Password, create a file called Configuration_Secure.h with
+ * the following defines, customized for your network. This specific file is excluded via
+ * .gitignore to prevent it from accidentally leaking to the public.
+ *
+ * #define WIFI_SSID "WiFi SSID"
+ * #define WIFI_PWD "WiFi Password"
+ */
+ //#include "Configuration_Secure.h" // External file with WiFi SSID / Password
#endif
/**
@@ -2251,10 +3308,15 @@
// @section develop
-/**
- * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
- */
-#define PINS_DEBUGGING
+//
+// M100 Free Memory Watcher to debug memory usage
+//
+//#define M100_FREE_MEMORY_WATCHER
+
+//
+// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
+//
+//#define PINS_DEBUGGING
// Enable Marlin dev mode which adds some special commands
//#define MARLIN_DEV_MODE
diff --git a/Marlin/Makefile b/Marlin/Makefile
index acf9c94c71..33a787fb64 100644
--- a/Marlin/Makefile
+++ b/Marlin/Makefile
@@ -92,6 +92,9 @@ U8GLIB ?= 1
# this defines whether to include the Trinamic TMCStepper library
TMC ?= 1
+# this defines whether to include the AdaFruit NeoPixel library
+NEOPIXEL ?= 0
+
############
# Try to automatically determine whether RELOC_WORKAROUND is needed based
# on GCC versions:
@@ -122,169 +125,224 @@ ifeq ($(HARDWARE_MOTHERBOARD),0)
#
# MEGA/RAMPS up to 1.2
-else ifeq ($(HARDWARE_MOTHERBOARD),3)
+else ifeq ($(HARDWARE_MOTHERBOARD),1000)
# RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),33)
+else ifeq ($(HARDWARE_MOTHERBOARD),1010)
# RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),34)
+else ifeq ($(HARDWARE_MOTHERBOARD),1011)
# RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
-else ifeq ($(HARDWARE_MOTHERBOARD),35)
+else ifeq ($(HARDWARE_MOTHERBOARD),1012)
# RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),36)
+else ifeq ($(HARDWARE_MOTHERBOARD),1013)
# RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),38)
+else ifeq ($(HARDWARE_MOTHERBOARD),1014)
# RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),43)
+else ifeq ($(HARDWARE_MOTHERBOARD),1020)
# RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),44)
+else ifeq ($(HARDWARE_MOTHERBOARD),1021)
# RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
-else ifeq ($(HARDWARE_MOTHERBOARD),45)
+else ifeq ($(HARDWARE_MOTHERBOARD),1022)
# RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),46)
+else ifeq ($(HARDWARE_MOTHERBOARD),1023)
# RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),48)
+else ifeq ($(HARDWARE_MOTHERBOARD),1024)
# RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),143)
+else ifeq ($(HARDWARE_MOTHERBOARD),1030)
# RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
-else ifeq ($(HARDWARE_MOTHERBOARD),144)
+else ifeq ($(HARDWARE_MOTHERBOARD),1031)
# RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
-else ifeq ($(HARDWARE_MOTHERBOARD),145)
+else ifeq ($(HARDWARE_MOTHERBOARD),1032)
# RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),146)
+else ifeq ($(HARDWARE_MOTHERBOARD),1033)
# RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
-else ifeq ($(HARDWARE_MOTHERBOARD),148)
+else ifeq ($(HARDWARE_MOTHERBOARD),1034)
#
# RAMPS Derivatives - ATmega1280, ATmega2560
#
# 3Drag Controller
-else ifeq ($(HARDWARE_MOTHERBOARD),77)
+else ifeq ($(HARDWARE_MOTHERBOARD),1100)
# Velleman K8200 Controller (derived from 3Drag Controller)
-else ifeq ($(HARDWARE_MOTHERBOARD),78)
+else ifeq ($(HARDWARE_MOTHERBOARD),1101)
# Velleman K8400 Controller (derived from 3Drag Controller)
-else ifeq ($(HARDWARE_MOTHERBOARD),79)
+else ifeq ($(HARDWARE_MOTHERBOARD),1102)
# 2PrintBeta BAM&DICE with STK drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),401)
+else ifeq ($(HARDWARE_MOTHERBOARD),1103)
# 2PrintBeta BAM&DICE Due with STK drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),402)
+else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# MKS BASE v1.0
-else ifeq ($(HARDWARE_MOTHERBOARD),40)
+else ifeq ($(HARDWARE_MOTHERBOARD),1105)
+# MKS v1.4 with A4982 stepper drivers
+else ifeq ($(HARDWARE_MOTHERBOARD),1106)
# MKS v1.5 with Allegro A4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),405)
+else ifeq ($(HARDWARE_MOTHERBOARD),1107)
+# MKS v1.6 with Allegro A4982 stepper drivers
+else ifeq ($(HARDWARE_MOTHERBOARD),1108)
+
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
-else ifeq ($(HARDWARE_MOTHERBOARD),41)
+else ifeq ($(HARDWARE_MOTHERBOARD),1109)
# MKS GEN v1.3 or 1.4
-else ifeq ($(HARDWARE_MOTHERBOARD),47)
+else ifeq ($(HARDWARE_MOTHERBOARD),1110)
# MKS GEN L
-else ifeq ($(HARDWARE_MOTHERBOARD),53)
+else ifeq ($(HARDWARE_MOTHERBOARD),1111)
# zrib V2.0 control board (Chinese knock off RAMPS replica)
-else ifeq ($(HARDWARE_MOTHERBOARD),504)
+else ifeq ($(HARDWARE_MOTHERBOARD),1112)
+# BigTreeTech or BIQU KFB2.0
+else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# Felix 2.0+ Electronics Board (RAMPS like)
-else ifeq ($(HARDWARE_MOTHERBOARD),37)
+else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# Invent-A-Part RigidBoard
-else ifeq ($(HARDWARE_MOTHERBOARD),42)
+else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# Invent-A-Part RigidBoard V2
-else ifeq ($(HARDWARE_MOTHERBOARD),52)
+else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Sainsmart 2-in-1 board
-else ifeq ($(HARDWARE_MOTHERBOARD),49)
+else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Ultimaker
-else ifeq ($(HARDWARE_MOTHERBOARD),7)
+else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
-else ifeq ($(HARDWARE_MOTHERBOARD),71)
+else ifeq ($(HARDWARE_MOTHERBOARD),1119)
MCU ?= atmega1280
+
# Azteeg X3
-else ifeq ($(HARDWARE_MOTHERBOARD),67)
+else ifeq ($(HARDWARE_MOTHERBOARD),1120)
# Azteeg X3 Pro
-else ifeq ($(HARDWARE_MOTHERBOARD),68)
+else ifeq ($(HARDWARE_MOTHERBOARD),1121)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
-else ifeq ($(HARDWARE_MOTHERBOARD),72)
+else ifeq ($(HARDWARE_MOTHERBOARD),1122)
# Rumba
-else ifeq ($(HARDWARE_MOTHERBOARD),80)
+else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Raise3D Rumba
-else ifeq ($(HARDWARE_MOTHERBOARD),333)
+else ifeq ($(HARDWARE_MOTHERBOARD),1124)
+# Rapide Lite RL200 Rumba
+else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Formbot T-Rex 2 Plus
-else ifeq ($(HARDWARE_MOTHERBOARD),95)
+else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Formbot T-Rex 3
-else ifeq ($(HARDWARE_MOTHERBOARD),96)
+else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Formbot Raptor
-else ifeq ($(HARDWARE_MOTHERBOARD),97)
+else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot Raptor 2
-else ifeq ($(HARDWARE_MOTHERBOARD),98)
+else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# bq ZUM Mega 3D
-else ifeq ($(HARDWARE_MOTHERBOARD),503)
+else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
-else ifeq ($(HARDWARE_MOTHERBOARD),431)
+else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
-else ifeq ($(HARDWARE_MOTHERBOARD),343)
+else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
-else ifeq ($(HARDWARE_MOTHERBOARD),443)
+else ifeq ($(HARDWARE_MOTHERBOARD),1133)
+# TriGorilla Anycubic version 1.4 Rev 1.1
+else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# Creality: Ender-4, CR-8
-else ifeq ($(HARDWARE_MOTHERBOARD),243)
+else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# Creality: CR10S, CR20, CR-X
-else ifeq ($(HARDWARE_MOTHERBOARD),244)
-# Fysetc F6
-else ifeq ($(HARDWARE_MOTHERBOARD),541)
+else ifeq ($(HARDWARE_MOTHERBOARD),1136)
+# Dagoma F5
+else ifeq ($(HARDWARE_MOTHERBOARD),1137)
+# FYSETC F6 1.3
+else ifeq ($(HARDWARE_MOTHERBOARD),1138)
+# FYSETC F6 1.5
+else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# Duplicator i3 Plus
-else ifeq ($(HARDWARE_MOTHERBOARD),31)
+else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# VORON
-else ifeq ($(HARDWARE_MOTHERBOARD),441)
+else ifeq ($(HARDWARE_MOTHERBOARD),1141)
+# TRONXY V3 1.0
+else ifeq ($(HARDWARE_MOTHERBOARD),1142)
+# Z-Bolt X Series
+else ifeq ($(HARDWARE_MOTHERBOARD),1143)
+# TT OSCAR
+else ifeq ($(HARDWARE_MOTHERBOARD),1144)
+# Overlord/Overlord Pro
+else ifeq ($(HARDWARE_MOTHERBOARD),1145)
+# ADIMLab Gantry v1
+else ifeq ($(HARDWARE_MOTHERBOARD),1146)
+# ADIMLab Gantry v2
+else ifeq ($(HARDWARE_MOTHERBOARD),1147)
+# BIQU Tango V1
+else ifeq ($(HARDWARE_MOTHERBOARD),1148)
+# MKS GEN L V2
+else ifeq ($(HARDWARE_MOTHERBOARD),1149)
+# Copymaster 3D
+else ifeq ($(HARDWARE_MOTHERBOARD),1150)
+
+#
+# RAMBo and derivatives
+#
+
+# Rambo
+else ifeq ($(HARDWARE_MOTHERBOARD),1200)
+# Mini-Rambo
+else ifeq ($(HARDWARE_MOTHERBOARD),1201)
+# Mini-Rambo 1.0a
+else ifeq ($(HARDWARE_MOTHERBOARD),1202)
+# Einsy Rambo
+else ifeq ($(HARDWARE_MOTHERBOARD),1203)
+# Einsy Retro
+else ifeq ($(HARDWARE_MOTHERBOARD),1204)
+# abee Scoovo X9H
+else ifeq ($(HARDWARE_MOTHERBOARD),1205)
#
# Other ATmega1280, ATmega2560
#
# Cartesio CN Controls V11
-else ifeq ($(HARDWARE_MOTHERBOARD),111)
+else ifeq ($(HARDWARE_MOTHERBOARD),1300)
# Cartesio CN Controls V12
-else ifeq ($(HARDWARE_MOTHERBOARD),112)
+else ifeq ($(HARDWARE_MOTHERBOARD),1301)
+# Cartesio CN Controls V15
+else ifeq ($(HARDWARE_MOTHERBOARD),1302)
# Cheaptronic v1.0
-else ifeq ($(HARDWARE_MOTHERBOARD),2)
+else ifeq ($(HARDWARE_MOTHERBOARD),1303)
# Cheaptronic v2.0
-else ifeq ($(HARDWARE_MOTHERBOARD),21)
+else ifeq ($(HARDWARE_MOTHERBOARD),1304)
# Makerbot Mightyboard Revision E
-else ifeq ($(HARDWARE_MOTHERBOARD),200)
+else ifeq ($(HARDWARE_MOTHERBOARD),1305)
# Megatronics
-else ifeq ($(HARDWARE_MOTHERBOARD),70)
+else ifeq ($(HARDWARE_MOTHERBOARD),1306)
# Megatronics v2.0
-else ifeq ($(HARDWARE_MOTHERBOARD),701)
+else ifeq ($(HARDWARE_MOTHERBOARD),1307)
# Megatronics v3.0
-else ifeq ($(HARDWARE_MOTHERBOARD),703)
+else ifeq ($(HARDWARE_MOTHERBOARD),1308)
# Megatronics v3.1
-else ifeq ($(HARDWARE_MOTHERBOARD),704)
-# Rambo
-else ifeq ($(HARDWARE_MOTHERBOARD),301)
-# Mini-Rambo
-else ifeq ($(HARDWARE_MOTHERBOARD),302)
-# Mini-Rambo 1.0a
-else ifeq ($(HARDWARE_MOTHERBOARD),303)
-# Einsy Rambo
-else ifeq ($(HARDWARE_MOTHERBOARD),304)
-# Einsy Retro
-else ifeq ($(HARDWARE_MOTHERBOARD),305)
+else ifeq ($(HARDWARE_MOTHERBOARD),1309)
+# Megatronics v3.2
+else ifeq ($(HARDWARE_MOTHERBOARD),1310)
# Elefu Ra Board (v3)
-else ifeq ($(HARDWARE_MOTHERBOARD),21)
+else ifeq ($(HARDWARE_MOTHERBOARD),1311)
# Leapfrog
-else ifeq ($(HARDWARE_MOTHERBOARD),999)
+else ifeq ($(HARDWARE_MOTHERBOARD),1312)
# Mega controller
-else ifeq ($(HARDWARE_MOTHERBOARD),310)
-# abee Scoovo X9H
-else ifeq ($(HARDWARE_MOTHERBOARD),321)
+else ifeq ($(HARDWARE_MOTHERBOARD),1313)
+# Geeetech GT2560 Rev B for Mecreator2
+else ifeq ($(HARDWARE_MOTHERBOARD),1314)
# Geeetech GT2560 Rev. A
-else ifeq ($(HARDWARE_MOTHERBOARD),74)
+else ifeq ($(HARDWARE_MOTHERBOARD),1315)
# Geeetech GT2560 Rev. A+ (with auto level probe)
-else ifeq ($(HARDWARE_MOTHERBOARD),75)
+else ifeq ($(HARDWARE_MOTHERBOARD),1316)
+# Geeetech GT2560 Rev B for A10(M/D)
+else ifeq ($(HARDWARE_MOTHERBOARD),1317)
+# Geeetech GT2560 Rev B for A20(M/D)
+else ifeq ($(HARDWARE_MOTHERBOARD),1318)
+# Einstart retrofit
+else ifeq ($(HARDWARE_MOTHERBOARD),1319)
+# Wanhao 0ne+ i3 Mini
+else ifeq ($(HARDWARE_MOTHERBOARD),1320)
#
# ATmega1281, ATmega2561
#
-else ifeq ($(HARDWARE_MOTHERBOARD),702)
+# Minitronics v1.0/1.1
+else ifeq ($(HARDWARE_MOTHERBOARD),1400)
MCU ?= atmega1281
-else ifeq ($(HARDWARE_MOTHERBOARD),25)
+# Silvergate v1.0
+else ifeq ($(HARDWARE_MOTHERBOARD),1401)
MCU ?= atmega1281
#
@@ -292,43 +350,43 @@ else ifeq ($(HARDWARE_MOTHERBOARD),25)
#
# Sanguinololu < 1.2
-else ifeq ($(HARDWARE_MOTHERBOARD),6)
+else ifeq ($(HARDWARE_MOTHERBOARD),1500)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Sanguinololu 1.2 and above
-else ifeq ($(HARDWARE_MOTHERBOARD),62)
+else ifeq ($(HARDWARE_MOTHERBOARD),1501)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Melzi
-else ifeq ($(HARDWARE_MOTHERBOARD),63)
+else ifeq ($(HARDWARE_MOTHERBOARD),1502)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Melzi with ATmega1284 (MaKr3d version)
-else ifeq ($(HARDWARE_MOTHERBOARD),66)
+else ifeq ($(HARDWARE_MOTHERBOARD),1503)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# Melzi Creality3D board (for CR-10 etc)
-else ifeq ($(HARDWARE_MOTHERBOARD),89)
+else ifeq ($(HARDWARE_MOTHERBOARD),1504)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# Melzi Malyan M150 board
-else ifeq ($(HARDWARE_MOTHERBOARD),92)
+else ifeq ($(HARDWARE_MOTHERBOARD),1505)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# Tronxy X5S
-else ifeq ($(HARDWARE_MOTHERBOARD),505)
+else ifeq ($(HARDWARE_MOTHERBOARD),1506)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# STB V1.1
-else ifeq ($(HARDWARE_MOTHERBOARD),64)
+else ifeq ($(HARDWARE_MOTHERBOARD),1507)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# Azteeg X1
-else ifeq ($(HARDWARE_MOTHERBOARD),65)
+else ifeq ($(HARDWARE_MOTHERBOARD),1508)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
# Anet 1.0 (Melzi clone)
-else ifeq ($(HARDWARE_MOTHERBOARD),69)
+else ifeq ($(HARDWARE_MOTHERBOARD),1509)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
@@ -337,51 +395,51 @@ else ifeq ($(HARDWARE_MOTHERBOARD),69)
#
# Gen3 Monolithic Electronics
-else ifeq ($(HARDWARE_MOTHERBOARD),22)
+else ifeq ($(HARDWARE_MOTHERBOARD),1600)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Gen3+
-else ifeq ($(HARDWARE_MOTHERBOARD),9)
+else ifeq ($(HARDWARE_MOTHERBOARD),1601)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Gen6
-else ifeq ($(HARDWARE_MOTHERBOARD),5)
+else ifeq ($(HARDWARE_MOTHERBOARD),1602)
HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p
# Gen6 deluxe
-else ifeq ($(HARDWARE_MOTHERBOARD),51)
+else ifeq ($(HARDWARE_MOTHERBOARD),1603)
HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p
# Gen7 custom (Alfons3 Version)
-else ifeq ($(HARDWARE_MOTHERBOARD),10)
+else ifeq ($(HARDWARE_MOTHERBOARD),1604)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644
F_CPU ?= 20000000
# Gen7 v1.1, v1.2
-else ifeq ($(HARDWARE_MOTHERBOARD),11)
+else ifeq ($(HARDWARE_MOTHERBOARD),1605)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p
F_CPU ?= 20000000
# Gen7 v1.3
-else ifeq ($(HARDWARE_MOTHERBOARD),12)
+else ifeq ($(HARDWARE_MOTHERBOARD),1606)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p
F_CPU ?= 20000000
# Gen7 v1.4
-else ifeq ($(HARDWARE_MOTHERBOARD),13)
+else ifeq ($(HARDWARE_MOTHERBOARD),1607)
HARDWARE_VARIANT ?= Gen7
MCU ?= atmega1284p
F_CPU ?= 20000000
# Alpha OMCA board
-else ifeq ($(HARDWARE_MOTHERBOARD),90)
+else ifeq ($(HARDWARE_MOTHERBOARD),1608)
HARDWARE_VARIANT ?= SanguinoA
MCU ?= atmega644
# Final OMCA board
-else ifeq ($(HARDWARE_MOTHERBOARD),91)
+else ifeq ($(HARDWARE_MOTHERBOARD),1609)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
# Sethi 3D_1
-else ifeq ($(HARDWARE_MOTHERBOARD),20)
+else ifeq ($(HARDWARE_MOTHERBOARD),1610)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p
@@ -390,46 +448,46 @@ else ifeq ($(HARDWARE_MOTHERBOARD),20)
#
# Teensylu
-else ifeq ($(HARDWARE_MOTHERBOARD),8)
+else ifeq ($(HARDWARE_MOTHERBOARD),1700)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# Printrboard (AT90USB1286)
-else ifeq ($(HARDWARE_MOTHERBOARD),81)
+else ifeq ($(HARDWARE_MOTHERBOARD),1701)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# Printrboard Revision F (AT90USB1286)
-else ifeq ($(HARDWARE_MOTHERBOARD),811)
+else ifeq ($(HARDWARE_MOTHERBOARD),1702)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# Brainwave (AT90USB646)
-else ifeq ($(HARDWARE_MOTHERBOARD),82)
+else ifeq ($(HARDWARE_MOTHERBOARD),1703)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb646
# Brainwave Pro (AT90USB1286)
-else ifeq ($(HARDWARE_MOTHERBOARD),83)
+else ifeq ($(HARDWARE_MOTHERBOARD),1704)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# SAV Mk-I (AT90USB1286)
-else ifeq ($(HARDWARE_MOTHERBOARD),84)
+else ifeq ($(HARDWARE_MOTHERBOARD),1705)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# Teensy++2.0 (AT90USB1286)
-else ifeq ($(HARDWARE_MOTHERBOARD),85)
+else ifeq ($(HARDWARE_MOTHERBOARD),1706)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# 5DPrint D8 Driver Board
-else ifeq ($(HARDWARE_MOTHERBOARD),88)
+else ifeq ($(HARDWARE_MOTHERBOARD),1707)
HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286
# UltiMachine Archim1 (with DRV8825 drivers)
-else ifeq ($(HARDWARE_MOTHERBOARD),1591)
+else ifeq ($(HARDWARE_MOTHERBOARD),3023)
HARDWARE_VARIANT ?= archim
MCPU = cortex-m3
F_CPU = 84000000L
IS_MCU = 0
# UltiMachine Archim2 (with TMC2130 drivers)
-else ifeq ($(HARDWARE_MOTHERBOARD),1592)
+else ifeq ($(HARDWARE_MOTHERBOARD),3024)
HARDWARE_VARIANT ?= archim
MCPU = cortex-m3
F_CPU = 84000000L
@@ -576,7 +634,7 @@ ifeq ($(U8GLIB), 1)
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 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)
@@ -628,7 +686,7 @@ ifeq ($(HARDWARE_VARIANT), Teensy)
else ifeq ($(HARDWARE_VARIANT), archim)
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_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)
@@ -647,9 +705,9 @@ LIBWARN = -w -Wno-packed-bitfield-compat
CSTANDARD = -std=gnu99
CXXSTANDARD = -std=gnu++11
CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas
-CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas
-CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
+CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
+CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
+CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
-fshort-enums -ffunction-sections -fdata-sections
ifneq ($(HARDWARE_MOTHERBOARD),)
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
@@ -663,7 +721,7 @@ ASFLAGS := $(CDEFS)
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 -gcc -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -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
@@ -740,7 +798,7 @@ ifeq (${AVRDUDE_PROGRAMMER}, arduino)
stty -hup < $(UPLOAD_PORT); true
endif
- # Display size of file.
+# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
$(SIZE) $(BUILD_DIR)/$(TARGET).elf
@@ -790,7 +848,7 @@ extcoff: $(TARGET).elf
.elf.sym:
$(NM) -n $< > $@
- # Link: create ELF output file from library.
+# Link: create ELF output file from library.
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
$(Pecho) " CXX $@"
diff --git a/Marlin/Marlin.ino b/Marlin/Marlin.ino
index 842b2a14b9..d1d58d483d 100644
--- a/Marlin/Marlin.ino
+++ b/Marlin/Marlin.ino
@@ -3,7 +3,7 @@
Marlin Firmware
- (c) 2011-2018 MarlinFirmware
+ (c) 2011-2020 MarlinFirmware
Portions of Marlin are (c) by their respective authors.
All code complies with GPLv2 and/or GPLv3
@@ -19,7 +19,7 @@ Before diving in, we recommend the following essential links:
Marlin Firmware Official Website
- - http://marlinfw.org/
+ - https://marlinfw.org/
The official Marlin Firmware website contains the most up-to-date
documentation. Contributions are always welcome!
@@ -30,7 +30,7 @@ Configuration
(Applies to Marlin 1.0.x, so Jerk and Acceleration should be halved.)
Also... https://www.google.com/search?tbs=vid%3A1&q=configure+marlin
- - http://marlinfw.org/docs/configuration/configuration.html
+ - https://marlinfw.org/docs/configuration/configuration.html
Marlin's configuration options are explained in more detail here.
Getting Help
@@ -45,9 +45,9 @@ Getting Help
Contributing
- - http://marlinfw.org/docs/development/contributing.html
+ - https://marlinfw.org/docs/development/contributing.html
If you'd like to contribute to Marlin, read this first!
- - http://marlinfw.org/docs/development/coding_standards.html
+ - https://marlinfw.org/docs/development/coding_standards.html
Before submitting code get to know the Coding Standards.
*/
diff --git a/Marlin/Version.h b/Marlin/Version.h
new file mode 100644
index 0000000000..367f3ea22a
--- /dev/null
+++ b/Marlin/Version.h
@@ -0,0 +1,76 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+////////////////////////////
+// VENDOR VERSION EXAMPLE //
+////////////////////////////
+
+/**
+ * Marlin release version identifier
+ */
+#define SHORT_BUILD_VERSION "2.0.5_SX4N"
+
+/**
+ * Verbose version identifier which should contain a reference to the location
+ * from where the binary was downloaded or the source code was compiled.
+ */
+#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " TM3D"
+
+/**
+ * The STRING_DISTRIBUTION_DATE represents when the binary file was built,
+ * here we define this default string as the date where the latest release
+ * version was tagged.
+ */
+#define STRING_DISTRIBUTION_DATE "2020-05-01"
+
+/**
+ * Defines a generic printer name to be output to the LCD after booting Marlin.
+ */
+#define MACHINE_NAME "TM3D SX4"
+
+/**
+ * The SOURCE_CODE_URL is the location where users will find the Marlin Source
+ * Code which is installed on the device. In most cases —unless the manufacturer
+ * has a distinct Github fork— the Source Code URL should just be the main
+ * Marlin repository.
+ */
+#define SOURCE_CODE_URL "https://github.com/InsanityAutomation/Marlin/tree/TM_SX4_2.0"
+
+/**
+ * Default generic printer UUID.
+ */
+//#define DEFAULT_MACHINE_UUID "cede2a2f-41a2-4748-9b12-c55c62f367ff"
+
+/**
+ * The WEBSITE_URL is the location where users can get more information such as
+ * documentation about a specific Marlin release.
+ */
+#define WEBSITE_URL "tinymachines3d.com"
+
+/**
+ * Set the vendor info the serial USB interface, if changable
+ * Currently only supported by DUE platform
+ */
+//#define USB_DEVICE_VENDOR_ID 0x0000
+//#define USB_DEVICE_PRODUCT_ID 0x0000
+//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
diff --git a/Marlin/_Bootscreen.h b/Marlin/_Bootscreen.h
new file mode 100644
index 0000000000..d262102e47
--- /dev/null
+++ b/Marlin/_Bootscreen.h
@@ -0,0 +1,93 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Custom Bitmap for splashscreen
+ *
+ * You may use one of the following tools to generate the C++ bitmap array from
+ * a black and white image:
+ *
+ * - http://www.marlinfw.org/tools/u8glib/converter.html
+ * - http://www.digole.com/tools/PicturetoC_Hex_converter.php
+ */
+
+#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
+#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
+#define CUSTOM_BOOTSCREEN_INVERTED
+
+const unsigned char custom_start_bmp[] PROGMEM = {
+ B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,
+ B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
+ B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
+ B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
+ B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
+ B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111,
+ B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111,
+ B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111,
+ B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111,
+ B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111,
+ B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
+ B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111,
+ B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
+ B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111,
+ B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111,
+ B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111,
+ B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111,
+ B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111,
+ B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111,
+ B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111,
+ B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
+ B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
+ B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
+ B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
+ B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
+ B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
+ B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
+ B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
+ B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111,
+ B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111,
+ B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111,
+ B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011,
+ B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011,
+ B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011,
+ B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011,
+ B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111,
+ B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111,
+ B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111
+};
diff --git a/Marlin/_Statusscreen.h b/Marlin/_Statusscreen.h
new file mode 100644
index 0000000000..d0450837ab
--- /dev/null
+++ b/Marlin/_Statusscreen.h
@@ -0,0 +1,74 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Custom Status Screen bitmap
+ *
+ * Place this file in the root with your configuration files
+ * and enable CUSTOM_STATUS_SCREEN_IMAGE in Configuration.h.
+ *
+ * Use the Marlin Bitmap Converter to make your own:
+ * http://marlinfw.org/tools/u8glib/converter.html
+ */
+
+//
+// Status Screen Logo bitmap
+//
+#define STATUS_LOGO_Y 3
+#define STATUS_LOGO_WIDTH 24
+
+const unsigned char status_logo_bmp[] PROGMEM = {
+ B11111111,B11111111,B11111111,
+ B10000000,B00000000,B00000001,
+ B10001110,B00000000,B11100001,
+ B10011111,B00000001,B11110001,
+ B10010011,B10000001,B00111001,
+ B10011111,B10000001,B11111001,
+ B10011111,B10000001,B11111001,
+ B10011111,B10111001,B11111001,
+ B10001111,B00101000,B11110001,
+ B10000000,B00111000,B00000001,
+ B10000000,B00000000,B00000001,
+ B10011111,B11111111,B11111001,
+ B10010001,B01110100,B10011001,
+ B10011011,B00000110,B10101001,
+ B10011011,B01010100,B10101001,
+ B10011011,B01010110,B10101001,
+ B10011011,B01010100,B10011001,
+ B10011111,B11111111,B11111001,
+ B11111111,B11111111,B11111111
+};
+
+//
+// Use default bitmaps
+//
+#define STATUS_HOTEND_ANIM
+#define STATUS_BED_ANIM
+#if HOTENDS < 2
+ #define STATUS_LOGO_X 8
+ #define STATUS_HEATERS_X 40
+ #define STATUS_BED_X 72
+#else
+ #define STATUS_LOGO_X 0
+ #define STATUS_HEATERS_X 32
+ #define STATUS_BED_X 80
+#endif
diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp
new file mode 100644
index 0000000000..05d4e51dd0
--- /dev/null
+++ b/Marlin/src/HAL/AVR/HAL.cpp
@@ -0,0 +1,78 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef __AVR__
+
+#include "../../inc/MarlinConfig.h"
+#include "HAL.h"
+
+// ------------------------
+// Public Variables
+// ------------------------
+
+//uint8_t MCUSR;
+
+// ------------------------
+// Public functions
+// ------------------------
+
+void HAL_init() {
+ // Init Servo Pins
+ #define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW)
+ #if HAS_SERVO_0
+ INIT_SERVO(0);
+ #endif
+ #if HAS_SERVO_1
+ INIT_SERVO(1);
+ #endif
+ #if HAS_SERVO_2
+ INIT_SERVO(2);
+ #endif
+ #if HAS_SERVO_3
+ INIT_SERVO(3);
+ #endif
+}
+
+#if ENABLED(SDSUPPORT)
+
+ #include "../../sd/SdFatUtil.h"
+ int freeMemory() { return SdFatUtil::FreeRam(); }
+
+#else // !SDSUPPORT
+
+extern "C" {
+ extern char __bss_end;
+ extern char __heap_start;
+ extern void* __brkval;
+
+ int freeMemory() {
+ int free_memory;
+ if ((int)__brkval == 0)
+ free_memory = ((int)&free_memory) - ((int)&__bss_end);
+ else
+ free_memory = ((int)&free_memory) - ((int)__brkval);
+ return free_memory;
+ }
+}
+
+#endif // !SDSUPPORT
+
+#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h
similarity index 80%
rename from Marlin/src/HAL/HAL_AVR/HAL.h
rename to Marlin/src/HAL/AVR/HAL.h
index b5b63dc5d1..f715295d0a 100644
--- a/Marlin/src/HAL/HAL_AVR/HAL.h
+++ b/Marlin/src/HAL/AVR/HAL.h
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
@@ -18,40 +18,43 @@
*/
#pragma once
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
+#include "../shared/Marduino.h"
+#include "../shared/HAL_SPI.h"
+#include "fastio.h"
+#include "watchdog.h"
+#include "math.h"
+
+#ifdef USBCON
+ #include
+#else
+ #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
+ #include "MarlinSerial.h"
+#endif
#include
-
-#include
-
#include
#include
#include
#include
#include
-#include "../shared/HAL_SPI.h"
-#include "fastio_AVR.h"
-#include "watchdog_AVR.h"
-#include "math_AVR.h"
-
-#ifdef USBCON
- #include "HardwareSerial.h"
-#else
- #include "MarlinSerial.h"
+#ifndef pgm_read_ptr
+ // Compatibility for avr-libc 1.8.0-4.1 included with Ubuntu for
+ // Windows Subsystem for Linux on Windows 10 as of 10/18/2019
+ #define pgm_read_ptr_far(address_long) (void*)__ELPM_word((uint32_t)(address_long))
+ #define pgm_read_ptr_near(address_short) (void*)__LPM_word((uint16_t)(address_short))
+ #define pgm_read_ptr(address_short) pgm_read_ptr_near(address_short)
#endif
-// --------------------------------------------------------------------------
+// ------------------------
// Defines
-// --------------------------------------------------------------------------
+// ------------------------
//#define analogInputToDigitalPin(IO) IO
#ifndef CRITICAL_SECTION_START
- #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()
- #define CRITICAL_SECTION_END SREG = _sreg
+ #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli()
+ #define CRITICAL_SECTION_END() SREG = _sreg
#endif
#define ISRS_ENABLED() TEST(SREG, SREG_I)
#define ENABLE_ISRS() sei()
@@ -60,20 +63,21 @@
// On AVR this is in math.h?
//#define square(x) ((x)*(x))
-// --------------------------------------------------------------------------
+// ------------------------
// Types
-// --------------------------------------------------------------------------
+// ------------------------
typedef uint16_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFF
typedef int8_t pin_t;
+#define SHARED_SERVOS HAS_SERVOS
#define HAL_SERVO_LIB Servo
-// --------------------------------------------------------------------------
+// ------------------------
// Public Variables
-// --------------------------------------------------------------------------
+// ------------------------
//extern uint8_t MCUSR;
@@ -87,38 +91,56 @@ typedef int8_t pin_t;
#define NUM_SERIAL 1
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
- #error "SERIAL_PORT must be from -1 to 3"
+ #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#define MYSERIAL0 customizedSerial1
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
- #error "SERIAL_PORT_2 must be from -1 to 3"
+ #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
- #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
+ #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif
- #define NUM_SERIAL 2
#define MYSERIAL1 customizedSerial2
+ #define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#endif
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
+#ifdef DGUS_SERIAL_PORT
+ #if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
+ #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #elif DGUS_SERIAL_PORT == SERIAL_PORT
+ #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
+ #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
+ #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
+ #endif
+ #define DGUS_SERIAL internalDgusSerial
-//void cli(void);
+ #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
+#endif
+
+// ------------------------
+// Public functions
+// ------------------------
+
+void HAL_init();
+
+//void cli();
//void _delay_ms(const int delay);
-inline void HAL_clear_reset_source(void) { MCUSR = 0; }
-inline uint8_t HAL_get_reset_source(void) { return MCUSR; }
+inline void HAL_clear_reset_source() { MCUSR = 0; }
+inline uint8_t HAL_get_reset_source() { return MCUSR; }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
extern "C" {
- int freeMemory(void);
+ int freeMemory();
}
+#pragma GCC diagnostic pop
// timers
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
@@ -145,8 +167,7 @@ extern "C" {
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B)
-FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
- UNUSED(frequency);
+FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
switch (timer_num) {
case STEP_TIMER_NUM:
// waveform generation = 0100 = CTC
@@ -198,9 +219,9 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t freque
/* 18 cycles maximum latency */
#define HAL_STEP_TIMER_ISR() \
-extern "C" void TIMER1_COMPA_vect (void) __attribute__ ((signal, naked, used, externally_visible)); \
-extern "C" void TIMER1_COMPA_vect_bottom (void) asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
-void TIMER1_COMPA_vect (void) { \
+extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \
+extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
+void TIMER1_COMPA_vect() { \
__asm__ __volatile__ ( \
A("push r16") /* 2 Save R16 */ \
A("in r16, __SREG__") /* 1 Get SREG */ \
@@ -267,13 +288,13 @@ void TIMER1_COMPA_vect (void) { \
: \
); \
} \
-void TIMER1_COMPA_vect_bottom(void)
+void TIMER1_COMPA_vect_bottom()
/* 14 cycles maximum latency */
#define HAL_TEMP_TIMER_ISR() \
-extern "C" void TIMER0_COMPB_vect (void) __attribute__ ((signal, naked, used, externally_visible)); \
-extern "C" void TIMER0_COMPB_vect_bottom(void) asm ("TIMER0_COMPB_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
-void TIMER0_COMPB_vect (void) { \
+extern "C" void TIMER0_COMPB_vect() __attribute__ ((signal, naked, used, externally_visible)); \
+extern "C" void TIMER0_COMPB_vect_bottom() asm ("TIMER0_COMPB_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
+void TIMER0_COMPB_vect() { \
__asm__ __volatile__ ( \
A("push r16") /* 2 Save R16 */ \
A("in r16, __SREG__") /* 1 Get SREG */ \
@@ -333,16 +354,16 @@ void TIMER0_COMPB_vect (void) { \
: \
); \
} \
-void TIMER0_COMPB_vect_bottom(void)
+void TIMER0_COMPB_vect_bottom()
// ADC
#ifdef DIDR2
- #define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0)
+ #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
#else
- #define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
+ #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
#endif
-inline void HAL_adc_init(void) {
+inline void HAL_adc_init() {
ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07;
DIDR0 = 0;
#ifdef DIDR2
@@ -350,13 +371,14 @@ inline void HAL_adc_init(void) {
#endif
}
-#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
+#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
#ifdef MUX5
- #define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
+ #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#else
- #define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
+ #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#endif
+#define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() ADC
#define HAL_ADC_READY() !TEST(ADCSRA, ADSC)
@@ -373,6 +395,8 @@ inline void HAL_adc_init(void) {
// AVR compatibility
#define strtof strtod
+#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
+
/**
* set_pwm_frequency
* Sets the frequency of the timer corresponding to the provided pin
diff --git a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp b/Marlin/src/HAL/AVR/HAL_SPI.cpp
similarity index 76%
rename from Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp
rename to Marlin/src/HAL/AVR/HAL_SPI.cpp
index a3fe161251..f1f9654c4e 100644
--- a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp
+++ b/Marlin/src/HAL/AVR/HAL_SPI.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,56 +21,41 @@
*/
/**
- * Originally from Arduino Sd2Card Library
- * Copyright (C) 2009 by William Greiman
+ * Adapted from Arduino Sd2Card Library
+ * Copyright (c) 2009 by William Greiman
*/
/**
- * Description: HAL for AVR - SPI functions
+ * HAL for AVR - SPI functions
*/
#ifdef __AVR__
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include "../../inc/MarlinConfig.h"
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-void spiBegin (void) {
- SET_OUTPUT(SS_PIN);
- WRITE(SS_PIN, HIGH);
+void spiBegin() {
+ OUT_WRITE(SS_PIN, HIGH);
SET_OUTPUT(SCK_PIN);
SET_INPUT(MISO_PIN);
SET_OUTPUT(MOSI_PIN);
#if DISABLED(SOFTWARE_SPI)
// SS must be in output mode even it is not chip select
- SET_OUTPUT(SS_PIN);
+ //SET_OUTPUT(SS_PIN);
// set SS high - may be chip select for another SPI device
- #if SET_SPI_SS_HIGH
- WRITE(SS_PIN, HIGH);
- #endif // SET_SPI_SS_HIGH
+ //#if SET_SPI_SS_HIGH
+ //WRITE(SS_PIN, HIGH);
+ //#endif
// set a default rate
spiInit(1);
- #endif // SOFTWARE_SPI
+ #endif
}
+#if NONE(SOFTWARE_SPI, FORCE_SOFT_SPI)
-#if DISABLED(SOFTWARE_SPI)
-
- //------------------------------------------------------------------------------
+ // ------------------------
// Hardware SPI
- //------------------------------------------------------------------------------
+ // ------------------------
// make sure SPCR rate is in expected bits
#if (SPR0 != 0 || SPR1 != 1)
@@ -96,7 +81,7 @@ void spiBegin (void) {
}
/** SPI receive a byte */
- uint8_t spiRec(void) {
+ uint8_t spiRec() {
SPDR = 0xFF;
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
return SPDR;
@@ -184,28 +169,27 @@ void spiBegin (void) {
// Invert the SPI2X bit
clockDiv ^= 0x1;
- SPCR = _BV(SPE) | _BV(MSTR) | ((bitOrder == SPI_LSBFIRST) ? _BV(DORD) : 0) |
+ SPCR = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) |
(dataMode << CPHA) | ((clockDiv >> 1) << SPR0);
SPSR = clockDiv | 0x01;
}
-#else
+#else // SOFTWARE_SPI || FORCE_SOFT_SPI
- /** nop to tune soft SPI timing */
+ // ------------------------
+ // Software SPI
+ // ------------------------
+
+ // nop to tune soft SPI timing
#define nop asm volatile ("\tnop\n")
- /** Set SPI rate */
- void spiInit(uint8_t spiRate) {
- UNUSED(spiRate); // nothing to do
- }
+ void spiInit(uint8_t) { /* do nothing */ }
- /** Begin SPI transaction, set clock, bit order, data mode */
- void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
- UNUSED(spiBeginTransaction); // nothing to do
- }
+ // Begin SPI transaction, set clock, bit order, data mode
+ void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ }
- /** Soft SPI receive byte */
+ // Soft SPI receive byte
uint8_t spiRec() {
uint8_t data = 0;
// no interrupts during byte receive - about 8µs
@@ -213,7 +197,7 @@ void spiBegin (void) {
// output pin high - like sending 0xFF
WRITE(MOSI_PIN, HIGH);
- for (uint8_t i = 0; i < 8; i++) {
+ LOOP_L_N(i, 8) {
WRITE(SCK_PIN, HIGH);
nop; // adjust so SCK is nice
@@ -230,17 +214,17 @@ void spiBegin (void) {
return data;
}
- /** Soft SPI read data */
+ // Soft SPI read data
void spiRead(uint8_t* buf, uint16_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++)
buf[i] = spiRec();
}
- /** Soft SPI send byte */
+ // Soft SPI send byte
void spiSend(uint8_t data) {
// no interrupts during byte send - about 8µs
cli();
- for (uint8_t i = 0; i < 8; i++) {
+ LOOP_L_N(i, 8) {
WRITE(SCK_PIN, LOW);
WRITE(MOSI_PIN, data & 0x80);
data <<= 1;
@@ -257,13 +241,13 @@ void spiBegin (void) {
sei();
}
- /** Soft SPI send block */
+ // Soft SPI send block
void spiSendBlock(uint8_t token, const uint8_t* buf) {
spiSend(token);
for (uint16_t i = 0; i < 512; i++)
spiSend(buf[i]);
}
-#endif // SOFTWARE_SPI
+#endif // SOFTWARE_SPI || FORCE_SOFT_SPI
#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp
similarity index 92%
rename from Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp
rename to Marlin/src/HAL/AVR/MarlinSerial.cpp
index ff1b6569ba..350d0f302d 100644
--- a/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp
+++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
#include "MarlinSerial.h"
- #include "../../Marlin.h"
+ #include "../../MarlinCore.h"
template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } };
template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 };
@@ -55,7 +55,7 @@
// A SW memory barrier, to ensure GCC does not overoptimize loops
#define sw_barrier() asm volatile("": : :"memory");
- #include "../../feature/emergency_parser.h"
+ #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
@@ -271,7 +271,7 @@
// (called with TX irqs disabled)
template
- FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq(void) {
+ FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq() {
if (Cfg::TX_SIZE > 0) {
// Read positions
uint8_t t = tx_buffer.tail;
@@ -363,13 +363,13 @@
}
template
- int MarlinSerial::peek(void) {
+ 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(void) {
+ 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
@@ -412,13 +412,13 @@
}
template
- typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available(void) {
+ 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(void) {
+ void MarlinSerial::flush() {
// Set the tail to the head:
// - Read the RX head index in a safe way. (See atomic_read_rx_head.)
@@ -505,7 +505,7 @@
}
template
- void MarlinSerial::flushTX(void) {
+ void MarlinSerial::flushTX() {
if (Cfg::TX_SIZE == 0) {
// No bytes written, no need to flush. This special case is needed since there's
@@ -595,7 +595,7 @@
}
template
- void MarlinSerial::println(void) {
+ void MarlinSerial::println() {
print('\r');
print('\n');
}
@@ -682,7 +682,7 @@
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
- for (uint8_t i = 0; i < digits; ++i) rounding *= 0.1;
+ LOOP_L_N(i, digits) rounding *= 0.1;
number += rounding;
// Extract the integer part of the number and print it
@@ -739,24 +739,51 @@
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
+#ifdef INTERNAL_SERIAL_PORT
-#if defined(INTERNAL_SERIAL_PORT)
+ ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) {
+ MarlinSerial>::store_rxd_char();
+ }
- 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();
+ }
- ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) {
- MarlinSerial>::_tx_udr_empty_irq();
- }
+ // Preinstantiate
+ template class MarlinSerial>;
- // Preinstantiate
- template class MarlinSerial>;
-
- // Instantiate
- MarlinSerial> internalSerial;
+ // Instantiate
+ MarlinSerial> internalSerial;
#endif
+
+#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
+
// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
diff --git a/Marlin/src/HAL/HAL_AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h
similarity index 86%
rename from Marlin/src/HAL/HAL_AVR/MarlinSerial.h
rename to Marlin/src/HAL/AVR/MarlinSerial.h
index bd0a6234f0..e39ebc4037 100644
--- a/Marlin/src/HAL/HAL_AVR/MarlinSerial.h
+++ b/Marlin/src/HAL/AVR/MarlinSerial.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,10 +31,10 @@
* Templatized 01 October 2018 by Eduardo José Tagle to allow multiple instances
*/
-#include "../shared/MarlinSerial.h"
-
#include
+#include "../../inc/MarlinConfigPre.h"
+
#ifndef SERIAL_PORT
#define SERIAL_PORT 0
#endif
@@ -205,18 +205,21 @@
public:
FORCE_INLINE static void store_rxd_char();
- FORCE_INLINE static void _tx_udr_empty_irq(void);
+ FORCE_INLINE static void _tx_udr_empty_irq();
public:
MarlinSerial() {};
static void begin(const long);
static void end();
- static int peek(void);
- static int read(void);
- static void flush(void);
- static ring_buffer_pos_t available(void);
+ static int peek();
+ static int read();
+ static void flush();
+ static ring_buffer_pos_t available();
static void write(const uint8_t c);
- static void flushTX(void);
+ static void flushTX();
+ #ifdef DGUS_SERIAL_PORT
+ static ring_buffer_pos_t get_tx_buffer_free();
+ #endif
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
@@ -245,7 +248,7 @@
static void println(long, int = DEC);
static void println(unsigned long, int = DEC);
static void println(double, int = 2);
- static void println(void);
+ static void println();
operator bool() { return true; }
private:
@@ -258,12 +261,12 @@
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
- static constexpr bool XONOFF = bSERIAL_XON_XOFF;
- static constexpr bool EMERGENCYPARSER = bEMERGENCY_PARSER;
- static constexpr bool DROPPED_RX = bSERIAL_STATS_DROPPED_RX;
- static constexpr bool RX_OVERRUNS = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
- static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
- static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
+ static constexpr bool XONOFF = ENABLED(SERIAL_XON_XOFF);
+ static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
+ static constexpr bool DROPPED_RX = ENABLED(SERIAL_STATS_DROPPED_RX);
+ static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
+ static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
+ static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};
extern MarlinSerial> customizedSerial1;
@@ -275,8 +278,7 @@
#endif // !USBCON
-
-#if defined(INTERNAL_SERIAL_PORT)
+#ifdef INTERNAL_SERIAL_PORT
template
struct MarlinInternalSerialCfg {
static constexpr int PORT = serial;
@@ -293,6 +295,23 @@
extern MarlinSerial> internalSerial;
#endif
+#ifdef DGUS_SERIAL_PORT
+ template
+ struct MarlinInternalSerialCfg {
+ static constexpr int PORT = serial;
+ static constexpr unsigned int RX_SIZE = 128;
+ static constexpr unsigned int TX_SIZE = 48;
+ static constexpr bool XONOFF = false;
+ static constexpr bool EMERGENCYPARSER = false;
+ static constexpr bool DROPPED_RX = false;
+ static constexpr bool RX_OVERRUNS = 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> internalDgusSerial;
+#endif
+
// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
diff --git a/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp b/Marlin/src/HAL/AVR/Servo.cpp
similarity index 94%
rename from Marlin/src/HAL/HAL_AVR/servo_AVR.cpp
rename to Marlin/src/HAL/AVR/Servo.cpp
index e3d2194bf7..1d4d2034b2 100644
--- a/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp
+++ b/Marlin/src/HAL/AVR/Servo.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -58,7 +58,6 @@
#if HAS_SERVOS
#include
-#include
#include "../shared/servo.h"
#include "../shared/servo_private.h"
@@ -95,29 +94,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
// Interrupt handlers for Arduino
- #if ENABLED(_useTimer1)
+ #ifdef _useTimer1
SIGNAL(TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
- #if ENABLED(_useTimer3)
+ #ifdef _useTimer3
SIGNAL(TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
- #if ENABLED(_useTimer4)
+ #ifdef _useTimer4
SIGNAL(TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
#endif
- #if ENABLED(_useTimer5)
+ #ifdef _useTimer5
SIGNAL(TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
#endif
#else // WIRING
// Interrupt handlers for Wiring
- #if ENABLED(_useTimer1)
+ #ifdef _useTimer1
void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
- #if ENABLED(_useTimer3)
+ #ifdef _useTimer3
void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
@@ -126,12 +125,12 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
/****************** end of static functions ******************************/
void initISR(timer16_Sequence_t timer) {
- #if ENABLED(_useTimer1)
+ #ifdef _useTimer1
if (timer == _timer1) {
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
TCNT1 = 0; // clear the timer count
- #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
+ #if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
SBI(TIFR, OCF1A); // clear any pending interrupts;
SBI(TIMSK, OCIE1A); // enable the output compare interrupt
#else
@@ -145,7 +144,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
- #if ENABLED(_useTimer3)
+ #ifdef _useTimer3
if (timer == _timer3) {
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
@@ -163,7 +162,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
- #if ENABLED(_useTimer4)
+ #ifdef _useTimer4
if (timer == _timer4) {
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
@@ -173,7 +172,7 @@ void initISR(timer16_Sequence_t timer) {
}
#endif
- #if ENABLED(_useTimer5)
+ #ifdef _useTimer5
if (timer == _timer5) {
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
diff --git a/Marlin/src/HAL/HAL_AVR/ServoTimers.h b/Marlin/src/HAL/AVR/ServoTimers.h
similarity index 88%
rename from Marlin/src/HAL/HAL_AVR/ServoTimers.h
rename to Marlin/src/HAL/AVR/ServoTimers.h
index b63b69c82e..86007fd102 100644
--- a/Marlin/src/HAL/HAL_AVR/ServoTimers.h
+++ b/Marlin/src/HAL/AVR/ServoTimers.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,8 +53,8 @@
* --------------------
*/
-#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
-#define PRESCALER 8 // timer prescaler
+#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
+#define SERVO_TIMER_PRESCALER 8 // timer prescaler
// Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
@@ -75,16 +75,16 @@
#endif
typedef enum {
- #if ENABLED(_useTimer1)
+ #ifdef _useTimer1
_timer1,
#endif
- #if ENABLED(_useTimer3)
+ #ifdef _useTimer3
_timer3,
#endif
- #if ENABLED(_useTimer4)
+ #ifdef _useTimer4
_timer4,
#endif
- #if ENABLED(_useTimer5)
+ #ifdef _useTimer5
_timer5,
#endif
_Nbr_16timers
diff --git a/Marlin/src/HAL/HAL_AVR/persistent_store_eeprom.cpp b/Marlin/src/HAL/AVR/eeprom.cpp
similarity index 80%
rename from Marlin/src/HAL/HAL_AVR/persistent_store_eeprom.cpp
rename to Marlin/src/HAL/AVR/eeprom.cpp
index 4c2f9ea4f1..0519e5732e 100644
--- a/Marlin/src/HAL/HAL_AVR/persistent_store_eeprom.cpp
+++ b/Marlin/src/HAL/AVR/eeprom.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,9 +25,15 @@
#if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE)
-#include "../shared/persistent_store_api.h"
+/**
+ * PersistentStore for Arduino-style EEPROM interface
+ * with implementations supplied by the framework.
+ */
-bool PersistentStore::access_start() { return true; }
+#include "../shared/eeprom_api.h"
+
+size_t PersistentStore::capacity() { return E2END + 1; }
+bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
@@ -39,7 +45,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
if (v != eeprom_read_byte(p)) {
eeprom_write_byte(p, v);
if (eeprom_read_byte(p) != v) {
- SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
+ SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
}
}
@@ -61,7 +67,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
return false; // always assume success for AVR's
}
-size_t PersistentStore::capacity() { return E2END + 1; }
-
#endif // EEPROM_SETTINGS || SD_FIRMWARE_UPDATE
#endif // __AVR__
diff --git a/Marlin/src/HAL/AVR/endstop_interrupts.h b/Marlin/src/HAL/AVR/endstop_interrupts.h
new file mode 100644
index 0000000000..8f89c69baf
--- /dev/null
+++ b/Marlin/src/HAL/AVR/endstop_interrupts.h
@@ -0,0 +1,261 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+/**
+ * Endstop Interrupts
+ *
+ * Without endstop interrupts the endstop pins must be polled continually in
+ * the temperature-ISR via endstops.update(), most of the time finding no change.
+ * With this feature endstops.update() is called only when we know that at
+ * least one endstop has changed state, saving valuable CPU cycles.
+ *
+ * This feature only works when all used endstop pins can generate either an
+ * 'external interrupt' or a 'pin change interrupt'.
+ *
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
+ */
+
+#include "../../module/endstops.h"
+
+#include
+
+// One ISR for all EXT-Interrupts
+void endstop_ISR() { endstops.update(); }
+
+/**
+ * Patch for pins_arduino.h (...\Arduino\hardware\arduino\avr\variants\mega\pins_arduino.h)
+ *
+ * These macros for the Arduino MEGA do not include the two connected pins on Port J (D14, D15).
+ * So we extend them here because these are the normal pins for Y_MIN and Y_MAX on RAMPS.
+ * There are more PCI-enabled processor pins on Port J, but they are not connected to Arduino MEGA.
+ */
+#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA)
+
+ #define digitalPinHasPCICR(p) (WITHIN(p, 10, 15) || WITHIN(p, 50, 53) || WITHIN(p, 62, 69))
+
+ #undef digitalPinToPCICR
+ #define digitalPinToPCICR(p) (digitalPinHasPCICR(p) ? (&PCICR) : nullptr)
+
+ #undef digitalPinToPCICRbit
+ #define digitalPinToPCICRbit(p) (WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? 0 : \
+ WITHIN(p, 14, 15) ? 1 : \
+ WITHIN(p, 62, 69) ? 2 : \
+ 0)
+
+ #undef digitalPinToPCMSK
+ #define digitalPinToPCMSK(p) (WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? (&PCMSK0) : \
+ WITHIN(p, 14, 15) ? (&PCMSK1) : \
+ WITHIN(p, 62, 69) ? (&PCMSK2) : \
+ nullptr)
+
+ #undef digitalPinToPCMSKbit
+ #define digitalPinToPCMSKbit(p) (WITHIN(p, 10, 13) ? ((p) - 6) : \
+ (p) == 14 || (p) == 51 ? 2 : \
+ (p) == 15 || (p) == 52 ? 1 : \
+ (p) == 50 ? 3 : \
+ (p) == 53 ? 0 : \
+ WITHIN(p, 62, 69) ? ((p) - 62) : \
+ 0)
+
+#elif defined(__AVR_ATmega164A__) || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324A__) || \
+ defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega324PB__) || \
+ defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || \
+ defined(__AVR_ATmega1284P__)
+
+ #define digitalPinHasPCICR(p) WITHIN(p, 0, NUM_DIGITAL_PINS)
+
+#else
+
+ #error "Unsupported AVR variant!"
+
+#endif
+
+
+// Install Pin change interrupt for a pin. Can be called multiple times.
+void pciSetup(const int8_t pin) {
+ if (digitalPinHasPCICR(pin)) {
+ SBI(*digitalPinToPCMSK(pin), digitalPinToPCMSKbit(pin)); // enable pin
+ SBI(PCIFR, digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
+ SBI(PCICR, digitalPinToPCICRbit(pin)); // enable interrupt for the group
+ }
+}
+
+// Handlers for pin change interrupts
+#ifdef PCINT0_vect
+ ISR(PCINT0_vect) { endstop_ISR(); }
+#endif
+
+#ifdef PCINT1_vect
+ ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
+#endif
+
+#ifdef PCINT2_vect
+ ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
+#endif
+
+#ifdef PCINT3_vect
+ ISR(PCINT3_vect, ISR_ALIASOF(PCINT0_vect));
+#endif
+
+void setup_endstop_interrupts() {
+ #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
+ #if HAS_X_MAX
+ #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(X_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(X_MAX_PIN), "X_MAX_PIN is not interrupt-capable");
+ pciSetup(X_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_X_MIN
+ #if (digitalPinToInterrupt(X_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(X_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(X_MIN_PIN), "X_MIN_PIN is not interrupt-capable");
+ pciSetup(X_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Y_MAX
+ #if (digitalPinToInterrupt(Y_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Y_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Y_MAX_PIN), "Y_MAX_PIN is not interrupt-capable");
+ pciSetup(Y_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Y_MIN
+ #if (digitalPinToInterrupt(Y_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Y_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Y_MIN_PIN), "Y_MIN_PIN is not interrupt-capable");
+ pciSetup(Y_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Z_MAX
+ #if (digitalPinToInterrupt(Z_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z_MAX_PIN), "Z_MAX_PIN is not interrupt-capable");
+ pciSetup(Z_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Z_MIN
+ #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z_MIN_PIN), "Z_MIN_PIN is not interrupt-capable");
+ pciSetup(Z_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_X2_MAX
+ #if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(X2_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(X2_MAX_PIN), "X2_MAX_PIN is not interrupt-capable");
+ pciSetup(X2_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_X2_MIN
+ #if (digitalPinToInterrupt(X2_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(X2_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(X2_MIN_PIN), "X2_MIN_PIN is not interrupt-capable");
+ pciSetup(X2_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Y2_MAX
+ #if (digitalPinToInterrupt(Y2_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Y2_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Y2_MAX_PIN), "Y2_MAX_PIN is not interrupt-capable");
+ pciSetup(Y2_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Y2_MIN
+ #if (digitalPinToInterrupt(Y2_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Y2_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Y2_MIN_PIN), "Y2_MIN_PIN is not interrupt-capable");
+ pciSetup(Y2_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Z2_MAX
+ #if (digitalPinToInterrupt(Z2_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z2_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z2_MAX_PIN), "Z2_MAX_PIN is not interrupt-capable");
+ pciSetup(Z2_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Z2_MIN
+ #if (digitalPinToInterrupt(Z2_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z2_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z2_MIN_PIN), "Z2_MIN_PIN is not interrupt-capable");
+ pciSetup(Z2_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Z3_MAX
+ #if (digitalPinToInterrupt(Z3_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z3_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z3_MAX_PIN), "Z3_MAX_PIN is not interrupt-capable");
+ pciSetup(Z3_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Z3_MIN
+ #if (digitalPinToInterrupt(Z3_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z3_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z3_MIN_PIN), "Z3_MIN_PIN is not interrupt-capable");
+ pciSetup(Z3_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Z4_MAX
+ #if (digitalPinToInterrupt(Z4_MAX_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z4_MAX_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z4_MAX_PIN), "Z4_MAX_PIN is not interrupt-capable");
+ pciSetup(Z4_MAX_PIN);
+ #endif
+ #endif
+ #if HAS_Z4_MIN
+ #if (digitalPinToInterrupt(Z4_MIN_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z4_MIN_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z4_MIN_PIN), "Z4_MIN_PIN is not interrupt-capable");
+ pciSetup(Z4_MIN_PIN);
+ #endif
+ #endif
+ #if HAS_Z_MIN_PROBE_PIN
+ #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
+ _ATTACH(Z_MIN_PROBE_PIN);
+ #else
+ static_assert(digitalPinHasPCICR(Z_MIN_PROBE_PIN), "Z_MIN_PROBE_PIN is not interrupt-capable");
+ pciSetup(Z_MIN_PROBE_PIN);
+ #endif
+ #endif
+
+ // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
+}
diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp
new file mode 100644
index 0000000000..e855057486
--- /dev/null
+++ b/Marlin/src/HAL/AVR/fast_pwm.cpp
@@ -0,0 +1,282 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef __AVR__
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
+
+#include "HAL.h"
+
+struct Timer {
+ volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
+ volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
+ volatile uint16_t* ICRn; // max 1 ICR register per timer
+ uint8_t n; // the timer number [0->5]
+ uint8_t q; // the timer output [0->2] (A->C)
+};
+
+/**
+ * get_pwm_timer
+ * Get the timer information and register of the provided pin.
+ * Return a Timer struct containing this information.
+ * Used by set_pwm_frequency, set_pwm_duty
+ */
+Timer get_pwm_timer(const pin_t pin) {
+ uint8_t q = 0;
+ switch (digitalPinToTimer(pin)) {
+ // Protect reserved timers (TIMER0 & TIMER1)
+ #ifdef TCCR0A
+ #if !AVR_AT90USB1286_FAMILY
+ case TIMER0A:
+ #endif
+ case TIMER0B:
+ #endif
+ #ifdef TCCR1A
+ case TIMER1A: case TIMER1B:
+ #endif
+ break;
+ #if defined(TCCR2) || defined(TCCR2A)
+ #ifdef TCCR2
+ case TIMER2: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR2, nullptr, nullptr },
+ /*OCRnQ*/ { (uint16_t*)&OCR2, nullptr, nullptr },
+ /*ICRn*/ nullptr,
+ /*n, q*/ 2, 0
+ };
+ }
+ #elif defined(TCCR2A)
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ case TIMER2A: break; // protect TIMER2A
+ case TIMER2B: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr },
+ /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr },
+ /*ICRn*/ nullptr,
+ /*n, q*/ 2, 1
+ };
+ return timer;
+ }
+ #else
+ case TIMER2B: ++q;
+ case TIMER2A: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr },
+ /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr },
+ /*ICRn*/ nullptr,
+ 2, q
+ };
+ return timer;
+ }
+ #endif
+ #endif
+ #endif
+ #ifdef OCR3C
+ case TIMER3C: ++q;
+ case TIMER3B: ++q;
+ case TIMER3A: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C },
+ /*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C },
+ /*ICRn*/ &ICR3,
+ /*n, q*/ 3, q
+ };
+ return timer;
+ }
+ #elif defined(OCR3B)
+ case TIMER3B: ++q;
+ case TIMER3A: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR3A, &TCCR3B, nullptr },
+ /*OCRnQ*/ { &OCR3A, &OCR3B, nullptr },
+ /*ICRn*/ &ICR3,
+ /*n, q*/ 3, q
+ };
+ return timer;
+ }
+ #endif
+ #ifdef TCCR4A
+ case TIMER4C: ++q;
+ case TIMER4B: ++q;
+ case TIMER4A: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C },
+ /*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C },
+ /*ICRn*/ &ICR4,
+ /*n, q*/ 4, q
+ };
+ return timer;
+ }
+ #endif
+ #ifdef TCCR5A
+ case TIMER5C: ++q;
+ case TIMER5B: ++q;
+ case TIMER5A: {
+ Timer timer = {
+ /*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C },
+ /*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C },
+ /*ICRn*/ &ICR5,
+ /*n, q*/ 5, q
+ };
+ return timer;
+ }
+ #endif
+ }
+ Timer timer = {
+ /*TCCRnQ*/ { nullptr, nullptr, nullptr },
+ /*OCRnQ*/ { nullptr, nullptr, nullptr },
+ /*ICRn*/ nullptr,
+ 0, 0
+ };
+ return timer;
+}
+
+void set_pwm_frequency(const pin_t pin, int f_desired) {
+ Timer timer = get_pwm_timer(pin);
+ if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
+ uint16_t size;
+ if (timer.n == 2) size = 255; else size = 65535;
+
+ uint16_t res = 255; // resolution (TOP value)
+ uint8_t j = 0; // prescaler index
+ uint8_t wgm = 1; // waveform generation mode
+
+ // Calculating the prescaler and resolution to use to achieve closest frequency
+ if (f_desired != 0) {
+ int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable
+ uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
+
+ // loop over prescaler values
+ LOOP_S_L_N(i, 1, 8) {
+ uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
+ if (timer.n == 2) {
+ // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
+ res_temp_fast = rtf - 1;
+ res_temp_phase_correct = rtf / 2;
+ #endif
+ }
+ else {
+ // Skip TIMER2 specific prescalers when not TIMER2
+ if (i == 3 || i == 5) continue;
+ const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
+ res_temp_fast = rtf - 1;
+ res_temp_phase_correct = rtf / 2;
+ }
+
+ LIMIT(res_temp_fast, 1u, size);
+ LIMIT(res_temp_phase_correct, 1u, size);
+ // Calculate frequencies of test prescaler and resolution values
+ const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)),
+ f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),
+ f_diff = ABS(f - f_desired),
+ f_fast_diff = ABS(f_temp_fast - f_desired),
+ f_phase_diff = ABS(f_temp_phase_correct - f_desired);
+
+ // If FAST values are closest to desired f
+ if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) {
+ // Remember this combination
+ f = f_temp_fast;
+ res = res_temp_fast;
+ j = i;
+ // Set the Wave Generation Mode to FAST PWM
+ if (timer.n == 2) {
+ wgm = (
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ WGM2_FAST_PWM_OCR2A
+ #else
+ WGM2_FAST_PWM
+ #endif
+ );
+ }
+ else wgm = WGM_FAST_PWM_ICRn;
+ }
+ // If PHASE CORRECT values are closes to desired f
+ else if (f_phase_diff < f_diff) {
+ f = f_temp_phase_correct;
+ res = res_temp_phase_correct;
+ j = i;
+ // Set the Wave Generation Mode to PWM PHASE CORRECT
+ if (timer.n == 2) {
+ wgm = (
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ WGM2_PWM_PC_OCR2A
+ #else
+ WGM2_PWM_PC
+ #endif
+ );
+ }
+ else wgm = WGM_PWM_PC_ICRn;
+ }
+ }
+ }
+ _SET_WGMnQ(timer.TCCRnQ, wgm);
+ _SET_CSn(timer.TCCRnQ, j);
+
+ if (timer.n == 2) {
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ _SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
+ #endif
+ }
+ else
+ _SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
+}
+
+void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
+ // If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
+ // Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
+ if (v == 0)
+ digitalWrite(pin, invert);
+ else if (v == v_size)
+ digitalWrite(pin, !invert);
+ else {
+ Timer timer = get_pwm_timer(pin);
+ if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
+ // Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
+ _SET_COMnQ(timer.TCCRnQ, (timer.q
+ #ifdef TCCR2
+ + (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
+ #endif
+ ), COM_CLEAR_SET + invert
+ );
+
+ uint16_t top;
+ if (timer.n == 2) { // if TIMER2
+ top = (
+ #if ENABLED(USE_OCR2A_AS_TOP)
+ *timer.OCRnQ[0] // top = OCR2A
+ #else
+ 255 // top = 0xFF (max)
+ #endif
+ );
+ }
+ else
+ top = *timer.ICRn; // top = ICRn
+
+ _SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top / v_size)); // Scale 8/16-bit v to top value
+ }
+}
+
+#endif // NEEDS_HARDWARE_PWM
+#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_AVR.cpp b/Marlin/src/HAL/AVR/fastio.cpp
similarity index 96%
rename from Marlin/src/HAL/HAL_AVR/fastio_AVR.cpp
rename to Marlin/src/HAL/AVR/fastio.cpp
index 63fbe4d969..9f70b50f71 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_AVR.cpp
+++ b/Marlin/src/HAL/AVR/fastio.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,11 +26,11 @@
#ifdef __AVR__
-#include "fastio_AVR.h"
+#include "fastio.h"
#ifdef FASTIO_EXT_START
-#include
+#include "../shared/Marduino.h"
#define _IS_EXT(P) WITHIN(P, FASTIO_EXT_START, FASTIO_EXT_END)
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_AVR.h b/Marlin/src/HAL/AVR/fastio.h
similarity index 85%
rename from Marlin/src/HAL/HAL_AVR/fastio_AVR.h
rename to Marlin/src/HAL/AVR/fastio.h
index a843f1ae75..a45e0f2beb 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_AVR.h
+++ b/Marlin/src/HAL/AVR/fastio.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@
*/
#include
-#include "../../core/macros.h"
#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__))
@@ -40,15 +39,15 @@
* Include Ports and Functions
*/
#if AVR_ATmega328_FAMILY
- #include "fastio_168.h"
+ #include "fastio/fastio_168.h"
#elif AVR_ATmega1284_FAMILY
- #include "fastio_644.h"
+ #include "fastio/fastio_644.h"
#elif AVR_ATmega2560_FAMILY
- #include "fastio_1280.h"
+ #include "fastio/fastio_1280.h"
#elif AVR_AT90USB1286_FAMILY
- #include "fastio_AT90USB.h"
+ #include "fastio/fastio_AT90USB.h"
#elif AVR_ATmega2561_FAMILY
- #include "fastio_1281.h"
+ #include "fastio/fastio_1281.h"
#else
#error "No FastIO definition for the selected AVR Board."
#endif
@@ -81,9 +80,8 @@
#define _SET_INPUT(IO) CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _SET_OUTPUT(IO) SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
-#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
+#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
#define _IS_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
-#define _HAS_TIMER(IO) DIO ## IO ## _PWM
// digitalRead/Write wrappers
#ifdef FASTIO_EXT_START
@@ -100,13 +98,12 @@
#define SET_INPUT(IO) _SET_INPUT(IO)
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _WRITE(IO, HIGH); }while(0)
+#define SET_INPUT_PULLDOWN SET_INPUT
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
-
-#define SET_PWM(IO) SET_OUTPUT(IO)
+#define SET_PWM SET_OUTPUT
#define IS_INPUT(IO) _IS_INPUT(IO)
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
-#define HAS_TIMER(IO) _HAS_TIMER(IO)
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
@@ -275,24 +272,37 @@ enum ClockSource2 : char {
#define SET_FOCB(T,V) SET_FOC(T,B,V)
#define SET_FOCC(T,V) SET_FOC(T,C,V)
+#if 0
+
/**
* PWM availability macros
*/
// Determine which harware PWMs are already in use
+#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#if PIN_EXISTS(CONTROLLER_FAN)
- #define PWM_CHK_FAN_B(P) (P == CONTROLLER_FAN_PIN || P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
+ #define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
#else
- #define PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
+ #define PWM_CHK_FAN_B(P) _PWM_CHK_FAN_B(P)
#endif
-#if ANY_PIN(FAN, FAN1, FAN2)
- #if PIN_EXISTS(FAN2)
- #define PWM_CHK_FAN_A(P) (P == FAN_PIN || P == FAN1_PIN || P == FAN2_PIN)
+#if ANY_PIN(FAN, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7)
+ #if PIN_EXISTS(FAN7)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN || P == FAN7_PIN)
+ #elif PIN_EXISTS(FAN6)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN)
+ #elif PIN_EXISTS(FAN5)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN)
+ #elif PIN_EXISTS(FAN4)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN)
+ #elif PIN_EXISTS(FAN3)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN)
+ #elif PIN_EXISTS(FAN2)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN)
#elif PIN_EXISTS(FAN1)
- #define PWM_CHK_FAN_A(P) (P == FAN_PIN || P == FAN1_PIN)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN)
#else
- #define PWM_CHK_FAN_A(P) (P == FAN_PIN)
+ #define PWM_CHK_FAN_A(P) (P == FAN0_PIN)
#endif
#else
#define PWM_CHK_FAN_A(P) false
@@ -338,6 +348,8 @@ enum ClockSource2 : char {
#define PWM_CHK(P) (PWM_CHK_HEATER(P) || PWM_CHK_SERVO(P) || PWM_CHK_MOTOR_CURRENT(P) || PWM_CHK_FAN_A(P) || PWM_CHK_FAN_B(P))
+#endif // PWM_CHK is not used in Marlin
+
// define which hardware PWMs are available for the current CPU
// all timer 1 PWMS deleted from this list because they are never available
#if AVR_ATmega2560_FAMILY
@@ -353,5 +365,3 @@ enum ClockSource2 : char {
#else
#error "unknown CPU"
#endif
-
-#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(P))
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_1280.h b/Marlin/src/HAL/AVR/fastio/fastio_1280.h
similarity index 83%
rename from Marlin/src/HAL/HAL_AVR/fastio_1280.h
rename to Marlin/src/HAL/AVR/fastio/fastio_1280.h
index 1e3c44a4f5..b62156caa7 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_1280.h
+++ b/Marlin/src/HAL/AVR/fastio/fastio_1280.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,10 +26,10 @@
*
* Hardware Pin : 02 03 06 07 01 05 15 16 17 18 23 24 25 26 64 63 13 12 46 45 44 43 78 77 76 75 74 73 72 71 60 59 58 57 56 55 54 53 50 70 52 51 42 41 40 39 38 37 36 35 22 21 20 19 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 | 04 08 09 10 11 14 27 28 29 30 31 32 33 34 47 48 49 61 62 65 66 67 68 69 79 80 81 98 99 100
* Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 | E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx
- * Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 78 79 80 xx xx 84 85 71 70 xx xx xx xx xx 81 82 83 xx xx 72 72 75 76 77 74 xx xx xx xx xx
+ * Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 78 79 80 xx xx 84 85 71 70 xx xx xx xx xx 81 82 83 xx xx 72 73 75 76 77 74 xx xx xx xx xx
*/
-#include "fastio_AVR.h"
+#include "../fastio.h"
// change for your board
#define DEBUG_LED DIO21
@@ -71,13 +71,13 @@
#define DIO0_RPORT PINE
#define DIO0_WPORT PORTE
#define DIO0_DDR DDRE
-#define DIO0_PWM NULL
+#define DIO0_PWM nullptr
#define DIO1_PIN PINE1
#define DIO1_RPORT PINE
#define DIO1_WPORT PORTE
#define DIO1_DDR DDRE
-#define DIO1_PWM NULL
+#define DIO1_PWM nullptr
#define DIO2_PIN PINE4
#define DIO2_RPORT PINE
@@ -137,13 +137,13 @@
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
-#define DIO11_PWM NULL
+#define DIO11_PWM nullptr
#define DIO12_PIN PINB6
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
-#define DIO12_PWM NULL
+#define DIO12_PWM nullptr
#define DIO13_PIN PINB7
#define DIO13_RPORT PINB
@@ -155,181 +155,181 @@
#define DIO14_RPORT PINJ
#define DIO14_WPORT PORTJ
#define DIO14_DDR DDRJ
-#define DIO14_PWM NULL
+#define DIO14_PWM nullptr
#define DIO15_PIN PINJ0
#define DIO15_RPORT PINJ
#define DIO15_WPORT PORTJ
#define DIO15_DDR DDRJ
-#define DIO15_PWM NULL
+#define DIO15_PWM nullptr
#define DIO16_PIN PINH1
#define DIO16_RPORT PINH
#define DIO16_WPORT PORTH
#define DIO16_DDR DDRH
-#define DIO16_PWM NULL
+#define DIO16_PWM nullptr
#define DIO17_PIN PINH0
#define DIO17_RPORT PINH
#define DIO17_WPORT PORTH
#define DIO17_DDR DDRH
-#define DIO17_PWM NULL
+#define DIO17_PWM nullptr
#define DIO18_PIN PIND3
#define DIO18_RPORT PIND
#define DIO18_WPORT PORTD
#define DIO18_DDR DDRD
-#define DIO18_PWM NULL
+#define DIO18_PWM nullptr
#define DIO19_PIN PIND2
#define DIO19_RPORT PIND
#define DIO19_WPORT PORTD
#define DIO19_DDR DDRD
-#define DIO19_PWM NULL
+#define DIO19_PWM nullptr
#define DIO20_PIN PIND1
#define DIO20_RPORT PIND
#define DIO20_WPORT PORTD
#define DIO20_DDR DDRD
-#define DIO20_PWM NULL
+#define DIO20_PWM nullptr
#define DIO21_PIN PIND0
#define DIO21_RPORT PIND
#define DIO21_WPORT PORTD
#define DIO21_DDR DDRD
-#define DIO21_PWM NULL
+#define DIO21_PWM nullptr
#define DIO22_PIN PINA0
#define DIO22_RPORT PINA
#define DIO22_WPORT PORTA
#define DIO22_DDR DDRA
-#define DIO22_PWM NULL
+#define DIO22_PWM nullptr
#define DIO23_PIN PINA1
#define DIO23_RPORT PINA
#define DIO23_WPORT PORTA
#define DIO23_DDR DDRA
-#define DIO23_PWM NULL
+#define DIO23_PWM nullptr
#define DIO24_PIN PINA2
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
-#define DIO24_PWM NULL
+#define DIO24_PWM nullptr
#define DIO25_PIN PINA3
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
-#define DIO25_PWM NULL
+#define DIO25_PWM nullptr
#define DIO26_PIN PINA4
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
-#define DIO26_PWM NULL
+#define DIO26_PWM nullptr
#define DIO27_PIN PINA5
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
-#define DIO27_PWM NULL
+#define DIO27_PWM nullptr
#define DIO28_PIN PINA6
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
-#define DIO28_PWM NULL
+#define DIO28_PWM nullptr
#define DIO29_PIN PINA7
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
-#define DIO29_PWM NULL
+#define DIO29_PWM nullptr
#define DIO30_PIN PINC7
#define DIO30_RPORT PINC
#define DIO30_WPORT PORTC
#define DIO30_DDR DDRC
-#define DIO30_PWM NULL
+#define DIO30_PWM nullptr
#define DIO31_PIN PINC6
#define DIO31_RPORT PINC
#define DIO31_WPORT PORTC
#define DIO31_DDR DDRC
-#define DIO31_PWM NULL
+#define DIO31_PWM nullptr
#define DIO32_PIN PINC5
#define DIO32_RPORT PINC
#define DIO32_WPORT PORTC
#define DIO32_DDR DDRC
-#define DIO32_PWM NULL
+#define DIO32_PWM nullptr
#define DIO33_PIN PINC4
#define DIO33_RPORT PINC
#define DIO33_WPORT PORTC
#define DIO33_DDR DDRC
-#define DIO33_PWM NULL
+#define DIO33_PWM nullptr
#define DIO34_PIN PINC3
#define DIO34_RPORT PINC
#define DIO34_WPORT PORTC
#define DIO34_DDR DDRC
-#define DIO34_PWM NULL
+#define DIO34_PWM nullptr
#define DIO35_PIN PINC2
#define DIO35_RPORT PINC
#define DIO35_WPORT PORTC
#define DIO35_DDR DDRC
-#define DIO35_PWM NULL
+#define DIO35_PWM nullptr
#define DIO36_PIN PINC1
#define DIO36_RPORT PINC
#define DIO36_WPORT PORTC
#define DIO36_DDR DDRC
-#define DIO36_PWM NULL
+#define DIO36_PWM nullptr
#define DIO37_PIN PINC0
#define DIO37_RPORT PINC
#define DIO37_WPORT PORTC
#define DIO37_DDR DDRC
-#define DIO37_PWM NULL
+#define DIO37_PWM nullptr
#define DIO38_PIN PIND7
#define DIO38_RPORT PIND
#define DIO38_WPORT PORTD
#define DIO38_DDR DDRD
-#define DIO38_PWM NULL
+#define DIO38_PWM nullptr
#define DIO39_PIN PING2
#define DIO39_RPORT PING
#define DIO39_WPORT PORTG
#define DIO39_DDR DDRG
-#define DIO39_PWM NULL
+#define DIO39_PWM nullptr
#define DIO40_PIN PING1
#define DIO40_RPORT PING
#define DIO40_WPORT PORTG
#define DIO40_DDR DDRG
-#define DIO40_PWM NULL
+#define DIO40_PWM nullptr
#define DIO41_PIN PING0
#define DIO41_RPORT PING
#define DIO41_WPORT PORTG
#define DIO41_DDR DDRG
-#define DIO41_PWM NULL
+#define DIO41_PWM nullptr
#define DIO42_PIN PINL7
#define DIO42_RPORT PINL
#define DIO42_WPORT PORTL
#define DIO42_DDR DDRL
-#define DIO42_PWM NULL
+#define DIO42_PWM nullptr
#define DIO43_PIN PINL6
#define DIO43_RPORT PINL
#define DIO43_WPORT PORTL
#define DIO43_DDR DDRL
-#define DIO43_PWM NULL
+#define DIO43_PWM nullptr
#define DIO44_PIN PINL5
#define DIO44_RPORT PINL
@@ -353,139 +353,139 @@
#define DIO47_RPORT PINL
#define DIO47_WPORT PORTL
#define DIO47_DDR DDRL
-#define DIO47_PWM NULL
+#define DIO47_PWM nullptr
#define DIO48_PIN PINL1
#define DIO48_RPORT PINL
#define DIO48_WPORT PORTL
#define DIO48_DDR DDRL
-#define DIO48_PWM NULL
+#define DIO48_PWM nullptr
#define DIO49_PIN PINL0
#define DIO49_RPORT PINL
#define DIO49_WPORT PORTL
#define DIO49_DDR DDRL
-#define DIO49_PWM NULL
+#define DIO49_PWM nullptr
#define DIO50_PIN PINB3
#define DIO50_RPORT PINB
#define DIO50_WPORT PORTB
#define DIO50_DDR DDRB
-#define DIO50_PWM NULL
+#define DIO50_PWM nullptr
#define DIO51_PIN PINB2
#define DIO51_RPORT PINB
#define DIO51_WPORT PORTB
#define DIO51_DDR DDRB
-#define DIO51_PWM NULL
+#define DIO51_PWM nullptr
#define DIO52_PIN PINB1
#define DIO52_RPORT PINB
#define DIO52_WPORT PORTB
#define DIO52_DDR DDRB
-#define DIO52_PWM NULL
+#define DIO52_PWM nullptr
#define DIO53_PIN PINB0
#define DIO53_RPORT PINB
#define DIO53_WPORT PORTB
#define DIO53_DDR DDRB
-#define DIO53_PWM NULL
+#define DIO53_PWM nullptr
#define DIO54_PIN PINF0
#define DIO54_RPORT PINF
#define DIO54_WPORT PORTF
#define DIO54_DDR DDRF
-#define DIO54_PWM NULL
+#define DIO54_PWM nullptr
#define DIO55_PIN PINF1
#define DIO55_RPORT PINF
#define DIO55_WPORT PORTF
#define DIO55_DDR DDRF
-#define DIO55_PWM NULL
+#define DIO55_PWM nullptr
#define DIO56_PIN PINF2
#define DIO56_RPORT PINF
#define DIO56_WPORT PORTF
#define DIO56_DDR DDRF
-#define DIO56_PWM NULL
+#define DIO56_PWM nullptr
#define DIO57_PIN PINF3
#define DIO57_RPORT PINF
#define DIO57_WPORT PORTF
#define DIO57_DDR DDRF
-#define DIO57_PWM NULL
+#define DIO57_PWM nullptr
#define DIO58_PIN PINF4
#define DIO58_RPORT PINF
#define DIO58_WPORT PORTF
#define DIO58_DDR DDRF
-#define DIO58_PWM NULL
+#define DIO58_PWM nullptr
#define DIO59_PIN PINF5
#define DIO59_RPORT PINF
#define DIO59_WPORT PORTF
#define DIO59_DDR DDRF
-#define DIO59_PWM NULL
+#define DIO59_PWM nullptr
#define DIO60_PIN PINF6
#define DIO60_RPORT PINF
#define DIO60_WPORT PORTF
#define DIO60_DDR DDRF
-#define DIO60_PWM NULL
+#define DIO60_PWM nullptr
#define DIO61_PIN PINF7
#define DIO61_RPORT PINF
#define DIO61_WPORT PORTF
#define DIO61_DDR DDRF
-#define DIO61_PWM NULL
+#define DIO61_PWM nullptr
#define DIO62_PIN PINK0
#define DIO62_RPORT PINK
#define DIO62_WPORT PORTK
#define DIO62_DDR DDRK
-#define DIO62_PWM NULL
+#define DIO62_PWM nullptr
#define DIO63_PIN PINK1
#define DIO63_RPORT PINK
#define DIO63_WPORT PORTK
#define DIO63_DDR DDRK
-#define DIO63_PWM NULL
+#define DIO63_PWM nullptr
#define DIO64_PIN PINK2
#define DIO64_RPORT PINK
#define DIO64_WPORT PORTK
#define DIO64_DDR DDRK
-#define DIO64_PWM NULL
+#define DIO64_PWM nullptr
#define DIO65_PIN PINK3
#define DIO65_RPORT PINK
#define DIO65_WPORT PORTK
#define DIO65_DDR DDRK
-#define DIO65_PWM NULL
+#define DIO65_PWM nullptr
#define DIO66_PIN PINK4
#define DIO66_RPORT PINK
#define DIO66_WPORT PORTK
#define DIO66_DDR DDRK
-#define DIO66_PWM NULL
+#define DIO66_PWM nullptr
#define DIO67_PIN PINK5
#define DIO67_RPORT PINK
#define DIO67_WPORT PORTK
#define DIO67_DDR DDRK
-#define DIO67_PWM NULL
+#define DIO67_PWM nullptr
#define DIO68_PIN PINK6
#define DIO68_RPORT PINK
#define DIO68_WPORT PORTK
#define DIO68_DDR DDRK
-#define DIO68_PWM NULL
+#define DIO68_PWM nullptr
#define DIO69_PIN PINK7
#define DIO69_RPORT PINK
#define DIO69_WPORT PORTK
#define DIO69_DDR DDRK
-#define DIO69_PWM NULL
+#define DIO69_PWM nullptr
//#define FASTIO_EXT_START 70
//#define FASTIO_EXT_END 85
@@ -494,171 +494,171 @@
#define DIO70_RPORT PING
#define DIO70_WPORT PORTG
#define DIO70_DDR DDRG
-#define DIO70_PWM NULL
+#define DIO70_PWM nullptr
#define DIO71_PIN PING3
#define DIO71_RPORT PING
#define DIO71_WPORT PORTG
#define DIO71_DDR DDRG
-#define DIO71_PWM NULL
+#define DIO71_PWM nullptr
#define DIO72_PIN PINJ2
#define DIO72_RPORT PINJ
#define DIO72_WPORT PORTJ
#define DIO72_DDR DDRJ
-#define DIO72_PWM NULL
+#define DIO72_PWM nullptr
#define DIO73_PIN PINJ3
#define DIO73_RPORT PINJ
#define DIO73_WPORT PORTJ
#define DIO73_DDR DDRJ
-#define DIO73_PWM NULL
+#define DIO73_PWM nullptr
#define DIO74_PIN PINJ7
#define DIO74_RPORT PINJ
#define DIO74_WPORT PORTJ
#define DIO74_DDR DDRJ
-#define DIO74_PWM NULL
+#define DIO74_PWM nullptr
#define DIO75_PIN PINJ4
#define DIO75_RPORT PINJ
#define DIO75_WPORT PORTJ
#define DIO75_DDR DDRJ
-#define DIO75_PWM NULL
+#define DIO75_PWM nullptr
#define DIO76_PIN PINJ5
#define DIO76_RPORT PINJ
#define DIO76_WPORT PORTJ
#define DIO76_DDR DDRJ
-#define DIO76_PWM NULL
+#define DIO76_PWM nullptr
#define DIO77_PIN PINJ6
#define DIO77_RPORT PINJ
#define DIO77_WPORT PORTJ
#define DIO77_DDR DDRJ
-#define DIO77_PWM NULL
+#define DIO77_PWM nullptr
#define DIO78_PIN PINE2
#define DIO78_RPORT PINE
#define DIO78_WPORT PORTE
#define DIO78_DDR DDRE
-#define DIO78_PWM NULL
+#define DIO78_PWM nullptr
#define DIO79_PIN PINE6
#define DIO79_RPORT PINE
#define DIO79_WPORT PORTE
#define DIO79_DDR DDRE
-#define DIO79_PWM NULL
+#define DIO79_PWM nullptr
#define DIO80_PIN PINE7
#define DIO80_RPORT PINE
#define DIO80_WPORT PORTE
#define DIO80_DDR DDRE
-#define DIO80_PWM NULL
+#define DIO80_PWM nullptr
#define DIO81_PIN PIND4
#define DIO81_RPORT PIND
#define DIO81_WPORT PORTD
#define DIO81_DDR DDRD
-#define DIO81_PWM NULL
+#define DIO81_PWM nullptr
#define DIO82_PIN PIND5
#define DIO82_RPORT PIND
#define DIO82_WPORT PORTD
#define DIO82_DDR DDRD
-#define DIO82_PWM NULL
+#define DIO82_PWM nullptr
#define DIO83_PIN PIND6
#define DIO83_RPORT PIND
#define DIO83_WPORT PORTD
#define DIO83_DDR DDRD
-#define DIO83_PWM NULL
+#define DIO83_PWM nullptr
#define DIO84_PIN PINH2
#define DIO84_RPORT PINH
#define DIO84_WPORT PORTH
#define DIO84_DDR DDRH
-#define DIO84_PWM NULL
+#define DIO84_PWM nullptr
#define DIO85_PIN PINH7
#define DIO85_RPORT PINH
#define DIO85_WPORT PORTH
#define DIO85_DDR DDRH
-#define DIO85_PWM NULL
+#define DIO85_PWM nullptr
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
-#define PA0_PWM NULL
+#define PA0_PWM nullptr
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
-#define PA1_PWM NULL
+#define PA1_PWM nullptr
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
-#define PA2_PWM NULL
+#define PA2_PWM nullptr
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
-#define PA3_PWM NULL
+#define PA3_PWM nullptr
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
-#define PA4_PWM NULL
+#define PA4_PWM nullptr
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
-#define PA5_PWM NULL
+#define PA5_PWM nullptr
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
-#define PA6_PWM NULL
+#define PA6_PWM nullptr
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
-#define PA7_PWM NULL
+#define PA7_PWM nullptr
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
-#define PB0_PWM NULL
+#define PB0_PWM nullptr
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
-#define PB1_PWM NULL
+#define PB1_PWM nullptr
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
-#define PB2_PWM NULL
+#define PB2_PWM nullptr
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
-#define PB3_PWM NULL
+#define PB3_PWM nullptr
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
@@ -670,13 +670,13 @@
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
-#define PB5_PWM NULL
+#define PB5_PWM nullptr
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
-#define PB6_PWM NULL
+#define PB6_PWM nullptr
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
@@ -689,117 +689,117 @@
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
-#define PC0_PWM NULL
+#define PC0_PWM nullptr
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
-#define PC1_PWM NULL
+#define PC1_PWM nullptr
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
-#define PC2_PWM NULL
+#define PC2_PWM nullptr
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
-#define PC3_PWM NULL
+#define PC3_PWM nullptr
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
-#define PC4_PWM NULL
+#define PC4_PWM nullptr
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
-#define PC5_PWM NULL
+#define PC5_PWM nullptr
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
-#define PC6_PWM NULL
+#define PC6_PWM nullptr
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
-#define PC7_PWM NULL
+#define PC7_PWM nullptr
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
-#define PD0_PWM NULL
+#define PD0_PWM nullptr
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
-#define PD1_PWM NULL
+#define PD1_PWM nullptr
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
-#define PD2_PWM NULL
+#define PD2_PWM nullptr
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
-#define PD3_PWM NULL
+#define PD3_PWM nullptr
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
-#define PD4_PWM NULL
+#define PD4_PWM nullptr
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
-#define PD5_PWM NULL
+#define PD5_PWM nullptr
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
-#define PD6_PWM NULL
+#define PD6_PWM nullptr
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
-#define PD7_PWM NULL
+#define PD7_PWM nullptr
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_DDR DDRE
-#define PE0_PWM NULL
+#define PE0_PWM nullptr
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_DDR DDRE
-#define PE1_PWM NULL
+#define PE1_PWM nullptr
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_DDR DDRE
-#define PE2_PWM NULL
+#define PE2_PWM nullptr
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
@@ -823,93 +823,93 @@
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_DDR DDRE
-#define PE6_PWM NULL
+#define PE6_PWM nullptr
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_DDR DDRE
-#define PE7_PWM NULL
+#define PE7_PWM nullptr
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_DDR DDRF
-#define PF0_PWM NULL
+#define PF0_PWM nullptr
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_DDR DDRF
-#define PF1_PWM NULL
+#define PF1_PWM nullptr
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_DDR DDRF
-#define PF2_PWM NULL
+#define PF2_PWM nullptr
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_DDR DDRF
-#define PF3_PWM NULL
+#define PF3_PWM nullptr
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_DDR DDRF
-#define PF4_PWM NULL
+#define PF4_PWM nullptr
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_DDR DDRF
-#define PF5_PWM NULL
+#define PF5_PWM nullptr
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_DDR DDRF
-#define PF6_PWM NULL
+#define PF6_PWM nullptr
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_DDR DDRF
-#define PF7_PWM NULL
+#define PF7_PWM nullptr
#undef PG0
#define PG0_PIN PING0
#define PG0_RPORT PING
#define PG0_WPORT PORTG
#define PG0_DDR DDRG
-#define PG0_PWM NULL
+#define PG0_PWM nullptr
#undef PG1
#define PG1_PIN PING1
#define PG1_RPORT PING
#define PG1_WPORT PORTG
#define PG1_DDR DDRG
-#define PG1_PWM NULL
+#define PG1_PWM nullptr
#undef PG2
#define PG2_PIN PING2
#define PG2_RPORT PING
#define PG2_WPORT PORTG
#define PG2_DDR DDRG
-#define PG2_PWM NULL
+#define PG2_PWM nullptr
#undef PG3
#define PG3_PIN PING3
#define PG3_RPORT PING
#define PG3_WPORT PORTG
#define PG3_DDR DDRG
-#define PG3_PWM NULL
+#define PG3_PWM nullptr
#undef PG4
#define PG4_PIN PING4
#define PG4_RPORT PING
#define PG4_WPORT PORTG
#define PG4_DDR DDRG
-#define PG4_PWM NULL
+#define PG4_PWM nullptr
#undef PG5
#define PG5_PIN PING5
#define PG5_RPORT PING
@@ -922,19 +922,19 @@
#define PH0_RPORT PINH
#define PH0_WPORT PORTH
#define PH0_DDR DDRH
-#define PH0_PWM NULL
+#define PH0_PWM nullptr
#undef PH1
#define PH1_PIN PINH1
#define PH1_RPORT PINH
#define PH1_WPORT PORTH
#define PH1_DDR DDRH
-#define PH1_PWM NULL
+#define PH1_PWM nullptr
#undef PH2
#define PH2_PIN PINH2
#define PH2_RPORT PINH
#define PH2_WPORT PORTH
#define PH2_DDR DDRH
-#define PH2_PWM NULL
+#define PH2_PWM nullptr
#undef PH3
#define PH3_PIN PINH3
#define PH3_RPORT PINH
@@ -964,124 +964,124 @@
#define PH7_RPORT PINH
#define PH7_WPORT PORTH
#define PH7_DDR DDRH
-#define PH7_PWM NULL
+#define PH7_PWM nullptr
#undef PJ0
#define PJ0_PIN PINJ0
#define PJ0_RPORT PINJ
#define PJ0_WPORT PORTJ
#define PJ0_DDR DDRJ
-#define PJ0_PWM NULL
+#define PJ0_PWM nullptr
#undef PJ1
#define PJ1_PIN PINJ1
#define PJ1_RPORT PINJ
#define PJ1_WPORT PORTJ
#define PJ1_DDR DDRJ
-#define PJ1_PWM NULL
+#define PJ1_PWM nullptr
#undef PJ2
#define PJ2_PIN PINJ2
#define PJ2_RPORT PINJ
#define PJ2_WPORT PORTJ
#define PJ2_DDR DDRJ
-#define PJ2_PWM NULL
+#define PJ2_PWM nullptr
#undef PJ3
#define PJ3_PIN PINJ3
#define PJ3_RPORT PINJ
#define PJ3_WPORT PORTJ
#define PJ3_DDR DDRJ
-#define PJ3_PWM NULL
+#define PJ3_PWM nullptr
#undef PJ4
#define PJ4_PIN PINJ4
#define PJ4_RPORT PINJ
#define PJ4_WPORT PORTJ
#define PJ4_DDR DDRJ
-#define PJ4_PWM NULL
+#define PJ4_PWM nullptr
#undef PJ5
#define PJ5_PIN PINJ5
#define PJ5_RPORT PINJ
#define PJ5_WPORT PORTJ
#define PJ5_DDR DDRJ
-#define PJ5_PWM NULL
+#define PJ5_PWM nullptr
#undef PJ6
#define PJ6_PIN PINJ6
#define PJ6_RPORT PINJ
#define PJ6_WPORT PORTJ
#define PJ6_DDR DDRJ
-#define PJ6_PWM NULL
+#define PJ6_PWM nullptr
#undef PJ7
#define PJ7_PIN PINJ7
#define PJ7_RPORT PINJ
#define PJ7_WPORT PORTJ
#define PJ7_DDR DDRJ
-#define PJ7_PWM NULL
+#define PJ7_PWM nullptr
#undef PK0
#define PK0_PIN PINK0
#define PK0_RPORT PINK
#define PK0_WPORT PORTK
#define PK0_DDR DDRK
-#define PK0_PWM NULL
+#define PK0_PWM nullptr
#undef PK1
#define PK1_PIN PINK1
#define PK1_RPORT PINK
#define PK1_WPORT PORTK
#define PK1_DDR DDRK
-#define PK1_PWM NULL
+#define PK1_PWM nullptr
#undef PK2
#define PK2_PIN PINK2
#define PK2_RPORT PINK
#define PK2_WPORT PORTK
#define PK2_DDR DDRK
-#define PK2_PWM NULL
+#define PK2_PWM nullptr
#undef PK3
#define PK3_PIN PINK3
#define PK3_RPORT PINK
#define PK3_WPORT PORTK
#define PK3_DDR DDRK
-#define PK3_PWM NULL
+#define PK3_PWM nullptr
#undef PK4
#define PK4_PIN PINK4
#define PK4_RPORT PINK
#define PK4_WPORT PORTK
#define PK4_DDR DDRK
-#define PK4_PWM NULL
+#define PK4_PWM nullptr
#undef PK5
#define PK5_PIN PINK5
#define PK5_RPORT PINK
#define PK5_WPORT PORTK
#define PK5_DDR DDRK
-#define PK5_PWM NULL
+#define PK5_PWM nullptr
#undef PK6
#define PK6_PIN PINK6
#define PK6_RPORT PINK
#define PK6_WPORT PORTK
#define PK6_DDR DDRK
-#define PK6_PWM NULL
+#define PK6_PWM nullptr
#undef PK7
#define PK7_PIN PINK7
#define PK7_RPORT PINK
#define PK7_WPORT PORTK
#define PK7_DDR DDRK
-#define PK7_PWM NULL
+#define PK7_PWM nullptr
#undef PL0
#define PL0_PIN PINL0
#define PL0_RPORT PINL
#define PL0_WPORT PORTL
#define PL0_DDR DDRL
-#define PL0_PWM NULL
+#define PL0_PWM nullptr
#undef PL1
#define PL1_PIN PINL1
#define PL1_RPORT PINL
#define PL1_WPORT PORTL
#define PL1_DDR DDRL
-#define PL1_PWM NULL
+#define PL1_PWM nullptr
#undef PL2
#define PL2_PIN PINL2
#define PL2_RPORT PINL
#define PL2_WPORT PORTL
#define PL2_DDR DDRL
-#define PL2_PWM NULL
+#define PL2_PWM nullptr
#undef PL3
#define PL3_PIN PINL3
#define PL3_RPORT PINL
@@ -1105,10 +1105,10 @@
#define PL6_RPORT PINL
#define PL6_WPORT PORTL
#define PL6_DDR DDRL
-#define PL6_PWM NULL
+#define PL6_PWM nullptr
#undef PL7
#define PL7_PIN PINL7
#define PL7_RPORT PINL
#define PL7_WPORT PORTL
#define PL7_DDR DDRL
-#define PL7_PWM NULL
+#define PL7_PWM nullptr
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_1281.h b/Marlin/src/HAL/AVR/fastio/fastio_1281.h
similarity index 83%
rename from Marlin/src/HAL/HAL_AVR/fastio_1281.h
rename to Marlin/src/HAL/AVR/fastio/fastio_1281.h
index 9707c7d54b..7552540ffe 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_1281.h
+++ b/Marlin/src/HAL/AVR/fastio/fastio_1281.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
* Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5
*/
-#include "fastio_AVR.h"
+#include "../fastio.h"
// change for your board
#define DEBUG_LED DIO46
@@ -63,13 +63,13 @@
#define DIO0_RPORT PINE
#define DIO0_WPORT PORTE
#define DIO0_DDR DDRE
-#define DIO0_PWM NULL
+#define DIO0_PWM nullptr
#define DIO1_PIN PINE1
#define DIO1_RPORT PINE
#define DIO1_WPORT PORTE
#define DIO1_DDR DDRE
-#define DIO1_PWM NULL
+#define DIO1_PWM nullptr
#define DIO2_PIN PINE4
#define DIO2_RPORT PINE
@@ -123,339 +123,339 @@
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
-#define DIO10_PWM NULL
+#define DIO10_PWM nullptr
#define DIO11_PIN PINB2
#define DIO11_RPORT PINB
#define DIO11_WPORT PORTB
#define DIO11_DDR DDRB
-#define DIO11_PWM NULL
+#define DIO11_PWM nullptr
#define DIO12_PIN PINB3
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
-#define DIO12_PWM NULL
+#define DIO12_PWM nullptr
#define DIO13_PIN PINE2
#define DIO13_RPORT PINE
#define DIO13_WPORT PORTE
#define DIO13_DDR DDRE
-#define DIO13_PWM NULL
+#define DIO13_PWM nullptr
#define DIO14_PIN PINE6
#define DIO14_RPORT PINE
#define DIO14_WPORT PORTE
#define DIO14_DDR DDRE
-#define DIO14_PWM NULL
+#define DIO14_PWM nullptr
#define DIO15_PIN PINE7
#define DIO15_RPORT PINE
#define DIO15_WPORT PORTE
#define DIO15_DDR DDRE
-#define DIO15_PWM NULL
+#define DIO15_PWM nullptr
#define DIO16_PIN PINB0
#define DIO16_RPORT PINB
#define DIO16_WPORT PORTB
#define DIO16_DDR DDRB
-#define DIO16_PWM NULL
+#define DIO16_PWM nullptr
#define DIO17_PIN PIND0
#define DIO17_RPORT PIND
#define DIO17_WPORT PORTD
#define DIO17_DDR DDRD
-#define DIO17_PWM NULL
+#define DIO17_PWM nullptr
#define DIO18_PIN PIND1
#define DIO18_RPORT PIND
#define DIO18_WPORT PORTD
#define DIO18_DDR DDRD
-#define DIO18_PWM NULL
+#define DIO18_PWM nullptr
#define DIO19_PIN PIND2
#define DIO19_RPORT PIND
#define DIO19_WPORT PORTD
#define DIO19_DDR DDRD
-#define DIO19_PWM NULL
+#define DIO19_PWM nullptr
#define DIO20_PIN PIND3
#define DIO20_RPORT PIND
#define DIO20_WPORT PORTD
#define DIO20_DDR DDRD
-#define DIO20_PWM NULL
+#define DIO20_PWM nullptr
#define DIO21_PIN PIND4
#define DIO21_RPORT PIND
#define DIO21_WPORT PORTD
#define DIO21_DDR DDRD
-#define DIO21_PWM NULL
+#define DIO21_PWM nullptr
#define DIO22_PIN PIND5
#define DIO22_RPORT PIND
#define DIO22_WPORT PORTD
#define DIO22_DDR DDRD
-#define DIO22_PWM NULL
+#define DIO22_PWM nullptr
#define DIO23_PIN PIND6
#define DIO23_RPORT PIND
#define DIO23_WPORT PORTD
#define DIO23_DDR DDRD
-#define DIO23_PWM NULL
+#define DIO23_PWM nullptr
#define DIO24_PIN PIND7
#define DIO24_RPORT PIND
#define DIO24_WPORT PORTD
#define DIO24_DDR DDRD
-#define DIO24_PWM NULL
+#define DIO24_PWM nullptr
#define DIO25_PIN PING0
#define DIO25_RPORT PING
#define DIO25_WPORT PORTG
#define DIO25_DDR DDRG
-#define DIO25_PWM NULL
+#define DIO25_PWM nullptr
#define DIO26_PIN PING1
#define DIO26_RPORT PING
#define DIO26_WPORT PORTG
#define DIO26_DDR DDRG
-#define DIO26_PWM NULL
+#define DIO26_PWM nullptr
#define DIO27_PIN PING2
#define DIO27_RPORT PING
#define DIO27_WPORT PORTG
#define DIO27_DDR DDRG
-#define DIO27_PWM NULL
+#define DIO27_PWM nullptr
#define DIO28_PIN PING3
#define DIO28_RPORT PING
#define DIO28_WPORT PORTG
#define DIO28_DDR DDRG
-#define DIO28_PWM NULL
+#define DIO28_PWM nullptr
#define DIO29_PIN PING4
#define DIO29_RPORT PING
#define DIO29_WPORT PORTG
#define DIO29_DDR DDRG
-#define DIO29_PWM NULL
+#define DIO29_PWM nullptr
#define DIO30_PIN PINC0
#define DIO30_RPORT PINC
#define DIO30_WPORT PORTC
#define DIO30_DDR DDRC
-#define DIO30_PWM NULL
+#define DIO30_PWM nullptr
#define DIO31_PIN PINC1
#define DIO31_RPORT PINC
#define DIO31_WPORT PORTC
#define DIO31_DDR DDRC
-#define DIO31_PWM NULL
+#define DIO31_PWM nullptr
#define DIO32_PIN PINC2
#define DIO32_RPORT PINC
#define DIO32_WPORT PORTC
#define DIO32_DDR DDRC
-#define DIO32_PWM NULL
+#define DIO32_PWM nullptr
#define DIO33_PIN PINC3
#define DIO33_RPORT PINC
#define DIO33_WPORT PORTC
#define DIO33_DDR DDRC
-#define DIO33_PWM NULL
+#define DIO33_PWM nullptr
#define DIO34_PIN PINC4
#define DIO34_RPORT PINC
#define DIO34_WPORT PORTC
#define DIO34_DDR DDRC
-#define DIO34_PWM NULL
+#define DIO34_PWM nullptr
#define DIO35_PIN PINC5
#define DIO35_RPORT PINC
#define DIO35_WPORT PORTC
#define DIO35_DDR DDRC
-#define DIO35_PWM NULL
+#define DIO35_PWM nullptr
#define DIO36_PIN PINC6
#define DIO36_RPORT PINC
#define DIO36_WPORT PORTC
#define DIO36_DDR DDRC
-#define DIO36_PWM NULL
+#define DIO36_PWM nullptr
#define DIO37_PIN PINC7
#define DIO37_RPORT PINC
#define DIO37_WPORT PORTC
#define DIO37_DDR DDRC
-#define DIO37_PWM NULL
+#define DIO37_PWM nullptr
#define DIO38_PIN PINA0
#define DIO38_RPORT PINA
#define DIO38_WPORT PORTA
#define DIO38_DDR DDRA
-#define DIO38_PWM NULL
+#define DIO38_PWM nullptr
#define DIO39_PIN PINA1
#define DIO39_RPORT PINA
#define DIO39_WPORT PORTA
#define DIO39_DDR DDRA
-#define DIO39_PWM NULL
+#define DIO39_PWM nullptr
#define DIO40_PIN PINA2
#define DIO40_RPORT PINA
#define DIO40_WPORT PORTA
#define DIO40_DDR DDRA
-#define DIO40_PWM NULL
+#define DIO40_PWM nullptr
#define DIO41_PIN PINA3
#define DIO41_RPORT PINA
#define DIO41_WPORT PORTA
#define DIO41_DDR DDRA
-#define DIO41_PWM NULL
+#define DIO41_PWM nullptr
#define DIO42_PIN PINA4
#define DIO42_RPORT PINA
#define DIO42_WPORT PORTA
#define DIO42_DDR DDRA
-#define DIO42_PWM NULL
+#define DIO42_PWM nullptr
#define DIO43_PIN PINA5
#define DIO43_RPORT PINA
#define DIO43_WPORT PORTA
#define DIO43_DDR DDRA
-#define DIO43_PWM NULL
+#define DIO43_PWM nullptr
#define DIO44_PIN PINA6
#define DIO44_RPORT PINA
#define DIO44_WPORT PORTA
#define DIO44_DDR DDRA
-#define DIO44_PWM NULL
+#define DIO44_PWM nullptr
#define DIO45_PIN PINA7
#define DIO45_RPORT PINA
#define DIO45_WPORT PORTA
#define DIO45_DDR DDRA
-#define DIO45_PWM NULL
+#define DIO45_PWM nullptr
#define DIO46_PIN PINF0
#define DIO46_RPORT PINF
#define DIO46_WPORT PORTF
#define DIO46_DDR DDRF
-#define DIO46_PWM NULL
+#define DIO46_PWM nullptr
#define DIO47_PIN PINF1
#define DIO47_RPORT PINF
#define DIO47_WPORT PORTF
#define DIO47_DDR DDRF
-#define DIO47_PWM NULL
+#define DIO47_PWM nullptr
#define DIO48_PIN PINF2
#define DIO48_RPORT PINF
#define DIO48_WPORT PORTF
#define DIO48_DDR DDRF
-#define DIO48_PWM NULL
+#define DIO48_PWM nullptr
#define DIO49_PIN PINF3
#define DIO49_RPORT PINF
#define DIO49_WPORT PORTF
#define DIO49_DDR DDRF
-#define DIO49_PWM NULL
+#define DIO49_PWM nullptr
#define DIO50_PIN PINF4
#define DIO50_RPORT PINF
#define DIO50_WPORT PORTF
#define DIO50_DDR DDRF
-#define DIO50_PWM NULL
+#define DIO50_PWM nullptr
#define DIO51_PIN PINF5
#define DIO51_RPORT PINF
#define DIO51_WPORT PORTF
#define DIO51_DDR DDRF
-#define DIO51_PWM NULL
+#define DIO51_PWM nullptr
#define DIO52_PIN PINF6
#define DIO52_RPORT PINF
#define DIO52_WPORT PORTF
#define DIO52_DDR DDRF
-#define DIO52_PWM NULL
+#define DIO52_PWM nullptr
#define DIO53_PIN PINF7
#define DIO53_RPORT PINF
#define DIO53_WPORT PORTF
#define DIO53_DDR DDRF
-#define DIO53_PWM NULL
+#define DIO53_PWM nullptr
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
-#define PA0_PWM NULL
+#define PA0_PWM nullptr
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
-#define PA1_PWM NULL
+#define PA1_PWM nullptr
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
-#define PA2_PWM NULL
+#define PA2_PWM nullptr
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
-#define PA3_PWM NULL
+#define PA3_PWM nullptr
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
-#define PA4_PWM NULL
+#define PA4_PWM nullptr
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
-#define PA5_PWM NULL
+#define PA5_PWM nullptr
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
-#define PA6_PWM NULL
+#define PA6_PWM nullptr
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
-#define PA7_PWM NULL
+#define PA7_PWM nullptr
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
-#define PB0_PWM NULL
+#define PB0_PWM nullptr
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
-#define PB1_PWM NULL
+#define PB1_PWM nullptr
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
-#define PB2_PWM NULL
+#define PB2_PWM nullptr
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
-#define PB3_PWM NULL
+#define PB3_PWM nullptr
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
@@ -467,13 +467,13 @@
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
-#define PB5_PWM NULL
+#define PB5_PWM nullptr
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
-#define PB6_PWM NULL
+#define PB6_PWM nullptr
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
@@ -486,117 +486,117 @@
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
-#define PC0_PWM NULL
+#define PC0_PWM nullptr
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
-#define PC1_PWM NULL
+#define PC1_PWM nullptr
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
-#define PC2_PWM NULL
+#define PC2_PWM nullptr
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
-#define PC3_PWM NULL
+#define PC3_PWM nullptr
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
-#define PC4_PWM NULL
+#define PC4_PWM nullptr
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
-#define PC5_PWM NULL
+#define PC5_PWM nullptr
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
-#define PC6_PWM NULL
+#define PC6_PWM nullptr
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
-#define PC7_PWM NULL
+#define PC7_PWM nullptr
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
-#define PD0_PWM NULL
+#define PD0_PWM nullptr
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
-#define PD1_PWM NULL
+#define PD1_PWM nullptr
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
-#define PD2_PWM NULL
+#define PD2_PWM nullptr
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
-#define PD3_PWM NULL
+#define PD3_PWM nullptr
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
-#define PD4_PWM NULL
+#define PD4_PWM nullptr
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
-#define PD5_PWM NULL
+#define PD5_PWM nullptr
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
-#define PD6_PWM NULL
+#define PD6_PWM nullptr
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
-#define PD7_PWM NULL
+#define PD7_PWM nullptr
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
#define PE0_DDR DDRE
-#define PE0_PWM NULL
+#define PE0_PWM nullptr
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
#define PE1_DDR DDRE
-#define PE1_PWM NULL
+#define PE1_PWM nullptr
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
#define PE2_DDR DDRE
-#define PE2_PWM NULL
+#define PE2_PWM nullptr
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
@@ -620,93 +620,93 @@
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
#define PE6_DDR DDRE
-#define PE6_PWM NULL
+#define PE6_PWM nullptr
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
#define PE7_DDR DDRE
-#define PE7_PWM NULL
+#define PE7_PWM nullptr
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
#define PF0_DDR DDRF
-#define PF0_PWM NULL
+#define PF0_PWM nullptr
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
#define PF1_DDR DDRF
-#define PF1_PWM NULL
+#define PF1_PWM nullptr
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
#define PF2_DDR DDRF
-#define PF2_PWM NULL
+#define PF2_PWM nullptr
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
#define PF3_DDR DDRF
-#define PF3_PWM NULL
+#define PF3_PWM nullptr
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
#define PF4_DDR DDRF
-#define PF4_PWM NULL
+#define PF4_PWM nullptr
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
#define PF5_DDR DDRF
-#define PF5_PWM NULL
+#define PF5_PWM nullptr
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
#define PF6_DDR DDRF
-#define PF6_PWM NULL
+#define PF6_PWM nullptr
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
#define PF7_DDR DDRF
-#define PF7_PWM NULL
+#define PF7_PWM nullptr
#undef PG0
#define PG0_PIN PING0
#define PG0_RPORT PING
#define PG0_WPORT PORTG
#define PG0_DDR DDRG
-#define PG0_PWM NULL
+#define PG0_PWM nullptr
#undef PG1
#define PG1_PIN PING1
#define PG1_RPORT PING
#define PG1_WPORT PORTG
#define PG1_DDR DDRG
-#define PG1_PWM NULL
+#define PG1_PWM nullptr
#undef PG2
#define PG2_PIN PING2
#define PG2_RPORT PING
#define PG2_WPORT PORTG
#define PG2_DDR DDRG
-#define PG2_PWM NULL
+#define PG2_PWM nullptr
#undef PG3
#define PG3_PIN PING3
#define PG3_RPORT PING
#define PG3_WPORT PORTG
#define PG3_DDR DDRG
-#define PG3_PWM NULL
+#define PG3_PWM nullptr
#undef PG4
#define PG4_PIN PING4
#define PG4_RPORT PING
#define PG4_WPORT PORTG
#define PG4_DDR DDRG
-#define PG4_PWM NULL
+#define PG4_PWM nullptr
#undef PG5
#define PG5_PIN PING5
#define PG5_RPORT PING
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_168.h b/Marlin/src/HAL/AVR/fastio/fastio_168.h
similarity index 84%
rename from Marlin/src/HAL/HAL_AVR/fastio_168.h
rename to Marlin/src/HAL/AVR/fastio/fastio_168.h
index 2964ef5a0b..549e0246d5 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_168.h
+++ b/Marlin/src/HAL/AVR/fastio/fastio_168.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
* Port: B0 B1 B2 B3 B4 B5 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7
*/
-#include "fastio_AVR.h"
+#include "../fastio.h"
#define DEBUG_LED AIO5
@@ -60,19 +60,19 @@
#define DIO0_RPORT PIND
#define DIO0_WPORT PORTD
#define DIO0_DDR DDRD
-#define DIO0_PWM NULL
+#define DIO0_PWM nullptr
#define DIO1_PIN PIND1
#define DIO1_RPORT PIND
#define DIO1_WPORT PORTD
#define DIO1_DDR DDRD
-#define DIO1_PWM NULL
+#define DIO1_PWM nullptr
#define DIO2_PIN PIND2
#define DIO2_RPORT PIND
#define DIO2_WPORT PORTD
#define DIO2_DDR DDRD
-#define DIO2_PWM NULL
+#define DIO2_PWM nullptr
#define DIO3_PIN PIND3
#define DIO3_RPORT PIND
@@ -84,7 +84,7 @@
#define DIO4_RPORT PIND
#define DIO4_WPORT PORTD
#define DIO4_DDR DDRD
-#define DIO4_PWM NULL
+#define DIO4_PWM nullptr
#define DIO5_PIN PIND5
#define DIO5_RPORT PIND
@@ -102,25 +102,25 @@
#define DIO7_RPORT PIND
#define DIO7_WPORT PORTD
#define DIO7_DDR DDRD
-#define DIO7_PWM NULL
+#define DIO7_PWM nullptr
#define DIO8_PIN PINB0
#define DIO8_RPORT PINB
#define DIO8_WPORT PORTB
#define DIO8_DDR DDRB
-#define DIO8_PWM NULL
+#define DIO8_PWM nullptr
#define DIO9_PIN PINB1
#define DIO9_RPORT PINB
#define DIO9_WPORT PORTB
#define DIO9_DDR DDRB
-#define DIO9_PWM NULL
+#define DIO9_PWM nullptr
#define DIO10_PIN PINB2
#define DIO10_RPORT PINB
#define DIO10_WPORT PORTB
#define DIO10_DDR DDRB
-#define DIO10_PWM NULL
+#define DIO10_PWM nullptr
#define DIO11_PIN PINB3
#define DIO11_RPORT PINB
@@ -132,82 +132,82 @@
#define DIO12_RPORT PINB
#define DIO12_WPORT PORTB
#define DIO12_DDR DDRB
-#define DIO12_PWM NULL
+#define DIO12_PWM nullptr
#define DIO13_PIN PINB5
#define DIO13_RPORT PINB
#define DIO13_WPORT PORTB
#define DIO13_DDR DDRB
-#define DIO13_PWM NULL
+#define DIO13_PWM nullptr
#define DIO14_PIN PINC0
#define DIO14_RPORT PINC
#define DIO14_WPORT PORTC
#define DIO14_DDR DDRC
-#define DIO14_PWM NULL
+#define DIO14_PWM nullptr
#define DIO15_PIN PINC1
#define DIO15_RPORT PINC
#define DIO15_WPORT PORTC
#define DIO15_DDR DDRC
-#define DIO15_PWM NULL
+#define DIO15_PWM nullptr
#define DIO16_PIN PINC2
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
-#define DIO16_PWM NULL
+#define DIO16_PWM nullptr
#define DIO17_PIN PINC3
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
-#define DIO17_PWM NULL
+#define DIO17_PWM nullptr
#define DIO18_PIN PINC4
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
-#define DIO18_PWM NULL
+#define DIO18_PWM nullptr
#define DIO19_PIN PINC5
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
-#define DIO19_PWM NULL
+#define DIO19_PWM nullptr
#define DIO20_PIN PINC6
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
-#define DIO20_PWM NULL
+#define DIO20_PWM nullptr
#define DIO21_PIN PINC7
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
-#define DIO21_PWM NULL
+#define DIO21_PWM nullptr
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
-#define PB0_PWM NULL
+#define PB0_PWM nullptr
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
-#define PB1_PWM NULL
+#define PB1_PWM nullptr
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
-#define PB2_PWM NULL
+#define PB2_PWM nullptr
#undef PB3
#define PB3_PIN PINB3
@@ -221,105 +221,105 @@
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
-#define PB4_PWM NULL
+#define PB4_PWM nullptr
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
-#define PB5_PWM NULL
+#define PB5_PWM nullptr
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
-#define PB6_PWM NULL
+#define PB6_PWM nullptr
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
-#define PB7_PWM NULL
+#define PB7_PWM nullptr
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
-#define PC0_PWM NULL
+#define PC0_PWM nullptr
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
-#define PC1_PWM NULL
+#define PC1_PWM nullptr
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
-#define PC2_PWM NULL
+#define PC2_PWM nullptr
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
-#define PC3_PWM NULL
+#define PC3_PWM nullptr
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
-#define PC4_PWM NULL
+#define PC4_PWM nullptr
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
-#define PC5_PWM NULL
+#define PC5_PWM nullptr
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
-#define PC6_PWM NULL
+#define PC6_PWM nullptr
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
-#define PC7_PWM NULL
+#define PC7_PWM nullptr
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
-#define PD0_PWM NULL
+#define PD0_PWM nullptr
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
-#define PD1_PWM NULL
+#define PD1_PWM nullptr
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
-#define PD2_PWM NULL
+#define PD2_PWM nullptr
#undef PD3
#define PD3_PIN PIND3
@@ -333,7 +333,7 @@
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
-#define PD4_PWM NULL
+#define PD4_PWM nullptr
#undef PD5
#define PD5_PIN PIND5
@@ -354,4 +354,4 @@
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
-#define PD7_PWM NULL
+#define PD7_PWM nullptr
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_644.h b/Marlin/src/HAL/AVR/fastio/fastio_644.h
similarity index 83%
rename from Marlin/src/HAL/HAL_AVR/fastio_644.h
rename to Marlin/src/HAL/AVR/fastio/fastio_644.h
index bcd825d24c..3a48c109e9 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_644.h
+++ b/Marlin/src/HAL/AVR/fastio/fastio_644.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,7 +54,7 @@
* +--------+
*/
-#include "fastio_AVR.h"
+#include "../fastio.h"
#define DEBUG_LED DIO0
@@ -91,462 +91,462 @@
#define DIO0_RPORT PINB
#define DIO0_WPORT PORTB
#define DIO0_DDR DDRB
-#define DIO0_PWM NULL
+#define DIO0_PWM nullptr
#define DIO1_PIN PINB1
#define DIO1_RPORT PINB
#define DIO1_WPORT PORTB
#define DIO1_DDR DDRB
-#define DIO1_PWM NULL
+#define DIO1_PWM nullptr
#define DIO2_PIN PINB2
#define DIO2_RPORT PINB
#define DIO2_WPORT PORTB
#define DIO2_DDR DDRB
-#define DIO2_PWM NULL
+#define DIO2_PWM nullptr
#define DIO3_PIN PINB3
#define DIO3_RPORT PINB
#define DIO3_WPORT PORTB
#define DIO3_DDR DDRB
-#define DIO3_PWM OCR0A
+#define DIO3_PWM &OCR0A
#define DIO4_PIN PINB4
#define DIO4_RPORT PINB
#define DIO4_WPORT PORTB
#define DIO4_DDR DDRB
-#define DIO4_PWM OCR0B
+#define DIO4_PWM &OCR0B
#define DIO5_PIN PINB5
#define DIO5_RPORT PINB
#define DIO5_WPORT PORTB
#define DIO5_DDR DDRB
-#define DIO5_PWM NULL
+#define DIO5_PWM nullptr
#define DIO6_PIN PINB6
#define DIO6_RPORT PINB
#define DIO6_WPORT PORTB
#define DIO6_DDR DDRB
-#define DIO6_PWM NULL
+#define DIO6_PWM nullptr
#define DIO7_PIN PINB7
#define DIO7_RPORT PINB
#define DIO7_WPORT PORTB
#define DIO7_DDR DDRB
-#define DIO7_PWM NULL
+#define DIO7_PWM nullptr
#define DIO8_PIN PIND0
#define DIO8_RPORT PIND
#define DIO8_WPORT PORTD
#define DIO8_DDR DDRD
-#define DIO8_PWM NULL
+#define DIO8_PWM nullptr
#define DIO9_PIN PIND1
#define DIO9_RPORT PIND
#define DIO9_WPORT PORTD
#define DIO9_DDR DDRD
-#define DIO9_PWM NULL
+#define DIO9_PWM nullptr
#define DIO10_PIN PIND2
#define DIO10_RPORT PIND
#define DIO10_WPORT PORTD
#define DIO10_DDR DDRD
-#define DIO10_PWM NULL
+#define DIO10_PWM nullptr
#define DIO11_PIN PIND3
#define DIO11_RPORT PIND
#define DIO11_WPORT PORTD
#define DIO11_DDR DDRD
-#define DIO11_PWM NULL
+#define DIO11_PWM nullptr
#define DIO12_PIN PIND4
#define DIO12_RPORT PIND
#define DIO12_WPORT PORTD
#define DIO12_DDR DDRD
-#define DIO12_PWM OCR1B
+#define DIO12_PWM &OCR1B
#define DIO13_PIN PIND5
#define DIO13_RPORT PIND
#define DIO13_WPORT PORTD
#define DIO13_DDR DDRD
-#define DIO13_PWM OCR1A
+#define DIO13_PWM &OCR1A
#define DIO14_PIN PIND6
#define DIO14_RPORT PIND
#define DIO14_WPORT PORTD
#define DIO14_DDR DDRD
-#define DIO14_PWM OCR2B
+#define DIO14_PWM &OCR2B
#define DIO15_PIN PIND7
#define DIO15_RPORT PIND
#define DIO15_WPORT PORTD
#define DIO15_DDR DDRD
-#define DIO15_PWM OCR2A
+#define DIO15_PWM &OCR2A
#define DIO16_PIN PINC0
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
#define DIO16_DDR DDRC
-#define DIO16_PWM NULL
+#define DIO16_PWM nullptr
#define DIO17_PIN PINC1
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
#define DIO17_DDR DDRC
-#define DIO17_PWM NULL
+#define DIO17_PWM nullptr
#define DIO18_PIN PINC2
#define DIO18_RPORT PINC
#define DIO18_WPORT PORTC
#define DIO18_DDR DDRC
-#define DIO18_PWM NULL
+#define DIO18_PWM nullptr
#define DIO19_PIN PINC3
#define DIO19_RPORT PINC
#define DIO19_WPORT PORTC
#define DIO19_DDR DDRC
-#define DIO19_PWM NULL
+#define DIO19_PWM nullptr
#define DIO20_PIN PINC4
#define DIO20_RPORT PINC
#define DIO20_WPORT PORTC
#define DIO20_DDR DDRC
-#define DIO20_PWM NULL
+#define DIO20_PWM nullptr
#define DIO21_PIN PINC5
#define DIO21_RPORT PINC
#define DIO21_WPORT PORTC
#define DIO21_DDR DDRC
-#define DIO21_PWM NULL
+#define DIO21_PWM nullptr
#define DIO22_PIN PINC6
#define DIO22_RPORT PINC
#define DIO22_WPORT PORTC
#define DIO22_DDR DDRC
-#define DIO22_PWM NULL
+#define DIO22_PWM nullptr
#define DIO23_PIN PINC7
#define DIO23_RPORT PINC
#define DIO23_WPORT PORTC
#define DIO23_DDR DDRC
-#define DIO23_PWM NULL
+#define DIO23_PWM nullptr
#define DIO24_PIN PINA7
#define DIO24_RPORT PINA
#define DIO24_WPORT PORTA
#define DIO24_DDR DDRA
-#define DIO24_PWM NULL
+#define DIO24_PWM nullptr
#define DIO25_PIN PINA6
#define DIO25_RPORT PINA
#define DIO25_WPORT PORTA
#define DIO25_DDR DDRA
-#define DIO25_PWM NULL
+#define DIO25_PWM nullptr
#define DIO26_PIN PINA5
#define DIO26_RPORT PINA
#define DIO26_WPORT PORTA
#define DIO26_DDR DDRA
-#define DIO26_PWM NULL
+#define DIO26_PWM nullptr
#define DIO27_PIN PINA4
#define DIO27_RPORT PINA
#define DIO27_WPORT PORTA
#define DIO27_DDR DDRA
-#define DIO27_PWM NULL
+#define DIO27_PWM nullptr
#define DIO28_PIN PINA3
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
#define DIO28_DDR DDRA
-#define DIO28_PWM NULL
+#define DIO28_PWM nullptr
#define DIO29_PIN PINA2
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
#define DIO29_DDR DDRA
-#define DIO29_PWM NULL
+#define DIO29_PWM nullptr
#define DIO30_PIN PINA1
#define DIO30_RPORT PINA
#define DIO30_WPORT PORTA
#define DIO30_DDR DDRA
-#define DIO30_PWM NULL
+#define DIO30_PWM nullptr
#define DIO31_PIN PINA0
#define DIO31_RPORT PINA
#define DIO31_WPORT PORTA
#define DIO31_DDR DDRA
-#define DIO31_PWM NULL
+#define DIO31_PWM nullptr
#define AIO0_PIN PINA0
#define AIO0_RPORT PINA
#define AIO0_WPORT PORTA
#define AIO0_DDR DDRA
-#define AIO0_PWM NULL
+#define AIO0_PWM nullptr
#define AIO1_PIN PINA1
#define AIO1_RPORT PINA
#define AIO1_WPORT PORTA
#define AIO1_DDR DDRA
-#define AIO1_PWM NULL
+#define AIO1_PWM nullptr
#define AIO2_PIN PINA2
#define AIO2_RPORT PINA
#define AIO2_WPORT PORTA
#define AIO2_DDR DDRA
-#define AIO2_PWM NULL
+#define AIO2_PWM nullptr
#define AIO3_PIN PINA3
#define AIO3_RPORT PINA
#define AIO3_WPORT PORTA
#define AIO3_DDR DDRA
-#define AIO3_PWM NULL
+#define AIO3_PWM nullptr
#define AIO4_PIN PINA4
#define AIO4_RPORT PINA
#define AIO4_WPORT PORTA
#define AIO4_DDR DDRA
-#define AIO4_PWM NULL
+#define AIO4_PWM nullptr
#define AIO5_PIN PINA5
#define AIO5_RPORT PINA
#define AIO5_WPORT PORTA
#define AIO5_DDR DDRA
-#define AIO5_PWM NULL
+#define AIO5_PWM nullptr
#define AIO6_PIN PINA6
#define AIO6_RPORT PINA
#define AIO6_WPORT PORTA
#define AIO6_DDR DDRA
-#define AIO6_PWM NULL
+#define AIO6_PWM nullptr
#define AIO7_PIN PINA7
#define AIO7_RPORT PINA
#define AIO7_WPORT PORTA
#define AIO7_DDR DDRA
-#define AIO7_PWM NULL
+#define AIO7_PWM nullptr
#undef PA0
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
#define PA0_DDR DDRA
-#define PA0_PWM NULL
+#define PA0_PWM nullptr
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
#define PA1_DDR DDRA
-#define PA1_PWM NULL
+#define PA1_PWM nullptr
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
#define PA2_DDR DDRA
-#define PA2_PWM NULL
+#define PA2_PWM nullptr
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
#define PA3_DDR DDRA
-#define PA3_PWM NULL
+#define PA3_PWM nullptr
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
#define PA4_DDR DDRA
-#define PA4_PWM NULL
+#define PA4_PWM nullptr
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
#define PA5_DDR DDRA
-#define PA5_PWM NULL
+#define PA5_PWM nullptr
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
#define PA6_DDR DDRA
-#define PA6_PWM NULL
+#define PA6_PWM nullptr
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
#define PA7_DDR DDRA
-#define PA7_PWM NULL
+#define PA7_PWM nullptr
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
#define PB0_DDR DDRB
-#define PB0_PWM NULL
+#define PB0_PWM nullptr
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
#define PB1_DDR DDRB
-#define PB1_PWM NULL
+#define PB1_PWM nullptr
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
#define PB2_DDR DDRB
-#define PB2_PWM NULL
+#define PB2_PWM nullptr
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
#define PB3_DDR DDRB
-#define PB3_PWM OCR0A
+#define PB3_PWM &OCR0A
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
#define PB4_DDR DDRB
-#define PB4_PWM OCR0B
+#define PB4_PWM &OCR0B
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
#define PB5_DDR DDRB
-#define PB5_PWM NULL
+#define PB5_PWM nullptr
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
#define PB6_DDR DDRB
-#define PB6_PWM NULL
+#define PB6_PWM nullptr
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
#define PB7_DDR DDRB
-#define PB7_PWM NULL
+#define PB7_PWM nullptr
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
#define PC0_DDR DDRC
-#define PC0_PWM NULL
+#define PC0_PWM nullptr
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
#define PC1_DDR DDRC
-#define PC1_PWM NULL
+#define PC1_PWM nullptr
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
#define PC2_DDR DDRC
-#define PC2_PWM NULL
+#define PC2_PWM nullptr
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
#define PC3_DDR DDRC
-#define PC3_PWM NULL
+#define PC3_PWM nullptr
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
#define PC4_DDR DDRC
-#define PC4_PWM NULL
+#define PC4_PWM nullptr
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
#define PC5_DDR DDRC
-#define PC5_PWM NULL
+#define PC5_PWM nullptr
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
#define PC6_DDR DDRC
-#define PC6_PWM NULL
+#define PC6_PWM nullptr
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
#define PC7_DDR DDRC
-#define PC7_PWM NULL
+#define PC7_PWM nullptr
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
#define PD0_DDR DDRD
-#define PD0_PWM NULL
+#define PD0_PWM nullptr
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
#define PD1_DDR DDRD
-#define PD1_PWM NULL
+#define PD1_PWM nullptr
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
#define PD2_DDR DDRD
-#define PD2_PWM NULL
+#define PD2_PWM nullptr
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
#define PD3_DDR DDRD
-#define PD3_PWM NULL
+#define PD3_PWM nullptr
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
#define PD4_DDR DDRD
-#define PD4_PWM NULL
+#define PD4_PWM nullptr
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
#define PD5_DDR DDRD
-#define PD5_PWM NULL
+#define PD5_PWM nullptr
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
#define PD6_DDR DDRD
-#define PD6_PWM OCR2B
+#define PD6_PWM &OCR2B
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
#define PD7_DDR DDRD
-#define PD7_PWM OCR2A
+#define PD7_PWM &OCR2A
diff --git a/Marlin/src/HAL/HAL_AVR/fastio_AT90USB.h b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h
similarity index 81%
rename from Marlin/src/HAL/HAL_AVR/fastio_AT90USB.h
rename to Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h
index 805c0daf73..23d16a20e5 100644
--- a/Marlin/src/HAL/HAL_AVR/fastio_AT90USB.h
+++ b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
* The logical pins 46 and 47 are not supported by Teensyduino, but are supported below as E2 and E3
*/
-#include "fastio_AVR.h"
+#include "../fastio.h"
// change for your board
#define DEBUG_LED DIO31 /* led D5 red */
@@ -45,325 +45,325 @@
#define DIO0_PIN PIND0
#define DIO0_RPORT PIND
#define DIO0_WPORT PORTD
-#define DIO0_PWM NULL
+#define DIO0_PWM 0
#define DIO0_DDR DDRD
#define DIO1_PIN PIND1
#define DIO1_RPORT PIND
#define DIO1_WPORT PORTD
-#define DIO1_PWM NULL
+#define DIO1_PWM 0
#define DIO1_DDR DDRD
#define DIO2_PIN PIND2
#define DIO2_RPORT PIND
#define DIO2_WPORT PORTD
-#define DIO2_PWM NULL
+#define DIO2_PWM 0
#define DIO2_DDR DDRD
#define DIO3_PIN PIND3
#define DIO3_RPORT PIND
#define DIO3_WPORT PORTD
-#define DIO3_PWM NULL
+#define DIO3_PWM 0
#define DIO3_DDR DDRD
#define DIO4_PIN PIND4
#define DIO4_RPORT PIND
#define DIO4_WPORT PORTD
-#define DIO4_PWM NULL
+#define DIO4_PWM 0
#define DIO4_DDR DDRD
#define DIO5_PIN PIND5
#define DIO5_RPORT PIND
#define DIO5_WPORT PORTD
-#define DIO5_PWM NULL
+#define DIO5_PWM 0
#define DIO5_DDR DDRD
#define DIO6_PIN PIND6
#define DIO6_RPORT PIND
#define DIO6_WPORT PORTD
-#define DIO6_PWM NULL
+#define DIO6_PWM 0
#define DIO6_DDR DDRD
#define DIO7_PIN PIND7
#define DIO7_RPORT PIND
#define DIO7_WPORT PORTD
-#define DIO7_PWM NULL
+#define DIO7_PWM 0
#define DIO7_DDR DDRD
#define DIO8_PIN PINE0
#define DIO8_RPORT PINE
#define DIO8_WPORT PORTE
-#define DIO8_PWM NULL
+#define DIO8_PWM 0
#define DIO8_DDR DDRE
#define DIO9_PIN PINE1
#define DIO9_RPORT PINE
#define DIO9_WPORT PORTE
-#define DIO9_PWM NULL
+#define DIO9_PWM 0
#define DIO9_DDR DDRE
#define DIO10_PIN PINC0
#define DIO10_RPORT PINC
#define DIO10_WPORT PORTC
-#define DIO10_PWM NULL
+#define DIO10_PWM 0
#define DIO10_DDR DDRC
#define DIO11_PIN PINC1
#define DIO11_RPORT PINC
#define DIO11_WPORT PORTC
-#define DIO11_PWM NULL
+#define DIO11_PWM 0
#define DIO11_DDR DDRC
#define DIO12_PIN PINC2
#define DIO12_RPORT PINC
#define DIO12_WPORT PORTC
-#define DIO12_PWM NULL
+#define DIO12_PWM 0
#define DIO12_DDR DDRC
#define DIO13_PIN PINC3
#define DIO13_RPORT PINC
#define DIO13_WPORT PORTC
-#define DIO13_PWM NULL
+#define DIO13_PWM 0
#define DIO13_DDR DDRC
#define DIO14_PIN PINC4
#define DIO14_RPORT PINC
#define DIO14_WPORT PORTC
-#define DIO14_PWM NULL
+#define DIO14_PWM 0 // OC3C
#define DIO14_DDR DDRC
#define DIO15_PIN PINC5
#define DIO15_RPORT PINC
#define DIO15_WPORT PORTC
-#define DIO15_PWM NULL
+#define DIO15_PWM 0 // OC3B
#define DIO15_DDR DDRC
#define DIO16_PIN PINC6
#define DIO16_RPORT PINC
#define DIO16_WPORT PORTC
-#define DIO16_PWM NULL
+#define DIO16_PWM 0 // OC3A
#define DIO16_DDR DDRC
#define DIO17_PIN PINC7
#define DIO17_RPORT PINC
#define DIO17_WPORT PORTC
-#define DIO17_PWM NULL
+#define DIO17_PWM 0
#define DIO17_DDR DDRC
#define DIO18_PIN PINE6
#define DIO18_RPORT PINE
#define DIO18_WPORT PORTE
-#define DIO18_PWM NULL
+#define DIO18_PWM 0
#define DIO18_DDR DDRE
#define DIO19_PIN PINE7
#define DIO19_RPORT PINE
#define DIO19_WPORT PORTE
-#define DIO19_PWM NULL
+#define DIO19_PWM 0
#define DIO19_DDR DDRE
#define DIO20_PIN PINB0
#define DIO20_RPORT PINB
#define DIO20_WPORT PORTB
-#define DIO20_PWM NULL
+#define DIO20_PWM 0
#define DIO20_DDR DDRB
#define DIO21_PIN PINB1
#define DIO21_RPORT PINB
#define DIO21_WPORT PORTB
-#define DIO21_PWM NULL
+#define DIO21_PWM 0
#define DIO21_DDR DDRB
#define DIO22_PIN PINB2
#define DIO22_RPORT PINB
#define DIO22_WPORT PORTB
-#define DIO22_PWM NULL
+#define DIO22_PWM 0
#define DIO22_DDR DDRB
#define DIO23_PIN PINB3
#define DIO23_RPORT PINB
#define DIO23_WPORT PORTB
-#define DIO23_PWM NULL
+#define DIO23_PWM 0
#define DIO23_DDR DDRB
#define DIO24_PIN PINB4
#define DIO24_RPORT PINB
#define DIO24_WPORT PORTB
-#define DIO24_PWM NULL
+#define DIO24_PWM 0 // OC2A
#define DIO24_DDR DDRB
#define DIO25_PIN PINB5
#define DIO25_RPORT PINB
#define DIO25_WPORT PORTB
-#define DIO25_PWM NULL
+#define DIO25_PWM 0 // OC1A
#define DIO25_DDR DDRB
#define DIO26_PIN PINB6
#define DIO26_RPORT PINB
#define DIO26_WPORT PORTB
-#define DIO26_PWM NULL
+#define DIO26_PWM 0 // OC1B
#define DIO26_DDR DDRB
#define DIO27_PIN PINB7
#define DIO27_RPORT PINB
#define DIO27_WPORT PORTB
-#define DIO27_PWM NULL
+#define DIO27_PWM 0 // OC1C
#define DIO27_DDR DDRB
#define DIO28_PIN PINA0
#define DIO28_RPORT PINA
#define DIO28_WPORT PORTA
-#define DIO28_PWM NULL
+#define DIO28_PWM 0
#define DIO28_DDR DDRA
#define DIO29_PIN PINA1
#define DIO29_RPORT PINA
#define DIO29_WPORT PORTA
-#define DIO29_PWM NULL
+#define DIO29_PWM 0
#define DIO29_DDR DDRA
#define DIO30_PIN PINA2
#define DIO30_RPORT PINA
#define DIO30_WPORT PORTA
-#define DIO30_PWM NULL
+#define DIO30_PWM 0
#define DIO30_DDR DDRA
#define DIO31_PIN PINA3
#define DIO31_RPORT PINA
#define DIO31_WPORT PORTA
-#define DIO31_PWM NULL
+#define DIO31_PWM 0
#define DIO31_DDR DDRA
#define DIO32_PIN PINA4
#define DIO32_RPORT PINA
#define DIO32_WPORT PORTA
-#define DIO32_PWM NULL
+#define DIO32_PWM 0
#define DIO32_DDR DDRA
#define DIO33_PIN PINA5
#define DIO33_RPORT PINA
#define DIO33_WPORT PORTA
-#define DIO33_PWM NULL
+#define DIO33_PWM 0
#define DIO33_DDR DDRA
#define DIO34_PIN PINA6
#define DIO34_RPORT PINA
#define DIO34_WPORT PORTA
-#define DIO34_PWM NULL
+#define DIO34_PWM 0
#define DIO34_DDR DDRA
#define DIO35_PIN PINA7
#define DIO35_RPORT PINA
#define DIO35_WPORT PORTA
-#define DIO35_PWM NULL
+#define DIO35_PWM 0
#define DIO35_DDR DDRA
#define DIO36_PIN PINE4
#define DIO36_RPORT PINE
#define DIO36_WPORT PORTE
-#define DIO36_PWM NULL
+#define DIO36_PWM 0
#define DIO36_DDR DDRE
#define DIO37_PIN PINE5
#define DIO37_RPORT PINE
#define DIO37_WPORT PORTE
-#define DIO37_PWM NULL
+#define DIO37_PWM 0
#define DIO37_DDR DDRE
#define DIO38_PIN PINF0
#define DIO38_RPORT PINF
#define DIO38_WPORT PORTF
-#define DIO38_PWM NULL
+#define DIO38_PWM 0
#define DIO38_DDR DDRF
#define DIO39_PIN PINF1
#define DIO39_RPORT PINF
#define DIO39_WPORT PORTF
-#define DIO39_PWM NULL
+#define DIO39_PWM 0
#define DIO39_DDR DDRF
#define DIO40_PIN PINF2
#define DIO40_RPORT PINF
#define DIO40_WPORT PORTF
-#define DIO40_PWM NULL
+#define DIO40_PWM 0
#define DIO40_DDR DDRF
#define DIO41_PIN PINF3
#define DIO41_RPORT PINF
#define DIO41_WPORT PORTF
-#define DIO41_PWM NULL
+#define DIO41_PWM 0
#define DIO41_DDR DDRF
#define DIO42_PIN PINF4
#define DIO42_RPORT PINF
#define DIO42_WPORT PORTF
-#define DIO42_PWM NULL
+#define DIO42_PWM 0
#define DIO42_DDR DDRF
#define DIO43_PIN PINF5
#define DIO43_RPORT PINF
#define DIO43_WPORT PORTF
-#define DIO43_PWM NULL
+#define DIO43_PWM 0
#define DIO43_DDR DDRF
#define DIO44_PIN PINF6
#define DIO44_RPORT PINF
#define DIO44_WPORT PORTF
-#define DIO44_PWM NULL
+#define DIO44_PWM 0
#define DIO44_DDR DDRF
#define DIO45_PIN PINF7
#define DIO45_RPORT PINF
#define DIO45_WPORT PORTF
-#define DIO45_PWM NULL
+#define DIO45_PWM 0
#define DIO45_DDR DDRF
#define AIO0_PIN PINF0
#define AIO0_RPORT PINF
#define AIO0_WPORT PORTF
-#define AIO0_PWM NULL
+#define AIO0_PWM 0
#define AIO0_DDR DDRF
#define AIO1_PIN PINF1
#define AIO1_RPORT PINF
#define AIO1_WPORT PORTF
-#define AIO1_PWM NULL
+#define AIO1_PWM 0
#define AIO1_DDR DDRF
#define AIO2_PIN PINF2
#define AIO2_RPORT PINF
#define AIO2_WPORT PORTF
-#define AIO2_PWM NULL
+#define AIO2_PWM 0
#define AIO2_DDR DDRF
#define AIO3_PIN PINF3
#define AIO3_RPORT PINF
#define AIO3_WPORT PORTF
-#define AIO3_PWM NULL
+#define AIO3_PWM 0
#define AIO3_DDR DDRF
#define AIO4_PIN PINF4
#define AIO4_RPORT PINF
#define AIO4_WPORT PORTF
-#define AIO4_PWM NULL
+#define AIO4_PWM 0
#define AIO4_DDR DDRF
#define AIO5_PIN PINF5
#define AIO5_RPORT PINF
#define AIO5_WPORT PORTF
-#define AIO5_PWM NULL
+#define AIO5_PWM 0
#define AIO5_DDR DDRF
#define AIO6_PIN PINF6
#define AIO6_RPORT PINF
#define AIO6_WPORT PORTF
-#define AIO6_PWM NULL
+#define AIO6_PWM 0
#define AIO6_DDR DDRF
#define AIO7_PIN PINF7
#define AIO7_RPORT PINF
#define AIO7_WPORT PORTF
-#define AIO7_PWM NULL
+#define AIO7_PWM 0
#define AIO7_DDR DDRF
//-- Begin not supported by Teensyduino
@@ -371,13 +371,13 @@
#define DIO46_PIN PINE2
#define DIO46_RPORT PINE
#define DIO46_WPORT PORTE
-#define DIO46_PWM NULL
+#define DIO46_PWM 0
#define DIO46_DDR DDRE
#define DIO47_PIN PINE3
#define DIO47_RPORT PINE
#define DIO47_WPORT PORTE
-#define DIO47_PWM NULL
+#define DIO47_PWM 0
#define DIO47_DDR DDRE
#define TEENSY_E2 46
@@ -389,300 +389,300 @@
#define PA0_PIN PINA0
#define PA0_RPORT PINA
#define PA0_WPORT PORTA
-#define PA0_PWM NULL
+#define PA0_PWM 0
#define PA0_DDR DDRA
#undef PA1
#define PA1_PIN PINA1
#define PA1_RPORT PINA
#define PA1_WPORT PORTA
-#define PA1_PWM NULL
+#define PA1_PWM 0
#define PA1_DDR DDRA
#undef PA2
#define PA2_PIN PINA2
#define PA2_RPORT PINA
#define PA2_WPORT PORTA
-#define PA2_PWM NULL
+#define PA2_PWM 0
#define PA2_DDR DDRA
#undef PA3
#define PA3_PIN PINA3
#define PA3_RPORT PINA
#define PA3_WPORT PORTA
-#define PA3_PWM NULL
+#define PA3_PWM 0
#define PA3_DDR DDRA
#undef PA4
#define PA4_PIN PINA4
#define PA4_RPORT PINA
#define PA4_WPORT PORTA
-#define PA4_PWM NULL
+#define PA4_PWM 0
#define PA4_DDR DDRA
#undef PA5
#define PA5_PIN PINA5
#define PA5_RPORT PINA
#define PA5_WPORT PORTA
-#define PA5_PWM NULL
+#define PA5_PWM 0
#define PA5_DDR DDRA
#undef PA6
#define PA6_PIN PINA6
#define PA6_RPORT PINA
#define PA6_WPORT PORTA
-#define PA6_PWM NULL
+#define PA6_PWM 0
#define PA6_DDR DDRA
#undef PA7
#define PA7_PIN PINA7
#define PA7_RPORT PINA
#define PA7_WPORT PORTA
-#define PA7_PWM NULL
+#define PA7_PWM 0
#define PA7_DDR DDRA
#undef PB0
#define PB0_PIN PINB0
#define PB0_RPORT PINB
#define PB0_WPORT PORTB
-#define PB0_PWM NULL
+#define PB0_PWM 0
#define PB0_DDR DDRB
#undef PB1
#define PB1_PIN PINB1
#define PB1_RPORT PINB
#define PB1_WPORT PORTB
-#define PB1_PWM NULL
+#define PB1_PWM 0
#define PB1_DDR DDRB
#undef PB2
#define PB2_PIN PINB2
#define PB2_RPORT PINB
#define PB2_WPORT PORTB
-#define PB2_PWM NULL
+#define PB2_PWM 0
#define PB2_DDR DDRB
#undef PB3
#define PB3_PIN PINB3
#define PB3_RPORT PINB
#define PB3_WPORT PORTB
-#define PB3_PWM NULL
+#define PB3_PWM 0
#define PB3_DDR DDRB
#undef PB4
#define PB4_PIN PINB4
#define PB4_RPORT PINB
#define PB4_WPORT PORTB
-#define PB4_PWM NULL
+#define PB4_PWM 0
#define PB4_DDR DDRB
#undef PB5
#define PB5_PIN PINB5
#define PB5_RPORT PINB
#define PB5_WPORT PORTB
-#define PB5_PWM NULL
+#define PB5_PWM 0
#define PB5_DDR DDRB
#undef PB6
#define PB6_PIN PINB6
#define PB6_RPORT PINB
#define PB6_WPORT PORTB
-#define PB6_PWM NULL
+#define PB6_PWM 0
#define PB6_DDR DDRB
#undef PB7
#define PB7_PIN PINB7
#define PB7_RPORT PINB
#define PB7_WPORT PORTB
-#define PB7_PWM NULL
+#define PB7_PWM 0
#define PB7_DDR DDRB
#undef PC0
#define PC0_PIN PINC0
#define PC0_RPORT PINC
#define PC0_WPORT PORTC
-#define PC0_PWM NULL
+#define PC0_PWM 0
#define PC0_DDR DDRC
#undef PC1
#define PC1_PIN PINC1
#define PC1_RPORT PINC
#define PC1_WPORT PORTC
-#define PC1_PWM NULL
+#define PC1_PWM 0
#define PC1_DDR DDRC
#undef PC2
#define PC2_PIN PINC2
#define PC2_RPORT PINC
#define PC2_WPORT PORTC
-#define PC2_PWM NULL
+#define PC2_PWM 0
#define PC2_DDR DDRC
#undef PC3
#define PC3_PIN PINC3
#define PC3_RPORT PINC
#define PC3_WPORT PORTC
-#define PC3_PWM NULL
+#define PC3_PWM 0
#define PC3_DDR DDRC
#undef PC4
#define PC4_PIN PINC4
#define PC4_RPORT PINC
#define PC4_WPORT PORTC
-#define PC4_PWM NULL
+#define PC4_PWM 0
#define PC4_DDR DDRC
#undef PC5
#define PC5_PIN PINC5
#define PC5_RPORT PINC
#define PC5_WPORT PORTC
-#define PC5_PWM NULL
+#define PC5_PWM 0
#define PC5_DDR DDRC
#undef PC6
#define PC6_PIN PINC6
#define PC6_RPORT PINC
#define PC6_WPORT PORTC
-#define PC6_PWM NULL
+#define PC6_PWM 0
#define PC6_DDR DDRC
#undef PC7
#define PC7_PIN PINC7
#define PC7_RPORT PINC
#define PC7_WPORT PORTC
-#define PC7_PWM NULL
+#define PC7_PWM 0
#define PC7_DDR DDRC
#undef PD0
#define PD0_PIN PIND0
#define PD0_RPORT PIND
#define PD0_WPORT PORTD
-#define PD0_PWM NULL
+#define PD0_PWM 0 // OC0B
#define PD0_DDR DDRD
#undef PD1
#define PD1_PIN PIND1
#define PD1_RPORT PIND
#define PD1_WPORT PORTD
-#define PD1_PWM NULL
+#define PD1_PWM 0 // OC2B
#define PD1_DDR DDRD
#undef PD2
#define PD2_PIN PIND2
#define PD2_RPORT PIND
#define PD2_WPORT PORTD
-#define PD2_PWM NULL
+#define PD2_PWM 0
#define PD2_DDR DDRD
#undef PD3
#define PD3_PIN PIND3
#define PD3_RPORT PIND
#define PD3_WPORT PORTD
-#define PD3_PWM NULL
+#define PD3_PWM 0
#define PD3_DDR DDRD
#undef PD4
#define PD4_PIN PIND4
#define PD4_RPORT PIND
#define PD4_WPORT PORTD
-#define PD4_PWM NULL
+#define PD4_PWM 0
#define PD4_DDR DDRD
#undef PD5
#define PD5_PIN PIND5
#define PD5_RPORT PIND
#define PD5_WPORT PORTD
-#define PD5_PWM NULL
+#define PD5_PWM 0
#define PD5_DDR DDRD
#undef PD6
#define PD6_PIN PIND6
#define PD6_RPORT PIND
#define PD6_WPORT PORTD
-#define PD6_PWM NULL
+#define PD6_PWM 0
#define PD6_DDR DDRD
#undef PD7
#define PD7_PIN PIND7
#define PD7_RPORT PIND
#define PD7_WPORT PORTD
-#define PD7_PWM NULL
+#define PD7_PWM 0
#define PD7_DDR DDRD
#undef PE0
#define PE0_PIN PINE0
#define PE0_RPORT PINE
#define PE0_WPORT PORTE
-#define PE0_PWM NULL
+#define PE0_PWM 0
#define PE0_DDR DDRE
#undef PE1
#define PE1_PIN PINE1
#define PE1_RPORT PINE
#define PE1_WPORT PORTE
-#define PE1_PWM NULL
+#define PE1_PWM 0
#define PE1_DDR DDRE
#undef PE2
#define PE2_PIN PINE2
#define PE2_RPORT PINE
#define PE2_WPORT PORTE
-#define PE2_PWM NULL
+#define PE2_PWM 0
#define PE2_DDR DDRE
#undef PE3
#define PE3_PIN PINE3
#define PE3_RPORT PINE
#define PE3_WPORT PORTE
-#define PE3_PWM NULL
+#define PE3_PWM 0
#define PE3_DDR DDRE
#undef PE4
#define PE4_PIN PINE4
#define PE4_RPORT PINE
#define PE4_WPORT PORTE
-#define PE4_PWM NULL
+#define PE4_PWM 0
#define PE4_DDR DDRE
#undef PE5
#define PE5_PIN PINE5
#define PE5_RPORT PINE
#define PE5_WPORT PORTE
-#define PE5_PWM NULL
+#define PE5_PWM 0
#define PE5_DDR DDRE
#undef PE6
#define PE6_PIN PINE6
#define PE6_RPORT PINE
#define PE6_WPORT PORTE
-#define PE6_PWM NULL
+#define PE6_PWM 0
#define PE6_DDR DDRE
#undef PE7
#define PE7_PIN PINE7
#define PE7_RPORT PINE
#define PE7_WPORT PORTE
-#define PE7_PWM NULL
+#define PE7_PWM 0
#define PE7_DDR DDRE
#undef PF0
#define PF0_PIN PINF0
#define PF0_RPORT PINF
#define PF0_WPORT PORTF
-#define PF0_PWM NULL
+#define PF0_PWM 0
#define PF0_DDR DDRF
#undef PF1
#define PF1_PIN PINF1
#define PF1_RPORT PINF
#define PF1_WPORT PORTF
-#define PF1_PWM NULL
+#define PF1_PWM 0
#define PF1_DDR DDRF
#undef PF2
#define PF2_PIN PINF2
#define PF2_RPORT PINF
#define PF2_WPORT PORTF
-#define PF2_PWM NULL
+#define PF2_PWM 0
#define PF2_DDR DDRF
#undef PF3
#define PF3_PIN PINF3
#define PF3_RPORT PINF
#define PF3_WPORT PORTF
-#define PF3_PWM NULL
+#define PF3_PWM 0
#define PF3_DDR DDRF
#undef PF4
#define PF4_PIN PINF4
#define PF4_RPORT PINF
#define PF4_WPORT PORTF
-#define PF4_PWM NULL
+#define PF4_PWM 0
#define PF4_DDR DDRF
#undef PF5
#define PF5_PIN PINF5
#define PF5_RPORT PINF
#define PF5_WPORT PORTF
-#define PF5_PWM NULL
+#define PF5_PWM 0
#define PF5_DDR DDRF
#undef PF6
#define PF6_PIN PINF6
#define PF6_RPORT PINF
#define PF6_WPORT PORTF
-#define PF6_PWM NULL
+#define PF6_PWM 0
#define PF6_DDR DDRF
#undef PF7
#define PF7_PIN PINF7
#define PF7_RPORT PINF
#define PF7_WPORT PORTF
-#define PF7_PWM NULL
+#define PF7_PWM 0
#define PF7_DDR DDRF
/**
- * some of the pin mapping functions of the Teensduino extension to the Arduino IDE
- * do not function the same as the other Arduino extensions
+ * Some of the pin mapping functions of the Teensduino extension to the Arduino IDE
+ * do not function the same as the other Arduino extensions.
*/
//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
diff --git a/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h b/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/AVR/inc/Conditionals_adv.h b/Marlin/src/HAL/AVR/inc/Conditionals_adv.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/AVR/inc/Conditionals_adv.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/AVR/inc/Conditionals_post.h b/Marlin/src/HAL/AVR/inc/Conditionals_post.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/AVR/inc/Conditionals_post.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h
new file mode 100644
index 0000000000..ccdd391114
--- /dev/null
+++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h
@@ -0,0 +1,55 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+/**
+ * Test AVR-specific configuration values for errors at compile-time.
+ */
+
+/**
+ * Checks for FAST PWM
+ */
+#if ENABLED(FAST_PWM_FAN) && (ENABLED(USE_OCR2A_AS_TOP) && defined(TCCR2))
+ #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2"
+#endif
+
+/**
+ * Sanity checks for Spindle / Laser PWM
+ */
+#if ENABLED(SPINDLE_LASER_PWM)
+ #if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13)
+ #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt."
+ #elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
+ #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
+ #endif
+#endif
+
+/**
+ * The Trinamic library includes SoftwareSerial.h, leading to a compile error.
+ */
+#if BOTH(HAS_TRINAMIC_CONFIG, ENDSTOP_INTERRUPTS_FEATURE)
+ #error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+#endif
+
+#if BOTH(HAS_TMC_SW_SERIAL, MONITOR_DRIVER_STATUS)
+ #error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
+#endif
diff --git a/Marlin/src/HAL/HAL_AVR/math_AVR.h b/Marlin/src/HAL/AVR/math.h
similarity index 96%
rename from Marlin/src/HAL/HAL_AVR/math_AVR.h
rename to Marlin/src/HAL/AVR/math.h
index 8299b8bbd3..e8be0a04bc 100644
--- a/Marlin/src/HAL/HAL_AVR/math_AVR.h
+++ b/Marlin/src/HAL/AVR/math.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h
similarity index 93%
rename from Marlin/src/HAL/HAL_AVR/pinsDebug.h
rename to Marlin/src/HAL/AVR/pinsDebug.h
index 8df4ffcf87..fbd2e084fa 100644
--- a/Marlin/src/HAL/HAL_AVR/pinsDebug.h
+++ b/Marlin/src/HAL/AVR/pinsDebug.h
@@ -1,9 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +26,10 @@
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
+#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H)
+
#if AVR_AT90USB1286_FAMILY
+
// Working with Teensyduino extension so need to re-define some things
#include "pinsDebug_Teensyduino.h"
// Can't use the "digitalPinToPort" function from the Teensyduino type IDEs
@@ -38,7 +38,9 @@
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
#define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p)
#define GET_PINMODE(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin))
+
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
+
#include "pinsDebug_plus_70.h"
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer_plus_70(p)
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask_plus_70(p)
@@ -46,11 +48,13 @@
bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
#else
+
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
#define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin)
+
#endif
#define VALID_PIN(pin) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0)
@@ -66,12 +70,12 @@
void PRINT_ARRAY_NAME(uint8_t x) {
char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name);
- for (uint8_t y = 0; y < MAX_NAME_LENGTH; y++) {
+ LOOP_L_N(y, MAX_NAME_LENGTH) {
char temp_char = pgm_read_byte(name_mem_pointer + y);
if (temp_char != 0)
SERIAL_CHAR(temp_char);
else {
- for (uint8_t i = 0; i < MAX_NAME_LENGTH - y; i++) SERIAL_CHAR(' ');
+ LOOP_L_N(i, MAX_NAME_LENGTH - y) SERIAL_CHAR(' ');
break;
}
}
@@ -227,21 +231,11 @@ static void err_is_interrupt() { SERIAL_ECHOPGM(" compare interrupt enabled"
static void err_prob_interrupt() { SERIAL_ECHOPGM(" overflow interrupt enabled"); }
static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); SERIAL_ECHO_SP(14); }
-void com_print(uint8_t N, uint8_t Z) {
+inline void com_print(const uint8_t N, const uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPGM(" COM");
- SERIAL_CHAR(N + '0');
- switch (Z) {
- case 'A':
- SERIAL_ECHOPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6));
- break;
- case 'B':
- SERIAL_ECHOPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4));
- break;
- case 'C':
- SERIAL_ECHOPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2));
- break;
- }
+ SERIAL_CHAR('0' + N, Z);
+ SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}
void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout
@@ -252,8 +246,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
SERIAL_ECHOPGM(" TIMER");
- SERIAL_CHAR(T + '0');
- SERIAL_CHAR(L);
+ SERIAL_CHAR(T + '0', L);
SERIAL_ECHO_SP(3);
if (N == 3) {
@@ -356,6 +349,8 @@ static void pwm_details(uint8_t pin) {
timer_prefix(0, 'A', 3);
#endif
}
+ #else
+ UNUSED(print_is_also_tied);
#endif
} // pwm_details
@@ -403,4 +398,4 @@ static void pwm_details(uint8_t pin) {
#endif
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer);} while (0)
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
diff --git a/Marlin/src/HAL/HAL_AVR/pinsDebug_Teensyduino.h b/Marlin/src/HAL/AVR/pinsDebug_Teensyduino.h
similarity index 94%
rename from Marlin/src/HAL/HAL_AVR/pinsDebug_Teensyduino.h
rename to Marlin/src/HAL/AVR/pinsDebug_Teensyduino.h
index e97d694bb0..f6da077743 100644
--- a/Marlin/src/HAL/HAL_AVR/pinsDebug_Teensyduino.h
+++ b/Marlin/src/HAL/AVR/pinsDebug_Teensyduino.h
@@ -1,9 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_AVR/pinsDebug_plus_70.h b/Marlin/src/HAL/AVR/pinsDebug_plus_70.h
similarity index 97%
rename from Marlin/src/HAL/HAL_AVR/pinsDebug_plus_70.h
rename to Marlin/src/HAL/AVR/pinsDebug_plus_70.h
index 028c8f02a4..6e7b8fbaa9 100644
--- a/Marlin/src/HAL/HAL_AVR/pinsDebug_plus_70.h
+++ b/Marlin/src/HAL/AVR/pinsDebug_plus_70.h
@@ -1,9 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,7 +47,7 @@
const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
// PORTLIST
- // -------------------------------------------
+ // ------------------------
PE , // PE 0 ** 0 ** USART0_RX
PE , // PE 1 ** 1 ** USART0_TX
PE , // PE 4 ** 2 ** PWM2
@@ -143,7 +140,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
// PIN IN PORT
- // -------------------------------------------
+ // ------------------------
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
_BV( 4 ) , // PE 4 ** 2 ** PWM2
@@ -237,7 +234,7 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
const uint8_t PROGMEM digital_pin_to_timer_PGM_plus_70[] = {
// TIMERS
- // -------------------------------------------
+ // ------------------------
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
TIMER3B , // PE 4 ** 2 ** PWM2
diff --git a/Marlin/src/HAL/HAL_AVR/spi_pins.h b/Marlin/src/HAL/AVR/spi_pins.h
similarity index 94%
rename from Marlin/src/HAL/HAL_AVR/spi_pins.h
rename to Marlin/src/HAL/AVR/spi_pins.h
index 85d2d8f6e5..daaebb76d7 100644
--- a/Marlin/src/HAL/HAL_AVR/spi_pins.h
+++ b/Marlin/src/HAL/AVR/spi_pins.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
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
new file mode 100644
index 0000000000..fab79646f0
--- /dev/null
+++ b/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp
@@ -0,0 +1,193 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Based on u8g_com_st7920_hw_spi.c
+ *
+ * Universal 8bit Graphics Library
+ *
+ * Copyright (c) 2011, olikraus@gmail.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if defined(ARDUINO) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_SAM)
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if HAS_GRAPHICAL_LCD
+
+#include "../shared/Marduino.h"
+#include "../shared/Delay.h"
+
+#include
+
+uint8_t u8g_bitData, u8g_bitNotData, u8g_bitClock, u8g_bitNotClock;
+volatile uint8_t *u8g_outData, *u8g_outClock;
+
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin) {
+ u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
+ u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
+ u8g_bitData = digitalPinToBitMask(dataPin);
+ u8g_bitClock = digitalPinToBitMask(clockPin);
+
+ u8g_bitNotClock = u8g_bitClock;
+ u8g_bitNotClock ^= 0xFF;
+
+ u8g_bitNotData = u8g_bitData;
+ u8g_bitNotData ^= 0xFF;
+}
+
+void u8g_spiSend_sw_AVR_mode_0(uint8_t val) {
+ uint8_t bitData = u8g_bitData,
+ bitNotData = u8g_bitNotData,
+ bitClock = u8g_bitClock,
+ bitNotClock = u8g_bitNotClock;
+ volatile uint8_t *outData = u8g_outData,
+ *outClock = u8g_outClock;
+ U8G_ATOMIC_START();
+ LOOP_L_N(i, 8) {
+ if (val & 0x80)
+ *outData |= bitData;
+ else
+ *outData &= bitNotData;
+ *outClock |= bitClock;
+ val <<= 1;
+ *outClock &= bitNotClock;
+ }
+ U8G_ATOMIC_END();
+}
+
+void u8g_spiSend_sw_AVR_mode_3(uint8_t val) {
+ uint8_t bitData = u8g_bitData,
+ bitNotData = u8g_bitNotData,
+ bitClock = u8g_bitClock,
+ bitNotClock = u8g_bitNotClock;
+ volatile uint8_t *outData = u8g_outData,
+ *outClock = u8g_outClock;
+ U8G_ATOMIC_START();
+ LOOP_L_N(i, 8) {
+ *outClock &= bitNotClock;
+ if (val & 0x80)
+ *outData |= bitData;
+ else
+ *outData &= bitNotData;
+ *outClock |= bitClock;
+ val <<= 1;
+ }
+ U8G_ATOMIC_END();
+}
+
+
+#if ENABLED(FYSETC_MINI_12864)
+ #define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_3
+#else
+ #define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_0
+#endif
+
+uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
+ switch (msg) {
+ case U8G_COM_MSG_INIT:
+ u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
+ u8g_com_arduino_assign_pin_output_high(u8g);
+ u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 0);
+ u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, 0);
+ break;
+
+ case U8G_COM_MSG_STOP:
+ break;
+
+ case U8G_COM_MSG_RESET:
+ if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
+ break;
+
+ case U8G_COM_MSG_CHIP_SELECT:
+ #if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
+ if (arg_val) { // SCK idle state needs to be set to the proper idle state before
+ // the next chip select goes active
+ u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
+ u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
+ }
+ else {
+ u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
+ u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive
+ }
+ #else
+ u8g_com_arduino_digital_write(u8g, U8G_PI_CS, !arg_val);
+ #endif
+ break;
+
+ case U8G_COM_MSG_WRITE_BYTE:
+ SPISEND_SW_AVR(arg_val);
+ break;
+
+ case U8G_COM_MSG_WRITE_SEQ: {
+ uint8_t *ptr = (uint8_t *)arg_ptr;
+ while (arg_val > 0) {
+ SPISEND_SW_AVR(*ptr++);
+ arg_val--;
+ }
+ }
+ break;
+
+ case U8G_COM_MSG_WRITE_SEQ_P: {
+ uint8_t *ptr = (uint8_t *)arg_ptr;
+ while (arg_val > 0) {
+ SPISEND_SW_AVR(u8g_pgm_read(ptr));
+ ptr++;
+ arg_val--;
+ }
+ }
+ break;
+
+ case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
+ u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
+ break;
+ }
+ return 1;
+}
+
+#endif // HAS_GRAPHICAL_LCD
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp b/Marlin/src/HAL/AVR/watchdog.cpp
similarity index 88%
rename from Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp
rename to Marlin/src/HAL/AVR/watchdog.cpp
index 7c65a904f4..ef1ed0e596 100644
--- a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp
+++ b/Marlin/src/HAL/AVR/watchdog.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,16 +19,15 @@
* along with this program. If not, see .
*
*/
-
#ifdef __AVR__
#include "../../inc/MarlinConfig.h"
#if ENABLED(USE_WATCHDOG)
-#include "watchdog_AVR.h"
+#include "watchdog.h"
-#include "../../Marlin.h"
+#include "../../MarlinCore.h"
// Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
void watchdog_init() {
@@ -38,7 +37,7 @@ void watchdog_init() {
#define WDTO_NS WDTO_4S
#endif
#if ENABLED(WATCHDOG_RESET_MANUAL)
- // We enable the watchdog timer, but only for the interrupt.
+ // Enable the watchdog timer, but only for the interrupt.
// Take care, as this requires the correct order of operation, with interrupts disabled.
// See the datasheet of any AVR chip for details.
wdt_reset();
@@ -62,10 +61,10 @@ void watchdog_init() {
#if ENABLED(WATCHDOG_RESET_MANUAL)
ISR(WDT_vect) {
sei(); // With the interrupt driven serial we need to allow interrupts.
- SERIAL_ERROR_MSG(MSG_WATCHDOG_FIRED);
+ SERIAL_ERROR_MSG(STR_WATCHDOG_FIRED);
minkill(); // interrupt-safe final kill and infinite loop
}
-#endif // WATCHDOG_RESET_MANUAL
+#endif
#endif // USE_WATCHDOG
#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.h b/Marlin/src/HAL/AVR/watchdog.h
similarity index 85%
rename from Marlin/src/HAL/HAL_AVR/watchdog_AVR.h
rename to Marlin/src/HAL/AVR/watchdog.h
index ed5150fe08..57dfcfc0bf 100644
--- a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.h
+++ b/Marlin/src/HAL/AVR/watchdog.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,4 +28,4 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or AVR will go into emergency procedures.
-inline void watchdog_reset() { wdt_reset(); }
+inline void HAL_watchdog_refresh() { wdt_reset(); }
diff --git a/Marlin/src/HAL/HAL_DUE/DebugMonitor_Due.cpp b/Marlin/src/HAL/DUE/DebugMonitor.cpp
similarity index 93%
rename from Marlin/src/HAL/HAL_DUE/DebugMonitor_Due.cpp
rename to Marlin/src/HAL/DUE/DebugMonitor.cpp
index 89206fa94c..84ea137ad7 100644
--- a/Marlin/src/HAL/HAL_DUE/DebugMonitor_Due.cpp
+++ b/Marlin/src/HAL/DUE/DebugMonitor.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,16 +19,16 @@
* along with this program. If not, see .
*
*/
-
#ifdef ARDUINO_ARCH_SAM
#include "../../core/macros.h"
#include "../../core/serial.h"
-#include
#include "../shared/backtrace/unwinder.h"
#include "../shared/backtrace/unwmemaccess.h"
+#include
+
// Debug monitor that dumps to the Programming port all status when
// an exception or WDT timeout happens - And then resets the board
@@ -41,7 +41,7 @@
#define sw_barrier() __asm__ volatile("": : :"memory");
// (re)initialize UART0 as a monitor output to 250000,n,8,1
-static void TXBegin(void) {
+static void TXBegin() {
// Disable UART interrupt in NVIC
NVIC_DisableIRQ( UART_IRQn );
@@ -234,7 +234,7 @@ void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause
for (;;) WDT_Restart(WDT);
}
-__attribute__((naked)) void NMI_Handler(void) {
+__attribute__((naked)) void NMI_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -247,7 +247,7 @@ __attribute__((naked)) void NMI_Handler(void) {
);
}
-__attribute__((naked)) void HardFault_Handler(void) {
+__attribute__((naked)) void HardFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -260,7 +260,7 @@ __attribute__((naked)) void HardFault_Handler(void) {
);
}
-__attribute__((naked)) void MemManage_Handler(void) {
+__attribute__((naked)) void MemManage_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -273,7 +273,7 @@ __attribute__((naked)) void MemManage_Handler(void) {
);
}
-__attribute__((naked)) void BusFault_Handler(void) {
+__attribute__((naked)) void BusFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -286,7 +286,7 @@ __attribute__((naked)) void BusFault_Handler(void) {
);
}
-__attribute__((naked)) void UsageFault_Handler(void) {
+__attribute__((naked)) void UsageFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -299,7 +299,7 @@ __attribute__((naked)) void UsageFault_Handler(void) {
);
}
-__attribute__((naked)) void DebugMon_Handler(void) {
+__attribute__((naked)) void DebugMon_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -313,7 +313,7 @@ __attribute__((naked)) void DebugMon_Handler(void) {
}
/* This is NOT an exception, it is an interrupt handler - Nevertheless, the framing is the same */
-__attribute__((naked)) void WDT_Handler(void) {
+__attribute__((naked)) void WDT_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -326,7 +326,7 @@ __attribute__((naked)) void WDT_Handler(void) {
);
}
-__attribute__((naked)) void RSTC_Handler(void) {
+__attribute__((naked)) void RSTC_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp
new file mode 100644
index 0000000000..cb381ff4bb
--- /dev/null
+++ b/Marlin/src/HAL/DUE/HAL.cpp
@@ -0,0 +1,106 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+#include "../../inc/MarlinConfig.h"
+#include "HAL.h"
+
+#include
+#include "usb/usb_task.h"
+
+// ------------------------
+// Public Variables
+// ------------------------
+
+uint16_t HAL_adc_result;
+
+// ------------------------
+// Public functions
+// ------------------------
+
+// HAL initialization task
+void HAL_init() {
+ // Initialize the USB stack
+ #if ENABLED(SDSUPPORT)
+ OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
+ #endif
+ usb_task_init();
+}
+
+// HAL idle task
+void HAL_idletask() {
+ // Perform USB stack housekeeping
+ usb_task_idle();
+}
+
+// Disable interrupts
+void cli() { noInterrupts(); }
+
+// Enable interrupts
+void sei() { interrupts(); }
+
+void HAL_clear_reset_source() { }
+
+uint8_t HAL_get_reset_source() {
+ switch ((RSTC->RSTC_SR >> 8) & 0x07) {
+ case 0: return RST_POWER_ON;
+ case 1: return RST_BACKUP;
+ case 2: return RST_WATCHDOG;
+ case 3: return RST_SOFTWARE;
+ case 4: return RST_EXTERNAL;
+ default: return 0;
+ }
+}
+
+void _delay_ms(const int delay_ms) {
+ // Todo: port for Due?
+ delay(delay_ms);
+}
+
+extern "C" {
+ extern unsigned int _ebss; // end of bss section
+}
+
+// Return free memory between end of heap (or end bss) and whatever is current
+int freeMemory() {
+ int free_memory, heap_end = (int)_sbrk(0);
+ return (int)&free_memory - (heap_end ?: (int)&_ebss);
+}
+
+// ------------------------
+// ADC
+// ------------------------
+
+void HAL_adc_start_conversion(const uint8_t ch) {
+ HAL_adc_result = analogRead(ch);
+}
+
+uint16_t HAL_adc_get_result() {
+ // nop
+ return HAL_adc_result;
+}
+
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h
new file mode 100644
index 0000000000..0624c5b401
--- /dev/null
+++ b/Marlin/src/HAL/DUE/HAL.h
@@ -0,0 +1,190 @@
+/**
+ * Marlin 3D Printer Firmware
+ *
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#define CPU_32_BIT
+
+#include "../shared/Marduino.h"
+#include "../shared/eeprom_if.h"
+#include "../shared/math_32bit.h"
+#include "../shared/HAL_SPI.h"
+#include "fastio.h"
+#include "watchdog.h"
+#include "timers.h"
+
+#include
+
+// Define MYSERIAL0/1 before MarlinSerial includes!
+#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
+ #define MYSERIAL0 customizedSerial1
+#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 == 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 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 DGUS_SERIAL_PORT
+ #if DGUS_SERIAL_PORT == SERIAL_PORT
+ #error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
+ #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
+ #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
+ #elif DGUS_SERIAL_PORT == -1
+ #define DGUS_SERIAL internalDgusSerial
+ #elif DGUS_SERIAL_PORT == 0
+ #define DGUS_SERIAL Serial
+ #elif DGUS_SERIAL_PORT == 1
+ #define DGUS_SERIAL Serial1
+ #elif DGUS_SERIAL_PORT == 2
+ #define DGUS_SERIAL Serial2
+ #elif DGUS_SERIAL_PORT == 3
+ #define DGUS_SERIAL Serial3
+ #else
+ #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+ #endif
+#endif
+
+#include "MarlinSerial.h"
+#include "MarlinSerialUSB.h"
+
+// On AVR this is in math.h?
+#define square(x) ((x)*(x))
+
+#ifndef strncpy_P
+ #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
+#endif
+
+// Fix bug in pgm_read_ptr
+#undef pgm_read_ptr
+#define pgm_read_ptr(addr) (*((void**)(addr)))
+#undef pgm_read_word
+#define pgm_read_word(addr) (*((uint16_t*)(addr)))
+
+typedef int8_t pin_t;
+
+#define SHARED_SERVOS HAS_SERVOS
+#define HAL_SERVO_LIB Servo
+
+//
+// Interrupts
+//
+#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
+#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
+#define ISRS_ENABLED() (!__get_PRIMASK())
+#define ENABLE_ISRS() __enable_irq()
+#define DISABLE_ISRS() __disable_irq()
+
+void cli(); // Disable interrupts
+void sei(); // Enable interrupts
+
+void HAL_clear_reset_source(); // clear reset reason
+uint8_t HAL_get_reset_source(); // get reset reason
+
+//
+// ADC
+//
+extern uint16_t HAL_adc_result; // result of last ADC conversion
+
+#ifndef analogInputToDigitalPin
+ #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
+#endif
+
+#define HAL_ANALOG_SELECT(ch)
+
+inline void HAL_adc_init() {}//todo
+
+#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
+#define HAL_ADC_RESOLUTION 10
+#define HAL_READ_ADC() HAL_adc_result
+#define HAL_ADC_READY() true
+
+void HAL_adc_start_conversion(const uint8_t ch);
+uint16_t HAL_adc_get_result();
+
+//
+// Pin Map
+//
+#define GET_PIN_MAP_PIN(index) index
+#define GET_PIN_MAP_INDEX(pin) pin
+#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
+
+//
+// Tone
+//
+void toneInit();
+void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
+void noTone(const pin_t _pin);
+
+// Enable hooks into idle and setup for HAL
+#define HAL_IDLETASK 1
+void HAL_idletask();
+void HAL_init();
+
+//
+// Utility functions
+//
+void _delay_ms(const int delay);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+int freeMemory();
+#pragma GCC diagnostic pop
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
+#ifdef __cplusplus
+ }
+#endif
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp
similarity index 92%
rename from Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp
rename to Marlin/src/HAL/DUE/HAL_SPI.cpp
index a1934886f9..97a6fa05a1 100644
--- a/Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp
+++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
/**
* Software SPI functions originally from Arduino Sd2Card Library
- * Copyright (C) 2009 by William Greiman
+ * Copyright (c) 2009 by William Greiman
*
* Completely rewritten and tuned by Eduardo José Tagle in 2017/2018
* in ARM thumb2 inline assembler and tuned for maximum speed and performance
@@ -37,27 +37,18 @@
#ifdef ARDUINO_ARCH_SAM
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
-#if ENABLED(DUE_SOFTWARE_SPI)
+#if EITHER(DUE_SOFTWARE_SPI, FORCE_SOFT_SPI)
- // --------------------------------------------------------------------------
- // software SPI
- // --------------------------------------------------------------------------
+ // ------------------------
+ // Software SPI
+ // ------------------------
// Make sure GCC optimizes this file.
// Note that this line triggers a bug in GCC which is fixed by casting.
@@ -160,13 +151,12 @@
(((uint32_t)(addr) & 0xF0000000) + 0x02000000 + ((uint32_t)(addr)&0xFFFFF)*32 + (bit)*4)
// run at ~8 .. ~10Mhz - Rx version (Tx line not altered)
- static uint8_t spiTransferRx0(uint8_t bout) { // using Mode 0
+ static uint8_t spiTransferRx0(uint8_t) { // using Mode 0
uint32_t bin = 0;
uint32_t work = 0;
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(MISO_PIN))+0x3C, PIN_SHIFT(MISO_PIN)); /* PDSR of port in bitband area */
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SCK_PIN);
- UNUSED(bout);
/* The software SPI routine */
__asm__ __volatile__(
@@ -250,7 +240,7 @@
}
// all the others
- static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4uS => 125khz
+ static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
int bits = 8;
@@ -437,7 +427,7 @@
static void spiTxBlockX(const uint8_t* buf, uint32_t todo) {
do {
- (void) spiTransferTx(*buf++);
+ (void)spiTransferTx(*buf++);
} while (--todo);
}
@@ -551,9 +541,9 @@
// slave selects controlled by SPI controller
// doesn't support changing SPI speeds for SD card
- // --------------------------------------------------------------------------
+ // ------------------------
// hardware SPI
- // --------------------------------------------------------------------------
+ // ------------------------
static bool spiInitialized = false;
void spiInit(uint8_t spiRate) {
@@ -739,7 +729,42 @@
#define SPI_MODE_2_DUE_HW 0
#define SPI_MODE_3_DUE_HW 1
+ /**
+ * The DUE SPI controller is set up so the upper word of the longword
+ * written to the transmit data register selects which SPI Chip Select
+ * Register is used. This allows different streams to have different SPI
+ * settings.
+ *
+ * In practice it's spooky. Some combinations hang the system, while others
+ * upset the peripheral device.
+ *
+ * SPI mode should be the same for all streams. The FYSETC_MINI_12864 gets
+ * upset if the clock phase changes after chip select goes active.
+ *
+ * SPI_CSR_CSAAT should be set for all streams. If not the WHILE_TX(0)
+ * macro returns immediately which can result in the SPI chip select going
+ * inactive before all the data has been sent.
+ *
+ * The TMC2130 library uses SPI0->SPI_CSR[3].
+ *
+ * The U8G hardware SPI uses SPI0->SPI_CSR[0]. The system hangs and/or the
+ * FYSETC_MINI_12864 gets upset if lower baud rates are used and the SD card
+ * is inserted or removed.
+ *
+ * The SD card uses SPI0->SPI_CSR[3]. Efforts were made to use [1] and [2]
+ * but they all resulted in hangs or garbage on the LCD.
+ *
+ * The SPI controlled chip selects are NOT enabled in the GPIO controller.
+ * The application must control the chip select.
+ *
+ * All of the above can be avoided by defining FORCE_SOFT_SPI to force the
+ * display to use software SPI.
+ *
+ */
+
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)
+ // Also sets U8G SPI rate to 4MHz and the SPI mode to 3
+
// 8.4 MHz, 4 MHz, 2 MHz, 1 MHz, 0.5 MHz, 0.329 MHz, 0.329 MHz
constexpr int spiDivider[] = { 10, 21, 42, 84, 168, 255, 255 };
if (spiRate > 6) spiRate = 1;
@@ -760,15 +785,16 @@
// TMC2103 compatible setup
// Master mode, no fault detection, PCS bits in data written to TDR select CSR register
SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS;
- // SPI mode 0, 8 Bit data transfer, baud rate
- SPI0->SPI_CSR[3] = SPI_CSR_SCBR(spiDivider[spiRate]) | SPI_CSR_CSAAT | SPI_MODE_0_DUE_HW; // use same CSR as TMC2130
+ // SPI mode 3, 8 Bit data transfer, baud rate
+ SPI0->SPI_CSR[3] = SPI_CSR_SCBR(spiDivider[spiRate]) | SPI_CSR_CSAAT | SPI_MODE_3_DUE_HW; // use same CSR as TMC2130
+ SPI0->SPI_CSR[0] = SPI_CSR_SCBR(spiDivider[1]) | SPI_CSR_CSAAT | SPI_MODE_3_DUE_HW; // U8G default to 4MHz
}
void spiBegin() { spiInit(); }
static uint8_t spiTransfer(uint8_t data) {
WHILE_TX(0);
- SPI0->SPI_TDR = (uint32_t)data | 0x00070000UL; // Add TMC2130 PCS bits to every byte
+ SPI0->SPI_TDR = (uint32_t)data | 0x00070000UL; // Add TMC2130 PCS bits to every byte (use SPI0->SPI_CSR[3])
WHILE_TX(0);
WHILE_RX(0);
return SPI0->SPI_RDR;
diff --git a/Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.cpp b/Marlin/src/HAL/DUE/InterruptVectors.cpp
similarity index 89%
rename from Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.cpp
rename to Marlin/src/HAL/DUE/InterruptVectors.cpp
index 446eb2884d..7964f2d1f6 100644
--- a/Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.cpp
+++ b/Marlin/src/HAL/DUE/InterruptVectors.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,21 +34,21 @@
#include "../../inc/MarlinConfig.h"
#include "HAL.h"
-#include "InterruptVectors_Due.h"
+#include "InterruptVectors.h"
/* The relocated Exception/Interrupt Table - According to the ARM
reference manual, alignment to 128 bytes should suffice, but in
practice, we need alignment to 256 bytes to make this work in all
cases */
__attribute__ ((aligned(256)))
-static DeviceVectors ram_tab = { NULL };
+static DeviceVectors ram_tab = { nullptr };
/**
* This function checks if the exception/interrupt table is already in SRAM or not.
* If it is not, then it copies the ROM table to the SRAM and relocates the table
* by reprogramming the NVIC registers
*/
-static pfnISR_Handler* get_relocated_table_addr(void) {
+static pfnISR_Handler* get_relocated_table_addr() {
// Get the address of the interrupt/exception table
uint32_t isrtab = SCB->VTOR;
@@ -63,13 +63,13 @@ static pfnISR_Handler* get_relocated_table_addr(void) {
memcpy(&ram_tab, romtab, sizeof(ram_tab));
// Disable global interrupts
- CRITICAL_SECTION_START;
+ CRITICAL_SECTION_START();
// Set the vector table base address to the SRAM copy
SCB->VTOR = (uint32_t)(&ram_tab);
// Reenable interrupts
- CRITICAL_SECTION_END;
+ CRITICAL_SECTION_END();
// Return the address of the table
return (pfnISR_Handler*)(&ram_tab);
@@ -80,7 +80,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) {
pfnISR_Handler *isrtab = get_relocated_table_addr();
// Disable global interrupts
- CRITICAL_SECTION_START;
+ CRITICAL_SECTION_START();
// Get the original handler
pfnISR_Handler oldHandler = isrtab[irq + 16];
@@ -89,7 +89,7 @@ pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler) {
isrtab[irq + 16] = newHandler;
// Reenable interrupts
- CRITICAL_SECTION_END;
+ CRITICAL_SECTION_END();
// Return the original one
return oldHandler;
diff --git a/Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.h b/Marlin/src/HAL/DUE/InterruptVectors.h
similarity index 87%
rename from Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.h
rename to Marlin/src/HAL/DUE/InterruptVectors.h
index 71de4bf52e..534cd17f42 100644
--- a/Marlin/src/HAL/HAL_DUE/InterruptVectors_Due.h
+++ b/Marlin/src/HAL/DUE/InterruptVectors.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,8 +24,6 @@
/**
* InterruptVectors_Due.h
*
- * Copyright (c) 2017 Eduardo José Tagle. All right reserved
- *
* This module relocates the Interrupt vector table to SRAM, allowing new
* interrupt handlers to be added at runtime. This is required because the
* Arduino runtime steals interrupt handlers that Marlin MUST use to support
@@ -39,7 +37,7 @@
#ifdef ARDUINO_ARCH_SAM
// ISR handler type
-typedef void (*pfnISR_Handler)(void);
+typedef void (*pfnISR_Handler)();
// Install a new interrupt vector handler for the given irq, returning the old one
pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler);
diff --git a/Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp
similarity index 95%
rename from Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.cpp
rename to Marlin/src/HAL/DUE/MarlinSerial.cpp
index 4be9c43f47..d114c75989 100644
--- a/Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.cpp
+++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,9 +29,9 @@
#include "../../inc/MarlinConfig.h"
-#include "MarlinSerial_Due.h"
-#include "InterruptVectors_Due.h"
-#include "../../Marlin.h"
+#include "MarlinSerial.h"
+#include "InterruptVectors.h"
+#include "../../MarlinCore.h"
template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } };
template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 };
@@ -45,7 +45,7 @@ template typename MarlinSerial::ring_buffer_pos_t MarlinSeria
// A SW memory barrier, to ensure GCC does not overoptimize loops
#define sw_barrier() asm volatile("": : :"memory");
-#include "../../feature/emergency_parser.h"
+#include "../../feature/e_parser.h"
// (called with RX interrupts disabled)
template
@@ -178,7 +178,7 @@ FORCE_INLINE void MarlinSerial::store_rxd_char() {
}
template
-FORCE_INLINE void MarlinSerial::_tx_thr_empty_irq(void) {
+FORCE_INLINE void MarlinSerial::_tx_thr_empty_irq() {
if (Cfg::TX_SIZE > 0) {
// Read positions
uint8_t t = tx_buffer.tail;
@@ -221,7 +221,7 @@ FORCE_INLINE void MarlinSerial::_tx_thr_empty_irq(void) {
}
template
-void MarlinSerial::UART_ISR(void) {
+void MarlinSerial::UART_ISR() {
const uint32_t status = HWUART->UART_SR;
// Data received?
@@ -308,13 +308,13 @@ void MarlinSerial::end() {
}
template
-int MarlinSerial::peek(void) {
+int MarlinSerial::peek() {
const int v = rx_buffer.head == rx_buffer.tail ? -1 : rx_buffer.buffer[rx_buffer.tail];
return v;
}
template
-int MarlinSerial::read(void) {
+int MarlinSerial::read() {
const ring_buffer_pos_t h = rx_buffer.head;
ring_buffer_pos_t t = rx_buffer.tail;
@@ -354,13 +354,13 @@ int MarlinSerial::read(void) {
}
template
-typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available(void) {
+typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available() {
const ring_buffer_pos_t h = rx_buffer.head, t = rx_buffer.tail;
return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1);
}
template
-void MarlinSerial::flush(void) {
+void MarlinSerial::flush() {
rx_buffer.tail = rx_buffer.head;
if (Cfg::XONOFF) {
@@ -431,7 +431,7 @@ void MarlinSerial::write(const uint8_t c) {
}
template
-void MarlinSerial::flushTX(void) {
+void MarlinSerial::flushTX() {
// TX
if (Cfg::TX_SIZE == 0) {
@@ -520,7 +520,7 @@ void MarlinSerial::print(double n, int digits) {
}
template
-void MarlinSerial::println(void) {
+void MarlinSerial::println() {
print('\r');
print('\n');
}
@@ -606,7 +606,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) {
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
- for (uint8_t i = 0; i < digits; ++i) rounding *= 0.1;
+ LOOP_L_N(i, digits) rounding *= 0.1;
number += rounding;
// Extract the integer part of the number and print it
@@ -629,23 +629,13 @@ void MarlinSerial::printFloat(double number, uint8_t digits) {
// If not using the USB port as serial port
#if SERIAL_PORT >= 0
-
- // Preinstantiate
- template class MarlinSerial>;
-
- // Instantiate
- MarlinSerial> customizedSerial1;
-
+ template class MarlinSerial>; // Define
+ MarlinSerial> customizedSerial1; // Instantiate
#endif
-#ifdef SERIAL_PORT_2
-
- // Preinstantiate
- template class MarlinSerial>;
-
- // Instantiate
- MarlinSerial> customizedSerial2;
-
+#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
+ template class MarlinSerial>; // Define
+ MarlinSerial> customizedSerial2; // Instantiate
#endif
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.h b/Marlin/src/HAL/DUE/MarlinSerial.h
similarity index 87%
rename from Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.h
rename to Marlin/src/HAL/DUE/MarlinSerial.h
index 9b03d46f28..fa6a2c7d15 100644
--- a/Marlin/src/HAL/HAL_DUE/MarlinSerial_Due.h
+++ b/Marlin/src/HAL/DUE/MarlinSerial.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,10 +27,10 @@
* Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved.
*/
-#include "../shared/MarlinSerial.h"
-
#include
+#include "../../inc/MarlinConfigPre.h"
+
#define DEC 10
#define HEX 16
#define OCT 8
@@ -108,19 +108,19 @@ protected:
static ring_buffer_pos_t rx_max_enqueued;
FORCE_INLINE static void store_rxd_char();
- FORCE_INLINE static void _tx_thr_empty_irq(void);
- static void UART_ISR(void);
+ FORCE_INLINE static void _tx_thr_empty_irq();
+ static void UART_ISR();
public:
MarlinSerial() {};
static void begin(const long);
static void end();
- static int peek(void);
- static int read(void);
- static void flush(void);
- static ring_buffer_pos_t available(void);
+ static int peek();
+ static int read();
+ static void flush();
+ static ring_buffer_pos_t available();
static void write(const uint8_t c);
- static void flushTX(void);
+ static void flushTX();
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; }
@@ -149,7 +149,7 @@ public:
static void println(long, int = DEC);
static void println(unsigned long, int = DEC);
static void println(double, int = 2);
- static void println(void);
+ static void println();
operator bool() { return true; }
private:
@@ -163,22 +163,18 @@ struct MarlinSerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
- static constexpr bool XONOFF = bSERIAL_XON_XOFF;
- static constexpr bool EMERGENCYPARSER = bEMERGENCY_PARSER;
- static constexpr bool DROPPED_RX = bSERIAL_STATS_DROPPED_RX;
- static constexpr bool RX_OVERRUNS = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
- static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
- static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
+ static constexpr bool XONOFF = ENABLED(SERIAL_XON_XOFF);
+ static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
+ static constexpr bool DROPPED_RX = ENABLED(SERIAL_STATS_DROPPED_RX);
+ static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
+ static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
+ static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};
#if SERIAL_PORT >= 0
-
extern MarlinSerial> customizedSerial1;
-
-#endif // SERIAL_PORT >= 0
-
-#ifdef SERIAL_PORT_2
-
- extern MarlinSerial> customizedSerial2;
-
+#endif
+
+#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
+ extern MarlinSerial> customizedSerial2;
#endif
diff --git a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.cpp b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
similarity index 85%
rename from Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.cpp
rename to Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
index 7b1100dd9d..d267422813 100644
--- a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.cpp
+++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,21 +29,21 @@
#include "../../inc/MarlinConfig.h"
-#if SERIAL_PORT == -1
+#if HAS_USB_SERIAL
-#include "MarlinSerialUSB_Due.h"
+#include "MarlinSerialUSB.h"
#if ENABLED(EMERGENCY_PARSER)
- #include "../../feature/emergency_parser.h"
+ #include "../../feature/e_parser.h"
#endif
// Imports from Atmel USB Stack/CDC implementation
extern "C" {
- bool usb_task_cdc_isenabled(void);
- bool usb_task_cdc_dtr_active(void);
- bool udi_cdc_is_rx_ready(void);
- int udi_cdc_getc(void);
- bool udi_cdc_is_tx_ready(void);
+ bool usb_task_cdc_isenabled();
+ bool usb_task_cdc_dtr_active();
+ bool udi_cdc_is_rx_ready();
+ int udi_cdc_getc();
+ bool udi_cdc_is_tx_ready();
int udi_cdc_putc(int value);
};
@@ -55,13 +55,11 @@ static int pending_char = -1;
#endif
// Public Methods
-void MarlinSerialUSB::begin(const long baud_setting) {
-}
+void MarlinSerialUSB::begin(const long) {}
-void MarlinSerialUSB::end() {
-}
+void MarlinSerialUSB::end() {}
-int MarlinSerialUSB::peek(void) {
+int MarlinSerialUSB::peek() {
if (pending_char >= 0)
return pending_char;
@@ -75,14 +73,12 @@ int MarlinSerialUSB::peek(void) {
pending_char = udi_cdc_getc();
- #if ENABLED(EMERGENCY_PARSER)
- emergency_parser.update(emergency_state, (char)pending_char);
- #endif
+ TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char));
return pending_char;
}
-int MarlinSerialUSB::read(void) {
+int MarlinSerialUSB::read() {
if (pending_char >= 0) {
int ret = pending_char;
pending_char = -1;
@@ -99,14 +95,12 @@ int MarlinSerialUSB::read(void) {
int c = udi_cdc_getc();
- #if ENABLED(EMERGENCY_PARSER)
- emergency_parser.update(emergency_state, (char)c);
- #endif
+ TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c));
return c;
}
-bool MarlinSerialUSB::available(void) {
+bool MarlinSerialUSB::available() {
/* If Pending chars */
return pending_char >= 0 ||
/* or USB CDC enumerated and configured on the PC side and some
@@ -114,8 +108,8 @@ bool MarlinSerialUSB::available(void) {
(usb_task_cdc_isenabled() && udi_cdc_is_rx_ready());
}
-void MarlinSerialUSB::flush(void) { }
-void MarlinSerialUSB::flushTX(void) { }
+void MarlinSerialUSB::flush() { }
+void MarlinSerialUSB::flushTX() { }
void MarlinSerialUSB::write(const uint8_t c) {
@@ -185,7 +179,7 @@ void MarlinSerialUSB::print(double n, int digits) {
printFloat(n, digits);
}
-void MarlinSerialUSB::println(void) {
+void MarlinSerialUSB::println() {
print('\r');
print('\n');
}
@@ -261,7 +255,7 @@ void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
- for (uint8_t i = 0; i < digits; ++i)
+ LOOP_L_N(i, digits)
rounding *= 0.1;
number += rounding;
@@ -285,8 +279,12 @@ void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
}
// Preinstantiate
-MarlinSerialUSB customizedSerial1;
-
-#endif // SERIAL_PORT == -1
+#if SERIAL_PORT == -1
+ MarlinSerialUSB customizedSerial1;
+#endif
+#if SERIAL_PORT_2 == -1
+ MarlinSerialUSB customizedSerial2;
+#endif
+#endif // HAS_USB_SERIAL
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.h b/Marlin/src/HAL/DUE/MarlinSerialUSB.h
similarity index 85%
rename from Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.h
rename to Marlin/src/HAL/DUE/MarlinSerialUSB.h
index 5025b82284..9aece901b1 100644
--- a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB_Due.h
+++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
#include "../../inc/MarlinConfig.h"
-#if SERIAL_PORT == -1
+#if HAS_USB_SERIAL
#include
@@ -43,11 +43,11 @@ public:
MarlinSerialUSB() {};
static void begin(const long);
static void end();
- static int peek(void);
- static int read(void);
- static void flush(void);
- static void flushTX(void);
- static bool available(void);
+ static int peek();
+ static int read();
+ static void flush();
+ static void flushTX();
+ static bool available();
static void write(const uint8_t c);
#if ENABLED(SERIAL_STATS_DROPPED_RX)
@@ -80,7 +80,7 @@ public:
static void println(long, int = DEC);
static void println(unsigned long, int = DEC);
static void println(double, int = 2);
- static void println(void);
+ static void println();
operator bool() { return true; }
private:
@@ -88,6 +88,12 @@ private:
static void printFloat(double, uint8_t);
};
-extern MarlinSerialUSB customizedSerial1;
+#if SERIAL_PORT == -1
+ extern MarlinSerialUSB customizedSerial1;
+#endif
-#endif // SERIAL_PORT == -1
+#if SERIAL_PORT_2 == -1
+ extern MarlinSerialUSB customizedSerial2;
+#endif
+
+#endif // HAS_USB_SERIAL
diff --git a/Marlin/src/HAL/HAL_DUE/Servo_Due.cpp b/Marlin/src/HAL/DUE/Servo.cpp
similarity index 86%
rename from Marlin/src/HAL/HAL_DUE/Servo_Due.cpp
rename to Marlin/src/HAL/DUE/Servo.cpp
index 848d263b70..6f965783ce 100644
--- a/Marlin/src/HAL/HAL_DUE/Servo_Due.cpp
+++ b/Marlin/src/HAL/DUE/Servo.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,31 +44,30 @@
#if HAS_SERVOS
-#include
#include "../shared/servo.h"
#include "../shared/servo_private.h"
static volatile int8_t Channel[_Nbr_16timers]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
-//------------------------------------------------------------------------------
+// ------------------------
/// Interrupt handler for the TC0 channel 1.
-//------------------------------------------------------------------------------
+// ------------------------
void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
#ifdef _useTimer1
- void HANDLER_FOR_TIMER1(void) { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); }
+ void HANDLER_FOR_TIMER1() { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); }
#endif
#ifdef _useTimer2
- void HANDLER_FOR_TIMER2(void) { Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); }
+ void HANDLER_FOR_TIMER2() { Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); }
#endif
#ifdef _useTimer3
- void HANDLER_FOR_TIMER3(void) { Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); }
+ void HANDLER_FOR_TIMER3() { Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); }
#endif
#ifdef _useTimer4
- void HANDLER_FOR_TIMER4(void) { Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); }
+ void HANDLER_FOR_TIMER4() { Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); }
#endif
#ifdef _useTimer5
- void HANDLER_FOR_TIMER5(void) { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); }
+ void HANDLER_FOR_TIMER5() { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); }
#endif
void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
@@ -137,7 +136,7 @@ void initISR(timer16_Sequence_t timer) {
#endif
}
-void finISR(timer16_Sequence_t timer) {
+void finISR(timer16_Sequence_t) {
#ifdef _useTimer1
TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1);
#endif
diff --git a/Marlin/src/HAL/HAL_DUE/ServoTimers.h b/Marlin/src/HAL/DUE/ServoTimers.h
similarity index 85%
rename from Marlin/src/HAL/HAL_DUE/ServoTimers.h
rename to Marlin/src/HAL/DUE/ServoTimers.h
index 8d5d0fa583..c32c938253 100644
--- a/Marlin/src/HAL/HAL_DUE/ServoTimers.h
+++ b/Marlin/src/HAL/DUE/ServoTimers.h
@@ -36,8 +36,8 @@
//!#define _useTimer4
#define _useTimer5
-#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
-#define PRESCALER 32 // timer prescaler
+#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
+#define SERVO_TIMER_PRESCALER 32 // timer prescaler
/*
TC0, chan 0 => TC0_Handler
@@ -87,5 +87,21 @@
#define HANDLER_FOR_TIMER5 TC0_Handler
#endif
-//typedef enum { _timer1, _timer2, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t;
-typedef enum { _timer3, _timer5, _Nbr_16timers } timer16_Sequence_t;
+typedef enum : unsigned char {
+ #ifdef _useTimer1
+ _timer1,
+ #endif
+ #ifdef _useTimer2
+ _timer2,
+ #endif
+ #ifdef _useTimer3
+ _timer3,
+ #endif
+ #ifdef _useTimer4
+ _timer4,
+ #endif
+ #ifdef _useTimer5
+ _timer5,
+ #endif
+ _Nbr_16timers
+} timer16_Sequence_t;
diff --git a/Marlin/src/HAL/HAL_DUE/Tone.cpp b/Marlin/src/HAL/DUE/Tone.cpp
similarity index 89%
rename from Marlin/src/HAL/HAL_DUE/Tone.cpp
rename to Marlin/src/HAL/DUE/Tone.cpp
index 292be1401f..9b580b8b4c 100644
--- a/Marlin/src/HAL/HAL_DUE/Tone.cpp
+++ b/Marlin/src/HAL/DUE/Tone.cpp
@@ -1,9 +1,11 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +31,7 @@
#include "../../inc/MarlinConfig.h"
#include "HAL.h"
-#include "HAL_timers_Due.h"
+#include "timers.h"
static pin_t tone_pin;
volatile static int32_t toggles;
diff --git a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
similarity index 61%
rename from Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp
rename to Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
index ba7700150f..0fb8a782e5 100644
--- a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,66 +21,57 @@
*/
-/*
-
- based on u8g_com_msp430_hw_spi.c
-
- Universal 8bit Graphics Library
-
- Copyright (c) 2012, olikraus@gmail.com
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list
- of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*/
+/**
+ * Based on u8g_com_msp430_hw_spi.c
+ *
+ * Universal 8bit Graphics Library
+ *
+ * Copyright (c) 2012, olikraus@gmail.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifdef __SAM3X8E__
-#include "../../inc/MarlinConfigPre.h"
+#include "../../../inc/MarlinConfigPre.h"
#if HAS_GRAPHICAL_LCD
#include
-#include "../../Marlin.h"
-
-#define SPI_FULL_SPEED 0
-#define SPI_HALF_SPEED 1
-#define SPI_QUARTER_SPEED 2
-#define SPI_EIGHTH_SPEED 3
-#define SPI_SIXTEENTH_SPEED 4
-#define SPI_SPEED_5 5
-#define SPI_SPEED_6 6
+#include "../../../MarlinCore.h"
void spiBegin();
void spiInit(uint8_t spiRate);
void spiSend(uint8_t b);
void spiSend(const uint8_t* buf, size_t n);
-#include
-#include "fastio_Due.h"
+#include "../../shared/Marduino.h"
+#include "../fastio.h"
void u8g_SetPIOutput_DUE_hw_spi(u8g_t *u8g, uint8_t pin_index) {
PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
diff --git a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp
similarity index 76%
rename from Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp
rename to Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp
index 1546407a1e..01320ba9b9 100644
--- a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -55,52 +55,28 @@
#ifdef ARDUINO_ARCH_SAM
-#include "../../inc/MarlinConfigPre.h"
+#include "../../../inc/MarlinConfigPre.h"
-#if HAS_GRAPHICAL_LCD
+#if ENABLED(U8GLIB_ST7920)
+
+#include "../../shared/Delay.h"
#include
-#include
-#include "../shared/Delay.h"
-void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
- PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
- g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration); // OUTPUT
-}
+#include "u8g_com_HAL_DUE_sw_spi_shared.h"
-void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
- volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
- uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
- if (level) port->PIO_SODR = mask; else port->PIO_CODR = mask;
-}
-
-Pio *SCK_pPio, *MOSI_pPio;
-uint32_t SCK_dwMask, MOSI_dwMask;
-
-static void spiSend_sw_DUE(uint8_t val) { // 800KHz
- for (uint8_t i = 0; i < 8; i++) {
- if (val & 0x80)
- MOSI_pPio->PIO_SODR = MOSI_dwMask;
- else
- MOSI_pPio->PIO_CODR = MOSI_dwMask;
- DELAY_NS(48);
- SCK_pPio->PIO_SODR = SCK_dwMask;
- DELAY_NS(905); // 762 dead, 810 garbage, 858/0 900kHz, 905/1 825k, 953/1 800k, 1000/2 725KHz
- val <<= 1;
- SCK_pPio->PIO_CODR = SCK_dwMask;
- }
-}
+#define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_0
static uint8_t rs_last_state = 255;
static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
if (rs != rs_last_state) { // time to send a command/data byte
rs_last_state = rs;
- spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
+ SPISEND_SW_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
}
- spiSend_sw_DUE(val & 0x0F0);
- spiSend_sw_DUE(val << 4);
+ SPISEND_SW_DUE(val & 0xF0);
+ SPISEND_SW_DUE(val << 4);
}
uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
@@ -123,7 +99,7 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
u8g_Delay(5);
- u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
+ u8g->pin_list[U8G_PI_A0_STATE] = 0; /* initial RS state: command mode */
break;
case U8G_COM_MSG_STOP:
@@ -168,6 +144,42 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
return 1;
}
-#endif // HAS_GRAPHICAL_LCD
+#if ENABLED(LIGHTWEIGHT_UI)
+ #include "../../../lcd/ultralcd.h"
+ #include "../../shared/HAL_ST7920.h"
+ #define ST7920_CS_PIN LCD_PINS_RS
+
+ #if DOGM_SPI_DELAY_US > 0
+ #define U8G_DELAY() DELAY_US(DOGM_SPI_DELAY_US)
+ #else
+ #define U8G_DELAY() DELAY_US(10)
+ #endif
+
+ void ST7920_cs() {
+ WRITE(ST7920_CS_PIN, HIGH);
+ U8G_DELAY();
+ }
+
+ void ST7920_ncs() {
+ WRITE(ST7920_CS_PIN, LOW);
+ }
+
+ void ST7920_set_cmd() {
+ SPISEND_SW_DUE(0xF8);
+ DELAY_US(40);
+ }
+
+ void ST7920_set_dat() {
+ SPISEND_SW_DUE(0xFA);
+ DELAY_US(40);
+ }
+
+ void ST7920_write_byte(const uint8_t val) {
+ SPISEND_SW_DUE(val & 0xF0);
+ SPISEND_SW_DUE(val << 4);
+ }
+#endif // LIGHTWEIGHT_UI
+
+#endif // U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
similarity index 59%
rename from Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
rename to Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
index 1419a74f42..c4816c3db5 100644
--- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,56 +53,75 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef TARGET_LPC1768
+#ifdef ARDUINO_ARCH_SAM
#include "../../../inc/MarlinConfigPre.h"
-#if HAS_GRAPHICAL_LCD
-
-#include
-#include "SoftwareSPI.h"
+#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
#undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz
-static uint8_t SPI_speed = 0;
+#include "u8g_com_HAL_DUE_sw_spi_shared.h"
-static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
- swSpiTransfer(val, SPI_speed, clockPin, -1, dataPin);
-}
+#include "../../shared/Marduino.h"
+#include "../../shared/Delay.h"
-uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
+#include
+
+#if ENABLED(FYSETC_MINI_12864)
+ #define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_3
+#else
+ #define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_0
+#endif
+
+uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
- u8g_SetPIOutput(u8g, U8G_PI_SCK);
- u8g_SetPIOutput(u8g, U8G_PI_MOSI);
- u8g_SetPIOutput(u8g, U8G_PI_CS);
- u8g_SetPIOutput(u8g, U8G_PI_A0);
- if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET);
- SPI_speed = swSpiInit(SPI_SPEED, u8g->pin_list[U8G_PI_SCK], u8g->pin_list[U8G_PI_MOSI]);
- u8g_SetPILevel(u8g, U8G_PI_SCK, 0);
- u8g_SetPILevel(u8g, U8G_PI_MOSI, 0);
+ SCK_pPio = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].pPort;
+ SCK_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].ulPin;
+ MOSI_pPio = g_APinDescription[u8g->pin_list[U8G_PI_MOSI]].pPort;
+ MOSI_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_MOSI]].ulPin;
+ u8g_SetPIOutput_DUE(u8g, U8G_PI_SCK);
+ u8g_SetPIOutput_DUE(u8g, U8G_PI_MOSI);
+ u8g_SetPIOutput_DUE(u8g, U8G_PI_CS);
+ u8g_SetPIOutput_DUE(u8g, U8G_PI_A0);
+ if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput_DUE(u8g, U8G_PI_RESET);
+ u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0);
+ u8g_SetPILevel_DUE(u8g, U8G_PI_MOSI, 0);
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
- if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
+ if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel_DUE(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_CHIP_SELECT:
- u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
+ #if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
+ if (arg_val) { // SCK idle state needs to be set to the proper idle state before
+ // the next chip select goes active
+ u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1); //set SCK to mode 3 idle state before CS goes active
+ u8g_SetPILevel_DUE(u8g, U8G_PI_CS, LOW);
+ }
+ else {
+ u8g_SetPILevel_DUE(u8g, U8G_PI_CS, HIGH);
+ u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); //set SCK to mode 0 idle state after CS goes inactive
+ }
+ #else
+ u8g_SetPILevel_DUE(u8g, U8G_PI_CS, !arg_val);
+ #endif
break;
case U8G_COM_MSG_WRITE_BYTE:
- u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
+ SPISEND_SW_DUE(arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
- u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
+ SPISEND_SW_DUE(*ptr++);
arg_val--;
}
}
@@ -111,7 +130,7 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
- u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
+ SPISEND_SW_DUE(u8g_pgm_read(ptr));
ptr++;
arg_val--;
}
@@ -119,12 +138,11 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
- u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
+ u8g_SetPILevel_DUE(u8g, U8G_PI_A0, arg_val);
break;
}
return 1;
}
-#endif // HAS_GRAPHICAL_LCD
-
-#endif // TARGET_LPC1768
+#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
new file mode 100644
index 0000000000..96b7a1f61e
--- /dev/null
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp
@@ -0,0 +1,112 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Based on u8g_com_st7920_hw_spi.c
+ *
+ * Universal 8bit Graphics Library
+ *
+ * Copyright (c) 2011, olikraus@gmail.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list
+ * of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+#include "../../../inc/MarlinConfigPre.h"
+
+#if HAS_GRAPHICAL_LCD
+
+#include "../../shared/Delay.h"
+
+#include
+
+#include "u8g_com_HAL_DUE_sw_spi_shared.h"
+
+void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
+ PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
+ g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration); // OUTPUT
+}
+
+void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
+ volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
+ uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
+ if (level) port->PIO_SODR = mask; else port->PIO_CODR = mask;
+}
+
+Pio *SCK_pPio, *MOSI_pPio;
+uint32_t SCK_dwMask, MOSI_dwMask;
+
+void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
+ LOOP_L_N(i, 8) {
+ if (val & 0x80)
+ MOSI_pPio->PIO_SODR = MOSI_dwMask;
+ else
+ MOSI_pPio->PIO_CODR = MOSI_dwMask;
+ DELAY_NS(48);
+ SCK_pPio->PIO_SODR = SCK_dwMask;
+ DELAY_NS(905);
+ val <<= 1;
+ SCK_pPio->PIO_CODR = SCK_dwMask;
+ }
+}
+
+void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
+ LOOP_L_N(i, 8) {
+ SCK_pPio->PIO_CODR = SCK_dwMask;
+ DELAY_NS(50);
+ if (val & 0x80)
+ MOSI_pPio->PIO_SODR = MOSI_dwMask;
+ else
+ MOSI_pPio->PIO_CODR = MOSI_dwMask;
+ val <<= 1;
+ DELAY_NS(10);
+ SCK_pPio->PIO_SODR = SCK_dwMask;
+ DELAY_NS(70);
+ }
+}
+
+#endif // HAS_GRAPHICAL_LCD
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h
new file mode 100644
index 0000000000..e0f15bfd81
--- /dev/null
+++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h
@@ -0,0 +1,35 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include "../../../inc/MarlinConfigPre.h"
+#include "../../shared/Marduino.h"
+#include
+
+void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index);
+void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level);
+
+void u8g_spiSend_sw_DUE_mode_0(uint8_t val);
+void u8g_spiSend_sw_DUE_mode_3(uint8_t val);
+
+extern Pio *SCK_pPio, *MOSI_pPio;
+extern uint32_t SCK_dwMask, MOSI_dwMask;
diff --git a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp
similarity index 86%
rename from Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp
rename to Marlin/src/HAL/DUE/eeprom_flash.cpp
index 21f1a8c9d4..c07d05adfc 100644
--- a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp
+++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp
@@ -1,3 +1,34 @@
+/**
+ * Marlin 3D Printer Firmware
+ *
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_SAM
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(FLASH_EEPROM_EMULATION)
+
+#ifndef E2END
+ #define E2END 0xFFF // Default to Flash emulated EEPROM size (eeprom_emul.cpp)
+#endif
/* EEPROM emulation over flash with reduced wear
*
@@ -29,14 +60,7 @@
*
*/
-#ifdef ARDUINO_ARCH_SAM
-
-#include "../shared/persistent_store_api.h"
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM, SPI_EEPROM)
-
-#include
+//#define EE_EMU_DEBUG
#define EEPROMSize 4096
#define PagesPerGroup 128
@@ -113,15 +137,18 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes
curPage = 0, // Current FLASH page inside the group
curGroup = 0xFF; // Current FLASH group
-//#define EE_EMU_DEBUG
-#ifdef EE_EMU_DEBUG
- static void ee_Dump(int page,const void* data) {
+#define DEBUG_OUT ENABLED(EE_EMU_DEBUG)
+#include "../../core/debug_out.h"
+
+static void ee_Dump(const int page, const void* data) {
+
+ #ifdef EE_EMU_DEBUG
const uint8_t* c = (const uint8_t*) data;
char buffer[80];
sprintf_P(buffer, PSTR("Page: %d (0x%04x)\n"), page, page);
- SERIAL_ECHO(buffer);
+ DEBUG_ECHO(buffer);
char* p = &buffer[0];
for (int i = 0; i< PageSize; ++i) {
@@ -131,12 +158,16 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes
if ((i & 0xF) == 0xF) {
*p++ = '\n';
*p = 0;
- SERIAL_ECHO(buffer);
+ DEBUG_ECHO(buffer);
p = &buffer[0];
}
}
- }
-#endif
+
+ #else
+ UNUSED(page);
+ UNUSED(data);
+ #endif
+}
/* Flash Writing Protection Key */
#define FWP_KEY 0x5Au
@@ -149,17 +180,16 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes
#define EEFC_ERROR_FLAGS (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE)
#endif
-
/**
* Writes the contents of the specified page (no previous erase)
* @param page (page #)
* @param data (pointer to the data buffer)
*/
__attribute__ ((long_call, section (".ramfunc")))
-static bool ee_PageWrite(uint16_t page,const void* data) {
+static bool ee_PageWrite(uint16_t page, const void* data) {
uint16_t i;
- uint32_t addrflash = ((uint32_t)getFlashStorage(page));
+ uint32_t addrflash = uint32_t(getFlashStorage(page));
// Read the flash contents
uint32_t pageContents[PageSize>>2];
@@ -174,13 +204,11 @@ static bool ee_PageWrite(uint16_t page,const void* data) {
for (i = 0; i > 2; i++)
pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i]));
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM PageWrite ", page);
- SERIAL_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
- SERIAL_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
- SERIAL_FLUSH();
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM PageWrite ", page);
+ DEBUG_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
+ DEBUG_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
+ DEBUG_FLUSH();
// Get the page relative to the start of the EFC controller, and the EFC controller to use
Efc *efc;
@@ -222,10 +250,8 @@ static bool ee_PageWrite(uint16_t page,const void* data) {
// Reenable interrupts
__enable_irq();
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Unlock failure for page ", page);
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Unlock failure for page ", page);
return false;
}
@@ -249,10 +275,9 @@ static bool ee_PageWrite(uint16_t page,const void* data) {
// Reenable interrupts
__enable_irq();
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Write failure for page ", page);
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Write failure for page ", page);
+
return false;
}
@@ -266,11 +291,11 @@ static bool ee_PageWrite(uint16_t page,const void* data) {
if (memcmp(getFlashStorage(page),data,PageSize)) {
#ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Verify Write failure for page ", page);
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Verify Write failure for page ", page);
- ee_Dump( page,(uint32_t *) addrflash);
- ee_Dump(-page,data);
+ ee_Dump( page, (uint32_t *)addrflash);
+ ee_Dump(-page, data);
// Calculate count of changed bits
uint32_t* p1 = (uint32_t*)addrflash;
@@ -286,7 +311,7 @@ static bool ee_PageWrite(uint16_t page,const void* data) {
}
}
}
- SERIAL_ECHOLNPAIR("--> Differing bits: ", count);
+ DEBUG_ECHOLNPAIR("--> Differing bits: ", count);
#endif
return false;
@@ -303,15 +328,13 @@ __attribute__ ((long_call, section (".ramfunc")))
static bool ee_PageErase(uint16_t page) {
uint16_t i;
- uint32_t addrflash = ((uint32_t)getFlashStorage(page));
+ uint32_t addrflash = uint32_t(getFlashStorage(page));
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM PageErase ", page);
- SERIAL_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
- SERIAL_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
- SERIAL_FLUSH();
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM PageErase ", page);
+ DEBUG_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
+ DEBUG_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
+ DEBUG_FLUSH();
// Get the page relative to the start of the EFC controller, and the EFC controller to use
Efc *efc;
@@ -352,10 +375,9 @@ static bool ee_PageErase(uint16_t page) {
// Reenable interrupts
__enable_irq();
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Unlock failure for page ",page);
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Unlock failure for page ",page);
+
return false;
}
@@ -377,10 +399,9 @@ static bool ee_PageErase(uint16_t page) {
// Reenable interrupts
__enable_irq();
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Erase failure for page ",page);
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Erase failure for page ",page);
+
return false;
}
@@ -394,20 +415,17 @@ static bool ee_PageErase(uint16_t page) {
uint32_t * aligned_src = (uint32_t *) addrflash;
for (i = 0; i < PageSize >> 2; i++) {
if (*aligned_src++ != 0xFFFFFFFF) {
-
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Verify Erase failure for page ",page);
-
- ee_Dump( page,(uint32_t *) addrflash);
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Verify Erase failure for page ",page);
+ ee_Dump(page, (uint32_t *)addrflash);
return false;
}
}
return true;
}
-static uint8_t ee_Read(uint32_t address, bool excludeRAMBuffer = false) {
+
+static uint8_t ee_Read(uint32_t address, bool excludeRAMBuffer=false) {
uint32_t baddr;
uint32_t blen;
@@ -490,7 +508,7 @@ static uint8_t ee_Read(uint32_t address, bool excludeRAMBuffer = false) {
return 0xFF;
}
-static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer = false) {
+static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer=false) {
uint32_t baddr,
blen,
nextAddr = 0xFFFF,
@@ -582,7 +600,7 @@ static bool ee_IsPageClean(int page) {
return true;
}
-static bool ee_Flush(uint32_t overrideAddress = 0xFFFFFFFF, uint8_t overrideData = 0xFF) {
+static bool ee_Flush(uint32_t overrideAddress = 0xFFFFFFFF, uint8_t overrideData=0xFF) {
// Check if RAM buffer has something to be written
bool isEmpty = true;
@@ -908,11 +926,9 @@ static void ee_Init() {
// If all groups seem to be used, default to first group
if (curGroup >= GroupCount) curGroup = 0;
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Current Group: ",curGroup);
- SERIAL_FLUSH();
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Current Group: ",curGroup);
+ DEBUG_FLUSH();
// Now, validate that all the other group pages are empty
for (int grp = 0; grp < GroupCount; grp++) {
@@ -920,12 +936,9 @@ static void ee_Init() {
for (int page = 0; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOPAIR("EEPROM Page ",page);
- SERIAL_ECHOLNPAIR(" not clean on group ",grp);
- SERIAL_FLUSH();
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Page ", page, " not clean on group ", grp);
+ DEBUG_FLUSH();
ee_PageErase(grp * PagesPerGroup + page);
}
}
@@ -935,67 +948,66 @@ static void ee_Init() {
// and also validate that all the other ones are clean
for (curPage = 0; curPage < PagesPerGroup; curPage++) {
if (ee_IsPageClean(curGroup * PagesPerGroup + curPage)) {
- #ifdef EE_EMU_DEBUG
- ee_Dump(curGroup * PagesPerGroup + curPage, getFlashStorage(curGroup * PagesPerGroup + curPage));
- #endif
+ ee_Dump(curGroup * PagesPerGroup + curPage, getFlashStorage(curGroup * PagesPerGroup + curPage));
break;
}
}
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOLNPAIR("EEPROM Active page: ",curPage);
- SERIAL_FLUSH();
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Active page: ", curPage);
+ DEBUG_FLUSH();
// Make sure the pages following the first clean one are also clean
for (int page = curPage + 1; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(curGroup * PagesPerGroup + page)) {
- #ifdef EE_EMU_DEBUG
- SERIAL_ECHO_START();
- SERIAL_ECHOPAIR("EEPROM Page ",page);
- SERIAL_ECHOLNPAIR(" not clean on active group ",curGroup);
- SERIAL_FLUSH();
- ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page));
- #endif
+ DEBUG_ECHO_START();
+ DEBUG_ECHOLNPAIR("EEPROM Page ", page, " not clean on active group ", curGroup);
+ DEBUG_FLUSH();
+ ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page));
ee_PageErase(curGroup * PagesPerGroup + page);
}
}
}
-uint8_t eeprom_read_byte(uint8_t* addr) {
- ee_Init();
- return ee_Read((uint32_t)addr);
+/* PersistentStore -----------------------------------------------------------*/
+
+#include "../shared/eeprom_api.h"
+
+size_t PersistentStore::capacity() { return E2END + 1; }
+bool PersistentStore::access_start() { ee_Init(); return true; }
+bool PersistentStore::access_finish() { ee_Flush(); return true; }
+
+bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
+ while (size--) {
+ uint8_t * const p = (uint8_t * const)pos;
+ uint8_t v = *value;
+ // EEPROM has only ~100,000 write cycles,
+ // so only write bytes that have changed!
+ if (v != ee_Read(uint32_t(p))) {
+ ee_Write(uint32_t(p), v);
+ delay(2);
+ if (ee_Read(uint32_t(p)) != v) {
+ SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
+ return true;
+ }
+ }
+ crc16(crc, &v, 1);
+ pos++;
+ value++;
+ };
+ return false;
}
-void eeprom_write_byte(uint8_t* addr, uint8_t value) {
- ee_Init();
- ee_Write((uint32_t)addr, value);
+bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
+ do {
+ uint8_t c = ee_Read(uint32_t(pos));
+ if (writing) *value = c;
+ crc16(crc, &c, 1);
+ pos++;
+ value++;
+ } while (--size);
+ return false;
}
-void eeprom_update_block(const void* __src, void* __dst, size_t __n) {
- uint8_t* dst = (uint8_t*)__dst;
- const uint8_t* src = (const uint8_t*)__src;
- while (__n--) {
- eeprom_write_byte(dst, *src);
- ++dst;
- ++src;
- }
-}
-
-void eeprom_read_block(void* __dst, const void* __src, size_t __n) {
- uint8_t* dst = (uint8_t*)__dst;
- uint8_t* src = (uint8_t*)__src;
- while (__n--) {
- *dst = eeprom_read_byte(src);
- ++dst;
- ++src;
- }
-}
-
-void eeprom_flush(void) {
- ee_Flush();
-}
-
-#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
-#endif // ARDUINO_ARCH_AVR
+#endif // FLASH_EEPROM_EMULATION
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp b/Marlin/src/HAL/DUE/eeprom_wired.cpp
similarity index 74%
rename from Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp
rename to Marlin/src/HAL/DUE/eeprom_wired.cpp
index b67c76c4c1..a9b2cc92d2 100644
--- a/Marlin/src/HAL/HAL_STM32F4/persistent_store_eeprom.cpp
+++ b/Marlin/src/HAL/DUE/eeprom_wired.cpp
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
* Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
@@ -20,16 +20,22 @@
* along with this program. If not, see .
*
*/
-
-#if defined(STM32GENERIC) && defined(STM32F4)
-
-#include "../shared/persistent_store_api.h"
+#ifdef ARDUINO_ARCH_SAM
#include "../../inc/MarlinConfig.h"
-#if ENABLED(EEPROM_SETTINGS)
+#if USE_WIRED_EEPROM
-bool PersistentStore::access_start() { return true; }
+/**
+ * PersistentStore for Arduino-style EEPROM interface
+ * with simple implementations supplied by Marlin.
+ */
+
+#include "../shared/eeprom_if.h"
+#include "../shared/eeprom_api.h"
+
+size_t PersistentStore::capacity() { return E2END + 1; }
+bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
@@ -40,8 +46,9 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
eeprom_write_byte(p, v);
+ delay(2);
if (eeprom_read_byte(p) != v) {
- SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
+ SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
return true;
}
}
@@ -52,7 +59,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
return false;
}
-bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing) {
+bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
do {
uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c;
@@ -63,7 +70,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
return false;
}
-size_t PersistentStore::capacity() { return E2END + 1; }
-
-#endif // EEPROM_SETTINGS
-#endif // STM32GENERIC && STM32F4
+#endif // USE_WIRED_EEPROM
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h b/Marlin/src/HAL/DUE/endstop_interrupts.h
similarity index 57%
rename from Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h
rename to Marlin/src/HAL/DUE/endstop_interrupts.h
index ad0235179b..759fefae29 100644
--- a/Marlin/src/HAL/HAL_TEENSY31_32/endstop_interrupts.h
+++ b/Marlin/src/HAL/DUE/endstop_interrupts.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
* along with this program. If not, see .
*
*/
+#pragma once
/**
* Endstop Interrupts
@@ -34,53 +35,33 @@
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
*/
-#pragma once
-
#include "../../module/endstops.h"
// One ISR for all EXT-Interrupts
-void endstop_ISR(void) { endstops.update(); }
+void endstop_ISR() { endstops.update(); }
/**
* Endstop interrupts for Due based targets.
* On Due, all pins support external interrupt capability.
*/
-void setup_endstop_interrupts( void ) {
-
- #if HAS_X_MAX
- attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
- #endif
-
- #if HAS_X_MIN
- attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Y_MAX
- attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Y_MIN
- attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Z_MAX
- attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Z_MIN
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Z2_MAX
- attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Z2_MIN
- attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
- #endif
-
- #if HAS_Z_MIN_PROBE_PIN
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
- #endif
+void setup_endstop_interrupts() {
+ #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
+ TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
+ TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
+ TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
+ TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
+ TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
+ TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
+ TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
+ TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
+ TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
+ TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
+ TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
+ TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
+ TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
+ TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
+ TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
+ TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
+ TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
}
diff --git a/Marlin/src/HAL/HAL_DUE/fastio_Due.h b/Marlin/src/HAL/DUE/fastio.h
similarity index 94%
rename from Marlin/src/HAL/HAL_DUE/fastio_Due.h
rename to Marlin/src/HAL/DUE/fastio.h
index 542469f65e..8f4b5a9e2f 100644
--- a/Marlin/src/HAL/HAL_DUE/fastio_Due.h
+++ b/Marlin/src/HAL/DUE/fastio.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,6 +39,8 @@
#include
+#include "../../inc/MarlinConfigPre.h"
+
/**
* Utility functions
*/
@@ -46,7 +48,6 @@
// Due has 12 PWMs assigned to logical pins 2-13.
// 6, 7, 8 & 9 come from the PWM controller. The others come from the timers.
#define PWM_PIN(P) WITHIN(P, 2, 13)
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
#ifndef MASK
#define MASK(PIN) (1 << PIN)
@@ -63,28 +64,20 @@
// Read a pin
#define _READ(IO) bool(DIO ## IO ## _WPORT -> PIO_PDSR & MASK(DIO ## IO ## _PIN))
-// Write to a pin
-#define _WRITE_VAR(IO,V) do { \
- volatile Pio* port = digitalPinToPort(IO); \
- const uint32_t mask = digitalPinToBitMask(IO); \
- if (V) port->PIO_SODR = mask; \
- else port->PIO_CODR = mask; \
-} while(0)
-
// Write to a pin
#define _WRITE(IO,V) do { \
volatile Pio* port = (DIO ## IO ## _WPORT); \
const uint32_t mask = MASK(DIO ## IO ## _PIN); \
if (V) port->PIO_SODR = mask; \
else port->PIO_CODR = mask; \
-} while(0)
+}while(0)
// Toggle a pin
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
#if MB(PRINTRBOARD_G2)
- #include "G2_pins.h"
+ #include "fastio/G2_pins.h"
// Set pin as input
#define _SET_INPUT(IO) do{ \
@@ -161,7 +154,6 @@
#define READ(IO) _READ(IO)
// Write to a pin (wrapper)
-#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
#define WRITE(IO,V) _WRITE(IO,V)
// Toggle a pin (wrapper)
@@ -174,17 +166,15 @@
// Set pin as output (wrapper) - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
// Set pin as PWM
-#define SET_PWM(IO) SET_OUTPUT(IO)
+#define SET_PWM SET_OUTPUT
// Check if pin is an input
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
// Check if pin is an output
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
-// Check if pin is a timer - Must be a constexpr
-#define HAS_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
// Shorthand
-#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
+#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp
new file mode 100644
index 0000000000..672932f56c
--- /dev/null
+++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp
@@ -0,0 +1,206 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * The PWM module is only used to generate interrupts at specified times. It
+ * is NOT used to directly toggle pins. The ISR writes to the pin assigned to
+ * that interrupt.
+ *
+ * All PWMs use the same repetition rate. The G2 needs about 10KHz min in order to
+ * not have obvious ripple on the Vref signals.
+ *
+ * The data structures are setup to minimize the computation done by the ISR which
+ * minimizes ISR execution time. Execution times are 0.8 to 1.1 microseconds.
+ *
+ * FIve PWM interrupt sources are used. Channel 0 sets the base period. All Vref
+ * signals are set active when this counter overflows and resets to zero. The compare
+ * values in channels 1-4 are set to give the desired duty cycle for that Vref pin.
+ * When counter 0 matches the compare value then that channel generates an interrupt.
+ * The ISR checks the source of the interrupt and sets the corresponding pin inactive.
+ *
+ * Some jitter in the Vref signal is OK so the interrupt priority is left at its default value.
+ */
+
+#include "../../../inc/MarlinConfig.h"
+
+#if MB(PRINTRBOARD_G2)
+
+#include "G2_PWM.h"
+
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
+ #define G2_PWM_X 1
+#else
+ #define G2_PWM_X 0
+#endif
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
+ #define G2_PWM_Y 1
+#else
+ #define G2_PWM_Y 0
+#endif
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
+ #define G2_PWM_Z 1
+#else
+ #define G2_PWM_Z 0
+#endif
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
+ #define G2_PWM_E 1
+#else
+ #define G2_PWM_E 0
+#endif
+#define G2_MASK_X(V) (G2_PWM_X * (V))
+#define G2_MASK_Y(V) (G2_PWM_Y * (V))
+#define G2_MASK_Z(V) (G2_PWM_Z * (V))
+#define G2_MASK_E(V) (G2_PWM_E * (V))
+
+volatile uint32_t *SODR_A = &PIOA->PIO_SODR,
+ *SODR_B = &PIOB->PIO_SODR,
+ *CODR_A = &PIOA->PIO_CODR,
+ *CODR_B = &PIOB->PIO_CODR;
+
+PWM_map ISR_table[NUM_PWMS] = PWM_MAP_INIT;
+
+void Stepper::digipot_init() {
+
+ #if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
+ OUT_WRITE(MOTOR_CURRENT_PWM_X_PIN, 0); // init pins
+ #endif
+ #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
+ OUT_WRITE(MOTOR_CURRENT_PWM_Y_PIN, 0);
+ #endif
+ #if G2_PWM_Z
+ OUT_WRITE(MOTOR_CURRENT_PWM_Z_PIN, 0);
+ #endif
+ #if G2_PWM_E
+ OUT_WRITE(MOTOR_CURRENT_PWM_E_PIN, 0);
+ #endif
+
+ #define WPKEY (0x50574D << 8) // “PWM” in ASCII
+ #define WPCMD_DIS_SW 0 // command to disable Write Protect SW
+ #define WPRG_ALL (PWM_WPCR_WPRG0 | PWM_WPCR_WPRG1 | PWM_WPCR_WPRG2 | PWM_WPCR_WPRG3 | PWM_WPCR_WPRG4 | PWM_WPCR_WPRG5) // all Write Protect Groups
+
+ #define PWM_CLOCK_F F_CPU / 1000000UL // set clock to 1MHz
+
+ PMC->PMC_PCER1 = PMC_PCER1_PID36; // enable PWM controller clock (disabled on power up)
+
+ PWM->PWM_WPCR = WPKEY | WPRG_ALL | WPCMD_DIS_SW; // enable setting of all PWM registers
+ PWM->PWM_CLK = PWM_CLOCK_F; // enable CLK_A and set it to 1MHz, leave CLK_B disabled
+ PWM->PWM_CH_NUM[0].PWM_CMR = 0b1011; // set channel 0 to Clock A input & to left aligned
+ if (G2_PWM_X) PWM->PWM_CH_NUM[1].PWM_CMR = 0b1011; // set channel 1 to Clock A input & to left aligned
+ if (G2_PWM_Y) PWM->PWM_CH_NUM[2].PWM_CMR = 0b1011; // set channel 2 to Clock A input & to left aligned
+ if (G2_PWM_Z) PWM->PWM_CH_NUM[3].PWM_CMR = 0b1011; // set channel 3 to Clock A input & to left aligned
+ if (G2_PWM_E) PWM->PWM_CH_NUM[4].PWM_CMR = 0b1011; // set channel 4 to Clock A input & to left aligned
+
+ PWM->PWM_CH_NUM[0].PWM_CPRD = PWM_PERIOD_US; // set channel 0 Period
+
+ PWM->PWM_IER2 = PWM_IER1_CHID0; // generate interrupt when counter0 overflows
+ PWM->PWM_IER2 = PWM_IER2_CMPM0
+ | G2_MASK_X(PWM_IER2_CMPM1)
+ | G2_MASK_Y(PWM_IER2_CMPM2)
+ | G2_MASK_Z(PWM_IER2_CMPM3)
+ | G2_MASK_E(PWM_IER2_CMPM4)
+ ; // generate interrupt on compare event
+
+ if (G2_PWM_X) PWM->PWM_CMP[1].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0])); // interrupt when counter0 == CMPV - used to set Motor 1 PWM inactive
+ if (G2_PWM_Y) PWM->PWM_CMP[2].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0])); // interrupt when counter0 == CMPV - used to set Motor 2 PWM inactive
+ if (G2_PWM_Z) PWM->PWM_CMP[3].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[1])); // interrupt when counter0 == CMPV - used to set Motor 3 PWM inactive
+ if (G2_PWM_E) PWM->PWM_CMP[4].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[2])); // interrupt when counter0 == CMPV - used to set Motor 4 PWM inactive
+
+ if (G2_PWM_X) PWM->PWM_CMP[1].PWM_CMPM = 0x0001; // enable compare event
+ if (G2_PWM_Y) PWM->PWM_CMP[2].PWM_CMPM = 0x0001; // enable compare event
+ if (G2_PWM_Z) PWM->PWM_CMP[3].PWM_CMPM = 0x0001; // enable compare event
+ if (G2_PWM_E) PWM->PWM_CMP[4].PWM_CMPM = 0x0001; // enable compare event
+
+ PWM->PWM_SCM = PWM_SCM_UPDM_MODE0 | PWM_SCM_SYNC0
+ | G2_MASK_X(PWM_SCM_SYNC1)
+ | G2_MASK_Y(PWM_SCM_SYNC2)
+ | G2_MASK_Z(PWM_SCM_SYNC3)
+ | G2_MASK_E(PWM_SCM_SYNC4)
+ ; // sync 1-4 with 0, use mode 0 for updates
+
+ PWM->PWM_ENA = PWM_ENA_CHID0
+ | G2_MASK_X(PWM_ENA_CHID1)
+ | G2_MASK_Y(PWM_ENA_CHID2)
+ | G2_MASK_Z(PWM_ENA_CHID3)
+ | G2_MASK_E(PWM_ENA_CHID4)
+ ; // enable channels used by G2
+
+ PWM->PWM_IER1 = PWM_IER1_CHID0
+ | G2_MASK_X(PWM_IER1_CHID1)
+ | G2_MASK_Y(PWM_IER1_CHID2)
+ | G2_MASK_Z(PWM_IER1_CHID3)
+ | G2_MASK_E(PWM_IER1_CHID4)
+ ; // enable interrupts for channels used by G2
+
+ NVIC_EnableIRQ(PWM_IRQn); // Enable interrupt handler
+ NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals)
+}
+
+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
+
+ switch (driver) {
+ case 0:
+ if (G2_PWM_X) PWM->PWM_CMP[1].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update X & Y
+ if (G2_PWM_Y) PWM->PWM_CMP[2].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));
+ if (G2_PWM_X) PWM->PWM_CMP[1].PWM_CMPMUPD = 0x0001; // enable compare event
+ if (G2_PWM_Y) PWM->PWM_CMP[2].PWM_CMPMUPD = 0x0001; // enable compare event
+ if (G2_PWM_X || G2_PWM_Y) PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
+ break;
+ case 1:
+ if (G2_PWM_Z) {
+ PWM->PWM_CMP[3].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update Z
+ PWM->PWM_CMP[3].PWM_CMPMUPD = 0x0001; // enable compare event
+ PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
+ }
+ break;
+ default:
+ if (G2_PWM_E) {
+ PWM->PWM_CMP[4].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update E
+ PWM->PWM_CMP[4].PWM_CMPMUPD = 0x0001; // enable compare event
+ PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
+ }
+ break;
+ }
+}
+
+volatile uint32_t PWM_ISR1_STATUS, PWM_ISR2_STATUS;
+
+void PWM_Handler() {
+ PWM_ISR1_STATUS = PWM->PWM_ISR1;
+ PWM_ISR2_STATUS = PWM->PWM_ISR2;
+ if (PWM_ISR1_STATUS & PWM_IER1_CHID0) { // CHAN_0 interrupt
+ if (G2_PWM_X) *ISR_table[0].set_register = ISR_table[0].write_mask; // set X to active
+ if (G2_PWM_Y) *ISR_table[1].set_register = ISR_table[1].write_mask; // set Y to active
+ if (G2_PWM_Z) *ISR_table[2].set_register = ISR_table[2].write_mask; // set Z to active
+ if (G2_PWM_E) *ISR_table[3].set_register = ISR_table[3].write_mask; // set E to active
+ }
+ else {
+ if (G2_PWM_X && (PWM_ISR2_STATUS & PWM_IER2_CMPM1)) *ISR_table[0].clr_register = ISR_table[0].write_mask; // set X to inactive
+ if (G2_PWM_Y && (PWM_ISR2_STATUS & PWM_IER2_CMPM2)) *ISR_table[1].clr_register = ISR_table[1].write_mask; // set Y to inactive
+ if (G2_PWM_Z && (PWM_ISR2_STATUS & PWM_IER2_CMPM3)) *ISR_table[2].clr_register = ISR_table[2].write_mask; // set Z to inactive
+ if (G2_PWM_E && (PWM_ISR2_STATUS & PWM_IER2_CMPM4)) *ISR_table[3].clr_register = ISR_table[3].write_mask; // set E to inactive
+ }
+ return;
+}
+
+#endif // PRINTRBOARD_G2
diff --git a/Marlin/src/HAL/HAL_DUE/G2_PWM.h b/Marlin/src/HAL/DUE/fastio/G2_PWM.h
similarity index 90%
rename from Marlin/src/HAL/HAL_DUE/G2_PWM.h
rename to Marlin/src/HAL/DUE/fastio/G2_PWM.h
index 5cbeaceba9..a94c1c5276 100644
--- a/Marlin/src/HAL/HAL_DUE/G2_PWM.h
+++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,14 +19,15 @@
* along with this program. If not, see .
*
*/
+#pragma once
/**
* This module is stripped down version of the LPC1768_PWM.h file from
* PR #7500. It is hardwired for the PRINTRBOARD_G2 Motor Current needs.
*/
-#include "../../inc/MarlinConfigPre.h"
-#include "../../module/stepper.h"
+#include "../../../inc/MarlinConfigPre.h"
+#include "../../../module/stepper.h"
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\stepper.h
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\HAL\HAL_DUE\G2_PWM.h
@@ -62,7 +63,7 @@ extern PWM_map ISR_table[NUM_PWMS];
extern uint32_t motor_current_setting[3];
#define IR_BIT(p) (WITHIN(p, 0, 3) ? (p) : (p) + 4)
-#define COPY_ACTIVE_TABLE() do{ for (uint8_t i = 0; i < 6 ; i++) work_table[i] = active_table[i]; }while(0)
+#define COPY_ACTIVE_TABLE() do{ LOOP_L_N(i, 6) work_table[i] = active_table[i]; }while(0)
#define PWM_MR0 19999 // base repetition rate minus one count - 20mS
#define PWM_PR 24 // prescaler value - prescaler divide by 24 + 1 - 1 MHz output
diff --git a/Marlin/src/HAL/HAL_DUE/G2_pins.h b/Marlin/src/HAL/DUE/fastio/G2_pins.h
similarity index 98%
rename from Marlin/src/HAL/HAL_DUE/G2_pins.h
rename to Marlin/src/HAL/DUE/fastio/G2_pins.h
index a7f432846e..44b9cb35ee 100644
--- a/Marlin/src/HAL/HAL_DUE/G2_pins.h
+++ b/Marlin/src/HAL/DUE/fastio/G2_pins.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -248,7 +248,7 @@ const G2_PinDescription G2_g_APinDescription[] = {
{ PIOB, PIO_PB15A_CANRX1|PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
// END
- { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
+ { nullptr, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
};
// This section replaces the FASTIO definitions of pins 34-41
diff --git a/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h b/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/DUE/inc/Conditionals_adv.h b/Marlin/src/HAL/DUE/inc/Conditionals_adv.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/DUE/inc/Conditionals_adv.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.h b/Marlin/src/HAL/DUE/inc/Conditionals_post.h
similarity index 74%
rename from Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.h
rename to Marlin/src/HAL/DUE/inc/Conditionals_post.h
index 6ee92a73ec..9b76c25102 100644
--- a/Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.h
+++ b/Marlin/src/HAL/DUE/inc/Conditionals_post.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,8 +21,8 @@
*/
#pragma once
-// Initialize watchdog with a 4 second interrupt time
-void watchdog_init();
-
-// Reset watchdog.
-inline void watchdog_reset() { }
+#if USE_FALLBACK_EEPROM
+ #define FLASH_EEPROM_EMULATION
+#elif EITHER(I2C_EEPROM, SPI_EEPROM)
+ #define USE_SHARED_EEPROM 1
+#endif
diff --git a/Marlin/src/HAL/HAL_DUE/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h
similarity index 90%
rename from Marlin/src/HAL/HAL_DUE/SanityCheck.h
rename to Marlin/src/HAL/DUE/inc/SanityCheck.h
index 30a5d72b25..0f7be7955f 100644
--- a/Marlin/src/HAL/HAL_DUE/SanityCheck.h
+++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
* along with this program. If not, see .
*
*/
+#pragma once
/**
* Test Arduino Due specific configuration values for errors at compile-time.
@@ -54,3 +55,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
+
+#if HAS_TMC_SW_SERIAL
+ #error "TMC220x Software Serial is not supported on this platform."
+#endif
diff --git a/Marlin/src/HAL/HAL_DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h
similarity index 93%
rename from Marlin/src/HAL/HAL_DUE/pinsDebug.h
rename to Marlin/src/HAL/DUE/pinsDebug.h
index 9d86577052..448c2391d3 100644
--- a/Marlin/src/HAL/HAL_DUE/pinsDebug.h
+++ b/Marlin/src/HAL/DUE/pinsDebug.h
@@ -1,9 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +25,7 @@
* Translation of routines & variables used by pinsDebug.h
*/
-#include
+#include "../shared/Marduino.h"
/**
* Due/Marlin quirks
@@ -65,9 +62,8 @@
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
#define PRINT_PORT(p)
-#define NAME_FORMAT(p) PSTR("%-##p##s")
-#define PRINT_ARRAY_NAME(x) do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer);} while (0)
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
diff --git a/Marlin/src/HAL/HAL_DUE/spi_pins.h b/Marlin/src/HAL/DUE/spi_pins.h
similarity index 82%
rename from Marlin/src/HAL/HAL_DUE/spi_pins.h
rename to Marlin/src/HAL/DUE/spi_pins.h
index c805b0c1ea..a205540bcd 100644
--- a/Marlin/src/HAL/HAL_DUE/spi_pins.h
+++ b/Marlin/src/HAL/DUE/spi_pins.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,19 +26,22 @@
*
* Available chip select pins for HW SPI are 4 10 52 77
*/
-#if (SDSS == 4) || (SDSS == 10) || (SDSS == 52) || (SDSS == 77)
- #if (SDSS == 4)
+#if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87
+ #if SDSS == 4
#define SPI_PIN 87
#define SPI_CHAN 1
- #elif (SDSS == 10)
+ #elif SDSS == 10
#define SPI_PIN 77
#define SPI_CHAN 0
- #elif (SDSS == 52)
+ #elif SDSS == 52
#define SPI_PIN 86
#define SPI_CHAN 2
- #else
+ #elif SDSS == 77
#define SPI_PIN 77
#define SPI_CHAN 0
+ #else
+ #define SPI_PIN 87
+ #define SPI_CHAN 1
#endif
#define SCK_PIN 76
#define MISO_PIN 74
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp b/Marlin/src/HAL/DUE/timers.cpp
similarity index 69%
rename from Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp
rename to Marlin/src/HAL/DUE/timers.cpp
index 9d2233d914..74ae882843 100644
--- a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp
+++ b/Marlin/src/HAL/DUE/timers.cpp
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
@@ -28,43 +28,29 @@
#ifdef ARDUINO_ARCH_SAM
-// --------------------------------------------------------------------------
+// ------------------------
// Includes
-// --------------------------------------------------------------------------
+// ------------------------
#include "../../inc/MarlinConfig.h"
#include "HAL.h"
-#include "HAL_timers_Due.h"
+#include "timers.h"
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Local defines
-// --------------------------------------------------------------------------
+// ------------------------
#define NUM_HARDWARE_TIMERS 9
-#define PRESCALER 2
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Private Variables
-// --------------------------------------------------------------------------
+// ------------------------
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
{ TC0, 1, TC1_IRQn, 0}, // 1
{ TC0, 2, TC2_IRQn, 2}, // 2 - stepper
- { TC1, 0, TC3_IRQn, 0}, // 3
+ { TC1, 0, TC3_IRQn, 0}, // 3 - stepper for BOARD_ARCHIM1
{ TC1, 1, TC4_IRQn, 15}, // 4 - temperature
{ TC1, 2, TC5_IRQn, 3}, // 5 - [servo timer3]
{ TC2, 0, TC6_IRQn, 14}, // 6 - tone
@@ -72,17 +58,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
{ TC2, 2, TC8_IRQn, 0}, // 8
};
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
/*
Timer_clock1: Prescaler 2 -> 42MHz
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h b/Marlin/src/HAL/DUE/timers.h
similarity index 81%
rename from Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
rename to Marlin/src/HAL/DUE/timers.h
index a2676e0875..5144660116 100644
--- a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
+++ b/Marlin/src/HAL/DUE/timers.h
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
@@ -26,15 +26,11 @@
* For ARDUINO_ARCH_SAM
*/
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include
-// --------------------------------------------------------------------------
+// ------------------------
// Defines
-// --------------------------------------------------------------------------
+// ------------------------
#define FORCE_INLINE __attribute__((always_inline)) inline
@@ -43,7 +39,9 @@ typedef uint32_t hal_timer_t;
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
+#ifndef STEP_TIMER_NUM
#define STEP_TIMER_NUM 2 // index of timer to use for stepper
+#endif
#define TEMP_TIMER_NUM 4 // index of timer to use for temperature
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
@@ -65,13 +63,15 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
-#define HAL_STEP_TIMER_ISR() void TC2_Handler()
+#ifndef HAL_STEP_TIMER_ISR
+ #define HAL_STEP_TIMER_ISR() void TC2_Handler()
+#endif
#define HAL_TEMP_TIMER_ISR() void TC4_Handler()
#define HAL_TONE_TIMER_ISR() void TC6_Handler()
-// --------------------------------------------------------------------------
+// ------------------------
// Types
-// --------------------------------------------------------------------------
+// ------------------------
typedef struct {
Tc *pTimerRegs;
@@ -80,15 +80,15 @@ typedef struct {
uint8_t priority;
} tTimerConfig;
-// --------------------------------------------------------------------------
+// ------------------------
// Public Variables
-// --------------------------------------------------------------------------
+// ------------------------
extern const tTimerConfig TimerConfig[];
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
diff --git a/Marlin/src/HAL/DUE/upload_extra_script.py b/Marlin/src/HAL/DUE/upload_extra_script.py
new file mode 100644
index 0000000000..06c2b914f5
--- /dev/null
+++ b/Marlin/src/HAL/DUE/upload_extra_script.py
@@ -0,0 +1,18 @@
+#
+# Set upload_command
+#
+# Windows: bossac.exe
+# Other: leave unchanged
+#
+
+import platform
+current_OS = platform.system()
+
+if current_OS == 'Windows':
+
+ Import("env")
+
+ # Use bossac.exe on Windows
+ env.Replace(
+ UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot"
+ )
diff --git a/Marlin/src/HAL/HAL_DUE/usb/arduino_due_x.h b/Marlin/src/HAL/DUE/usb/arduino_due_x.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/arduino_due_x.h
rename to Marlin/src/HAL/DUE/usb/arduino_due_x.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/compiler.h b/Marlin/src/HAL/DUE/usb/compiler.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/compiler.h
rename to Marlin/src/HAL/DUE/usb/compiler.h
index d9ecd3f0fe..33df080e2f 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/compiler.h
+++ b/Marlin/src/HAL/DUE/usb/compiler.h
@@ -112,7 +112,7 @@
* \def unused
* \brief Marking \a v as a unused parameter or value.
*/
-#define unused(v) do { (void)(v); } while(0)
+#define unused(v) do { (void)(v); }while(0)
/**
* \def barrier
@@ -169,7 +169,7 @@
* heuristics and inline the function no matter how big it thinks it
* becomes.
*/
-#if defined(__CC_ARM)
+#ifdef __CC_ARM
# define __always_inline __forceinline
#elif (defined __GNUC__)
#ifdef __always_inline
@@ -187,7 +187,7 @@
* This annotation instructs the compiler to ignore its inlining
* heuristics and not inline the function.
*/
-#if defined(__CC_ARM)
+#ifdef __CC_ARM
# define __no_inline __attribute__((noinline))
#elif (defined __GNUC__)
# define __no_inline __attribute__((__noinline__))
@@ -204,7 +204,7 @@
*
* \param expr Expression to evaluate and supposed to be nonzero.
*/
-#if defined(_ASSERT_ENABLE_)
+#ifdef _ASSERT_ENABLE_
# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO)
// Assert() is defined in unit_test/suite.h
# include "unit_test/suite.h"
@@ -230,7 +230,7 @@
/* Define NO_INIT attribute */
#if 0 //ndef NO_INIT
-#if defined ( __CC_ARM )
+#ifdef __CC_ARM
# define NO_INIT __attribute__((zero_init))
#elif defined ( __ICCARM__ )
# define NO_INIT __no_init
@@ -262,7 +262,7 @@
//! @{
typedef unsigned char Bool; //!< Boolean.
#ifndef __cplusplus
-#if !defined(__bool_true_false_are_defined)
+#ifndef __bool_true_false_are_defined
typedef unsigned char bool; //!< Boolean.
#endif
#endif
@@ -443,9 +443,9 @@ typedef struct
#define DISABLE 0
#define ENABLE 1
#ifndef __cplusplus
-#if !defined(__bool_true_false_are_defined)
-#define false 0
-#define true 1
+#ifndef __bool_true_false_are_defined
+#define false (1==0)
+#define true (1==1)
#endif
#endif
#ifndef PASS
@@ -998,14 +998,14 @@ typedef U8 Byte; //!< 8-bit unsigned integer.
#endif // #ifndef __ASSEMBLY__
-#if defined(__ICCARM__)
+#ifdef __ICCARM__
#define SHORTENUM __packed
#elif defined(__GNUC__)
#define SHORTENUM __attribute__((packed))
#endif
/* No operation */
-#if defined(__ICCARM__)
+#ifdef __ICCARM__
#define nop() __no_operation()
#elif defined(__GNUC__)
#define nop() (__NOP())
diff --git a/Marlin/src/HAL/HAL_DUE/usb/conf_access.h b/Marlin/src/HAL/DUE/usb/conf_access.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/conf_access.h
rename to Marlin/src/HAL/DUE/usb/conf_access.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/conf_clock.h b/Marlin/src/HAL/DUE/usb/conf_clock.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/conf_clock.h
rename to Marlin/src/HAL/DUE/usb/conf_clock.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h b/Marlin/src/HAL/DUE/usb/conf_usb.h
similarity index 92%
rename from Marlin/src/HAL/HAL_DUE/usb/conf_usb.h
rename to Marlin/src/HAL/DUE/usb/conf_usb.h
index 6934494e57..7beb9b0bba 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/conf_usb.h
+++ b/Marlin/src/HAL/DUE/usb/conf_usb.h
@@ -48,9 +48,7 @@
#define _CONF_USB_H_
#undef UNUSED /* To avoid a macro clash as macros.h already defines it */
-#include "../../../core/macros.h" /* For ENABLED()/DISABLED() */
-#include "../../../core/boards.h" /* For MB() */
-#include "../../../../Configuration.h" /* For CUSTOM_MACHINE_NAME definition - We just need the name, no C++ allowed! */
+#include "../../../inc/MarlinConfigPre.h"
#include "compiler.h"
/**
@@ -59,8 +57,6 @@
*/
//! Device definition (mandatory)
-#define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */
-#define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */
#define USB_DEVICE_MAJOR_VERSION 1
#define USB_DEVICE_MINOR_VERSION 0
#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
@@ -70,15 +66,6 @@
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
-//! USB Device string definitions (Optional)
-#define USB_DEVICE_MANUFACTURE_NAME "marlinfw.org"
-#ifdef CUSTOM_MACHINE_NAME
- #define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME
-#else
- #define USB_DEVICE_PRODUCT_NAME "3D Printer"
-#endif
-#define USB_DEVICE_SERIAL_NAME "123985739853"
-
/**
* Device speeds support
* Low speed not supported by CDC and MSC
@@ -91,10 +78,6 @@
//! To define a Full speed device
//#define USB_DEVICE_FULL_SPEED
-#if MB(ARCHIM1)
- #define USB_DEVICE_FULL_SPEED
-#endif
-
//! To authorize the High speed
#ifndef USB_DEVICE_FULL_SPEED
#if (UC3A3||UC3A4)
diff --git a/Marlin/src/HAL/HAL_DUE/usb/ctrl_access.c b/Marlin/src/HAL/DUE/usb/ctrl_access.c
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/ctrl_access.c
rename to Marlin/src/HAL/DUE/usb/ctrl_access.c
diff --git a/Marlin/src/HAL/HAL_DUE/usb/ctrl_access.h b/Marlin/src/HAL/DUE/usb/ctrl_access.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/ctrl_access.h
rename to Marlin/src/HAL/DUE/usb/ctrl_access.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/genclk.h b/Marlin/src/HAL/DUE/usb/genclk.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/genclk.h
rename to Marlin/src/HAL/DUE/usb/genclk.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/mrepeat.h b/Marlin/src/HAL/DUE/usb/mrepeat.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/mrepeat.h
rename to Marlin/src/HAL/DUE/usb/mrepeat.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/osc.h b/Marlin/src/HAL/DUE/usb/osc.h
similarity index 97%
rename from Marlin/src/HAL/HAL_DUE/usb/osc.h
rename to Marlin/src/HAL/DUE/usb/osc.h
index fe09d6fd3e..3a9543507b 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/osc.h
+++ b/Marlin/src/HAL/DUE/usb/osc.h
@@ -61,27 +61,27 @@ extern "C" {
* Below BOARD_XXX macros are related to the specific board, and
* should be defined by the board code, otherwise default value are used.
*/
-#if !defined(BOARD_FREQ_SLCK_XTAL)
+#ifndef BOARD_FREQ_SLCK_XTAL
# warning The board slow clock xtal frequency has not been defined.
# define BOARD_FREQ_SLCK_XTAL (32768UL)
#endif
-#if !defined(BOARD_FREQ_SLCK_BYPASS)
+#ifndef BOARD_FREQ_SLCK_BYPASS
# warning The board slow clock bypass frequency has not been defined.
# define BOARD_FREQ_SLCK_BYPASS (32768UL)
#endif
-#if !defined(BOARD_FREQ_MAINCK_XTAL)
+#ifndef BOARD_FREQ_MAINCK_XTAL
# warning The board main clock xtal frequency has not been defined.
# define BOARD_FREQ_MAINCK_XTAL (12000000UL)
#endif
-#if !defined(BOARD_FREQ_MAINCK_BYPASS)
+#ifndef BOARD_FREQ_MAINCK_BYPASS
# warning The board main clock bypass frequency has not been defined.
# define BOARD_FREQ_MAINCK_BYPASS (12000000UL)
#endif
-#if !defined(BOARD_OSC_STARTUP_US)
+#ifndef BOARD_OSC_STARTUP_US
# warning The board main clock xtal startup time has not been defined.
# define BOARD_OSC_STARTUP_US (15625UL)
#endif
diff --git a/Marlin/src/HAL/HAL_DUE/usb/pll.h b/Marlin/src/HAL/DUE/usb/pll.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/pll.h
rename to Marlin/src/HAL/DUE/usb/pll.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/preprocessor.h b/Marlin/src/HAL/DUE/usb/preprocessor.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/preprocessor.h
rename to Marlin/src/HAL/DUE/usb/preprocessor.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/sbc_protocol.h b/Marlin/src/HAL/DUE/usb/sbc_protocol.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/sbc_protocol.h
rename to Marlin/src/HAL/DUE/usb/sbc_protocol.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
similarity index 81%
rename from Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp
rename to Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
index 468e9ee45d..ea2936359d 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp
+++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
@@ -15,11 +15,14 @@ extern "C" {
#define SD_MMC_BLOCK_SIZE 512
-void sd_mmc_spi_mem_init(void) {
+void sd_mmc_spi_mem_init() {
}
-Ctrl_status sd_mmc_spi_test_unit_ready(void) {
- if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
+Ctrl_status sd_mmc_spi_test_unit_ready() {
+ #ifdef DISABLE_DUE_SD_MMC
+ return CTRL_NO_PRESENT;
+ #endif
+ if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
return CTRL_GOOD;
}
@@ -27,24 +30,18 @@ Ctrl_status sd_mmc_spi_test_unit_ready(void) {
// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
- if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
+ if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
*nb_sector = card.getSd2Card().cardSize() - 1;
return CTRL_GOOD;
}
-bool sd_mmc_spi_unload(bool unload) {
- return true;
-}
+bool sd_mmc_spi_unload(bool) { return true; }
-bool sd_mmc_spi_wr_protect(void) {
- return false;
-}
+bool sd_mmc_spi_wr_protect() { return false; }
-bool sd_mmc_spi_removal(void) {
- if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
- return true;
- return false;
+bool sd_mmc_spi_removal() {
+ return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted());
}
#if ACCESS_USB == true
@@ -61,7 +58,10 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE];
// #define DEBUG_MMC
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
- if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
+ #ifdef DISABLE_DUE_SD_MMC
+ return CTRL_NO_PRESENT;
+ #endif
+ if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC
@@ -98,7 +98,10 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
}
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
- if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
+ #ifdef DISABLE_DUE_SD_MMC
+ return CTRL_NO_PRESENT;
+ #endif
+ if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC
diff --git a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.h b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.h
rename to Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/spc_protocol.h b/Marlin/src/HAL/DUE/usb/spc_protocol.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/spc_protocol.h
rename to Marlin/src/HAL/DUE/usb/spc_protocol.h
index e5e7603c9a..6fadb9f36c 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/spc_protocol.h
+++ b/Marlin/src/HAL/DUE/usb/spc_protocol.h
@@ -43,12 +43,12 @@
* \asf_license_stop
*
*/
+
/*
* Support and FAQ: visit Atmel Support
*/
-#ifndef _SPC_PROTOCOL_H_
-#define _SPC_PROTOCOL_H_
-
+#ifndef _SPC_PROTOCOL_H_
+#define _SPC_PROTOCOL_H_
/**
* \ingroup usb_msc_protocol
diff --git a/Marlin/src/HAL/HAL_DUE/usb/stringz.h b/Marlin/src/HAL/DUE/usb/stringz.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/stringz.h
rename to Marlin/src/HAL/DUE/usb/stringz.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/sysclk.c b/Marlin/src/HAL/DUE/usb/sysclk.c
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/sysclk.c
rename to Marlin/src/HAL/DUE/usb/sysclk.c
diff --git a/Marlin/src/HAL/HAL_DUE/usb/sysclk.h b/Marlin/src/HAL/DUE/usb/sysclk.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/sysclk.h
rename to Marlin/src/HAL/DUE/usb/sysclk.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/tpaste.h b/Marlin/src/HAL/DUE/usb/tpaste.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/tpaste.h
rename to Marlin/src/HAL/DUE/usb/tpaste.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udc.c b/Marlin/src/HAL/DUE/usb/udc.c
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/udc.c
rename to Marlin/src/HAL/DUE/usb/udc.c
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udc.h b/Marlin/src/HAL/DUE/usb/udc.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/udc.h
rename to Marlin/src/HAL/DUE/usb/udc.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udc_desc.h b/Marlin/src/HAL/DUE/usb/udc_desc.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/udc_desc.h
rename to Marlin/src/HAL/DUE/usb/udc_desc.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udd.h b/Marlin/src/HAL/DUE/usb/udd.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/udd.h
rename to Marlin/src/HAL/DUE/usb/udd.h
index 10807f43d7..c87763de23 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udd.h
+++ b/Marlin/src/HAL/DUE/usb/udd.h
@@ -94,11 +94,11 @@ typedef struct {
uint16_t payload_size;
//! Callback called after reception of ZLP from setup request
- void (*callback) (void);
+ void (*callback)(void);
//! Callback called when the buffer given (.payload) is full or empty.
//! This one return false to abort data transfer, or true with a new buffer in .payload.
- bool(*over_under_run) (void);
+ bool (*over_under_run)(void);
} udd_ctrl_request_t;
extern udd_ctrl_request_t udd_g_ctrlreq;
@@ -123,7 +123,7 @@ extern udd_ctrl_request_t udd_g_ctrlreq;
* Registered by routine udd_ep_wait_stall_clear()
* Callback called when endpoint stall is cleared.
*/
-typedef void (*udd_callback_halt_cleared_t) (void);
+typedef void (*udd_callback_halt_cleared_t)(void);
/**
* \brief End of transfer callback function type.
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi.h b/Marlin/src/HAL/DUE/usb/udi.h
similarity index 96%
rename from Marlin/src/HAL/HAL_DUE/usb/udi.h
rename to Marlin/src/HAL/DUE/usb/udi.h
index 1fc7ae5d01..709908cad9 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi.h
+++ b/Marlin/src/HAL/DUE/usb/udi.h
@@ -82,7 +82,7 @@ typedef struct {
*
* \return \c 1 if function was successfully done, otherwise \c 0.
*/
- bool(*enable) (void);
+ bool (*enable)(void);
/**
* \brief Disable the interface.
@@ -95,7 +95,7 @@ typedef struct {
* - the device is detached from the host (i.e. Vbus is no
* longer present)
*/
- void (*disable) (void);
+ void (*disable)(void);
/**
* \brief Handle a control request directed at an interface.
@@ -108,7 +108,7 @@ typedef struct {
*
* \return \c 1 if this interface supports the SETUP request, otherwise \c 0.
*/
- bool(*setup) (void);
+ bool (*setup)(void);
/**
* \brief Returns the current setting of the selected interface.
@@ -117,12 +117,12 @@ typedef struct {
*
* \return alternate setting of selected interface
*/
- uint8_t(*getsetting) (void);
+ uint8_t (*getsetting)(void);
/**
* \brief To signal that a SOF is occurred
*/
- void(*sof_notify) (void);
+ void (*sof_notify)(void);
} udi_api_t;
//@}
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc.c b/Marlin/src/HAL/DUE/usb/udi_cdc.c
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_cdc.c
rename to Marlin/src/HAL/DUE/usb/udi_cdc.c
index e54ee570fa..60c9546ce2 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc.c
+++ b/Marlin/src/HAL/DUE/usb/udi_cdc.c
@@ -458,7 +458,7 @@ void udi_cdc_data_sof_notify(void)
}
-//-------------------------------------------------
+// ------------------------
//------- Internal routines to control serial line
static uint8_t udi_cdc_setup_to_port(void)
@@ -579,7 +579,7 @@ static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n,
}
-//-------------------------------------------------
+// ------------------------
//------- Internal routines to process data transfer
@@ -781,7 +781,7 @@ static void udi_cdc_tx_send(uint8_t port)
}
-//---------------------------------------------
+// ------------------------
//------- Application interface
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc.h b/Marlin/src/HAL/DUE/usb/udi_cdc.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_cdc.h
rename to Marlin/src/HAL/DUE/usb/udi_cdc.h
index 45c5cef5ae..526419c860 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc.h
+++ b/Marlin/src/HAL/DUE/usb/udi_cdc.h
@@ -55,7 +55,7 @@
#include "udi.h"
// Check the number of port
-#ifndef UDI_CDC_PORT_NB
+#ifndef UDI_CDC_PORT_NB
# define UDI_CDC_PORT_NB 1
#endif
#if (UDI_CDC_PORT_NB < 1) || (UDI_CDC_PORT_NB > 7)
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc_conf.h b/Marlin/src/HAL/DUE/usb/udi_cdc_conf.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_cdc_conf.h
rename to Marlin/src/HAL/DUE/usb/udi_cdc_conf.h
index b99d611171..cbd3eb00ae 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc_conf.h
+++ b/Marlin/src/HAL/DUE/usb/udi_cdc_conf.h
@@ -50,7 +50,7 @@
#include "usb_protocol_cdc.h"
#include "conf_usb.h"
-#ifndef UDI_CDC_PORT_NB
+#ifndef UDI_CDC_PORT_NB
# define UDI_CDC_PORT_NB 1
#endif
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_cdc_desc.c b/Marlin/src/HAL/DUE/usb/udi_cdc_desc.c
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_cdc_desc.c
rename to Marlin/src/HAL/DUE/usb/udi_cdc_desc.c
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_composite_desc.c b/Marlin/src/HAL/DUE/usb/udi_composite_desc.c
similarity index 95%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_composite_desc.c
rename to Marlin/src/HAL/DUE/usb/udi_composite_desc.c
index 3c5f001a26..07bdd1b9d6 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi_composite_desc.c
+++ b/Marlin/src/HAL/DUE/usb/udi_composite_desc.c
@@ -67,9 +67,9 @@ UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
.bLength = sizeof(usb_dev_desc_t),
.bDescriptorType = USB_DT_DEVICE,
.bcdUSB = LE16(USB_V2_0),
- .bDeviceClass = 0,
- .bDeviceSubClass = 0,
- .bDeviceProtocol = 0,
+ .bDeviceClass = CDC_CLASS_MULTI,
+ .bDeviceSubClass = CDC_SUBCLASS_ACM,
+ .bDeviceProtocol = CDC_PROTOCOL_V25TER,
.bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
.idVendor = LE16(USB_DEVICE_VENDOR_ID),
.idProduct = LE16(USB_DEVICE_PRODUCT_ID),
@@ -101,9 +101,9 @@ UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
.bLength = sizeof(usb_dev_qual_desc_t),
.bDescriptorType = USB_DT_DEVICE_QUALIFIER,
.bcdUSB = LE16(USB_V2_0),
- .bDeviceClass = 0,
- .bDeviceSubClass = 0,
- .bDeviceProtocol = 0,
+ .bDeviceClass = CDC_CLASS_MULTI,
+ .bDeviceSubClass = CDC_SUBCLASS_ACM,
+ .bDeviceProtocol = CDC_PROTOCOL_V25TER,
.bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
.bNumConfigurations = 1
};
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_msc.c b/Marlin/src/HAL/DUE/usb/udi_msc.c
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_msc.c
rename to Marlin/src/HAL/DUE/usb/udi_msc.c
index 97d3f2990b..627bca0d4f 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/udi_msc.c
+++ b/Marlin/src/HAL/DUE/usb/udi_msc.c
@@ -457,7 +457,7 @@ uint8_t udi_msc_getsetting(void)
}
-//---------------------------------------------
+// ------------------------
//------- Routines to process CBW packet
static void udi_msc_cbw_invalid(void)
@@ -613,7 +613,7 @@ static bool udi_msc_cbw_validate(uint32_t alloc_len, uint8_t dir_flag)
}
-//---------------------------------------------
+// ------------------------
//------- Routines to process small data packet
static void udi_msc_data_send(uint8_t * buffer, uint8_t buf_size)
@@ -645,7 +645,7 @@ static void udi_msc_data_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
-//---------------------------------------------
+// ------------------------
//------- Routines to process CSW packet
static void udi_msc_csw_process(void)
@@ -691,7 +691,7 @@ static void udi_msc_csw_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
-//---------------------------------------------
+// ------------------------
//------- Routines manage sense data
static void udi_msc_clear_sense(void)
@@ -757,7 +757,7 @@ static void udi_msc_sense_command_invalid(void)
}
-//---------------------------------------------
+// ------------------------
//------- Routines manage SCSI Commands
static void udi_msc_spc_requestsense(void)
diff --git a/Marlin/src/HAL/HAL_DUE/usb/udi_msc.h b/Marlin/src/HAL/DUE/usb/udi_msc.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/udi_msc.h
rename to Marlin/src/HAL/DUE/usb/udi_msc.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c b/Marlin/src/HAL/DUE/usb/uotghs_device_due.c
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
rename to Marlin/src/HAL/DUE/usb/uotghs_device_due.c
index 0dfcd5ac1f..2a10190c7e 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
+++ b/Marlin/src/HAL/DUE/usb/uotghs_device_due.c
@@ -40,6 +40,7 @@
* \asf_license_stop
*
*/
+
/*
* Support and FAQ: visit Atmel Support
*/
@@ -505,7 +506,7 @@ static bool udd_ep_interrupt(void);
//@}
-//--------------------------------------------------------
+// ------------------------
//--- INTERNAL ROUTINES TO MANAGED GLOBAL EVENTS
/**
@@ -1306,7 +1307,7 @@ void udd_test_mode_packet(void)
-//--------------------------------------------------------
+// ------------------------
//--- INTERNAL ROUTINES TO MANAGED THE CONTROL ENDPOINT
static void udd_reset_ep_ctrl(void)
@@ -1478,7 +1479,7 @@ static void udd_ctrl_in_sent(void)
// The IN data don't must be written in endpoint 0 DPRAM during
// a next setup reception in same endpoint 0 DPRAM.
// Thereby, an OUT ZLP reception must check before IN data write
- // and if no OUT ZLP is recevied the data must be written quickly (800us)
+ // and if no OUT ZLP is received the data must be written quickly (800µs)
// before an eventually ZLP OUT and SETUP reception
flags = cpu_irq_save();
if (Is_udd_out_received(0)) {
@@ -1728,7 +1729,7 @@ static bool udd_ctrl_interrupt(void)
}
-//--------------------------------------------------------
+// ------------------------
//--- INTERNAL ROUTINES TO MANAGED THE BULK/INTERRUPT/ISOCHRONOUS ENDPOINTS
#if (0 != USB_DEVICE_MAX_EP)
@@ -1904,7 +1905,7 @@ static void udd_ep_in_sent(udd_ep_id_t ep)
ptr_src = &ptr_job->buf[ptr_job->buf_cnt];
nb_remain = ptr_job->buf_size - ptr_job->buf_cnt;
// Fill a bank even if no data (ZLP)
- nb_data = MIN(nb_remain, pkt_size);
+ nb_data = min(nb_remain, pkt_size);
// Modify job information
ptr_job->buf_cnt += nb_data;
ptr_job->buf_load = nb_data;
diff --git a/Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h b/Marlin/src/HAL/DUE/usb/uotghs_device_due.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h
rename to Marlin/src/HAL/DUE/usb/uotghs_device_due.h
index 1cd6914f85..97877994bf 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h
+++ b/Marlin/src/HAL/DUE/usb/uotghs_device_due.h
@@ -291,7 +291,7 @@ extern "C" {
//! available greater size, then applies register format of UOTGHS controller
//! for endpoint size bit-field.
#undef udd_format_endpoint_size
-#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)MIN(MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
+#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)min(max(size, 8), 1024) << 1) - 1) - 1 - 3)
//! Configures the selected endpoint size
#define udd_configure_endpoint_size(ep, size) (Wr_bitfield(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPSIZE_Msk, udd_format_endpoint_size(size)))
//! Gets the configured selected endpoint size
diff --git a/Marlin/src/HAL/HAL_DUE/usb/uotghs_otg.h b/Marlin/src/HAL/DUE/usb/uotghs_otg.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/uotghs_otg.h
rename to Marlin/src/HAL/DUE/usb/uotghs_otg.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/usb_protocol.h b/Marlin/src/HAL/DUE/usb/usb_protocol.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/usb_protocol.h
rename to Marlin/src/HAL/DUE/usb/usb_protocol.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/usb_protocol_cdc.h b/Marlin/src/HAL/DUE/usb/usb_protocol_cdc.h
similarity index 99%
rename from Marlin/src/HAL/HAL_DUE/usb/usb_protocol_cdc.h
rename to Marlin/src/HAL/DUE/usb/usb_protocol_cdc.h
index 875e7e4dda..49fc7387ef 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/usb_protocol_cdc.h
+++ b/Marlin/src/HAL/DUE/usb/usb_protocol_cdc.h
@@ -61,6 +61,8 @@
#define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
#define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
#define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
+#define CDC_CLASS_MULTI 0xEF //!< CDC Multi-interface Function
+
//@}
//! \name USB CDC Subclass IDs
diff --git a/Marlin/src/HAL/HAL_DUE/usb/usb_protocol_msc.h b/Marlin/src/HAL/DUE/usb/usb_protocol_msc.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/usb_protocol_msc.h
rename to Marlin/src/HAL/DUE/usb/usb_protocol_msc.h
diff --git a/Marlin/src/HAL/HAL_DUE/usb/usb_task.c b/Marlin/src/HAL/DUE/usb/usb_task.c
similarity index 96%
rename from Marlin/src/HAL/HAL_DUE/usb/usb_task.c
rename to Marlin/src/HAL/DUE/usb/usb_task.c
index c9de09c113..29d02faef7 100644
--- a/Marlin/src/HAL/HAL_DUE/usb/usb_task.c
+++ b/Marlin/src/HAL/DUE/usb/usb_task.c
@@ -45,11 +45,12 @@
#ifdef ARDUINO_ARCH_SAM
-#include "conf_usb.h"
-#include "udc.h"
#include
#include
+#include "conf_usb.h"
+#include "udc.h"
+
#if ENABLED(SDSUPPORT)
static volatile bool main_b_msc_enable = false;
#endif
@@ -75,14 +76,14 @@ void usb_task_idle(void) {
bool usb_task_msc_isenabled(void) { return main_b_msc_enable; }
#endif
-bool usb_task_cdc_enable(const uint8_t port) { return ((main_b_cdc_enable = true)); }
-void usb_task_cdc_disable(const uint8_t port) { main_b_cdc_enable = false; main_b_dtr_active = false; }
+bool usb_task_cdc_enable(const uint8_t port) { UNUSED(port); return ((main_b_cdc_enable = true)); }
+void usb_task_cdc_disable(const uint8_t port) { UNUSED(port); main_b_cdc_enable = false; main_b_dtr_active = false; }
bool usb_task_cdc_isenabled(void) { return main_b_cdc_enable; }
/*! \brief Called by CDC interface
* Callback running when CDC device have received data
*/
-void usb_task_cdc_rx_notify(const uint8_t port) { }
+void usb_task_cdc_rx_notify(const uint8_t port) { UNUSED(port); }
/*! \brief Configures communication line
*
@@ -90,13 +91,13 @@ void usb_task_cdc_rx_notify(const uint8_t port) { }
*/
static uint16_t dwDTERate = 0;
void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg) {
- // Store last DTE rate
- dwDTERate = cfg->dwDTERate;
+ UNUSED(port);
+ // Store last DTE rate
+ dwDTERate = cfg->dwDTERate;
}
-
void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
-
+ UNUSED(port);
// Keep DTR status
main_b_dtr_active = b_enable;
diff --git a/Marlin/src/HAL/HAL_DUE/usb/usb_task.h b/Marlin/src/HAL/DUE/usb/usb_task.h
similarity index 100%
rename from Marlin/src/HAL/HAL_DUE/usb/usb_task.h
rename to Marlin/src/HAL/DUE/usb/usb_task.h
diff --git a/Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp b/Marlin/src/HAL/DUE/watchdog.cpp
similarity index 93%
rename from Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp
rename to Marlin/src/HAL/DUE/watchdog.cpp
index 2bf8080b76..2fa6ea5e5d 100644
--- a/Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp
+++ b/Marlin/src/HAL/DUE/watchdog.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,12 +19,11 @@
* along with this program. If not, see .
*
*/
-
#ifdef ARDUINO_ARCH_SAM
#include "../../inc/MarlinConfig.h"
-#include "../../Marlin.h"
-#include "watchdog_Due.h"
+#include "../../MarlinCore.h"
+#include "watchdog.h"
// Override Arduino runtime to either config or disable the watchdog
//
@@ -32,7 +31,7 @@
// process, because watchdog initialization at hardware reset on SAM3X8E
// is unreliable, and there is risk of unintended resets if we delay
// that initialization to a later time.
-void watchdogSetup(void) {
+void watchdogSetup() {
#if ENABLED(USE_WATCHDOG)
@@ -106,7 +105,7 @@ void watchdogSetup(void) {
// Initialize watchdog - On SAM3X, Watchdog was already configured
// and enabled or disabled at startup, so no need to reconfigure it
// here.
- void watchdog_init(void) {
+ void watchdog_init() {
// Reset watchdog to start clean
WDT_Restart(WDT);
}
diff --git a/Marlin/src/HAL/HAL_DUE/watchdog_Due.h b/Marlin/src/HAL/DUE/watchdog.h
similarity index 85%
rename from Marlin/src/HAL/HAL_DUE/watchdog_Due.h
rename to Marlin/src/HAL/DUE/watchdog.h
index 07187bfe6b..7d9665f20e 100644
--- a/Marlin/src/HAL/HAL_DUE/watchdog_Due.h
+++ b/Marlin/src/HAL/DUE/watchdog.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,4 +30,4 @@ void watchdog_init();
// Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or AVR will go into emergency procedures.
-inline void watchdog_reset() { watchdogReset(); }
+inline void HAL_watchdog_refresh() { watchdogReset(); }
diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp
new file mode 100644
index 0000000000..4d70d34edb
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp
@@ -0,0 +1,33 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "FlushableHardwareSerial.h"
+
+#ifdef ARDUINO_ARCH_ESP32
+
+FlushableHardwareSerial::FlushableHardwareSerial(int uart_nr)
+ : HardwareSerial(uart_nr)
+{}
+
+FlushableHardwareSerial flushableSerial(0);
+
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h
new file mode 100644
index 0000000000..703bcbeb73
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h
@@ -0,0 +1,37 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#ifdef ARDUINO_ARCH_ESP32
+
+#include
+
+class FlushableHardwareSerial : public HardwareSerial {
+public:
+ FlushableHardwareSerial(int uart_nr);
+
+ inline void flushTX() { /* No need to flush the hardware serial, but defined here for compatibility. */ }
+};
+
+extern FlushableHardwareSerial flushableSerial;
+
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp
new file mode 100644
index 0000000000..4194c531cf
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/HAL.cpp
@@ -0,0 +1,276 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_ESP32
+
+#include "HAL.h"
+#include "timers.h"
+#include
+#include
+#include
+#include
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if ENABLED(WIFISUPPORT)
+ #include
+ #include "wifi.h"
+ #if ENABLED(OTASUPPORT)
+ #include "ota.h"
+ #endif
+ #if ENABLED(WEBSUPPORT)
+ #include "spiffs.h"
+ #include "web.h"
+ #endif
+#endif
+
+// ------------------------
+// Externs
+// ------------------------
+
+portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
+
+// ------------------------
+// Local defines
+// ------------------------
+
+#define V_REF 1100
+
+// ------------------------
+// Public Variables
+// ------------------------
+
+uint16_t HAL_adc_result;
+
+// ------------------------
+// Private Variables
+// ------------------------
+
+esp_adc_cal_characteristics_t characteristics[ADC_ATTEN_MAX];
+adc_atten_t attenuations[ADC1_CHANNEL_MAX] = {};
+uint32_t thresholds[ADC_ATTEN_MAX];
+volatile int numPWMUsed = 0,
+ pwmPins[MAX_PWM_PINS],
+ pwmValues[MAX_PWM_PINS];
+
+// ------------------------
+// Public functions
+// ------------------------
+
+#if ENABLED(WIFI_CUSTOM_COMMAND)
+
+ bool wifi_custom_command(char * const command_ptr) {
+ #if ENABLED(ESP3D_WIFISUPPORT)
+ return esp3dlib.parse(command_ptr);
+ #else
+ UNUSED(command_ptr);
+ return false;
+ #endif
+ }
+
+#endif
+
+void HAL_init() { i2s_init(); }
+
+void HAL_init_board() {
+
+ #if ENABLED(ESP3D_WIFISUPPORT)
+ esp3dlib.init();
+ #elif ENABLED(WIFISUPPORT)
+ wifi_init();
+ TERN_(OTASUPPORT, OTA_init());
+ #if ENABLED(WEBSUPPORT)
+ spiffs_init();
+ web_init();
+ #endif
+ server.begin();
+ #endif
+
+ // ESP32 uses a GPIO matrix that allows pins to be assigned to hardware serial ports.
+ // The following code initializes hardware Serial1 and Serial2 to use user-defined pins
+ // if they have been defined.
+ #if defined(HARDWARE_SERIAL1_RX) && defined(HARDWARE_SERIAL1_TX)
+ HardwareSerial Serial1(1);
+ #ifdef TMC_BAUD_RATE // use TMC_BAUD_RATE for Serial1 if defined
+ Serial1.begin(TMC_BAUD_RATE, SERIAL_8N1, HARDWARE_SERIAL1_RX, HARDWARE_SERIAL1_TX);
+ #else // use default BAUDRATE if TMC_BAUD_RATE not defined
+ Serial1.begin(BAUDRATE, SERIAL_8N1, HARDWARE_SERIAL1_RX, HARDWARE_SERIAL1_TX);
+ #endif
+ #endif
+ #if defined(HARDWARE_SERIAL2_RX) && defined(HARDWARE_SERIAL2_TX)
+ HardwareSerial Serial2(2);
+ #ifdef TMC_BAUD_RATE // use TMC_BAUD_RATE for Serial1 if defined
+ Serial2.begin(TMC_BAUD_RATE, SERIAL_8N1, HARDWARE_SERIAL2_RX, HARDWARE_SERIAL2_TX);
+ #else // use default BAUDRATE if TMC_BAUD_RATE not defined
+ Serial2.begin(BAUDRATE, SERIAL_8N1, HARDWARE_SERIAL2_RX, HARDWARE_SERIAL2_TX);
+ #endif
+ #endif
+
+}
+
+void HAL_idletask() {
+ #if BOTH(WIFISUPPORT, OTASUPPORT)
+ OTA_handle();
+ #endif
+ TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask());
+}
+
+void HAL_clear_reset_source() { }
+
+uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); }
+
+void _delay_ms(int delay_ms) { delay(delay_ms); }
+
+// return free memory between end of heap (or end bss) and whatever is current
+int freeMemory() { return ESP.getFreeHeap(); }
+
+// ------------------------
+// ADC
+// ------------------------
+#define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL
+
+adc1_channel_t get_channel(int pin) {
+ switch (pin) {
+ case 39: return ADC1_CHANNEL(39);
+ case 36: return ADC1_CHANNEL(36);
+ case 35: return ADC1_CHANNEL(35);
+ case 34: return ADC1_CHANNEL(34);
+ case 33: return ADC1_CHANNEL(33);
+ case 32: return ADC1_CHANNEL(32);
+ }
+ return ADC1_CHANNEL_MAX;
+}
+
+void adc1_set_attenuation(adc1_channel_t chan, adc_atten_t atten) {
+ if (attenuations[chan] != atten) {
+ adc1_config_channel_atten(chan, atten);
+ attenuations[chan] = atten;
+ }
+}
+
+void HAL_adc_init() {
+ // Configure ADC
+ adc1_config_width(ADC_WIDTH_12Bit);
+
+ // Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects
+ TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
+ TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
+ TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
+
+ // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
+ // That's why we're not setting it up here.
+
+ // Calculate ADC characteristics (i.e., gain and offset factors for each attenuation level)
+ for (int i = 0; i < ADC_ATTEN_MAX; i++) {
+ esp_adc_cal_characterize(ADC_UNIT_1, (adc_atten_t)i, ADC_WIDTH_BIT_12, V_REF, &characteristics[i]);
+
+ // Change attenuation 100mV below the calibrated threshold
+ thresholds[i] = esp_adc_cal_raw_to_voltage(4095, &characteristics[i]);
+ }
+}
+
+void HAL_adc_start_conversion(const uint8_t adc_pin) {
+ const adc1_channel_t chan = get_channel(adc_pin);
+ uint32_t mv;
+ esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
+ HAL_adc_result = mv * 1023.0 / 3300.0;
+
+ // Change the attenuation level based on the new reading
+ adc_atten_t atten;
+ if (mv < thresholds[ADC_ATTEN_DB_0] - 100)
+ atten = ADC_ATTEN_DB_0;
+ else if (mv > thresholds[ADC_ATTEN_DB_0] - 50 && mv < thresholds[ADC_ATTEN_DB_2_5] - 100)
+ atten = ADC_ATTEN_DB_2_5;
+ else if (mv > thresholds[ADC_ATTEN_DB_2_5] - 50 && mv < thresholds[ADC_ATTEN_DB_6] - 100)
+ atten = ADC_ATTEN_DB_6;
+ else if (mv > thresholds[ADC_ATTEN_DB_6] - 50)
+ atten = ADC_ATTEN_DB_11;
+ else return;
+
+ adc1_set_attenuation(chan, atten);
+}
+
+void analogWrite(pin_t pin, int value) {
+ // Use ledc hardware for internal pins
+ if (pin < 34) {
+ static int cnt_channel = 1, pin_to_channel[40] = { 0 };
+ if (pin_to_channel[pin] == 0) {
+ ledcAttachPin(pin, cnt_channel);
+ ledcSetup(cnt_channel, 490, 8);
+ ledcWrite(cnt_channel, value);
+ pin_to_channel[pin] = cnt_channel++;
+ }
+ ledcWrite(pin_to_channel[pin], value);
+ return;
+ }
+
+ int idx = -1;
+
+ // Search Pin
+ for (int i = 0; i < numPWMUsed; ++i)
+ if (pwmPins[i] == pin) { idx = i; break; }
+
+ // not found ?
+ if (idx < 0) {
+ // No slots remaining
+ if (numPWMUsed >= MAX_PWM_PINS) return;
+
+ // Take new slot for pin
+ idx = numPWMUsed;
+ pwmPins[idx] = pin;
+ // Start timer on first use
+ if (idx == 0) HAL_timer_start(PWM_TIMER_NUM, PWM_TIMER_FREQUENCY);
+
+ ++numPWMUsed;
+ }
+
+ // Use 7bit internal value - add 1 to have 100% high at 255
+ pwmValues[idx] = (value + 1) / 2;
+}
+
+// Handle PWM timer interrupt
+HAL_PWM_TIMER_ISR() {
+ HAL_timer_isr_prologue(PWM_TIMER_NUM);
+
+ static uint8_t count = 0;
+
+ for (int i = 0; i < numPWMUsed; ++i) {
+ if (count == 0) // Start of interval
+ WRITE(pwmPins[i], pwmValues[i] ? HIGH : LOW);
+ else if (pwmValues[i] == count) // End of duration
+ WRITE(pwmPins[i], LOW);
+ }
+
+ // 128 for 7 Bit resolution
+ count = (count + 1) & 0x7F;
+
+ HAL_timer_isr_epilogue(PWM_TIMER_NUM);
+}
+
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h
new file mode 100644
index 0000000000..4b1ccbf20f
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/HAL.h
@@ -0,0 +1,174 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+/**
+ * Description: HAL for Espressif ESP32 WiFi
+ */
+
+#define CPU_32_BIT
+
+#include
+
+#include "../shared/Marduino.h"
+#include "../shared/math_32bit.h"
+#include "../shared/HAL_SPI.h"
+
+#include "fastio.h"
+#include "watchdog.h"
+#include "i2s.h"
+
+#include "timers.h"
+
+#if ENABLED(WIFISUPPORT)
+ #include "WebSocketSerial.h"
+#endif
+
+#if ENABLED(ESP3D_WIFISUPPORT)
+ #include "esp3dlib.h"
+#endif
+
+#include "FlushableHardwareSerial.h"
+
+// ------------------------
+// Defines
+// ------------------------
+
+extern portMUX_TYPE spinlock;
+
+#define MYSERIAL0 flushableSerial
+
+#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
+ #if ENABLED(ESP3D_WIFISUPPORT)
+ #define MYSERIAL1 Serial2Socket
+ #else
+ #define MYSERIAL1 webSocketSerial
+ #endif
+ #define NUM_SERIAL 2
+#else
+ #define NUM_SERIAL 1
+#endif
+
+#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
+#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock)
+#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL)
+#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
+#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
+
+// Fix bug in pgm_read_ptr
+#undef pgm_read_ptr
+#define pgm_read_ptr(addr) (*(addr))
+
+// ------------------------
+// Types
+// ------------------------
+
+typedef int16_t pin_t;
+
+#define HAL_SERVO_LIB Servo
+
+// ------------------------
+// Public Variables
+// ------------------------
+
+/** result of last ADC conversion */
+extern uint16_t HAL_adc_result;
+
+// ------------------------
+// Public functions
+// ------------------------
+
+// clear reset reason
+void HAL_clear_reset_source();
+
+// reset reason
+uint8_t HAL_get_reset_source();
+
+void _delay_ms(int delay);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+int freeMemory();
+#pragma GCC diagnostic pop
+
+void analogWrite(pin_t pin, int value);
+
+// ADC
+#define HAL_ANALOG_SELECT(pin)
+
+void HAL_adc_init();
+
+#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
+#define HAL_ADC_RESOLUTION 10
+#define HAL_READ_ADC() HAL_adc_result
+#define HAL_ADC_READY() true
+
+void HAL_adc_start_conversion(const uint8_t adc_pin);
+
+#define GET_PIN_MAP_PIN(index) index
+#define GET_PIN_MAP_INDEX(pin) pin
+#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
+
+// Enable hooks into idle and setup for HAL
+#define HAL_IDLETASK 1
+#define BOARD_INIT() HAL_init_board();
+void HAL_idletask();
+void HAL_init();
+void HAL_init_board();
+
+//
+// Delay in cycles (used by DELAY_NS / DELAY_US)
+//
+FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
+ unsigned long start, ccount, stop;
+
+ /**
+ * It's important to care for race conditions (and overflows) here.
+ * Race condition example: If `stop` calculates to being close to the upper boundary of
+ * `uint32_t` and if at the same time a longer loop interruption kicks in (e.g. due to other
+ * FreeRTOS tasks or interrupts), `ccount` might overflow (and therefore be below `stop` again)
+ * without the loop ever being able to notice that `ccount` had already been above `stop` once
+ * (and that therefore the number of cycles to delay has already passed).
+ * As DELAY_CYCLES (through DELAY_NS / DELAY_US) is used by software SPI bit banging to drive
+ * LCDs and therefore might be called very, very often, this seemingly improbable situation did
+ * actually happen in reality. It resulted in apparently random print pauses of ~17.9 seconds
+ * (0x100000000 / 240 MHz) or multiples thereof, essentially ruining the current print by causing
+ * large blobs of filament.
+ */
+
+ __asm__ __volatile__ ( "rsr %0, ccount" : "=a" (start) );
+ stop = start + x;
+ ccount = start;
+
+ if (stop >= start) {
+ // no overflow, so only loop while in between start and stop:
+ // 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
+ while (ccount >= start || ccount < stop) {
+ __asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
+ }
+ }
+
+}
diff --git a/Marlin/src/HAL/HAL_ESP32/HAL_spi_ESP32.cpp b/Marlin/src/HAL/ESP32/HAL_SPI.cpp
similarity index 59%
rename from Marlin/src/HAL/HAL_ESP32/HAL_spi_ESP32.cpp
rename to Marlin/src/HAL/ESP32/HAL_SPI.cpp
index 7beb9b4991..27414cf6f8 100644
--- a/Marlin/src/HAL/HAL_ESP32/HAL_spi_ESP32.cpp
+++ b/Marlin/src/HAL/ESP32/HAL_SPI.cpp
@@ -1,10 +1,10 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2017 Victor Perez
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,61 +20,66 @@
* along with this program. If not, see .
*
*/
-
#ifdef ARDUINO_ARCH_ESP32
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include "HAL.h"
#include "../shared/HAL_SPI.h"
-#include "pins_arduino.h"
+#include
#include "spi_pins.h"
-#include "../../core/macros.h"
#include
-// --------------------------------------------------------------------------
+#include "../../core/macros.h"
+
+// ------------------------
// Public Variables
-// --------------------------------------------------------------------------
+// ------------------------
static SPISettings spiConfig;
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
-// --------------------------------------------------------------------------
+#if ENABLED(SOFTWARE_SPI)
+
+ // ------------------------
+ // Software SPI
+ // ------------------------
+ #error "Software SPI not supported for ESP32. Use Hardware SPI."
+
+#else
+
+// ------------------------
// Hardware SPI
-// --------------------------------------------------------------------------
+// ------------------------
void spiBegin() {
#if !PIN_EXISTS(SS)
#error "SS_PIN not defined!"
#endif
- WRITE(SS_PIN, HIGH);
- SET_OUTPUT(SS_PIN);
+ OUT_WRITE(SS_PIN, HIGH);
}
void spiInit(uint8_t spiRate) {
uint32_t clock;
switch (spiRate) {
- case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV2; break;
- case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4; break;
- case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8; break;
- case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
- case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
- case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
- default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
+ case SPI_FULL_SPEED: clock = 16000000; break;
+ case SPI_HALF_SPEED: clock = 8000000; break;
+ case SPI_QUARTER_SPEED: clock = 4000000; break;
+ case SPI_EIGHTH_SPEED: clock = 2000000; break;
+ case SPI_SIXTEENTH_SPEED: clock = 1000000; break;
+ case SPI_SPEED_5: clock = 500000; break;
+ case SPI_SPEED_6: clock = 250000; break;
+ default: clock = 1000000; // Default from the SPI library
}
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
SPI.begin();
}
-uint8_t spiRec(void) {
+uint8_t spiRec() {
SPI.beginTransaction(spiConfig);
uint8_t returnByte = SPI.transfer(0xFF);
SPI.endTransaction();
@@ -106,4 +111,6 @@ void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode)
SPI.beginTransaction(spiConfig);
}
+#endif // !SOFTWARE_SPI
+
#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/Servo.cpp b/Marlin/src/HAL/ESP32/Servo.cpp
new file mode 100644
index 0000000000..f0a8658562
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/Servo.cpp
@@ -0,0 +1,69 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_ESP32
+
+#include "../../inc/MarlinConfig.h"
+
+#if HAS_SERVOS
+
+#include "Servo.h"
+
+// Adjacent channels (0/1, 2/3 etc.) share the same timer and therefore the same frequency and resolution settings on ESP32,
+// so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.)
+int Servo::channel_next_free = 12;
+
+Servo::Servo() {
+ channel = channel_next_free++;
+}
+
+int8_t Servo::attach(const int inPin) {
+ if (channel >= CHANNEL_MAX_NUM) return -1;
+ if (inPin > 0) pin = inPin;
+
+ ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth
+ ledcAttachPin(pin, channel);
+ return true;
+}
+
+void Servo::detach() { ledcDetachPin(pin); }
+
+int Servo::read() { return degrees; }
+
+void Servo::write(int inDegrees) {
+ degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
+ int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
+ int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
+ ledcWrite(channel, duty);
+}
+
+void Servo::move(const int value) {
+ constexpr uint16_t servo_delay[] = SERVO_DELAY;
+ static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
+ if (attach(0) >= 0) {
+ write(value);
+ safe_delay(servo_delay[channel]);
+ TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
+ }
+}
+#endif // HAS_SERVOS
+
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/Servo.h b/Marlin/src/HAL/ESP32/Servo.h
new file mode 100644
index 0000000000..3f575150eb
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/Servo.h
@@ -0,0 +1,49 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include
+
+class Servo {
+ static const int MIN_ANGLE = 0,
+ MAX_ANGLE = 180,
+ MIN_PULSE_WIDTH = 544, // Shortest pulse sent to a servo
+ MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
+ TAU_MSEC = 20,
+ TAU_USEC = (TAU_MSEC * 1000),
+ MAX_COMPARE = ((1 << 16) - 1), // 65535
+ CHANNEL_MAX_NUM = 16;
+
+public:
+ Servo();
+ int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
+ void detach();
+ void write(int degrees); // set angle
+ void move(const int degrees); // attach the servo, then move to value
+ int read(); // returns current pulse width as an angle between 0 and 180 degrees
+
+private:
+ static int channel_next_free;
+ int channel;
+ int pin;
+ int degrees;
+};
diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp
new file mode 100644
index 0000000000..c7ee6951e1
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp
@@ -0,0 +1,153 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_ESP32
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if ENABLED(WIFISUPPORT)
+
+#include "WebSocketSerial.h"
+#include "wifi.h"
+#include
+
+WebSocketSerial webSocketSerial;
+AsyncWebSocket ws("/ws"); // TODO Move inside the class.
+
+// RingBuffer impl
+
+#define NEXT_INDEX(I, SIZE) ((I + 1) & (ring_buffer_pos_t)(SIZE - 1))
+
+RingBuffer::RingBuffer(ring_buffer_pos_t size)
+ : data(new uint8_t[size]),
+ size(size),
+ read_index(0),
+ write_index(0)
+{}
+
+RingBuffer::~RingBuffer() { delete[] data; }
+
+ring_buffer_pos_t RingBuffer::write(const uint8_t c) {
+ const ring_buffer_pos_t n = NEXT_INDEX(write_index, size);
+
+ if (n != read_index) {
+ this->data[write_index] = c;
+ write_index = n;
+ return 1;
+ }
+
+ // TODO: buffer is full, handle?
+ return 0;
+}
+
+ring_buffer_pos_t RingBuffer::write(const uint8_t *buffer, ring_buffer_pos_t size) {
+ ring_buffer_pos_t written = 0;
+ for (ring_buffer_pos_t i = 0; i < size; i++) {
+ written += write(buffer[i]);
+ }
+ return written;
+}
+
+int RingBuffer::available() {
+ return (size - read_index + write_index) & (size - 1);
+}
+
+int RingBuffer::peek() {
+ return available() ? data[read_index] : -1;
+}
+
+int RingBuffer::read() {
+ if (available()) {
+ const int ret = data[read_index];
+ read_index = NEXT_INDEX(read_index, size);
+ return ret;
+ }
+ return -1;
+}
+
+ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
+ ring_buffer_pos_t len = available();
+
+ for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
+ buffer[i] = data[read_index];
+ read_index = NEXT_INDEX(read_index, size);
+ }
+
+ return len;
+}
+
+void RingBuffer::flush() { read_index = write_index; }
+
+// WebSocketSerial impl
+WebSocketSerial::WebSocketSerial()
+ : rx_buffer(RingBuffer(RX_BUFFER_SIZE)),
+ tx_buffer(RingBuffer(TX_BUFFER_SIZE))
+{}
+
+void WebSocketSerial::begin(const long baud_setting) {
+ ws.onEvent([this](AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) {
+ switch (type) {
+ case WS_EVT_CONNECT: client->ping(); break; // client connected
+ case WS_EVT_DISCONNECT: // client disconnected
+ case WS_EVT_ERROR: // error was received from the other end
+ case WS_EVT_PONG: break; // pong message was received (in response to a ping request maybe)
+ case WS_EVT_DATA: { // data packet
+ AwsFrameInfo * info = (AwsFrameInfo*)arg;
+ if (info->opcode == WS_TEXT || info->message_opcode == WS_TEXT)
+ this->rx_buffer.write(data, len);
+ }
+ }
+ });
+ server.addHandler(&ws);
+}
+
+void WebSocketSerial::end() { }
+int WebSocketSerial::peek() { return rx_buffer.peek(); }
+int WebSocketSerial::read() { return rx_buffer.read(); }
+int WebSocketSerial::available() { return rx_buffer.available(); }
+void WebSocketSerial::flush() { rx_buffer.flush(); }
+
+size_t WebSocketSerial::write(const uint8_t c) {
+ size_t ret = tx_buffer.write(c);
+
+ if (ret && c == '\n') {
+ uint8_t tmp[TX_BUFFER_SIZE];
+ ring_buffer_pos_t size = tx_buffer.read(tmp);
+ ws.textAll(tmp, size);
+ }
+
+ return ret;
+}
+
+size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
+ size_t written = 0;
+ for(size_t i = 0; i < size; i++) {
+ written += write(buffer[i]);
+ }
+ return written;
+}
+
+void WebSocketSerial::flushTX() {
+ // No need to do anything as there's no benefit to sending partial lines over the websocket connection.
+}
+
+#endif // WIFISUPPORT
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/WebSocketSerial.h
new file mode 100644
index 0000000000..e76a2bc68e
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/WebSocketSerial.h
@@ -0,0 +1,86 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include "../../inc/MarlinConfig.h"
+
+#include
+
+#ifndef TX_BUFFER_SIZE
+ #define TX_BUFFER_SIZE 32
+#endif
+#if ENABLED(WIFISUPPORT)
+ #ifndef RX_BUFFER_SIZE
+ #define RX_BUFFER_SIZE 128
+ #endif
+ #if TX_BUFFER_SIZE <= 0
+ #error "TX_BUFFER_SIZE is required for the WebSocket."
+ #endif
+#endif
+
+typedef uint16_t ring_buffer_pos_t;
+
+class RingBuffer {
+ uint8_t *data;
+ ring_buffer_pos_t size, read_index, write_index;
+
+public:
+ RingBuffer(ring_buffer_pos_t size);
+ ~RingBuffer();
+
+ int available();
+ int peek();
+ int read();
+ ring_buffer_pos_t read(uint8_t *buffer);
+ void flush();
+ ring_buffer_pos_t write(const uint8_t c);
+ ring_buffer_pos_t write(const uint8_t* buffer, ring_buffer_pos_t size);
+};
+
+class WebSocketSerial: public Stream {
+ RingBuffer rx_buffer;
+ RingBuffer tx_buffer;
+
+public:
+ WebSocketSerial();
+ void begin(const long);
+ void end();
+ int available();
+ int peek();
+ int read();
+ void flush();
+ void flushTX();
+ size_t write(const uint8_t c);
+ size_t write(const uint8_t* buffer, size_t size);
+
+ operator bool() { return true; }
+
+ #if ENABLED(SERIAL_STATS_DROPPED_RX)
+ FORCE_INLINE uint32_t dropped() { return 0; }
+ #endif
+
+ #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
+ FORCE_INLINE int rxMaxEnqueued() { return 0; }
+ #endif
+};
+
+extern WebSocketSerial webSocketSerial;
diff --git a/Marlin/src/HAL/ESP32/eeprom.cpp b/Marlin/src/HAL/ESP32/eeprom.cpp
new file mode 100644
index 0000000000..35cebb592f
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/eeprom.cpp
@@ -0,0 +1,62 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_ESP32
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(EEPROM_SETTINGS)
+
+#include "../shared/eeprom_api.h"
+#include
+
+#define EEPROM_SIZE 4096
+
+bool PersistentStore::access_start() {
+ return EEPROM.begin(EEPROM_SIZE);
+}
+
+bool PersistentStore::access_finish() {
+ EEPROM.end();
+ return true;
+}
+
+bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
+ for (size_t i = 0; i < size; i++) {
+ EEPROM.write(pos++, value[i]);
+ crc16(crc, &value[i], 1);
+ }
+ return false;
+}
+
+bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
+ for (size_t i = 0; i < size; i++) {
+ uint8_t c = EEPROM.read(pos++);
+ if (writing) value[i] = c;
+ crc16(crc, &c, 1);
+ }
+ return false;
+}
+
+size_t PersistentStore::capacity() { return EEPROM_SIZE; }
+
+#endif // EEPROM_SETTINGS
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h b/Marlin/src/HAL/ESP32/endstop_interrupts.h
similarity index 51%
rename from Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h
rename to Marlin/src/HAL/ESP32/endstop_interrupts.h
index d4c8cbd490..8738c409b3 100644
--- a/Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h
+++ b/Marlin/src/HAL/ESP32/endstop_interrupts.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,40 +38,25 @@
#include "../../module/endstops.h"
// One ISR for all EXT-Interrupts
-void ICACHE_RAM_ATTR endstop_ISR(void) { endstops.update(); }
+void ICACHE_RAM_ATTR endstop_ISR() { endstops.update(); }
-void setup_endstop_interrupts(void) {
- #if HAS_X_MAX
- attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_X_MIN
- attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MAX
- attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MIN
- attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MAX
- attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MAX
- attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MIN
- attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MAX
- attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MIN
- attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN_PROBE_PIN
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
- #endif
+void setup_endstop_interrupts() {
+ #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
+ TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
+ TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
+ TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
+ TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
+ TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
+ TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
+ TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
+ TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
+ TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
+ TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
+ TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
+ TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
+ TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
+ TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
+ TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
+ TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
+ TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
}
diff --git a/Marlin/src/HAL/HAL_ESP32/fastio_ESP32.h b/Marlin/src/HAL/ESP32/fastio.h
similarity index 70%
rename from Marlin/src/HAL/HAL_ESP32/fastio_ESP32.h
rename to Marlin/src/HAL/ESP32/fastio.h
index 08a09201b6..09930194d6 100644
--- a/Marlin/src/HAL/HAL_ESP32/fastio_ESP32.h
+++ b/Marlin/src/HAL/ESP32/fastio.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,10 @@
* Utility functions
*/
+// I2S expander pin mapping.
+#define IS_I2S_EXPANDER_PIN(IO) TEST(IO, 7)
+#define I2S_EXPANDER_PIN_INDEX(IO) (IO & 0x7F)
+
// Set pin as input
#define _SET_INPUT(IO) pinMode(IO, INPUT)
@@ -37,10 +41,10 @@
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
// Read a pin wrapper
-#define READ(IO) digitalRead(IO)
+#define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
// Write to a pin wrapper
-#define WRITE(IO, v) (TEST(IO, 7) ? i2s_write(IO & 0x7F, v) : digitalWrite(IO, v))
+#define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
// Set pin as input wrapper
#define SET_INPUT(IO) _SET_INPUT(IO)
@@ -52,7 +56,7 @@
#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0)
// Set pin as PWM
-#define SET_PWM(IO) SET_OUTPUT(IO)
+#define SET_PWM SET_OUTPUT
// Set pin as output and init
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
@@ -61,8 +65,11 @@
#define extDigitalRead(IO) digitalRead(IO)
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
-#define PWM_PIN(P) true
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
+// PWM outputs
+#define PWM_PIN(P) (P < 34 || P > 127) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
+
+// Toggle pin value
+#define TOGGLE(IO) WRITE(IO, !READ(IO))
//
// Ports and functions
diff --git a/Marlin/src/HAL/HAL_ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp
similarity index 85%
rename from Marlin/src/HAL/HAL_ESP32/i2s.cpp
rename to Marlin/src/HAL/ESP32/i2s.cpp
index c503a24bf8..d80c3c24e1 100644
--- a/Marlin/src/HAL/HAL_ESP32/i2s.cpp
+++ b/Marlin/src/HAL/ESP32/i2s.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,13 +21,15 @@
*/
#ifdef ARDUINO_ARCH_ESP32
-#include // replace that with the proper imports
+#include "../../inc/MarlinConfigPre.h"
+
#include "i2s.h"
-#include "../../core/macros.h"
-#include "driver/periph_ctrl.h"
-#include "rom/lldesc.h"
-#include "soc/i2s_struct.h"
-#include "freertos/queue.h"
+
+#include "../shared/Marduino.h"
+#include
+#include
+#include
+#include
#include "../../module/stepper.h"
#define DMA_BUF_COUNT 8 // number of DMA buffers to store data
@@ -54,7 +56,7 @@ static i2s_dev_t* I2S[I2S_NUM_MAX] = {&I2S0, &I2S1};
static i2s_dma_t dma;
// output value
-uint32_t i2s_port_data;
+uint32_t i2s_port_data = 0;
#define I2S_ENTER_CRITICAL() portENTER_CRITICAL(&i2s_spinlock[i2s_num])
#define I2S_EXIT_CRITICAL() portEXIT_CRITICAL(&i2s_spinlock[i2s_num])
@@ -138,21 +140,21 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) {
}
void stepperTask(void* parameter) {
- uint32_t i, remaining = 0;
+ uint32_t remaining = 0;
while (1) {
xQueueReceive(dma.queue, &dma.current, portMAX_DELAY);
dma.rw_pos = 0;
- for (i = 0; i < DMA_SAMPLE_COUNT; i++) {
+ while (dma.rw_pos < DMA_SAMPLE_COUNT) {
// Fill with the port data post pulse_phase until the next step
if (remaining) {
i2s_push_sample();
remaining--;
}
else {
- Stepper::stepper_pulse_phase_isr();
- remaining = Stepper::stepper_block_phase_isr();
+ Stepper::pulse_phase_isr();
+ remaining = Stepper::block_phase_isr();
}
}
}
@@ -175,29 +177,29 @@ int i2s_init() {
*
* fwclk = fbclk / 32
*
- * for fwclk = 250kHz (4uS pulse time)
+ * for fwclk = 250kHz (4µS pulse time)
* N = 10
* M = 20
*/
// Allocate the array of pointers to the buffers
dma.buffers = (uint32_t **)malloc(sizeof(uint32_t*) * DMA_BUF_COUNT);
- if (dma.buffers == NULL) return -1;
+ if (dma.buffers == nullptr) return -1;
// Allocate each buffer that can be used by the DMA controller
for (int buf_idx = 0; buf_idx < DMA_BUF_COUNT; buf_idx++) {
dma.buffers[buf_idx] = (uint32_t*) heap_caps_calloc(1, DMA_BUF_LEN, MALLOC_CAP_DMA);
- if (dma.buffers[buf_idx] == NULL) return -1;
+ if (dma.buffers[buf_idx] == nullptr) return -1;
}
// Allocate the array of DMA descriptors
dma.desc = (lldesc_t**) malloc(sizeof(lldesc_t*) * DMA_BUF_COUNT);
- if (dma.desc == NULL) return -1;
+ if (dma.desc == nullptr) return -1;
// Allocate each DMA descriptor that will be used by the DMA controller
for (int buf_idx = 0; buf_idx < DMA_BUF_COUNT; buf_idx++) {
dma.desc[buf_idx] = (lldesc_t*) heap_caps_malloc(sizeof(lldesc_t), MALLOC_CAP_DMA);
- if (dma.desc[buf_idx] == NULL) return -1;
+ if (dma.desc[buf_idx] == nullptr) return -1;
}
// Initialize
@@ -252,7 +254,13 @@ int i2s_init() {
I2S0.fifo_conf.dscr_en = 0;
- I2S0.conf_chan.tx_chan_mod = 0;
+ I2S0.conf_chan.tx_chan_mod = (
+ #if ENABLED(I2S_STEPPER_SPLIT_STREAM)
+ 4
+ #else
+ 0
+ #endif
+ );
I2S0.fifo_conf.tx_fifo_mod = 0;
I2S0.conf.tx_mono = 0;
@@ -296,25 +304,38 @@ int i2s_init() {
// Allocate and Enable the I2S interrupt
intr_handle_t i2s_isr_handle;
- esp_intr_alloc(ETS_I2S0_INTR_SOURCE, 0, i2s_intr_handler_default, NULL, &i2s_isr_handle);
+ esp_intr_alloc(ETS_I2S0_INTR_SOURCE, 0, i2s_intr_handler_default, nullptr, &i2s_isr_handle);
esp_intr_enable(i2s_isr_handle);
// Create the task that will feed the buffer
- xTaskCreate(stepperTask, "StepperTask", 10000, NULL, 1, NULL);
+ xTaskCreatePinnedToCore(stepperTask, "StepperTask", 10000, nullptr, 1, nullptr, CONFIG_ARDUINO_RUNNING_CORE); // run I2S stepper task on same core as rest of Marlin
// Route the i2s pins to the appropriate GPIO
- gpio_matrix_out_check(22, I2S0O_DATA_OUT23_IDX, 0, 0);
- gpio_matrix_out_check(25, I2S0O_WS_OUT_IDX, 0, 0);
- gpio_matrix_out_check(26, I2S0O_BCK_OUT_IDX, 0, 0);
+ gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0);
+ gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0);
+ gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0);
// Start the I2S peripheral
return i2s_start(I2S_NUM_0);
}
void i2s_write(uint8_t pin, uint8_t val) {
+ #if ENABLED(I2S_STEPPER_SPLIT_STREAM)
+ if (pin >= 16) {
+ SET_BIT_TO(I2S0.conf_single_data, pin, val);
+ return;
+ }
+ #endif
SET_BIT_TO(i2s_port_data, pin, val);
}
+uint8_t i2s_state(uint8_t pin) {
+ #if ENABLED(I2S_STEPPER_SPLIT_STREAM)
+ if (pin >= 16) return TEST(I2S0.conf_single_data, pin);
+ #endif
+ return TEST(i2s_port_data, pin);
+}
+
void i2s_push_sample() {
dma.current[dma.rw_pos++] = i2s_port_data;
}
diff --git a/Marlin/src/HAL/HAL_ESP32/i2s.h b/Marlin/src/HAL/ESP32/i2s.h
similarity index 84%
rename from Marlin/src/HAL/HAL_ESP32/i2s.h
rename to Marlin/src/HAL/ESP32/i2s.h
index 32999f712f..63a579a184 100644
--- a/Marlin/src/HAL/HAL_ESP32/i2s.h
+++ b/Marlin/src/HAL/ESP32/i2s.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,11 +21,15 @@
*/
#pragma once
+#include
+
// current value of the outputs provided over i2s
extern uint32_t i2s_port_data;
int i2s_init();
+uint8_t i2s_state(uint8_t pin);
+
void i2s_write(uint8_t pin, uint8_t val);
void i2s_push_sample();
diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h b/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_post.h b/Marlin/src/HAL/ESP32/inc/Conditionals_post.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/inc/Conditionals_post.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/HAL_ESP32/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h
similarity index 72%
rename from Marlin/src/HAL/HAL_ESP32/SanityCheck.h
rename to Marlin/src/HAL/ESP32/inc/SanityCheck.h
index f911d84ce0..b6ad7a3c4b 100644
--- a/Marlin/src/HAL/HAL_ESP32/SanityCheck.h
+++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
* along with this program. If not, see .
*
*/
+#pragma once
#if ENABLED(EMERGENCY_PARSER)
#error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue."
@@ -27,3 +28,11 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
+
+#if HAS_TMC_SW_SERIAL
+ #error "TMC220x Software Serial is not supported on this platform."
+#endif
+
+#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
+ #error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
+#endif
diff --git a/Marlin/src/HAL/HAL_ESP32/ota.cpp b/Marlin/src/HAL/ESP32/ota.cpp
similarity index 92%
rename from Marlin/src/HAL/HAL_ESP32/ota.cpp
rename to Marlin/src/HAL/ESP32/ota.cpp
index 40ec1ab875..34a2482c9b 100644
--- a/Marlin/src/HAL/HAL_ESP32/ota.cpp
+++ b/Marlin/src/HAL/ESP32/ota.cpp
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
@@ -21,13 +21,13 @@
#include "../../inc/MarlinConfigPre.h"
-#if ENABLED(OTASUPPORT)
+#if BOTH(WIFISUPPORT, OTASUPPORT)
#include
#include
#include
#include
-#include "driver/timer.h"
+#include
void OTA_init() {
ArduinoOTA
@@ -67,6 +67,5 @@ void OTA_handle() {
ArduinoOTA.handle();
}
-#endif // OTASUPPORT
-
+#endif // WIFISUPPORT && OTASUPPORT
#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_ESP32/ota.h b/Marlin/src/HAL/ESP32/ota.h
similarity index 92%
rename from Marlin/src/HAL/HAL_ESP32/ota.h
rename to Marlin/src/HAL/ESP32/ota.h
index 80e04e123d..1780fb32c1 100644
--- a/Marlin/src/HAL/HAL_ESP32/ota.h
+++ b/Marlin/src/HAL/ESP32/ota.h
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
diff --git a/Marlin/src/HAL/HAL_ESP32/servotimers.h b/Marlin/src/HAL/ESP32/servotimers.h
similarity index 84%
rename from Marlin/src/HAL/HAL_ESP32/servotimers.h
rename to Marlin/src/HAL/ESP32/servotimers.h
index 0604ca0a25..0285c52ee3 100644
--- a/Marlin/src/HAL/HAL_ESP32/servotimers.h
+++ b/Marlin/src/HAL/ESP32/servotimers.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,3 +19,4 @@
* along with this program. If not, see .
*
*/
+#pragma once
diff --git a/Marlin/src/HAL/HAL_ESP32/spi_pins.h b/Marlin/src/HAL/ESP32/spi_pins.h
similarity index 90%
rename from Marlin/src/HAL/HAL_ESP32/spi_pins.h
rename to Marlin/src/HAL/ESP32/spi_pins.h
index 896d9fa853..0e67615a2b 100644
--- a/Marlin/src/HAL/HAL_ESP32/spi_pins.h
+++ b/Marlin/src/HAL/ESP32/spi_pins.h
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
*/
#pragma once
-#define SS_PIN 5
+#define SS_PIN SDSS
#define SCK_PIN 18
#define MISO_PIN 19
#define MOSI_PIN 23
diff --git a/Marlin/src/HAL/ESP32/spiffs.cpp b/Marlin/src/HAL/ESP32/spiffs.cpp
new file mode 100644
index 0000000000..69fe7da58e
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/spiffs.cpp
@@ -0,0 +1,43 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef ARDUINO_ARCH_ESP32
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if BOTH(WIFISUPPORT, WEBSUPPORT)
+
+#include "../../core/serial.h"
+
+#include
+#include
+
+bool spiffs_initialized;
+
+void spiffs_init() {
+ if (SPIFFS.begin(true)) // formatOnFail = true
+ spiffs_initialized = true;
+ else
+ SERIAL_ERROR_MSG("SPIFFS mount failed");
+}
+
+#endif // WIFISUPPORT && WEBSUPPORT
+#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_LPC1768/persistent_store_api.h b/Marlin/src/HAL/ESP32/spiffs.h
similarity index 79%
rename from Marlin/src/HAL/HAL_LPC1768/persistent_store_api.h
rename to Marlin/src/HAL/ESP32/spiffs.h
index c3c6f67254..b9cbb23bda 100644
--- a/Marlin/src/HAL/HAL_LPC1768/persistent_store_api.h
+++ b/Marlin/src/HAL/ESP32/spiffs.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,8 @@
* along with this program. If not, see .
*
*/
-#include "../shared/persistent_store_api.h"
+#pragma once
-#define FLASH_EEPROM_EMULATION
+extern bool spiffs_initialized;
+
+void spiffs_init();
diff --git a/Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.cpp b/Marlin/src/HAL/ESP32/timers.cpp
similarity index 61%
rename from Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.cpp
rename to Marlin/src/HAL/ESP32/timers.cpp
index 39ca18fcea..ad897661c6 100644
--- a/Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.cpp
+++ b/Marlin/src/HAL/ESP32/timers.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,89 +19,63 @@
* along with this program. If not, see .
*
*/
-
#ifdef ARDUINO_ARCH_ESP32
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include
-#include "esp_types.h"
-#include "soc/timer_group_struct.h"
-#include "driver/periph_ctrl.h"
-#include "driver/timer.h"
+#include
+#include
+#include
+#include
#include "HAL.h"
-#include "HAL_timers_ESP32.h"
+#include "timers.h"
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Local defines
-// --------------------------------------------------------------------------
+// ------------------------
#define NUM_HARDWARE_TIMERS 4
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Private Variables
-// --------------------------------------------------------------------------
+// ------------------------
static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1};
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
- { TIMER_GROUP_1, TIMER_0, 1, NULL }, // 2
- { TIMER_GROUP_1, TIMER_1, 1, NULL }, // 3
+ { TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
+ { TIMER_GROUP_1, TIMER_1, 1, nullptr }, // 3
};
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
-void IRAM_ATTR timer_group0_isr(void *para) {
- const int timer_idx = (int)para;
+void IRAM_ATTR timer_isr(void *para) {
+ const tTimerConfig& timer = TimerConfig[(int)para];
// Retrieve the interrupt status and the counter value
// from the timer that reported the interrupt
- uint32_t intr_status = TIMERG0.int_st_timers.val;
- TIMERG0.hw_timer[timer_idx].update = 1;
+ uint32_t intr_status = TG[timer.group]->int_st_timers.val;
+ TG[timer.group]->hw_timer[timer.idx].update = 1;
// Clear the interrupt
- if (intr_status & BIT(timer_idx)) {
- switch (timer_idx) {
- case TIMER_0: TIMERG0.int_clr_timers.t0 = 1; break;
- case TIMER_1: TIMERG0.int_clr_timers.t1 = 1; break;
+ if (intr_status & BIT(timer.idx)) {
+ switch (timer.idx) {
+ case TIMER_0: TG[timer.group]->int_clr_timers.t0 = 1; break;
+ case TIMER_1: TG[timer.group]->int_clr_timers.t1 = 1; break;
+ case TIMER_MAX: break;
}
}
- const tTimerConfig timer = TimerConfig[timer_idx];
timer.fn();
// After the alarm has been triggered
// Enable it again so it gets triggered the next time
- TIMERG0.hw_timer[timer_idx].config.alarm_en = TIMER_ALARM_EN;
+ TG[timer.group]->hw_timer[timer.idx].config.alarm_en = TIMER_ALARM_EN;
}
/**
@@ -131,8 +105,7 @@ void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
timer_enable_intr(timer.group, timer.idx);
- // TODO need to deal with timer_group1_isr
- timer_isr_register(timer.group, timer.idx, timer_group0_isr, (void*)timer.idx, NULL, NULL);
+ timer_isr_register(timer.group, timer.idx, timer_isr, (void*)(uint32_t)timer_num, 0, nullptr);
timer_start(timer.group, timer.idx);
}
@@ -169,10 +142,8 @@ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
*/
hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
const tTimerConfig timer = TimerConfig[timer_num];
-
uint64_t counter_value;
timer_get_counter_value(timer.group, timer.idx, &counter_value);
-
return counter_value;
}
@@ -181,7 +152,7 @@ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
* @param timer_num timer number to enable interrupts on
*/
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
- const tTimerConfig timer = TimerConfig[timer_num];
+ //const tTimerConfig timer = TimerConfig[timer_num];
//timer_enable_intr(timer.group, timer.idx);
}
@@ -190,8 +161,8 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) {
* @param timer_num timer number to disable interrupts on
*/
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
- const tTimerConfig timer = TimerConfig[timer_num];
- // timer_disable_intr(timer.group, timer.idx);
+ //const tTimerConfig timer = TimerConfig[timer_num];
+ //timer_disable_intr(timer.group, timer.idx);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
diff --git a/Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.h b/Marlin/src/HAL/ESP32/timers.h
similarity index 68%
rename from Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.h
rename to Marlin/src/HAL/ESP32/timers.h
index 7fbaa5222d..bc4306be20 100644
--- a/Marlin/src/HAL/HAL_ESP32/HAL_timers_ESP32.h
+++ b/Marlin/src/HAL/ESP32/timers.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,16 +21,17 @@
*/
#pragma once
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include
-#include "driver/timer.h"
+#include
-// --------------------------------------------------------------------------
+// Includes needed to get I2S_STEPPER_STREAM. Note that pins.h
+// is included in case this header is being included early.
+#include "../../inc/MarlinConfig.h"
+#include "../../pins/pins.h"
+
+// ------------------------
// Defines
-// --------------------------------------------------------------------------
+// ------------------------
//
#define FORCE_INLINE __attribute__((always_inline)) inline
@@ -39,18 +40,19 @@ typedef uint64_t hal_timer_t;
#define STEP_TIMER_NUM 0 // index of timer to use for stepper
#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
+#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
#if ENABLED(I2S_STEPPER_STREAM)
#define STEPPER_TIMER_PRESCALE 1
- #define STEPPER_TIMER_RATE 250000 // 250khz, 4us pulses of i2s word clock
+ #define STEPPER_TIMER_RATE 250000 // 250khz, 4µs pulses of i2s word clock
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
#else
#define STEPPER_TIMER_PRESCALE 40
- #define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer, 2MHz
- #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+ #define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz
+ #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#endif
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
@@ -58,6 +60,14 @@ typedef uint64_t hal_timer_t;
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
+#define PWM_TIMER_PRESCALE 10
+#if ENABLED(FAST_PWM_FAN)
+ #define PWM_TIMER_FREQUENCY FAST_PWM_FAN_FREQUENCY
+#else
+ #define PWM_TIMER_FREQUENCY (50*128) // 50Hz and 7bit resolution
+#endif
+#define MAX_PWM_PINS 32 // Number of PWM pin-slots
+
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
@@ -69,33 +79,34 @@ typedef uint64_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
-#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler(void)
-#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler(void)
+#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler()
+#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler()
+#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
-extern "C" void tempTC_Handler(void);
-extern "C" void stepTC_Handler(void);
+extern "C" void tempTC_Handler();
+extern "C" void stepTC_Handler();
+extern "C" void pwmTC_Handler();
-
-// --------------------------------------------------------------------------
+// ------------------------
// Types
-// --------------------------------------------------------------------------
+// ------------------------
typedef struct {
timer_group_t group;
timer_idx_t idx;
uint32_t divider;
- void (*fn)(void);
+ void (*fn)();
} tTimerConfig;
-// --------------------------------------------------------------------------
+// ------------------------
// Public Variables
-// --------------------------------------------------------------------------
+// ------------------------
extern const tTimerConfig TimerConfig[];
-// --------------------------------------------------------------------------
+// ------------------------
// Public functions
-// --------------------------------------------------------------------------
+// ------------------------
void HAL_timer_start (const uint8_t timer_num, uint32_t frequency);
void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count);
diff --git a/Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.cpp b/Marlin/src/HAL/ESP32/watchdog.cpp
similarity index 82%
rename from Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.cpp
rename to Marlin/src/HAL/ESP32/watchdog.cpp
index b1c98cb55c..073da7f69d 100644
--- a/Marlin/src/HAL/HAL_ESP32/watchdog_ESP32.cpp
+++ b/Marlin/src/HAL/ESP32/watchdog.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,20 +19,19 @@
* along with this program. If not, see .
*
*/
-
#ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfig.h"
#if ENABLED(USE_WATCHDOG)
-#include "watchdog_ESP32.h"
+#include "watchdog.h"
-void watchdogSetup(void) {
+void watchdogSetup() {
// do whatever. don't remove this function.
}
-void watchdog_init(void) {
+void watchdog_init() {
// TODO
}
diff --git a/Marlin/src/HAL/ESP32/watchdog.h b/Marlin/src/HAL/ESP32/watchdog.h
new file mode 100644
index 0000000000..7e07990865
--- /dev/null
+++ b/Marlin/src/HAL/ESP32/watchdog.h
@@ -0,0 +1,38 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ esp_err_t esp_task_wdt_reset();
+
+#ifdef __cplusplus
+ }
+#endif
+
+// Initialize watchdog with a 4 second interrupt time
+void watchdog_init();
+
+// Reset watchdog.
+inline void HAL_watchdog_refresh() { esp_task_wdt_reset(); }
diff --git a/Marlin/src/HAL/HAL_ESP32/web.cpp b/Marlin/src/HAL/ESP32/web.cpp
similarity index 67%
rename from Marlin/src/HAL/HAL_ESP32/web.cpp
rename to Marlin/src/HAL/ESP32/web.cpp
index a3a6cce729..7c175bcc9b 100644
--- a/Marlin/src/HAL/HAL_ESP32/web.cpp
+++ b/Marlin/src/HAL/ESP32/web.cpp
@@ -1,7 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,35 +17,31 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-
#ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfigPre.h"
-#if ENABLED(WEBSUPPORT)
+#if BOTH(WIFISUPPORT, WEBSUPPORT)
-#include "../../core/serial.h"
+#include "../../inc/MarlinConfig.h"
-#include "FS.h"
-#include "SPIFFS.h"
+#undef DISABLED // esp32-hal-gpio.h
+#include
#include "wifi.h"
AsyncEventSource events("/events"); // event source (Server-Sent events)
-void onNotFound(AsyncWebServerRequest *request){
+void onNotFound(AsyncWebServerRequest *request) {
request->send(404);
}
void web_init() {
server.addHandler(&events); // attach AsyncEventSource
- if (SPIFFS.begin()) {
- server.serveStatic("/", SPIFFS, "/www").setDefaultFile("index.html");
- server.onNotFound(onNotFound);
- }
- else
- SERIAL_ECHO_MSG("SPIFFS Mount Failed");
+ server.serveStatic("/", SPIFFS, "/www").setDefaultFile("index.html");
+ server.onNotFound(onNotFound);
}
-#endif // WEBSUPPORT
+#endif // WIFISUPPORT && WEBSUPPORT
#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_ESP32/web.h b/Marlin/src/HAL/ESP32/web.h
similarity index 82%
rename from Marlin/src/HAL/HAL_ESP32/web.h
rename to Marlin/src/HAL/ESP32/web.h
index 7f8796e7d4..8dbefd8eef 100644
--- a/Marlin/src/HAL/HAL_ESP32/web.h
+++ b/Marlin/src/HAL/ESP32/web.h
@@ -1,7 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,6 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
#pragma once
diff --git a/Marlin/src/HAL/HAL_ESP32/wifi.cpp b/Marlin/src/HAL/ESP32/wifi.cpp
similarity index 66%
rename from Marlin/src/HAL/HAL_ESP32/wifi.cpp
rename to Marlin/src/HAL/ESP32/wifi.cpp
index 7afc7a87a8..9ac3ddde24 100644
--- a/Marlin/src/HAL/HAL_ESP32/wifi.cpp
+++ b/Marlin/src/HAL/ESP32/wifi.cpp
@@ -1,7 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,10 +17,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-
#ifdef ARDUINO_ARCH_ESP32
+#include "../../core/serial.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(WIFISUPPORT)
@@ -35,20 +38,28 @@ AsyncWebServer server(80);
#endif
void wifi_init() {
+
+ SERIAL_ECHO_MSG("Starting WiFi...");
+
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PWD);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
+ SERIAL_ERROR_MSG("Unable to connect to WiFi with SSID '" WIFI_SSID "', restarting.");
delay(5000);
ESP.restart();
}
delay(10);
-
- // Loop forever (watchdog kill) on failure
- if (!MDNS.begin(WIFI_HOSTNAME)) for(;;) delay(5000);
+ if (!MDNS.begin(WIFI_HOSTNAME)) {
+ SERIAL_ERROR_MSG("Unable to start mDNS with hostname '" WIFI_HOSTNAME "', restarting.");
+ delay(5000);
+ ESP.restart();
+ }
MDNS.addService("http", "tcp", 80);
+
+ SERIAL_ECHOLNPAIR("Successfully connected to WiFi with SSID '" WIFI_SSID "', hostname: '" WIFI_HOSTNAME "', IP address: ", WiFi.localIP().toString().c_str());
}
#endif // WIFISUPPORT
diff --git a/Marlin/src/HAL/HAL_ESP32/wifi.h b/Marlin/src/HAL/ESP32/wifi.h
similarity index 84%
rename from Marlin/src/HAL/HAL_ESP32/wifi.h
rename to Marlin/src/HAL/ESP32/wifi.h
index ef35cf14ca..580c6c87f4 100644
--- a/Marlin/src/HAL/HAL_ESP32/wifi.h
+++ b/Marlin/src/HAL/ESP32/wifi.h
@@ -1,7 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,6 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
#pragma once
diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h
new file mode 100644
index 0000000000..614c6cbaf9
--- /dev/null
+++ b/Marlin/src/HAL/HAL.h
@@ -0,0 +1,36 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include "platforms.h"
+
+#include HAL_PATH(.,HAL.h)
+
+#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
+
+#ifndef I2C_ADDRESS
+ #define I2C_ADDRESS(A) (A)
+#endif
+
+inline void watchdog_refresh() {
+ TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
+}
diff --git a/Marlin/src/HAL/HAL_AVR/HAL.cpp b/Marlin/src/HAL/HAL_AVR/HAL.cpp
deleted file mode 100644
index 2bfbccdf2d..0000000000
--- a/Marlin/src/HAL/HAL_AVR/HAL.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* **************************************************************************
-
- Marlin 3D Printer Firmware
- Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
-
- Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-****************************************************************************/
-
-#ifdef __AVR__
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "../../inc/MarlinConfig.h"
-#include "HAL.h"
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-//uint8_t MCUSR;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-#if ENABLED(SDSUPPORT)
-
- #include "../../sd/SdFatUtil.h"
- int freeMemory() { return SdFatUtil::FreeRam(); }
-
-#else // !SDSUPPORT
-
-extern "C" {
- extern char __bss_end;
- extern char __heap_start;
- extern void* __brkval;
-
- int freeMemory() {
- int free_memory;
- if ((int)__brkval == 0)
- free_memory = ((int)&free_memory) - ((int)&__bss_end);
- else
- free_memory = ((int)&free_memory) - ((int)__brkval);
- return free_memory;
- }
-}
-
-#endif // !SDSUPPORT
-
-#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_AVR/SanityCheck.h b/Marlin/src/HAL/HAL_AVR/SanityCheck.h
deleted file mode 100644
index 9c34a3d51e..0000000000
--- a/Marlin/src/HAL/HAL_AVR/SanityCheck.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Test AVR specific configuration values for errors at compile-time.
- */
-
-/**
- * Digipot requirement
- */
- #if ENABLED(DIGIPOT_MCP4018)
- #if !defined(DIGIPOTS_I2C_SDA_X) || !defined(DIGIPOTS_I2C_SDA_Y) || !defined(DIGIPOTS_I2C_SDA_Z) \
- || !defined(DIGIPOTS_I2C_SDA_E0) || !defined(DIGIPOTS_I2C_SDA_E1)
- #error "DIGIPOT_MCP4018 requires DIGIPOTS_I2C_SDA_* pins to be defined."
- #endif
-#endif
-
-/**
- * Checks for FAST PWM
- */
-#if ENABLED(FAST_PWM_FAN) && (ENABLED(USE_OCR2A_AS_TOP) && defined(TCCR2))
- #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2"
-#endif
-
-/**
- * Sanity checks for Spindle / Laser
- */
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !(WITHIN(SPINDLE_LASER_PWM_PIN, 2, 13) || WITHIN(SPINDLE_LASER_PWM_PIN, 44, 46))
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13)
- #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt."
- #elif PIN_EXISTS(X_MAX) && X_MAX_PIN == SPINDLE_LASER_PWM_PIN
- #error "SPINDLE_LASER_PWM pin is in use by X_MAX endstop."
- #elif PIN_EXISTS(X_MIN) && X_MIN_PIN == SPINDLE_LASER_PWM_PIN
- #error "SPINDLE_LASER_PWM pin is in use by X_MIN endstop."
- #elif PIN_EXISTS(Z_STEP) && Z_STEP_PIN == SPINDLE_LASER_PWM_PIN
- #error "SPINDLE_LASER_PWM pin in use by Z_STEP."
- #elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
- #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E5_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E5_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E5_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #elif PIN_EXISTS(MOTOR_CURRENT_PWM_XY) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_XY_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_XY."
- #elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_Z_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_Z."
- #elif PIN_EXISTS(MOTOR_CURRENT_PWM_E) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_E_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_E."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-/**
- * The Trinamic library includes SoftwareSerial.h, leading to a compile error.
- */
-#if HAS_TRINAMIC && ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
- #error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
-#endif
diff --git a/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h b/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h
deleted file mode 100644
index c066703942..0000000000
--- a/Marlin/src/HAL/HAL_AVR/endstop_interrupts.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Endstop Interrupts
- *
- * Without endstop interrupts the endstop pins must be polled continually in
- * the temperature-ISR via endstops.update(), most of the time finding no change.
- * With this feature endstops.update() is called only when we know that at
- * least one endstop has changed state, saving valuable CPU cycles.
- *
- * This feature only works when all used endstop pins can generate either an
- * 'external interrupt' or a 'pin change interrupt'.
- *
- * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
- * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
- */
-
-#include "../../core/macros.h"
-#include
-#include "../../module/endstops.h"
-
-// One ISR for all EXT-Interrupts
-void endstop_ISR(void) { endstops.update(); }
-
-/**
- * Patch for pins_arduino.h (...\Arduino\hardware\arduino\avr\variants\mega\pins_arduino.h)
- *
- * These macros for the Arduino MEGA do not include the two connected pins on Port J (D13, D14).
- * So we extend them here because these are the normal pins for Y_MIN and Y_MAX on RAMPS.
- * There are more PCI-enabled processor pins on Port J, but they are not connected to Arduino MEGA.
- */
-#if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA)
- #undef digitalPinToPCICR
- #define digitalPinToPCICR(p) ( WITHIN(p, 10, 15) || \
- WITHIN(p, 50, 53) || \
- WITHIN(p, 62, 69) ? &PCICR : (uint8_t*)0 )
- #undef digitalPinToPCICRbit
- #define digitalPinToPCICRbit(p) ( WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? 0 : \
- WITHIN(p, 14, 15) ? 1 : \
- WITHIN(p, 62, 69) ? 2 : \
- 0 )
- #undef digitalPinToPCMSK
- #define digitalPinToPCMSK(p) ( WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? &PCMSK0 : \
- WITHIN(p, 14, 15) ? &PCMSK1 : \
- WITHIN(p, 62, 69) ? &PCMSK2 : \
- (uint8_t *)0 )
- #undef digitalPinToPCMSKbit
- #define digitalPinToPCMSKbit(p) ( WITHIN(p, 10, 13) ? ((p) - 6) : \
- (p) == 14 || (p) == 51 ? 2 : \
- (p) == 15 || (p) == 52 ? 1 : \
- (p) == 50 ? 3 : \
- (p) == 53 ? 0 : \
- WITHIN(p, 62, 69) ? ((p) - 62) : \
- 0 )
-#endif
-
-
-// Install Pin change interrupt for a pin. Can be called multiple times.
-void pciSetup(const int8_t pin) {
- SBI(*digitalPinToPCMSK(pin), digitalPinToPCMSKbit(pin)); // enable pin
- SBI(PCIFR, digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
- SBI(PCICR, digitalPinToPCICRbit(pin)); // enable interrupt for the group
-}
-
-// Handlers for pin change interrupts
-#ifdef PCINT0_vect
- ISR(PCINT0_vect) { endstop_ISR(); }
-#endif
-
-#ifdef PCINT1_vect
- ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
-#endif
-
-#ifdef PCINT2_vect
- ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
-#endif
-
-#ifdef PCINT3_vect
- ISR(PCINT3_vect, ISR_ALIASOF(PCINT0_vect));
-#endif
-
-void setup_endstop_interrupts( void ) {
-
- #if HAS_X_MAX
- #if (digitalPinToInterrupt(X_MAX_PIN) != NOT_AN_INTERRUPT) // if pin has an external interrupt
- attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(X_MAX_PIN) != NULL, "X_MAX_PIN is not interrupt-capable"); // if pin has no pin change interrupt - error
- pciSetup(X_MAX_PIN); // assign it
- #endif
- #endif
-
- #if HAS_X_MIN
- #if (digitalPinToInterrupt(X_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(X_MIN_PIN) != NULL, "X_MIN_PIN is not interrupt-capable");
- pciSetup(X_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Y_MAX
- #if (digitalPinToInterrupt(Y_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Y_MAX_PIN) != NULL, "Y_MAX_PIN is not interrupt-capable");
- pciSetup(Y_MAX_PIN);
- #endif
- #endif
-
- #if HAS_Y_MIN
- #if (digitalPinToInterrupt(Y_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Y_MIN_PIN) != NULL, "Y_MIN_PIN is not interrupt-capable");
- pciSetup(Y_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Z_MAX
- #if (digitalPinToInterrupt(Z_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z_MAX_PIN) != NULL, "Z_MAX_PIN is not interrupt-capable");
- pciSetup(Z_MAX_PIN);
- #endif
- #endif
-
- #if HAS_Z_MIN
- #if (digitalPinToInterrupt(Z_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z_MIN_PIN) != NULL, "Z_MIN_PIN is not interrupt-capable");
- pciSetup(Z_MIN_PIN);
- #endif
- #endif
-
- #if HAS_X2_MAX
- #if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(X2_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(X2_MAX_PIN) != NULL, "X2_MAX_PIN is not interrupt-capable");
- pciSetup(X2_MAX_PIN);
- #endif
- #endif
-
- #if HAS_X2_MIN
- #if (digitalPinToInterrupt(X2_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(X2_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(X2_MIN_PIN) != NULL, "X2_MIN_PIN is not interrupt-capable");
- pciSetup(X2_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Y2_MAX
- #if (digitalPinToInterrupt(Y2_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Y2_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Y2_MAX_PIN) != NULL, "Y2_MAX_PIN is not interrupt-capable");
- pciSetup(Y2_MAX_PIN);
- #endif
- #endif
-
- #if HAS_Y2_MIN
- #if (digitalPinToInterrupt(Y2_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Y2_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Y2_MIN_PIN) != NULL, "Y2_MIN_PIN is not interrupt-capable");
- pciSetup(Y2_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Z2_MAX
- #if (digitalPinToInterrupt(Z2_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z2_MAX_PIN) != NULL, "Z2_MAX_PIN is not interrupt-capable");
- pciSetup(Z2_MAX_PIN);
- #endif
- #endif
-
- #if HAS_Z2_MIN
- #if (digitalPinToInterrupt(Z2_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z2_MIN_PIN) != NULL, "Z2_MIN_PIN is not interrupt-capable");
- pciSetup(Z2_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Z3_MAX
- #if (digitalPinToInterrupt(Z3_MAX_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z3_MAX_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z3_MAX_PIN) != NULL, "Z3_MAX_PIN is not interrupt-capable");
- pciSetup(Z3_MAX_PIN);
- #endif
- #endif
-
- #if HAS_Z3_MIN
- #if (digitalPinToInterrupt(Z3_MIN_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z3_MIN_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z3_MIN_PIN) != NULL, "Z3_MIN_PIN is not interrupt-capable");
- pciSetup(Z3_MIN_PIN);
- #endif
- #endif
-
- #if HAS_Z_MIN_PROBE_PIN
- #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
- attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
- #else
- // Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
- static_assert(digitalPinToPCICR(Z_MIN_PROBE_PIN) != NULL, "Z_MIN_PROBE_PIN is not interrupt-capable");
- pciSetup(Z_MIN_PROBE_PIN);
- #endif
- #endif
-
- // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
-}
diff --git a/Marlin/src/HAL/HAL_AVR/fast_pwm.cpp b/Marlin/src/HAL/HAL_AVR/fast_pwm.cpp
deleted file mode 100644
index b38a4acea2..0000000000
--- a/Marlin/src/HAL/HAL_AVR/fast_pwm.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-#ifdef __AVR__
-
-#include "../../inc/MarlinConfigPre.h"
-/**
- * get_pwm_timer
- * Grabs timer information and registers of the provided pin
- * returns Timer struct containing this information
- * Used by set_pwm_frequency, set_pwm_duty
- *
- */
-
-#if ENABLED(FAST_PWM_FAN)
-#include "HAL.h"
-
- struct Timer {
- volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
- volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
- volatile uint16_t* ICRn; // max 1 ICR register per timer
- uint8_t n; // the timer number [0->5]
- uint8_t q; // the timer output [0->2] (A->C)
- };
-
- Timer get_pwm_timer(pin_t pin) {
- uint8_t q = 0;
- switch (digitalPinToTimer(pin)) {
- // Protect reserved timers (TIMER0 & TIMER1)
- #ifdef TCCR0A
- #if !AVR_AT90USB1286_FAMILY
- case TIMER0A:
- #endif
- case TIMER0B:
- #endif
- #ifdef TCCR1A
- case TIMER1A: case TIMER1B:
- #endif
- break;
- #if defined(TCCR2) || defined(TCCR2A)
- #ifdef TCCR2
- case TIMER2: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR2, NULL, NULL},
- /*OCRnQ*/ { (uint16_t*)&OCR2, NULL, NULL},
- /*ICRn*/ NULL,
- /*n, q*/ 2, 0
- };
- }
- #elif defined TCCR2A
- #if ENABLED(USE_OCR2A_AS_TOP)
- case TIMER2A: break; // protect TIMER2A
- case TIMER2B: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR2A, &TCCR2B, NULL},
- /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, NULL},
- /*ICRn*/ NULL,
- /*n, q*/ 2, 1
- };
- return timer;
- }
- #else
- case TIMER2B: ++q;
- case TIMER2A: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR2A, &TCCR2B, NULL},
- /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, NULL},
- /*ICRn*/ NULL,
- 2, q
- };
- return timer;
- }
- #endif
- #endif
- #endif
- #ifdef TCCR3A
- case TIMER3C: ++q;
- case TIMER3B: ++q;
- case TIMER3A: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C},
- /*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C},
- /*ICRn*/ &ICR3,
- /*n, q*/ 3, q
- };
- return timer;
- }
- #endif
- #ifdef TCCR4A
- case TIMER4C: ++q;
- case TIMER4B: ++q;
- case TIMER4A: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C},
- /*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C},
- /*ICRn*/ &ICR4,
- /*n, q*/ 4, q
- };
- return timer;
- }
- #endif
- #ifdef TCCR5A
- case TIMER5C: ++q;
- case TIMER5B: ++q;
- case TIMER5A: {
- Timer timer = {
- /*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C},
- /*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C },
- /*ICRn*/ &ICR5,
- /*n, q*/ 5, q
- };
- return timer;
- }
- #endif
- }
- Timer timer = {
- /*TCCRnQ*/ { NULL, NULL, NULL},
- /*OCRnQ*/ { NULL, NULL, NULL},
- /*ICRn*/ NULL,
- 0, 0
- };
- return timer;
- }
-
- void set_pwm_frequency(const pin_t pin, int f_desired) {
- Timer timer = get_pwm_timer(pin);
- if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
- uint16_t size;
- if (timer.n == 2) size = 255; else size = 65535;
-
- uint16_t res = 255; // resolution (TOP value)
- uint8_t j = 0; // prescaler index
- uint8_t wgm = 1; // waveform generation mode
-
- // Calculating the prescaler and resolution to use to achieve closest frequency
- if (f_desired != 0) {
- int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable
- uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
-
- // loop over prescaler values
- for (uint8_t i = 1; i < 8; i++) {
- uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
- if (timer.n == 2) {
- // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
- #if ENABLED(USE_OCR2A_AS_TOP)
- const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
- res_temp_fast = rtf - 1;
- res_temp_phase_correct = rtf / 2;
- #endif
- }
- else {
- // Skip TIMER2 specific prescalers when not TIMER2
- if (i == 3 || i == 5) continue;
- const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired);
- res_temp_fast = rtf - 1;
- res_temp_phase_correct = rtf / 2;
- }
-
- LIMIT(res_temp_fast, 1u, size);
- LIMIT(res_temp_phase_correct, 1u, size);
- // Calculate frequencies of test prescaler and resolution values
- const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)),
- f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),
- f_diff = ABS(f - f_desired),
- f_fast_diff = ABS(f_temp_fast - f_desired),
- f_phase_diff = ABS(f_temp_phase_correct - f_desired);
-
- // If FAST values are closest to desired f
- if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) {
- // Remember this combination
- f = f_temp_fast;
- res = res_temp_fast;
- j = i;
- // Set the Wave Generation Mode to FAST PWM
- if (timer.n == 2) {
- wgm = (
- #if ENABLED(USE_OCR2A_AS_TOP)
- WGM2_FAST_PWM_OCR2A
- #else
- WGM2_FAST_PWM
- #endif
- );
- }
- else wgm = WGM_FAST_PWM_ICRn;
- }
- // If PHASE CORRECT values are closes to desired f
- else if (f_phase_diff < f_diff) {
- f = f_temp_phase_correct;
- res = res_temp_phase_correct;
- j = i;
- // Set the Wave Generation Mode to PWM PHASE CORRECT
- if (timer.n == 2) {
- wgm = (
- #if ENABLED(USE_OCR2A_AS_TOP)
- WGM2_PWM_PC_OCR2A
- #else
- WGM2_PWM_PC
- #endif
- );
- }
- else wgm = WGM_PWM_PC_ICRn;
- }
- }
- }
- _SET_WGMnQ(timer.TCCRnQ, wgm);
- _SET_CSn(timer.TCCRnQ, j);
-
- if (timer.n == 2) {
- #if ENABLED(USE_OCR2A_AS_TOP)
- _SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
- #endif
- }
- else
- _SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
- }
-
- void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
- // If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
- // Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
- if (v == 0)
- digitalWrite(pin, invert);
- else if (v == v_size)
- digitalWrite(pin, !invert);
- else {
- Timer timer = get_pwm_timer(pin);
- if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
- // Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
- _SET_COMnQ(timer.TCCRnQ, (timer.q
- #ifdef TCCR2
- + (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
- #endif
- ), COM_CLEAR_SET + invert
- );
-
- uint16_t top;
- if (timer.n == 2) { // if TIMER2
- top = (
- #if ENABLED(USE_OCR2A_AS_TOP)
- *timer.OCRnQ[0] // top = OCR2A
- #else
- 255 // top = 0xFF (max)
- #endif
- );
- }
- else
- top = *timer.ICRn; // top = ICRn
-
- _SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top / v_size)); // Scale 8/16-bit v to top value
- }
- }
-
-#endif // FAST_PWM_FAN
-#endif // __AVR__
diff --git a/Marlin/src/HAL/HAL_DUE/G2_PWM.cpp b/Marlin/src/HAL/HAL_DUE/G2_PWM.cpp
deleted file mode 100644
index cfb064097e..0000000000
--- a/Marlin/src/HAL/HAL_DUE/G2_PWM.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * The PWM module is only used to generate interrupts at specified times. It
- * is NOT used to directly toggle pins. The ISR writes to the pin assigned to
- * that interrupt.
- *
- * All PWMs use the same repetition rate. The G2 needs about 10KHz min in order to
- * not have obvious ripple on the Vref signals.
- *
- * The data structures are setup to minimize the computation done by the ISR which
- * minimizes ISR execution time. Execution times are 0.8 to 1.1 microseconds.
- *
- * FIve PWM interrupt sources are used. Channel 0 sets the base period. All Vref
- * signals are set active when this counter overflows and resets to zero. The compare
- * values in channels 1-4 are set to give the desired duty cycle for that Vref pin.
- * When counter 0 matches the compare value then that channel generates an interrupt.
- * The ISR checks the source of the interrupt and sets the corresponding pin inactive.
- *
- * Some jitter in the Vref signal is OK so the interrupt priority is left at its default value.
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if MB(PRINTRBOARD_G2)
-
-#include "G2_PWM.h"
-
-volatile uint32_t *SODR_A = &PIOA->PIO_SODR,
- *SODR_B = &PIOB->PIO_SODR,
- *CODR_A = &PIOA->PIO_CODR,
- *CODR_B = &PIOB->PIO_CODR;
-
-PWM_map ISR_table[NUM_PWMS] = PWM_MAP_INIT;
-
-void Stepper::digipot_init() {
-
- OUT_WRITE(MOTOR_CURRENT_PWM_X_PIN, 0); // init pins
- OUT_WRITE(MOTOR_CURRENT_PWM_Y_PIN, 0);
- OUT_WRITE(MOTOR_CURRENT_PWM_Z_PIN, 0);
- OUT_WRITE(MOTOR_CURRENT_PWM_E_PIN, 0);
-
- #define WPKEY (0x50574D << 8) // “PWM” in ASCII
- #define WPCMD_DIS_SW 0 // command to disable Write Protect SW
- #define WPRG_ALL (PWM_WPCR_WPRG0 | PWM_WPCR_WPRG1 | PWM_WPCR_WPRG2 | PWM_WPCR_WPRG3 | PWM_WPCR_WPRG4 | PWM_WPCR_WPRG5) // all Write Protect Groups
-
- #define PWM_CLOCK_F F_CPU / 1000000UL // set clock to 1MHz
-
- PMC->PMC_PCER1 = PMC_PCER1_PID36; // enable PWM controller clock (disabled on power up)
-
- PWM->PWM_WPCR = WPKEY | WPRG_ALL | WPCMD_DIS_SW; // enable setting of all PWM registers
- PWM->PWM_CLK = PWM_CLOCK_F; // enable CLK_A and set it to 1MHz, leave CLK_B disabled
- PWM->PWM_CH_NUM[0].PWM_CMR = 0b1011; // set channel 0 to Clock A input & to left aligned
- PWM->PWM_CH_NUM[1].PWM_CMR = 0b1011; // set channel 1 to Clock A input & to left aligned
- PWM->PWM_CH_NUM[2].PWM_CMR = 0b1011; // set channel 2 to Clock A input & to left aligned
- PWM->PWM_CH_NUM[3].PWM_CMR = 0b1011; // set channel 3 to Clock A input & to left aligned
- PWM->PWM_CH_NUM[4].PWM_CMR = 0b1011; // set channel 4 to Clock A input & to left aligned
-
- PWM->PWM_CH_NUM[0].PWM_CPRD = PWM_PERIOD_US; // set channel 0 Period
-
- PWM->PWM_IER2 = PWM_IER1_CHID0; // generate interrupt when counter0 overflows
- PWM->PWM_IER2 = PWM_IER2_CMPM0 | PWM_IER2_CMPM1 | PWM_IER2_CMPM2 | PWM_IER2_CMPM3 | PWM_IER2_CMPM4; // generate interrupt on compare event
-
- PWM->PWM_CMP[1].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0])); // interrupt when counter0 == CMPV - used to set Motor 1 PWM inactive
- PWM->PWM_CMP[2].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0])); // interrupt when counter0 == CMPV - used to set Motor 2 PWM inactive
- PWM->PWM_CMP[3].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[1])); // interrupt when counter0 == CMPV - used to set Motor 3 PWM inactive
- PWM->PWM_CMP[4].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[2])); // interrupt when counter0 == CMPV - used to set Motor 4 PWM inactive
-
- PWM->PWM_CMP[1].PWM_CMPM = 0x0001; // enable compare event
- PWM->PWM_CMP[2].PWM_CMPM = 0x0001; // enable compare event
- PWM->PWM_CMP[3].PWM_CMPM = 0x0001; // enable compare event
- PWM->PWM_CMP[4].PWM_CMPM = 0x0001; // enable compare event
-
- PWM->PWM_SCM = PWM_SCM_UPDM_MODE0 | PWM_SCM_SYNC0 | PWM_SCM_SYNC1 | PWM_SCM_SYNC2 | PWM_SCM_SYNC3 | PWM_SCM_SYNC4; // sync 1-4 with 0, use mode 0 for updates
-
- PWM->PWM_ENA = PWM_ENA_CHID0 | PWM_ENA_CHID1 | PWM_ENA_CHID2 | PWM_ENA_CHID3 | PWM_ENA_CHID4; // enable the channels used by G2
- PWM->PWM_IER1 = PWM_IER1_CHID0 | PWM_IER1_CHID1 | PWM_IER1_CHID2 | PWM_IER1_CHID3 | PWM_IER1_CHID4; // enable interrupts for the channels used by G2
-
- NVIC_EnableIRQ(PWM_IRQn); // Enable interrupt handler
- NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals)
-}
-
-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
-
- switch (driver) {
- case 0: PWM->PWM_CMP[1].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update X & Y
- PWM->PWM_CMP[2].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));
- PWM->PWM_CMP[1].PWM_CMPMUPD = 0x0001; // enable compare event
- PWM->PWM_CMP[2].PWM_CMPMUPD = 0x0001; // enable compare event
- PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
- break;
- case 1: PWM->PWM_CMP[3].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update Z
- PWM->PWM_CMP[3].PWM_CMPMUPD = 0x0001; // enable compare event
- PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
- break;
- default:PWM->PWM_CMP[4].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current)); // update E
- PWM->PWM_CMP[4].PWM_CMPMUPD = 0x0001; // enable compare event
- PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
- break;
- }
-}
-
-volatile uint32_t PWM_ISR1_STATUS, PWM_ISR2_STATUS;
-
-void PWM_Handler() {
- PWM_ISR1_STATUS = PWM->PWM_ISR1;
- PWM_ISR2_STATUS = PWM->PWM_ISR2;
- if (PWM_ISR1_STATUS & PWM_IER1_CHID0) { // CHAN_0 interrupt
- *ISR_table[0].set_register = ISR_table[0].write_mask; // set X to active
- *ISR_table[1].set_register = ISR_table[1].write_mask; // set Y to active
- *ISR_table[2].set_register = ISR_table[2].write_mask; // set Z to active
- *ISR_table[3].set_register = ISR_table[3].write_mask; // set E to active
- }
- else {
- if (PWM_ISR2_STATUS & PWM_IER2_CMPM1) *ISR_table[0].clr_register = ISR_table[0].write_mask; // set X to inactive
- if (PWM_ISR2_STATUS & PWM_IER2_CMPM2) *ISR_table[1].clr_register = ISR_table[1].write_mask; // set Y to inactive
- if (PWM_ISR2_STATUS & PWM_IER2_CMPM3) *ISR_table[2].clr_register = ISR_table[2].write_mask; // set Z to inactive
- if (PWM_ISR2_STATUS & PWM_IER2_CMPM4) *ISR_table[3].clr_register = ISR_table[3].write_mask; // set E to inactive
- }
- return;
-}
-
-#endif // PRINTRBOARD_G2
diff --git a/Marlin/src/HAL/HAL_DUE/HAL.cpp b/Marlin/src/HAL/HAL_DUE/HAL.cpp
deleted file mode 100644
index cefe308e81..0000000000
--- a/Marlin/src/HAL/HAL_DUE/HAL.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * Description: HAL for Arduino Due and compatible (SAM3X8E)
- *
- * For ARDUINO_ARCH_SAM
- */
-
-#ifdef ARDUINO_ARCH_SAM
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "../../inc/MarlinConfig.h"
-#include "HAL.h"
-
-#include
-#include "usb/usb_task.h"
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-// HAL initialization task
-void HAL_init(void) {
- // Initialize the USB stack
- #if ENABLED(SDSUPPORT)
- OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
- #endif
- usb_task_init();
-}
-
-// HAL idle task
-void HAL_idletask(void) {
- // Perform USB stack housekeeping
- usb_task_idle();
-}
-
-// Disable interrupts
-void cli(void) { noInterrupts(); }
-
-// Enable interrupts
-void sei(void) { interrupts(); }
-
-void HAL_clear_reset_source(void) { }
-
-uint8_t HAL_get_reset_source(void) {
- switch ((RSTC->RSTC_SR >> 8) & 0x07) {
- case 0: return RST_POWER_ON;
- case 1: return RST_BACKUP;
- case 2: return RST_WATCHDOG;
- case 3: return RST_SOFTWARE;
- case 4: return RST_EXTERNAL;
- default: return 0;
- }
-}
-
-void _delay_ms(const int delay_ms) {
- // Todo: port for Due?
- delay(delay_ms);
-}
-
-extern "C" {
- extern unsigned int _ebss; // end of bss section
-}
-
-// Return free memory between end of heap (or end bss) and whatever is current
-int freeMemory() {
- int free_memory, heap_end = (int)_sbrk(0);
- return (int)&free_memory - (heap_end ? heap_end : (int)&_ebss);
-}
-
-// --------------------------------------------------------------------------
-// ADC
-// --------------------------------------------------------------------------
-
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
- HAL_adc_result = analogRead(adc_pin);
-}
-
-uint16_t HAL_adc_get_result(void) {
- // nop
- return HAL_adc_result;
-}
-
-#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h
deleted file mode 100644
index d430e6b649..0000000000
--- a/Marlin/src/HAL/HAL_DUE/HAL.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Description: HAL for Arduino Due and compatible (SAM3X8E)
- *
- * For ARDUINO_ARCH_SAM
- */
-
-#define CPU_32_BIT
-
-#include
-
-#include
-
-#include "../shared/math_32bit.h"
-#include "../shared/HAL_SPI.h"
-#include "fastio_Due.h"
-#include "watchdog_Due.h"
-#include "HAL_timers_Due.h"
-
-// Serial ports
-#if !WITHIN(SERIAL_PORT, -1, 3)
- #error "SERIAL_PORT must be from -1 to 3"
-#endif
-
-// MYSERIAL0 required before MarlinSerial includes!
-#define MYSERIAL0 customizedSerial1
-
-#ifdef SERIAL_PORT_2
- #if !WITHIN(SERIAL_PORT_2, -1, 3)
- #error "SERIAL_PORT_2 must be from -1 to 3"
- #elif SERIAL_PORT_2 == SERIAL_PORT
- #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
- #endif
- #define NUM_SERIAL 2
- #define MYSERIAL1 customizedSerial2
-#else
- #define NUM_SERIAL 1
-#endif
-
-#include "MarlinSerial_Due.h"
-#include "MarlinSerialUSB_Due.h"
-
-// On AVR this is in math.h?
-#define square(x) ((x)*(x))
-
-#ifndef strncpy_P
- #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
-#endif
-
-#ifndef vsnprintf_P
- #define vsnprintf_P vsnprintf
-#endif
-
-// Fix bug in pgm_read_ptr
-#undef pgm_read_ptr
-#define pgm_read_ptr(addr) (*((void**)(addr)))
-#undef pgm_read_word
-#define pgm_read_word(addr) (*((uint16_t*)(addr)))
-
-#define RST_POWER_ON 1
-#define RST_EXTERNAL 2
-#define RST_BROWN_OUT 4
-#define RST_WATCHDOG 8
-#define RST_JTAG 16
-#define RST_SOFTWARE 32
-#define RST_BACKUP 64
-
-typedef int8_t pin_t;
-
-#define HAL_SERVO_LIB Servo
-
-//
-// Interrupts
-//
-#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
-#define CRITICAL_SECTION_END if (!primask) __enable_irq()
-#define ISRS_ENABLED() (!__get_PRIMASK())
-#define ENABLE_ISRS() __enable_irq()
-#define DISABLE_ISRS() __disable_irq()
-
-void cli(void); // Disable interrupts
-void sei(void); // Enable interrupts
-
-void HAL_clear_reset_source(void); // clear reset reason
-uint8_t HAL_get_reset_source(void); // get reset reason
-
-//
-// SPI: Extended functions taking a channel number (Hardware SPI only)
-//
-
-// Write single byte to specified SPI channel
-void spiSend(uint32_t chan, byte b);
-// Write buffer to specified SPI channel
-void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
-// Read single byte from specified SPI channel
-uint8_t spiRec(uint32_t chan);
-
-//
-// EEPROM
-//
-void eeprom_write_byte(uint8_t *pos, unsigned char value);
-uint8_t eeprom_read_byte(uint8_t *pos);
-void eeprom_read_block (void *__dst, const void *__src, size_t __n);
-void eeprom_update_block (const void *__src, void *__dst, size_t __n);
-
-//
-// ADC
-//
-extern uint16_t HAL_adc_result; // result of last ADC conversion
-
-#ifndef analogInputToDigitalPin
- #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
-#endif
-
-#define HAL_ANALOG_SELECT(pin)
-
-inline void HAL_adc_init(void) {}//todo
-
-#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
-#define HAL_READ_ADC() HAL_adc_result
-#define HAL_ADC_READY() true
-
-void HAL_adc_start_conversion(const uint8_t adc_pin);
-uint16_t HAL_adc_get_result(void);
-uint16_t HAL_getAdcReading(uint8_t chan);
-void HAL_startAdcConversion(uint8_t chan);
-uint8_t HAL_pinToAdcChannel(int pin);
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
-void HAL_enable_AdcFreerun(void);
-//void HAL_disable_AdcFreerun(uint8_t chan);
-
-//
-// Pin Map
-//
-#define GET_PIN_MAP_PIN(index) index
-#define GET_PIN_MAP_INDEX(pin) pin
-#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
-
-//
-// Tone
-//
-void toneInit();
-void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
-void noTone(const pin_t _pin);
-
-// Enable hooks into idle and setup for HAL
-#define HAL_IDLETASK 1
-#define HAL_INIT 1
-void HAL_idletask(void);
-void HAL_init(void);
-
-//
-// Utility functions
-//
-void _delay_ms(const int delay);
-int freeMemory(void);
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s);
-#ifdef __cplusplus
- }
-#endif
diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.cpp b/Marlin/src/HAL/HAL_ESP32/HAL.cpp
deleted file mode 100644
index 76b961b7b9..0000000000
--- a/Marlin/src/HAL/HAL_ESP32/HAL.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#ifdef ARDUINO_ARCH_ESP32
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-#include
-#include
-#include
-
-#include "../../inc/MarlinConfigPre.h"
-
-#if ENABLED(WIFISUPPORT)
- #include
- #include "wifi.h"
- #if ENABLED(OTASUPPORT)
- #include "ota.h"
- #endif
- #if ENABLED(WEBSUPPORT)
- #include "web.h"
- #endif
-#endif
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-#define V_REF 1100
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-esp_adc_cal_characteristics_t characteristics;
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-void HAL_init(void) {
- #if ENABLED(WIFISUPPORT)
- wifi_init();
- #if ENABLED(OTASUPPORT)
- OTA_init();
- #endif
- #if ENABLED(WEBSUPPORT)
- web_init();
- #endif
- server.begin();
- #endif
-
- i2s_init();
-}
-
-void HAL_idletask(void) {
- #if ENABLED(OTASUPPORT)
- OTA_handle();
- #endif
-}
-
-void HAL_clear_reset_source(void) { }
-
-uint8_t HAL_get_reset_source (void) {
- return rtc_get_reset_reason(1);
-}
-
-void _delay_ms(int delay_ms) {
- delay(delay_ms);
-}
-
-// return free memory between end of heap (or end bss) and whatever is current
-int freeMemory() {
- return ESP.getFreeHeap();
-}
-
-// --------------------------------------------------------------------------
-// ADC
-// --------------------------------------------------------------------------
-#define ADC1_CHANNEL(pin) ADC1_GPIO##pin_CHANNEL
-
-adc1_channel_t get_channel(int pin) {
- switch (pin) {
- case 36: return ADC1_GPIO36_CHANNEL;
- case 39: return ADC1_GPIO39_CHANNEL;
- }
-
- return ADC1_CHANNEL_MAX;
-}
-
-void HAL_adc_init() {
- // Configure ADC
- adc1_config_width(ADC_WIDTH_12Bit);
- adc1_config_channel_atten(get_channel(36), ADC_ATTEN_11db);
- adc1_config_channel_atten(get_channel(39), ADC_ATTEN_11db);
-
- // Calculate ADC characteristics i.e. gain and offset factors
- esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, V_REF, &characteristics);
-}
-
-void HAL_adc_start_conversion (uint8_t adc_pin) {
- uint32_t mv;
- esp_adc_cal_get_voltage((adc_channel_t)get_channel(adc_pin), &characteristics, &mv);
-
- HAL_adc_result = mv*1023.0/3300.0;
-}
-
-int pin_to_channel[40] = {};
-int cnt_channel = 1;
-void analogWrite(int pin, int value) {
- if (pin_to_channel[pin] == 0) {
- ledcAttachPin(pin, cnt_channel);
- ledcSetup(cnt_channel, 490, 8);
- ledcWrite(cnt_channel, value);
-
- pin_to_channel[pin] = cnt_channel++;
- }
-
- ledcWrite(pin_to_channel[pin], value);
-}
-#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.h b/Marlin/src/HAL/HAL_ESP32/HAL.h
deleted file mode 100644
index 8218447305..0000000000
--- a/Marlin/src/HAL/HAL_ESP32/HAL.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-#pragma once
-
-/**
- * Description: HAL for Espressif ESP32 WiFi
- */
-
-#define CPU_32_BIT
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include
-
-#undef DISABLED
-#undef M_PI
-
-#include
-
-#undef DISABLED
-#define DISABLED(V...) DO(DIS,&&,V)
-
-#include "../shared/math_32bit.h"
-#include "../shared/HAL_SPI.h"
-
-#include "fastio_ESP32.h"
-#include "watchdog_ESP32.h"
-#include "i2s.h"
-
-#include "HAL_timers_ESP32.h"
-
-#include "WebSocketSerial.h"
-
-// --------------------------------------------------------------------------
-// Defines
-// --------------------------------------------------------------------------
-
-extern portMUX_TYPE spinlock;
-
-#define MYSERIAL0 Serial
-
-#if ENABLED(WIFISUPPORT)
- #define NUM_SERIAL 2
- #define MYSERIAL1 webSocketSerial
-#else
- #define NUM_SERIAL 1
-#endif
-
-#define CRITICAL_SECTION_START portENTER_CRITICAL(&spinlock)
-#define CRITICAL_SECTION_END portEXIT_CRITICAL(&spinlock)
-#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL)
-#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
-#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
-
-
-// Fix bug in pgm_read_ptr
-#undef pgm_read_ptr
-#define pgm_read_ptr(addr) (*(addr))
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-typedef int16_t pin_t;
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-/** result of last ADC conversion */
-extern uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-// clear reset reason
-void HAL_clear_reset_source (void);
-
-// reset reason
-uint8_t HAL_get_reset_source (void);
-
-void _delay_ms(int delay);
-
-int freeMemory(void);
-
-void analogWrite(int pin, int value);
-
-// EEPROM
-void eeprom_write_byte(uint8_t *pos, unsigned char value);
-uint8_t eeprom_read_byte(uint8_t *pos);
-void eeprom_read_block (void *__dst, const void *__src, size_t __n);
-void eeprom_update_block (const void *__src, void *__dst, size_t __n);
-
-// ADC
-#define HAL_ANALOG_SELECT(pin)
-
-void HAL_adc_init(void);
-
-#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
-#define HAL_READ_ADC() HAL_adc_result
-#define HAL_ADC_READY() true
-
-void HAL_adc_start_conversion (uint8_t adc_pin);
-
-#define GET_PIN_MAP_PIN(index) index
-#define GET_PIN_MAP_INDEX(pin) pin
-#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
-
-// Enable hooks into idle and setup for HAL
-#define HAL_IDLETASK 1
-#define HAL_INIT 1
-void HAL_idletask(void);
-void HAL_init(void);
diff --git a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.cpp
deleted file mode 100644
index 4858ba4c3e..0000000000
--- a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#ifdef ARDUINO_ARCH_ESP32
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(WIFISUPPORT)
-
-#include "WebSocketSerial.h"
-
-extern WebSocketSerial webSocketSerial;
-
-#include "wifi.h"
-#include
-#include
-
-struct ring_buffer_r {
- unsigned char buffer[RX_BUFFER_SIZE];
- volatile ring_buffer_pos_t head, tail;
-};
-
-struct ring_buffer_t {
- unsigned char buffer[256];
- volatile uint8_t head, tail;
-};
-
-ring_buffer_r rx_buffer = { { 0 }, 0, 0 };
-ring_buffer_t tx_buffer = { { 0 }, 0, 0 };
-
-static bool _written;
-
-#if ENABLED(EMERGENCY_PARSER)
- static EmergencyParser::State emergency_state; // = EP_RESET
-#endif
-
-AsyncWebSocket ws("/ws"); // access at ws://[esp ip]/ws
-
-FORCE_INLINE int next_rx_index(const int i) { return (ring_buffer_pos_t)(i + 1) & (ring_buffer_pos_t)(RX_BUFFER_SIZE - 1); }
-FORCE_INLINE int next_tx_index(const int i) { return (ring_buffer_pos_t)(i + 1) & (ring_buffer_pos_t)(TX_BUFFER_SIZE - 1); }
-
-static void addToBuffer(uint8_t * const data, const size_t len) {
- for (size_t i = 0; i < len; i++) {
- ring_buffer_pos_t h = rx_buffer.head;
- const ring_buffer_pos_t t = rx_buffer.tail, n = next_rx_index(h);
-
- if (n != t) { rx_buffer.buffer[h] = data[i]; h = n; }
-
- // TODO: buffer is full, handle?
-
- rx_buffer.head = h;
- }
-}
-
-// Handle WebSocket event
-static void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
- switch (type) {
- case WS_EVT_CONNECT: client->ping(); break; // client connected
- case WS_EVT_DISCONNECT: // client disconnected
- case WS_EVT_ERROR: // error was received from the other end
- case WS_EVT_PONG: break; // pong message was received (in response to a ping request maybe)
- case WS_EVT_DATA: { // data packet
- AwsFrameInfo * info = (AwsFrameInfo*)arg;
- if (info->opcode == WS_TEXT || info->message_opcode == WS_TEXT)
- addToBuffer(data, len);
- }
- }
-}
-
-// Public Methods
-void WebSocketSerial::begin(const long baud_setting) {
- ws.onEvent(onEvent);
- server.addHandler(&ws); // attach AsyncWebSocket
-}
-
-void WebSocketSerial::end() { }
-
-int WebSocketSerial::peek(void) {
- const int v = rx_buffer.head == rx_buffer.tail ? -1 : rx_buffer.buffer[rx_buffer.tail];
- return v;
-}
-
-int WebSocketSerial::read(void) {
- const ring_buffer_pos_t h = rx_buffer.head, t = rx_buffer.tail;
- if (h == t) return -1; // Nothing to read? Return now
-
- const int v = rx_buffer.buffer[t];
-
- rx_buffer.tail = (ring_buffer_pos_t)(t + 1) & (RX_BUFFER_SIZE - 1); // Advance tail
-
- return v;
-}
-
-bool WebSocketSerial::available(void) {
- const ring_buffer_pos_t h = rx_buffer.head, t = rx_buffer.tail;
- return (ring_buffer_pos_t)(RX_BUFFER_SIZE + h - t) & (RX_BUFFER_SIZE - 1);
-}
-
-void WebSocketSerial::flush(void) {
- ws.textAll("flush");
- rx_buffer.tail = rx_buffer.head;
-}
-
-#if TX_BUFFER_SIZE
-
- void WebSocketSerial::write(const uint8_t c) {
- _written = true;
-
- const uint8_t i = (tx_buffer.head + 1) & (TX_BUFFER_SIZE - 1);
-
- // Store new char. head is always safe to move
- tx_buffer.buffer[tx_buffer.head] = c;
- tx_buffer.head = i;
-
- if (c == '\n') {
- ws.textAll(tx_buffer.buffer, tx_buffer.head);
- tx_buffer.head = 0;
- }
- }
-
- void WebSocketSerial::flushTx(void) {
- ws.textAll("flushTx");
- if (!_written) return;
- }
-
-#else
-
- //void WebSocketSerial::write(const uint8_t c) { _written = true; }
- //void WebSocketSerial::flushTx(void) { if (!_written) return; }
-
-#endif
-
-/**
- * Imports from print.h
- */
-
-void WebSocketSerial::print(char c, int base) { print((long)c, base); }
-void WebSocketSerial::print(unsigned char b, int base) { print((unsigned long)b, base); }
-void WebSocketSerial::print(int n, int base) { print((long)n, base); }
-void WebSocketSerial::print(unsigned int n, int base) { print((unsigned long)n, base); }
-void WebSocketSerial::print(long n, int base) {
- if (base == 0)
- write(n);
- else if (base == 10) {
- if (n < 0) { print('-'); n = -n; }
- printNumber(n, 10);
- }
- else
- printNumber(n, base);
-}
-
-void WebSocketSerial::print(unsigned long n, int base) {
- if (base == 0) write(n); else printNumber(n, base);
-}
-
-void WebSocketSerial::print(double n, int digits) { printFloat(n, digits); }
-
-void WebSocketSerial::println(void) { print('\r'); print('\n'); }
-void WebSocketSerial::println(const String& s) { print(s); println(); }
-void WebSocketSerial::println(const char c[]) { print(c); println(); }
-void WebSocketSerial::println(char c, int base) { print(c, base); println(); }
-void WebSocketSerial::println(unsigned char b, int base) { print(b, base); println(); }
-void WebSocketSerial::println(int n, int base) { print(n, base); println(); }
-void WebSocketSerial::println(unsigned int n, int base) { print(n, base); println(); }
-void WebSocketSerial::println(long n, int base) { print(n, base); println(); }
-void WebSocketSerial::println(unsigned long n, int base) { print(n, base); println(); }
-void WebSocketSerial::println(double n, int digits) { print(n, digits); println(); }
-
-// Private Methods
-
-void WebSocketSerial::printNumber(unsigned long n, uint8_t base) {
- if (n) {
- unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
- int8_t i = 0;
- while (n) {
- buf[i++] = n % base;
- n /= base;
- }
- while (i--)
- print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
- }
- else
- print('0');
-}
-
-void WebSocketSerial::printFloat(double number, uint8_t digits) {
- // Handle negative numbers
- if (number < 0.0) { print('-'); number = -number; }
-
- // Round correctly so that print(1.999, 2) prints as "2.00"
- // Use a lookup table for performance
- constexpr double rounds[] = { 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005 };
- number += rounds[digits];
-
- //number += pow(10, -(digits + 1)); // slower single-line equivalent
-
- // Extract the integer part of the number and print it
- unsigned long int_part = (unsigned long)number;
- print(int_part);
-
- // Print the decimal point, but only if there are digits beyond
- double remainder = number - (double)int_part;
- if (digits) {
- print('.');
- // Extract digits from the remainder one at a time
- while (digits--) {
- remainder *= 10.0;
- const int toPrint = int(remainder);
- print(toPrint);
- remainder -= toPrint;
- }
- }
-}
-
-#endif // WIFISUPPORT
-#endif // ARDUINO_ARCH_ESP32
diff --git a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h b/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h
deleted file mode 100644
index 43c8044107..0000000000
--- a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-#include "../../inc/MarlinConfig.h"
-
-#include
-
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-
-#ifndef RX_BUFFER_SIZE
- #define RX_BUFFER_SIZE 128
-#endif
-#ifndef TX_BUFFER_SIZE
- #define TX_BUFFER_SIZE 32
-#endif
-#if TX_BUFFER_SIZE <= 0
- #error "TX_BUFFER_SIZE is required for the WebSocket."
-#endif
-
-#if RX_BUFFER_SIZE > 256
- typedef uint16_t ring_buffer_pos_t;
-#else
- typedef uint8_t ring_buffer_pos_t;
-#endif
-
-class WebSocketSerial {
-public:
- WebSocketSerial() {};
- static void begin(const long);
- static void end();
- static int peek(void);
- static int read(void);
- static void flush(void);
- static void flushTx(void);
- static bool available(void);
- static void write(const uint8_t c);
-
- #if ENABLED(SERIAL_STATS_DROPPED_RX)
- FORCE_INLINE static uint32_t dropped() { return 0; }
- #endif
-
- #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
- FORCE_INLINE static int rxMaxEnqueued() { return 0; }
- #endif
-
- FORCE_INLINE static void write(const char* str) { while (*str) write(*str++); }
- FORCE_INLINE static void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
- FORCE_INLINE static void print(const String& s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
- FORCE_INLINE static void print(const char* str) { write(str); }
-
- static void print(char, int = 0);
- static void print(unsigned char, int = 0);
- static void print(int, int = DEC);
- static void print(unsigned int, int = DEC);
- static void print(long, int = DEC);
- static void print(unsigned long, int = DEC);
- static void print(double, int = 2);
-
- static void println(const String& s);
- static void println(const char[]);
- static void println(char, int = 0);
- static void println(unsigned char, int = 0);
- static void println(int, int = DEC);
- static void println(unsigned int, int = DEC);
- static void println(long, int = DEC);
- static void println(unsigned long, int = DEC);
- static void println(double, int = 2);
- static void println(void);
- operator bool() { return true; }
-
-private:
- static void printNumber(unsigned long, const uint8_t);
- static void printFloat(double, uint8_t);
-};
-
-extern WebSocketSerial webSocketSerial;
diff --git a/Marlin/src/HAL/HAL_LINUX/SanityCheck.h b/Marlin/src/HAL/HAL_LINUX/SanityCheck.h
deleted file mode 100644
index fd4c53241a..0000000000
--- a/Marlin/src/HAL/HAL_LINUX/SanityCheck.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Test X86_64 configuration values for errors at compile-time.
- */
-
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
- #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(FAST_PWM_FAN)
- #error "FAST_PWM_FAN is not yet implemented for this platform."
-#endif
diff --git a/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h b/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h
deleted file mode 100644
index 4ee5cca4a2..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Test Re-ARM specific configuration values for errors at compile-time.
- */
-
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
- #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI) \
- && (MB(RAMPS_14_RE_ARM_EFB) \
- || MB(RAMPS_14_RE_ARM_EEB) \
- || MB(RAMPS_14_RE_ARM_EFF) \
- || MB(RAMPS_14_RE_ARM_EEF) \
- || MB(RAMPS_14_RE_ARM_SF))
- #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
-#endif
-
-#if 1 < (ENABLED(LPC_SD_CUSTOM_CABLE) + ENABLED(LPC_SD_LCD) + ENABLED(LPC_SD_ONBOARD))
- #error "Enable only one of LPC_SD_CUSTOM_CABLE, LPC_SD_LCD, or LPC_SD_ONBOARD."
-#endif
-
-#if 1 < (ENABLED(USB_SD_DISABLED) + ENABLED(USB_SD_ONBOARD))
- #error "Enable only one of USB_SD_DISABLED or USB_SD_ONBOARD."
-#endif
diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp
deleted file mode 100644
index 609c0c7e66..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/main.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-#ifdef TARGET_LPC1768
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-extern "C" {
- #include
-}
-
-#include "../../sd/cardreader.h"
-#include "../../inc/MarlinConfig.h"
-#include "HAL.h"
-#include "HAL_timers.h"
-
-extern uint32_t MSC_SD_Init(uint8_t pdrv);
-extern "C" int isLPC1769();
-extern "C" void disk_timerproc(void);
-
-void SysTick_Callback() {
- disk_timerproc();
-}
-
-void HAL_init() {
-
- // Support the 4 LEDs some LPC176x boards have
- #if PIN_EXISTS(LED)
- SET_DIR_OUTPUT(LED_PIN);
- WRITE_PIN_CLR(LED_PIN);
- #if PIN_EXISTS(LED2)
- SET_DIR_OUTPUT(LED2_PIN);
- WRITE_PIN_CLR(LED2_PIN);
- #if PIN_EXISTS(LED3)
- SET_DIR_OUTPUT(LED3_PIN);
- WRITE_PIN_CLR(LED3_PIN);
- #if PIN_EXISTS(LED4)
- SET_DIR_OUTPUT(LED4_PIN);
- WRITE_PIN_CLR(LED4_PIN);
- #endif
- #endif
- #endif
-
- // Flash status LED 3 times to indicate Marlin has started booting
- for (uint8_t i = 0; i < 6; ++i) {
- TOGGLE(LED_PIN);
- delay(100);
- }
- #endif
-
- //debug_frmwrk_init();
- //_DBG("\n\nDebug running\n");
- // Initialise the SD card chip select pins as soon as possible
- #if PIN_EXISTS(SS)
- WRITE(SS_PIN, HIGH);
- SET_OUTPUT(SS_PIN);
- #endif
-
- #if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1
- WRITE(ONBOARD_SD_CS, HIGH);
- SET_OUTPUT(ONBOARD_SD_CS);
- #endif
-
- USB_Init(); // USB Initialization
- USB_Connect(FALSE); // USB clear connection
- delay(1000); // Give OS time to notice
- USB_Connect(TRUE);
-
- #if DISABLED(USB_SD_DISABLED)
- MSC_SD_Init(0); // Enable USB SD card access
- #endif
-
- const millis_t usb_timeout = millis() + 2000;
- while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
- delay(50);
- HAL_idletask();
- #if PIN_EXISTS(LED)
- TOGGLE(LED_PIN); // Flash quickly during USB initialization
- #endif
- }
-
- #if NUM_SERIAL > 0
- MYSERIAL0.begin(BAUDRATE);
- #if NUM_SERIAL > 1
- MYSERIAL1.begin(BAUDRATE);
- #endif
- SERIAL_PRINTF("\n\necho:%s (%dMhz) Initialized\n", isLPC1769() ? "LPC1769" : "LPC1768", SystemCoreClock / 1000000);
- SERIAL_FLUSHTX();
- #endif
-
- HAL_timer_init();
-}
-
-// HAL idle task
-void HAL_idletask(void) {
- #if BOTH(SDSUPPORT, SHARED_SD_CARD)
- // If Marlin is using the SD card we need to lock it to prevent access from
- // a PC via USB.
- // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
- // this will not reliably detect delete operations. To be safe we will lock
- // the disk if Marlin has it mounted. Unfortuately there is currently no way
- // to unmount the disk from the LCD menu.
- // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
- if (card.isDetected())
- MSC_Aquire_Lock();
- else
- MSC_Release_Lock();
- #endif
- // Perform USB stack housekeeping
- MSC_RunDeferredCommands();
-}
-
-#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/HAL_LPC1768/pinsDebug.h b/Marlin/src/HAL/HAL_LPC1768/pinsDebug.h
deleted file mode 100644
index 83d8c27fda..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/pinsDebug.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Support routines for LPC1768
- */
-
-/**
- * Translation of routines & variables used by pinsDebug.h
- */
-
-#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
-#define pwm_details(pin) pin = pin // do nothing // print PWM details
-#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin.
-#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
-#define digitalRead_mod(p) extDigitalRead(p)
-#define PRINT_PORT(p)
-#define GET_ARRAY_PIN(p) pin_array[p].pin
-#define NAME_FORMAT(p) PSTR("%-##p##s")
-#define PRINT_ARRAY_NAME(x) do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
-#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
-
-// active ADC function/mode/code values for PINSEL registers
-constexpr int8_t ADC_pin_mode(pin_t pin) {
- return (LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 2 ? 2 :
- LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 3 ? 2 :
- LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 23 ? 1 :
- LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 24 ? 1 :
- LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 25 ? 1 :
- LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 26 ? 1 :
- LPC1768_PIN_PORT(pin) == 1 && LPC1768_PIN_PIN(pin) == 30 ? 3 :
- LPC1768_PIN_PORT(pin) == 1 && LPC1768_PIN_PIN(pin) == 31 ? 3 : -1);
-}
-
-int8_t get_pin_mode(pin_t pin) {
- if (!VALID_PIN(pin)) return -1;
- uint8_t pin_port = LPC1768_PIN_PORT(pin);
- uint8_t pin_port_pin = LPC1768_PIN_PIN(pin);
- //get appropriate PINSEL register
- volatile uint32_t * pinsel_reg = (pin_port == 0 && pin_port_pin <= 15) ? &LPC_PINCON->PINSEL0 :
- (pin_port == 0) ? &LPC_PINCON->PINSEL1 :
- (pin_port == 1 && pin_port_pin <= 15) ? &LPC_PINCON->PINSEL2 :
- pin_port == 1 ? &LPC_PINCON->PINSEL3 :
- pin_port == 2 ? &LPC_PINCON->PINSEL4 :
- pin_port == 3 ? &LPC_PINCON->PINSEL7 : &LPC_PINCON->PINSEL9;
- uint8_t pinsel_start_bit = pin_port_pin > 15 ? 2 * (pin_port_pin - 16) : 2 * pin_port_pin;
- int8_t pin_mode = (int8_t) ((*pinsel_reg >> pinsel_start_bit) & 0x3);
- return pin_mode;
-}
-
-bool GET_PINMODE(pin_t pin) {
- int8_t pin_mode = get_pin_mode(pin);
- if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // found an invalid pin or active analog pin
- return false;
-
- uint32_t * FIO_reg[5] PROGMEM = {(uint32_t*) 0x2009C000,(uint32_t*) 0x2009C020,(uint32_t*) 0x2009C040,(uint32_t*) 0x2009C060,(uint32_t*) 0x2009C080};
- return ((*FIO_reg[LPC1768_PIN_PORT(pin)] >> LPC1768_PIN_PIN(pin) & 1) != 0); //input/output state
-}
-
-bool GET_ARRAY_IS_DIGITAL(pin_t pin) {
- return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
-}
diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_sw_i2c.cpp under construction b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_sw_i2c.cpp under construction
deleted file mode 100644
index 8b2cab7b0a..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_sw_i2c.cpp under construction
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Based on U8G2 code - u8x8_byte.c
- *
- * Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
- *
- * Copyright (c) 2016, olikraus@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list
- * of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice, this
- * list of conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * Software i2c,
- * ignores ACK response (which is anyway not provided by some displays)
- * also does not allow reading from the device
- */
-
-#ifdef TARGET_LPC1768
-
-#include "../../inc/MarlinConfigPre.h"
-
-#if HAS_GRAPHICAL_LCD
-
-#include
-
-//void pinMode(int16_t pin, uint8_t mode);
-//void digitalWrite(int16_t pin, uint8_t pin_status);
-
-
-#define I2C_SLA (0x3C*2)
-//#define I2C_CMD_MODE 0x080
-#define I2C_CMD_MODE 0x000
-#define I2C_DATA_MODE 0x040
-
-//static uint8_t I2C_speed; // 3 - 400KHz, 13 - 100KHz
-//#define SPEED_400KHz 3
-//#define SPEED_100KHz 13
-
-// #define U8G_I2C_OPT_FAST 16
-
-uint8_t SCL_pin_HAL_LPC1768_sw_I2C, SCL_port_HAL_LPC1768_sw_I2C, SDA_pin_HAL_LPC1768_sw_I2C, SDA_port_HAL_LPC1768_sw_I2C;
-
-#define SPI_SPEED 2 //20: 200KHz 5:750KHz 2:3-4MHz
-
-uint8_t u8g_i2c_send_byte_sw(uint8_t data) {
- for (uint8_t i = 0; i < 9; i++) { // 1 extra bit for the ack/nak
-
- if (val & 0x80)
- for (uint8_t j = 0; j < SPI_SPEED; j++) {
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- }
- else
- for (uint8_t j = 0; j < SPI_SPEED; j++) {
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- }
-
- for (uint8_t j = 0; j < SPI_SPEED; j++) {
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- }
-
- for (uint8_t j = 0; j < SPI_SPEED; j++) {
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- }
- val <<= 1;
- }
- return 1;
-}
-
-
-uint8_t u8g_i2c_start_sw(uint8_t sla) { // assert start condition and then send slave address with write bit
- /* send the start condition, both lines go from 1 to 0 */
-
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- DELAY_US(2);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
- DELAY_US(2);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- DELAY_US(2);
- LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
- DELAY_US(2);
- LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
-
- u8g_i2c_send_byte_sw(I2C_SLA); // send slave address with write bit
-}
-
-
-void u8g_i2c_stop_sw(void) { }
-
-void u8g_i2c_init_sw(uint8_t clock_option) { u8g_i2c_start(0); } // send slave address and write bit
-
-uint8_t u8g_com_ssd_I2C_start_sequence_sw(u8g_t *u8g) {
- /* are we requested to set the a0 state? */
- if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
-
- /* setup bus, might be a repeated start */
- if (u8g_i2c_start(I2C_SLA) == 0) return 0;
- if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
- if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
- }
- else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0) return 0;
-
- u8g->pin_list[U8G_PI_SET_A0] = 0;
-
- return 1;
-}
-
-uint8_t u8g_com_HAL_LPC1768_ssd_sw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
- switch (msg) {
- case U8G_COM_MSG_INIT:
-
- #define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
- #define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
- SCL_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SCL]);
- SCL_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SCL]);
- SDA_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SDA]);
- SDA_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SDA]);
- // As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
- #define OUTPUT 0x1
- u8g_SetPIOutput(u8g, U8G_PI_SCL);
- u8g_SetPIOutput(u8g, U8G_PI_SDA);
- if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS]) u8g_SetPIOutput(u8g, U8G_PI_CS);
- if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_A0]) u8g_SetPIOutput(u8g, U8G_PI_A0);
- if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET);
-
- //u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
- //u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
- //u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: unknown mode */
-
- u8g_i2c_init_sw(u8g->pin_list[U8G_PI_I2C_OPTION]);
- u8g_com_ssd_I2C_start_sequence_sw(u8g);
- break;
-
- case U8G_COM_MSG_STOP: break;
-
- case U8G_COM_MSG_RESET: break;
-
- case U8G_COM_MSG_CHIP_SELECT:
- u8g->pin_list[U8G_PI_A0_STATE] = 0;
- u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
- if (arg_val == 0) {
- /* disable chip, send stop condition */
- u8g_i2c_stop_sw();
- }
- else {
- /* enable, do nothing: any byte writing will trigger the i2c start */
- }
- break;
-
- case U8G_COM_MSG_WRITE_BYTE:
- //u8g->pin_list[U8G_PI_SET_A0] = 1;
- //if (u8g_com_arduino_ssd_start_sequence(u8g) == 0)
- // return u8g_i2c_stop(), 0;
- if (u8g_i2c_send_byte_sw(arg_val) == 0)
- return u8g_i2c_stop_sw(), 0;
- // u8g_i2c_stop();
- break;
-
- case U8G_COM_MSG_WRITE_SEQ: {
- //u8g->pin_list[U8G_PI_SET_A0] = 1;
- if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
- return u8g_i2c_stop_sw(), 0;
-
- uint8_t *ptr = (uint8_t *)arg_ptr;
- while (arg_val > 0) {
- if (u8g_i2c_send_byte_sw(*ptr++) == 0)
- return u8g_i2c_stop_sw(), 0;
- arg_val--;
- }
- }
- // u8g_i2c_stop();
- break;
-
- case U8G_COM_MSG_WRITE_SEQ_P: {
- //u8g->pin_list[U8G_PI_SET_A0] = 1;
- if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
- return u8g_i2c_stop_sw(), 0;
-
- uint8_t *ptr = (uint8_t *)arg_ptr;
- while (arg_val > 0) {
- if (u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0) return 0;
- ptr++;
- arg_val--;
- }
- }
- // u8g_i2c_stop();
- break;
-
- case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
- u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
- u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
- u8g_i2c_start_sw(0); // send slave address and write bit
- u8g_i2c_send_byte_sw(arg_val ? 0x40 : 0x80); // Write to ? Graphics DRAM mode : Command mode
- break;
- }
- return 1;
-}
-
-#endif // HAS_GRAPHICAL_LCD
-
-#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py b/Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py
deleted file mode 100644
index 59c5f51436..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# sets output_port
-# if target_filename is found then that drive is used
-# else if target_drive is found then that drive is used
-#
-
-target_filename = "FIRMWARE.CUR"
-target_drive = "REARM"
-
-import os
-import platform
-current_OS = platform.system()
-Import("env")
-
-def detect_error(e):
- print '\nUnable to find destination disk (' + e + ')\n' \
- 'Please select it in platformio.ini using the upload_port keyword ' \
- '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html)\n' \
- 'or copy the firmware (.pioenvs/' + env.get('PIOENV') + '/firmware.bin) manually to the appropriate disk\n'
-
-try:
- if current_OS == 'Windows':
- #
- # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
- # Windows - doesn't care about the disk's name, only cares about the drive letter
- #
-
- #
- # get all drives on this computer
- #
- import subprocess
- # typical result (string): 'Drives: C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
- driveStr = subprocess.check_output("fsutil fsinfo drives")
- # typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
- driveStr = driveStr.strip().lstrip('Drives: ')
- # typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\',
- # 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\']
- drives = driveStr.split()
-
- upload_disk = 'Disk not found'
- target_file_found = False
- target_drive_found = False
- for drive in drives:
- final_drive_name = drive.strip().rstrip('\\') # typical result (string): 'C:'
- try:
- volume_info = subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)
- except Exception as e:
- continue
- else:
- if target_drive in volume_info and target_file_found == False: # set upload if not found target file yet
- target_drive_found = True
- upload_disk = final_drive_name
- if target_filename in volume_info:
- if target_file_found == False:
- upload_disk = final_drive_name
- target_file_found = True
-
- #
- # set upload_port to drive if found
- #
-
- if target_file_found == True or target_drive_found == True:
- env.Replace(
- UPLOAD_PORT=upload_disk
- )
- print 'upload disk: ', upload_disk
- else:
- detect_error('Autodetect Error')
-
- elif current_OS == 'Linux':
- #
- # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
- #
- upload_disk = 'Disk not found'
- target_file_found = False
- target_drive_found = False
- medias = os.listdir('/media') #
- for media in medias:
- drives = os.listdir('/media/' + media) #
- if target_drive in drives and target_file_found == False: # set upload if not found target file yet
- target_drive_found = True
- upload_disk = '/media/' + media + '/' + target_drive + '/'
- for drive in drives:
- try:
- files = os.listdir('/media/' + media + '/' + drive)
- except:
- continue
- else:
- if target_filename in files:
- if target_file_found == False:
- upload_disk = '/media/' + media + '/' + drive + '/'
- target_file_found = True
-
- #
- # set upload_port to drive if found
- #
-
- if target_file_found == True or target_drive_found == True:
- env.Replace(
- UPLOAD_FLAGS="-P$UPLOAD_PORT",
- UPLOAD_PORT=upload_disk
- )
- print 'upload disk: ', upload_disk
- else:
- detect_error('Autodetect Error')
-
- elif current_OS == 'Darwin': # MAC
- #
- # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
- #
- upload_disk = 'Disk not found'
- drives = os.listdir('/Volumes') # human readable names
- target_file_found = False
- target_drive_found = False
- if target_drive in drives and target_file_found == False: # set upload if not found target file yet
- target_drive_found = True
- upload_disk = '/Volumes/' + target_drive + '/'
- for drive in drives:
- try:
- filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
- except:
- continue
- else:
- if target_filename in filenames:
- if target_file_found == False:
- upload_disk = '/Volumes/' + drive + '/'
- target_file_found = True
- #
- # set upload_port to drive if found
- #
-
- if target_file_found == True or target_drive_found == True:
- env.Replace(
- UPLOAD_PORT=upload_disk
- )
- print '\nupload disk: ', upload_disk, '\n'
- else:
- detect_error('Autodetect Error')
-
-except Exception as e:
- detect_error(str(e))
diff --git a/Marlin/src/HAL/HAL_LPC1768/usb_serial.cpp b/Marlin/src/HAL/HAL_LPC1768/usb_serial.cpp
deleted file mode 100644
index d143bae709..0000000000
--- a/Marlin/src/HAL/HAL_LPC1768/usb_serial.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifdef TARGET_LPC1768
-#include "../../inc/MarlinConfigPre.h"
-
-#if ENABLED(EMERGENCY_PARSER)
- #include "../../feature/emergency_parser.h"
- EmergencyParser::State emergency_state;
- bool CDC_RecvCallback(const char buffer) {
- emergency_parser.update(emergency_state, buffer);
- return true;
- }
-#endif // ENABLED(EMERGENCY_PARSER)
-
-#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/HAL_STM32/HAL.cpp b/Marlin/src/HAL/HAL_STM32/HAL.cpp
deleted file mode 100644
index ab61e57bfd..0000000000
--- a/Marlin/src/HAL/HAL_STM32/HAL.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
-
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-
-#include "../../inc/MarlinConfig.h"
-#include "../shared/Delay.h"
-
-#if ENABLED(EEPROM_EMULATED_WITH_SRAM)
- #if STM32F7xx
- #include "stm32f7xx_ll_pwr.h"
- #else
- #error "EEPROM_EMULATED_WITH_SRAM is currently only supported for STM32F7xx"
- #endif
-#endif // EEPROM_EMULATED_WITH_SRAM
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-
-// Needed for DELAY_NS() / DELAY_US() on CORTEX-M7
-#if (defined(__arm__) || defined(__thumb__)) && __CORTEX_M == 7
- // HAL pre-initialization task
- // Force the preinit function to run between the premain() and main() function
- // of the STM32 arduino core
- __attribute__((constructor (102)))
- void HAL_preinit() {
- enableCycleCounter();
- }
-#endif
-
-// HAL initialization task
-void HAL_init(void) {
- FastIO_init();
-
- #if ENABLED(SDSUPPORT)
- OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
- #endif
-
- #if PIN_EXISTS(LED)
- OUT_WRITE(LED_PIN, LOW);
- #endif
-
- #if ENABLED(EEPROM_EMULATED_WITH_SRAM)
- // Enable access to backup SRAM
- __HAL_RCC_PWR_CLK_ENABLE();
- HAL_PWR_EnableBkUpAccess();
- __HAL_RCC_BKPSRAM_CLK_ENABLE();
-
- // Enable backup regulator
- LL_PWR_EnableBkUpRegulator();
- // Wait until backup regulator is initialized
- while (!LL_PWR_IsActiveFlag_BRR());
- #endif // EEPROM_EMULATED_SRAM
-}
-
-void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
-
-uint8_t HAL_get_reset_source (void) {
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
- return 0;
-}
-
-void _delay_ms(const int delay_ms) { delay(delay_ms); }
-
-extern "C" {
- extern unsigned int _ebss; // end of bss section
-}
-
-// --------------------------------------------------------------------------
-// ADC
-// --------------------------------------------------------------------------
-
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
- HAL_adc_result = analogRead(adc_pin);
-}
-
-uint16_t HAL_adc_get_result(void) {
- return HAL_adc_result;
-}
-
-#endif // ARDUINO_ARCH_STM32
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp
deleted file mode 100644
index 86cdb57811..0000000000
--- a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
-
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "../../inc/MarlinConfig.h"
-
-#include
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-static SPISettings spiConfig;
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-#if ENABLED(SOFTWARE_SPI)
- // --------------------------------------------------------------------------
- // Software SPI
- // --------------------------------------------------------------------------
- #error "Software SPI not supported for STM32. Use Hardware SPI."
-
-#else
-
-// --------------------------------------------------------------------------
-// Hardware SPI
-// --------------------------------------------------------------------------
-
-/**
- * VGPV SPI speed start and PCLK2/2, by default 108/2 = 54Mhz
- */
-
-/**
- * @brief Begin SPI port setup
- *
- * @return Nothing
- *
- * @details Only configures SS pin since stm32duino creates and initialize the SPI object
- */
-void spiBegin(void) {
- #if !PIN_EXISTS(SS)
- #error "SS_PIN not defined!"
- #endif
-
- SET_OUTPUT(SS_PIN);
- WRITE(SS_PIN, HIGH);
-}
-
-/** Configure SPI for specified SPI speed */
-void spiInit(uint8_t spiRate) {
- // Use datarates Marlin uses
- uint32_t clock;
- switch (spiRate) {
- case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
- case SPI_HALF_SPEED: clock = 5000000; break;
- case SPI_QUARTER_SPEED: clock = 2500000; break;
- case SPI_EIGHTH_SPEED: clock = 1250000; break;
- case SPI_SPEED_5: clock = 625000; break;
- case SPI_SPEED_6: clock = 300000; break;
- default:
- clock = 4000000; // Default from the SPI library
- }
- spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
- SPI.begin();
-}
-
-/**
- * @brief Receives a single byte from the SPI port.
- *
- * @return Byte received
- *
- * @details
- */
-uint8_t spiRec(void) {
- SPI.beginTransaction(spiConfig);
- uint8_t returnByte = SPI.transfer(0xFF);
- SPI.endTransaction();
- return returnByte;
-}
-
-/**
- * @brief Receives a number of bytes from the SPI port to a buffer
- *
- * @param buf Pointer to starting address of buffer to write to.
- * @param nbyte Number of bytes to receive.
- * @return Nothing
- *
- * @details Uses DMA
- */
-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();
-}
-
-/**
- * @brief Sends a single byte on SPI port
- *
- * @param b Byte to send
- *
- * @details
- */
-void spiSend(uint8_t b) {
- SPI.beginTransaction(spiConfig);
- SPI.transfer(b);
- SPI.endTransaction();
-}
-
-/**
- * @brief Write token and then write from 512 byte buffer to SPI (for SD card)
- *
- * @param buf Pointer with buffer start address
- * @return Nothing
- *
- * @details Use DMA
- */
-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
-
-#endif // ARDUINO_ARCH_STM32
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp
deleted file mode 100644
index 28d8d095c7..0000000000
--- a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
-
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-
-#include "HAL_timers_STM32.h"
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-#define NUM_HARDWARE_TIMERS 2
-
-//#define PRESCALER 1
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-stm32f4_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-bool timers_initialized[NUM_HARDWARE_TIMERS] = { false };
-
-void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
-
- if (!timers_initialized[timer_num]) {
- uint32_t step_prescaler = STEPPER_TIMER_PRESCALE - 1,
- temp_prescaler = TEMP_TIMER_PRESCALE - 1;
- switch (timer_num) {
- case STEP_TIMER_NUM:
- // STEPPER TIMER - use a 32bit timer if possible
- TimerHandle[timer_num].timer = STEP_TIMER_DEV;
- TimerHandle[timer_num].irqHandle = Step_Handler;
- TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / step_prescaler) / frequency) - 1, step_prescaler);
- HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0);
- break;
-
- case TEMP_TIMER_NUM:
- // TEMP TIMER - any available 16bit Timer
- TimerHandle[timer_num].timer = TEMP_TIMER_DEV;
- TimerHandle[timer_num].irqHandle = Temp_Handler;
- TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / temp_prescaler) / frequency) - 1, temp_prescaler);
- HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_NAME, TEMP_TIMER_IRQ_PRIO, 0);
- break;
- }
- timers_initialized[timer_num] = true;
- }
-}
-
-void HAL_timer_enable_interrupt(const uint8_t timer_num) {
- const IRQn_Type IRQ_Id = IRQn_Type(getTimerIrq(TimerHandle[timer_num].timer));
- HAL_NVIC_EnableIRQ(IRQ_Id);
-}
-
-void HAL_timer_disable_interrupt(const uint8_t timer_num) {
- const IRQn_Type IRQ_Id = IRQn_Type(getTimerIrq(TimerHandle[timer_num].timer));
- HAL_NVIC_DisableIRQ(IRQ_Id);
-
- // We NEED memory barriers to ensure Interrupts are actually disabled!
- // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
- __DSB();
- __ISB();
-}
-
-bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
- const uint32_t IRQ_Id = getTimerIrq(TimerHandle[timer_num].timer);
- return NVIC->ISER[IRQ_Id >> 5] & _BV32(IRQ_Id & 0x1F);
-}
-
-#endif // ARDUINO_ARCH_STM32
diff --git a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.h b/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.h
deleted file mode 100644
index e92da9a5c8..0000000000
--- a/Marlin/src/HAL/HAL_STM32/HAL_timers_STM32.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include
-#include "../../inc/MarlinConfig.h"
-
-// --------------------------------------------------------------------------
-// Defines
-// --------------------------------------------------------------------------
-
-#define FORCE_INLINE __attribute__((always_inline)) inline
-
-#define hal_timer_t uint32_t
-#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
-
-#ifdef STM32F0xx
-
- #define HAL_TIMER_RATE (F_CPU) // frequency of timer peripherals
-
- #ifndef STEP_TIMER
- #define STEP_TIMER 16
- #endif
-
- #ifndef TEMP_TIMER
- #define TEMP_TIMER 17
- #endif
-
-#elif defined STM32F1xx
-
- #define HAL_TIMER_RATE (F_CPU) // frequency of timer peripherals
-
- #ifndef STEP_TIMER
- #define STEP_TIMER 4
- #endif
-
- #ifndef TEMP_TIMER
- #define TEMP_TIMER 2
- #endif
-
-#elif defined STM32F4xx
-
- #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals
-
- #ifndef STEP_TIMER
- #define STEP_TIMER 5
- #endif
-
- #ifndef TEMP_TIMER
- #define TEMP_TIMER 7
- #endif
-
-#elif defined STM32F7xx
-
- #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals
-
- #ifndef STEP_TIMER
- #define STEP_TIMER 5
- #endif
-
- #ifndef TEMP_TIMER
- #define TEMP_TIMER 7
- #endif
-
-#endif
-
-#ifndef STEP_TIMER_IRQ_PRIO
- #define STEP_TIMER_IRQ_PRIO 1
-#endif
-
-#ifndef TEMP_TIMER_IRQ_PRIO
- #define TEMP_TIMER_IRQ_PRIO 2
-#endif
-
-#define STEP_TIMER_NUM 0 // index of timer to use for stepper
-#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
-#define PULSE_TIMER_NUM STEP_TIMER_NUM
-
-#define TEMP_TIMER_RATE 72000 // 72 Khz
-#define TEMP_TIMER_PRESCALE ((HAL_TIMER_RATE)/(TEMP_TIMER_RATE))
-#define TEMP_TIMER_FREQUENCY 1000
-
-#define STEPPER_TIMER_RATE 2000000 // 2 Mhz
-#define STEPPER_TIMER_PRESCALE ((HAL_TIMER_RATE)/(STEPPER_TIMER_RATE))
-#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-
-#define PULSE_TIMER_RATE STEPPER_TIMER_RATE
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
-#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
-
-#define __TIMER_DEV(X) TIM##X
-#define _TIMER_DEV(X) __TIMER_DEV(X)
-#define STEP_TIMER_DEV _TIMER_DEV(STEP_TIMER)
-#define TEMP_TIMER_DEV _TIMER_DEV(TEMP_TIMER)
-
-#define __TIMER_CALLBACK(X) TIM##X##_IRQHandler
-#define _TIMER_CALLBACK(X) __TIMER_CALLBACK(X)
-
-#define STEP_TIMER_CALLBACK _TIMER_CALLBACK(STEP_TIMER)
-#define TEMP_TIMER_CALLBACK _TIMER_CALLBACK(TEMP_TIMER)
-
-#define __TIMER_IRQ_NAME(X) TIM##X##_IRQn
-#define _TIMER_IRQ_NAME(X) __TIMER_IRQ_NAME(X)
-
-#define STEP_TIMER_IRQ_NAME _TIMER_IRQ_NAME(STEP_TIMER)
-#define TEMP_TIMER_IRQ_NAME _TIMER_IRQ_NAME(TEMP_TIMER)
-
-#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
-#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
-#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
-
-#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
-#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
-
-extern void Step_Handler(stimer_t *htim);
-extern void Temp_Handler(stimer_t *htim);
-#define HAL_STEP_TIMER_ISR() void Step_Handler(stimer_t *htim)
-#define HAL_TEMP_TIMER_ISR() void Temp_Handler(stimer_t *htim)
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-typedef stimer_t stm32f4_timer_t;
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-extern stm32f4_timer_t TimerHandle[];
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
-void HAL_timer_enable_interrupt(const uint8_t timer_num);
-void HAL_timer_disable_interrupt(const uint8_t timer_num);
-bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
-
-FORCE_INLINE static uint32_t HAL_timer_get_count(const uint8_t timer_num) {
- return __HAL_TIM_GET_COUNTER(&TimerHandle[timer_num].handle);
-}
-
-FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
- __HAL_TIM_SET_AUTORELOAD(&TimerHandle[timer_num].handle, compare);
- if (HAL_timer_get_count(timer_num) >= compare)
- TimerHandle[timer_num].handle.Instance->EGR |= TIM_EGR_UG; // Generate an immediate update interrupt
-}
-
-FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
- return __HAL_TIM_GET_AUTORELOAD(&TimerHandle[timer_num].handle);
-}
-
-#define HAL_timer_isr_prologue(TIMER_NUM)
-#define HAL_timer_isr_epilogue(TIMER_NUM)
diff --git a/Marlin/src/HAL/HAL_STM32/SanityCheck.h b/Marlin/src/HAL/HAL_STM32/SanityCheck.h
deleted file mode 100644
index 9a65f9bfa8..0000000000
--- a/Marlin/src/HAL/HAL_STM32/SanityCheck.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Test Re-ARM specific configuration values for errors at compile-time.
- */
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
- #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(EMERGENCY_PARSER)
- #error "EMERGENCY_PARSER is not yet implemented for STM32. Disable EMERGENCY_PARSER to continue."
-#endif
-
-#if ENABLED(FAST_PWM_FAN)
- #error "FAST_PWM_FAN is not yet implemented for this platform."
-#endif
diff --git a/Marlin/src/HAL/HAL_STM32/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32/endstop_interrupts.h
deleted file mode 100644
index 23eca4bab7..0000000000
--- a/Marlin/src/HAL/HAL_STM32/endstop_interrupts.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-#include "../../module/endstops.h"
-
-// One ISR for all EXT-Interrupts
-void endstop_ISR(void) { endstops.update(); }
-
-void setup_endstop_interrupts(void) {
- #if HAS_X_MAX
- attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_X_MIN
- attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MAX
- attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MIN
- attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MAX
- attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN
- attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MAX
- attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MIN
- attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MAX
- attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MIN
- attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN_PROBE_PIN
- attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- #endif
-}
diff --git a/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp
deleted file mode 100644
index a6c50f0f7d..0000000000
--- a/Marlin/src/HAL/HAL_STM32/persistent_store_impl.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(EEPROM_SETTINGS)
-
-#include "../shared/persistent_store_api.h"
-
-#if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
- #include
- static bool eeprom_data_written = false;
-#endif
-
-bool PersistentStore::access_start() {
- #if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
- eeprom_buffer_fill();
- #endif
- return true;
-}
-
-bool PersistentStore::access_finish() {
- #if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
- if (eeprom_data_written) {
- eeprom_buffer_flush();
- eeprom_data_written = false;
- }
- #endif
- return true;
-}
-
-bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
- while (size--) {
- uint8_t v = *value;
-
- // Save to either external EEPROM, program flash or Backup SRAM
- #if EITHER(SPI_EEPROM, I2C_EEPROM)
- // EEPROM has only ~100,000 write cycles,
- // so only write bytes that have changed!
- uint8_t * const p = (uint8_t * const)pos;
- if (v != eeprom_read_byte(p)) {
- eeprom_write_byte(p, v);
- if (eeprom_read_byte(p) != v) {
- SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
- return true;
- }
- }
- #elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
- eeprom_buffered_write_byte(pos, v);
- #else
- *(__IO uint8_t *)(BKPSRAM_BASE + (uint8_t * const)pos) = v;
- #endif
-
- crc16(crc, &v, 1);
- pos++;
- value++;
- };
- #if DISABLED(EEPROM_EMULATED_WITH_SRAM, SPI_EEPROM, I2C_EEPROM)
- eeprom_data_written = true;
- #endif
-
- return false;
-}
-
-bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing) {
- do {
- // Read from either external EEPROM, program flash or Backup SRAM
- const uint8_t c = (
- #if EITHER(SPI_EEPROM, I2C_EEPROM)
- eeprom_read_byte((uint8_t*)pos)
- #elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
- eeprom_buffered_read_byte(pos)
- #else
- (*(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)))
- #endif
- );
-
- if (writing) *value = c;
- crc16(crc, &c, 1);
- pos++;
- value++;
- } while (--size);
- return false;
-}
-
-size_t PersistentStore::capacity() {
- #if EITHER(SPI_EEPROM, I2C_EEPROM)
- return E2END + 1;
- #elif DISABLED(EEPROM_EMULATED_WITH_SRAM)
- return E2END + 1;
- #else
- return 4096; // 4kB
- #endif
-}
-
-#endif // EEPROM_SETTINGS
-#endif // ARDUINO_ARCH_STM32
diff --git a/Marlin/src/HAL/HAL_STM32/pinsDebug.h b/Marlin/src/HAL/HAL_STM32/pinsDebug.h
deleted file mode 100644
index ac8b005754..0000000000
--- a/Marlin/src/HAL/HAL_STM32/pinsDebug.h
+++ /dev/null
@@ -1 +0,0 @@
-#error "Debug pins is not yet supported for STM32!"
diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_STM32F1.cpp b/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_STM32F1.cpp
deleted file mode 100644
index f8fc315ba0..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/HAL_Servo_STM32F1.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#ifdef __STM32F1__
-
-#include "../../inc/MarlinConfig.h"
-
-#if HAS_SERVOS
-
-uint8_t ServoCount; //=0
-
-#include "HAL_Servo_STM32F1.h"
-
-//#include "Servo.h"
-
-#include
-#include
-#include
-#include
-
-/**
- * 20 millisecond period config. For a 1-based prescaler,
- *
- * (prescaler * overflow / CYC_MSEC) msec = 1 timer cycle = 20 msec
- * => prescaler * overflow = 20 * CYC_MSEC
- *
- * This uses the smallest prescaler that allows an overflow < 2^16.
- */
-#define MAX_OVERFLOW ((1 << 16) - 1)
-#define CYC_MSEC (1000 * CYCLES_PER_MICROSECOND)
-#define TAU_MSEC 20
-#define TAU_USEC (TAU_MSEC * 1000)
-#define TAU_CYC (TAU_MSEC * CYC_MSEC)
-#define SERVO_PRESCALER (TAU_CYC / MAX_OVERFLOW + 1)
-#define SERVO_OVERFLOW ((uint16_t)round((double)TAU_CYC / SERVO_PRESCALER))
-
-// Unit conversions
-#define US_TO_COMPARE(us) ((uint16_t)map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW))
-#define COMPARE_TO_US(c) ((uint32_t)map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC))
-#define ANGLE_TO_US(a) ((uint16_t)(map((a), this->minAngle, this->maxAngle, \
- SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW)))
-#define US_TO_ANGLE(us) ((int16_t)(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, \
- this->minAngle, this->maxAngle)))
-
-libServo::libServo() {
- this->servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO;
-}
-
-bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t maxAngle) {
- if (this->servoIndex >= MAX_SERVOS) return false;
-
- this->pin = pin;
- this->minAngle = minAngle;
- this->maxAngle = maxAngle;
-
- timer_dev *tdev = PIN_MAP[this->pin].timer_device;
- uint8_t tchan = PIN_MAP[this->pin].timer_channel;
-
- pinMode(this->pin, PWM);
- pwmWrite(this->pin, 0);
-
- timer_pause(tdev);
- timer_set_prescaler(tdev, SERVO_PRESCALER - 1); // prescaler is 1-based
- timer_set_reload(tdev, SERVO_OVERFLOW);
- timer_generate_update(tdev);
- timer_resume(tdev);
-
- return true;
-}
-
-bool libServo::detach() {
- if (!this->attached()) return false;
- pwmWrite(this->pin, 0);
- return true;
-}
-
-int32_t libServo::read() const {
- if (this->attached()) {
- timer_dev *tdev = PIN_MAP[this->pin].timer_device;
- uint8_t tchan = PIN_MAP[this->pin].timer_channel;
- return US_TO_ANGLE(COMPARE_TO_US(timer_get_compare(tdev, tchan)));
- }
- return 0;
-}
-
-void libServo::move(const int32_t value) {
- constexpr uint16_t servo_delay[] = SERVO_DELAY;
- static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
-
- if (this->attached()) {
- pwmWrite(this->pin, US_TO_COMPARE(ANGLE_TO_US(constrain(value, this->minAngle, this->maxAngle))));
- safe_delay(servo_delay[this->servoIndex]);
- #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
- this->detach();
- #endif
- }
-}
-#endif // HAS_SERVOS
-
-#endif // __STM32F1__
diff --git a/Marlin/src/HAL/HAL_STM32F1/README.md b/Marlin/src/HAL/HAL_STM32F1/README.md
deleted file mode 100644
index 7defdc8749..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# This HAL is for STM32F103 boards used with libmaple/stm32duino Arduino core.
-
-# This HAL is in development. Currently has been tested in Malyan M200 (103CBT6), Chitu 3d (103ZET6), and custom boards(103VET6).
-
-### The stm32 core needs a modification in the file util.h to avoid conflict with Marlin macros for Debug.
-Since only 1 file needs change in the stm32duino core, it's preferable over making changes to Marlin.
-
-
-After these lines:
-<>
-#else
-#define ASSERT_FAULT(exp) (void)((0))
-#endif
-<>
-
-### Main developers:
-Victorpv
-xC000005
-
-
-### Most up to date repository for this HAL:
-https://github.com/victorpv/Marlin/tree/bugfix-2.0.x
-
-PRs should only be sent to Marlin bugfix-2.0.x branch once tested in printing so not to introduce new bugs.
-For testing/dev, you can submit to the above branch
diff --git a/Marlin/src/HAL/HAL_STM32F1/SanityCheck.h b/Marlin/src/HAL/HAL_STM32F1/SanityCheck.h
deleted file mode 100644
index 82a0789eeb..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/SanityCheck.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
- */
-
-/**
- * Test Re-ARM specific configuration values for errors at compile-time.
- */
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif SPINDLE_LASER_POWERUP_DELAY < 0
- #error "SPINDLE_LASER_POWERUP_DELAY must be positive"
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 0
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be positive"
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(EMERGENCY_PARSER)
- #error "EMERGENCY_PARSER is not yet implemented for STM32F1. Disable EMERGENCY_PARSER to continue."
-#endif
-
-#if ENABLED(SDIO_SUPPORT) && DISABLED(SDSUPPORT)
- #error "SDIO_SUPPORT requires SDSUPPORT. Enable SDSUPPORT to continue."
-#endif
-
-#if ENABLED(FAST_PWM_FAN)
- #error "FAST_PWM_FAN is not yet implemented for this platform."
-#endif
diff --git a/Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h b/Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h
deleted file mode 100644
index 3994b3268a..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Fast I/O interfaces for STM32F1
- * These use GPIO functions instead of Direct Port Manipulation, as on AVR.
- */
-
-#include
-
-#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
-#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << (16 * !((bool)V)))
-#define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit))
-#define WRITE_VAR(IO,V) WRITE(IO,V)
-
-#define _GET_MODE(IO) gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit)
-#define _SET_MODE(IO,M) gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M)
-#define _SET_OUTPUT(IO) _SET_MODE(IO, GPIO_OUTPUT_PP)
-
-#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
-
-#define SET_INPUT(IO) _SET_MODE(IO, GPIO_INPUT_FLOATING)
-#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, GPIO_INPUT_PU)
-#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
-#define SET_PWM(IO) pinMode(IO, PWM) // do{ gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP); timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, TIMER_PWM); }while(0)
-
-#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
-#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
-#define HAS_TIMER(IO) (PIN_MAP[IO].timer_device != NULL)
-
-#define PWM_PIN(P) HAS_TIMER(P)
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
-
-// digitalRead/Write wrappers
-#define extDigitalRead(IO) digitalRead(IO)
-#define extDigitalWrite(IO,V) digitalWrite(IO,V)
-
diff --git a/Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp b/Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
deleted file mode 100644
index aa03474d2b..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * persistent_store_flash.cpp
- * HAL for stm32duino and compatible (STM32F1)
- * Implementation of EEPROM settings in SDCard
- */
-
-#ifdef __STM32F1__
-
-#include "../../inc/MarlinConfig.h"
-
-// This is for EEPROM emulation in flash
-#if BOTH(EEPROM_SETTINGS, FLASH_EEPROM_EMULATION)
-
-#include "../shared/persistent_store_api.h"
-
-#include
-#include
-
-// Store settings in the last two pages
-// Flash pages must be erased before writing, so keep track.
-bool firstWrite = false;
-uint32_t pageBase = EEPROM_START_ADDRESS;
-
-bool PersistentStore::access_start() {
- firstWrite = true;
- return true;
-}
-
-bool PersistentStore::access_finish() {
- FLASH_Lock();
- firstWrite = false;
- return true;
-}
-
-bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
- FLASH_Status status;
-
- if (firstWrite) {
- FLASH_Unlock();
- status = FLASH_ErasePage(EEPROM_PAGE0_BASE);
- if (status != FLASH_COMPLETE) return true;
- status = FLASH_ErasePage(EEPROM_PAGE1_BASE);
- if (status != FLASH_COMPLETE) return true;
- firstWrite = false;
- }
-
- // First write full words
- int i = 0;
- int wordsToWrite = size / sizeof(uint16_t);
- uint16_t* wordBuffer = (uint16_t *)value;
- while (wordsToWrite) {
- status = FLASH_ProgramHalfWord(pageBase + pos + (i * 2), wordBuffer[i]);
- if (status != FLASH_COMPLETE) return true;
- wordsToWrite--;
- i++;
- }
-
- // Now, write any remaining single byte
- const uint16_t odd = size & 1;
- if (odd) {
- uint16_t temp = value[size - 1];
- status = FLASH_ProgramHalfWord(pageBase + pos + i, temp);
- if (status != FLASH_COMPLETE) return true;
- }
-
- crc16(crc, value, size);
- pos += size + odd;
- return false;
-}
-
-bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
- for (uint16_t i = 0; i < size; i++) {
- byte* accessPoint = (byte*)(pageBase + pos + i);
- uint8_t c = *accessPoint;
- if (writing) value[i] = c;
- crc16(crc, &c, 1);
- }
- pos += ((size + 1) & ~1); // i.e., size+(size&1), round up odd values
- return false;
-}
-
-size_t PersistentStore::capacity() { return E2END + 1; }
-
-#endif // EEPROM_SETTINGS && EEPROM FLASH
-#endif // __STM32F1__
diff --git a/Marlin/src/HAL/HAL_STM32F1/pinsDebug.h b/Marlin/src/HAL/HAL_STM32F1/pinsDebug.h
deleted file mode 100644
index e5022f79a4..0000000000
--- a/Marlin/src/HAL/HAL_STM32F1/pinsDebug.h
+++ /dev/null
@@ -1 +0,0 @@
-#error Debug pins is not supported on this Platform!
diff --git a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
deleted file mode 100644
index 8bae46777d..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
+++ /dev/null
@@ -1,569 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM/EEPROM_Emulation/src/eeprom.c
- * @author MCD Application Team
- * @version V1.2.6
- * @date 04-November-2016
- * @brief This file provides all the EEPROM emulation firmware functions.
- ******************************************************************************
- * @attention
- *
- * © Copyright © 2016 STMicroelectronics International N.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of other
- * contributors to this software may be used to endorse or promote products
- * derived from this software without specific written permission.
- * 4. This software, including modifications and/or derivative works of this
- * software, must execute solely and exclusively on microcontroller or
- * microprocessor devices manufactured by or for STMicroelectronics.
- * 5. Redistribution and use of this software other than as permitted under
- * this license is void and will automatically terminate your rights under
- * this license.
- *
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-/** @addtogroup EEPROM_Emulation
- * @{
- */
-#if defined(STM32GENERIC) && (defined(STM32F4))
-
-/* Includes ------------------------------------------------------------------*/
-#include "eeprom_emul.h"
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-
-/* Global variable used to store variable value in read sequence */
-uint16_t DataVar = 0;
-
-/* Virtual address defined by the user: 0xFFFF value is prohibited */
-uint16_t VirtAddVarTab[NB_OF_VAR];
-
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-static HAL_StatusTypeDef EE_Format(void);
-static uint16_t EE_FindValidPage(uint8_t Operation);
-static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data);
-static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data);
-static uint16_t EE_VerifyPageFullyErased(uint32_t Address);
-
-/**
- * @brief Restore the pages to a known good state in case of page's status
- * corruption after a power loss.
- * @param None.
- * @retval - Flash error code: on write Flash error
- * - FLASH_COMPLETE: on success
- */
-uint16_t EE_Initialize(void) {
- uint16_t PageStatus0 = 6, PageStatus1 = 6;
- uint16_t VarIdx = 0;
- uint16_t EepromStatus = 0, ReadStatus = 0;
- int16_t x = -1;
- HAL_StatusTypeDef FlashStatus;
- uint32_t SectorError = 0;
- FLASH_EraseInitTypeDef pEraseInit;
-
-
- /* Get Page0 status */
- PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
- /* Get Page1 status */
- PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
-
- pEraseInit.TypeErase = TYPEERASE_SECTORS;
- pEraseInit.Sector = PAGE0_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
-
- /* Check for invalid header states and repair if necessary */
- switch (PageStatus0) {
- case ERASED:
- if (PageStatus1 == VALID_PAGE) { /* Page0 erased, Page1 valid */
- /* Erase Page0 */
- if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- }
- else if (PageStatus1 == RECEIVE_DATA) { /* Page0 erased, Page1 receive */
- /* Erase Page0 */
- if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- /* Mark Page1 as valid */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- else { /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
- /* Erase both Page0 and Page1 and set Page0 as valid page */
- FlashStatus = EE_Format();
- /* If erase/program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- break;
-
- case RECEIVE_DATA:
- if (PageStatus1 == VALID_PAGE) { /* Page0 receive, Page1 valid */
- /* Transfer data from Page1 to Page0 */
- for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
- if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
- x = VarIdx;
- if (VarIdx != x) {
- /* Read the last variables' updates */
- ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
- /* In case variable corresponding to the virtual address was found */
- if (ReadStatus != 0x1) {
- /* Transfer the variable to the Page0 */
- EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
- /* If program operation was failed, a Flash error code is returned */
- if (EepromStatus != HAL_OK) return EepromStatus;
- }
- }
- }
- /* Mark Page0 as valid */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- pEraseInit.Sector = PAGE1_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
- /* Erase Page1 */
- if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- }
- else if (PageStatus1 == ERASED) { /* Page0 receive, Page1 erased */
- pEraseInit.Sector = PAGE1_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
- /* Erase Page1 */
- if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- /* Mark Page0 as valid */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- else { /* Invalid state -> format eeprom */
- /* Erase both Page0 and Page1 and set Page0 as valid page */
- FlashStatus = EE_Format();
- /* If erase/program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- break;
-
- case VALID_PAGE:
- if (PageStatus1 == VALID_PAGE) { /* Invalid state -> format eeprom */
- /* Erase both Page0 and Page1 and set Page0 as valid page */
- FlashStatus = EE_Format();
- /* If erase/program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- else if (PageStatus1 == ERASED) { /* Page0 valid, Page1 erased */
- pEraseInit.Sector = PAGE1_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
- /* Erase Page1 */
- if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- }
- else { /* Page0 valid, Page1 receive */
- /* Transfer data from Page0 to Page1 */
- for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
- if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
- x = VarIdx;
-
- if (VarIdx != x) {
- /* Read the last variables' updates */
- ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
- /* In case variable corresponding to the virtual address was found */
- if (ReadStatus != 0x1) {
- /* Transfer the variable to the Page1 */
- EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
- /* If program operation was failed, a Flash error code is returned */
- if (EepromStatus != HAL_OK) return EepromStatus;
- }
- }
- }
- /* Mark Page1 as valid */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- pEraseInit.Sector = PAGE0_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
- /* Erase Page0 */
- if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- }
- break;
-
- default: /* Any other state -> format eeprom */
- /* Erase both Page0 and Page1 and set Page0 as valid page */
- FlashStatus = EE_Format();
- /* If erase/program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- break;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Verify if specified page is fully erased.
- * @param Address: page address
- * This parameter can be one of the following values:
- * @arg PAGE0_BASE_ADDRESS: Page0 base address
- * @arg PAGE1_BASE_ADDRESS: Page1 base address
- * @retval page fully erased status:
- * - 0: if Page not erased
- * - 1: if Page erased
- */
-uint16_t EE_VerifyPageFullyErased(uint32_t Address) {
- uint32_t ReadStatus = 1;
- uint16_t AddressValue = 0x5555;
- /* Check each active page address starting from end */
- while (Address <= PAGE0_END_ADDRESS) {
- /* Get the current location content to be compared with virtual address */
- AddressValue = (*(__IO uint16_t*)Address);
- /* Compare the read address with the virtual address */
- if (AddressValue != ERASED) {
- /* In case variable value is read, reset ReadStatus flag */
- ReadStatus = 0;
- break;
- }
- /* Next address location */
- Address += 4;
- }
- /* Return ReadStatus value: (0: Page not erased, 1: Sector erased) */
- return ReadStatus;
-}
-
-/**
- * @brief Returns the last stored variable data, if found, which correspond to
- * the passed virtual address
- * @param VirtAddress: Variable virtual address
- * @param Data: Global variable contains the read variable value
- * @retval Success or error status:
- * - 0: if variable was found
- * - 1: if the variable was not found
- * - NO_VALID_PAGE: if no valid page was found.
- */
-uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) {
- uint16_t ValidPage = PAGE0;
- uint16_t AddressValue = 0x5555, ReadStatus = 1;
- uint32_t Address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS;
-
- /* Get active Page for read operation */
- ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
-
- /* Check if there is no valid page */
- if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
-
- /* Get the valid Page start Address */
- PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
-
- /* Get the valid Page end Address */
- Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
-
- /* Check each active page address starting from end */
- while (Address > (PageStartAddress + 2)) {
- /* Get the current location content to be compared with virtual address */
- AddressValue = (*(__IO uint16_t*)Address);
-
- /* Compare the read address with the virtual address */
- if (AddressValue == VirtAddress) {
- /* Get content of Address-2 which is variable value */
- *Data = (*(__IO uint16_t*)(Address - 2));
- /* In case variable value is read, reset ReadStatus flag */
- ReadStatus = 0;
- break;
- }
- else /* Next address location */
- Address -= 4;
- }
- /* Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) */
- return ReadStatus;
-}
-
-/**
- * @brief Writes/upadtes variable data in EEPROM.
- * @param VirtAddress: Variable virtual address
- * @param Data: 16 bit data to be written
- * @retval Success or error status:
- * - FLASH_COMPLETE: on success
- * - PAGE_FULL: if valid page is full
- * - NO_VALID_PAGE: if no valid page was found
- * - Flash error code: on write Flash error
- */
-uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data) {
- /* Write the variable virtual address and value in the EEPROM */
- uint16_t Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
-
- /* In case the EEPROM active page is full */
- if (Status == PAGE_FULL) /* Perform Page transfer */
- Status = EE_PageTransfer(VirtAddress, Data);
-
- /* Return last operation status */
- return Status;
-}
-
-/**
- * @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
- * @param None
- * @retval Status of the last operation (Flash write or erase) done during
- * EEPROM formating
- */
-static HAL_StatusTypeDef EE_Format(void) {
- HAL_StatusTypeDef FlashStatus = HAL_OK;
- uint32_t SectorError = 0;
- FLASH_EraseInitTypeDef pEraseInit;
-
- pEraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
- pEraseInit.Sector = PAGE0_ID;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
- /* Erase Page0 */
- if (!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
- /* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
-
- pEraseInit.Sector = PAGE1_ID;
- /* Erase Page1 */
- if (!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS)) {
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Find valid Page for write or read operation
- * @param Operation: operation to achieve on the valid page.
- * This parameter can be one of the following values:
- * @arg READ_FROM_VALID_PAGE: read operation from valid page
- * @arg WRITE_IN_VALID_PAGE: write operation from valid page
- * @retval Valid page number (PAGE or PAGE1) or NO_VALID_PAGE in case
- * of no valid page was found
- */
-static uint16_t EE_FindValidPage(uint8_t Operation) {
- uint16_t PageStatus0 = 6, PageStatus1 = 6;
-
- /* Get Page0 actual status */
- PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
-
- /* Get Page1 actual status */
- PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
-
- /* Write or read operation */
- switch (Operation) {
- case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */
- if (PageStatus1 == VALID_PAGE) {
- /* Page0 receiving data */
- if (PageStatus0 == RECEIVE_DATA) return PAGE0; /* Page0 valid */
- else return PAGE1; /* Page1 valid */
- }
- else if (PageStatus0 == VALID_PAGE) {
- /* Page1 receiving data */
- if (PageStatus1 == RECEIVE_DATA) return PAGE1; /* Page1 valid */
- else return PAGE0; /* Page0 valid */
- }
- else
- return NO_VALID_PAGE; /* No valid Page */
-
- case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */
- if (PageStatus0 == VALID_PAGE)
- return PAGE0; /* Page0 valid */
- else if (PageStatus1 == VALID_PAGE)
- return PAGE1; /* Page1 valid */
- else
- return NO_VALID_PAGE; /* No valid Page */
-
- default:
- return PAGE0; /* Page0 valid */
- }
-}
-
-/**
- * @brief Verify if active page is full and Writes variable in EEPROM.
- * @param VirtAddress: 16 bit virtual address of the variable
- * @param Data: 16 bit data to be written as variable value
- * @retval Success or error status:
- * - FLASH_COMPLETE: on success
- * - PAGE_FULL: if valid page is full
- * - NO_VALID_PAGE: if no valid page was found
- * - Flash error code: on write Flash error
- */
-static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data) {
- HAL_StatusTypeDef FlashStatus = HAL_OK;
- uint16_t ValidPage = PAGE0;
- uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE;
-
- /* Get valid Page for write operation */
- ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
-
- /* Check if there is no valid page */
- if (ValidPage == NO_VALID_PAGE) return NO_VALID_PAGE;
-
- /* Get the valid Page start Address */
- Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
-
- /* Get the valid Page end Address */
- PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((ValidPage + 1) * PAGE_SIZE));
-
- /* Check each active page address starting from begining */
- while (Address < PageEndAddress) {
- /* Verify if Address and Address+2 contents are 0xFFFFFFFF */
- if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF) {
- /* Set variable data */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address, Data);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
- /* Set variable virtual address */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address + 2, VirtAddress);
- /* Return program operation status */
- return FlashStatus;
- }
- else /* Next address location */
- Address += 4;
- }
-
- /* Return PAGE_FULL in case the valid page is full */
- return PAGE_FULL;
-}
-
-/**
- * @brief Transfers last updated variables data from the full Page to
- * an empty one.
- * @param VirtAddress: 16 bit virtual address of the variable
- * @param Data: 16 bit data to be written as variable value
- * @retval Success or error status:
- * - FLASH_COMPLETE: on success
- * - PAGE_FULL: if valid page is full
- * - NO_VALID_PAGE: if no valid page was found
- * - Flash error code: on write Flash error
- */
-static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
- HAL_StatusTypeDef FlashStatus = HAL_OK;
- uint32_t NewPageAddress = EEPROM_START_ADDRESS;
- uint16_t OldPageId=0;
- uint16_t ValidPage = PAGE0, VarIdx = 0;
- uint16_t EepromStatus = 0, ReadStatus = 0;
- uint32_t SectorError = 0;
- FLASH_EraseInitTypeDef pEraseInit;
-
- /* Get active Page for read operation */
- ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
-
- if (ValidPage == PAGE1) { /* Page1 valid */
- /* New page address where variable will be moved to */
- NewPageAddress = PAGE0_BASE_ADDRESS;
- /* Old page ID where variable will be taken from */
- OldPageId = PAGE1_ID;
- }
- else if (ValidPage == PAGE0) { /* Page0 valid */
- /* New page address where variable will be moved to */
- NewPageAddress = PAGE1_BASE_ADDRESS;
- /* Old page ID where variable will be taken from */
- OldPageId = PAGE0_ID;
- }
- else
- return NO_VALID_PAGE; /* No valid Page */
-
- /* Set the new Page status to RECEIVE_DATA status */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, RECEIVE_DATA);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
-
- /* Write the variable passed as parameter in the new active page */
- EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
- /* If program operation was failed, a Flash error code is returned */
- if (EepromStatus != HAL_OK) return EepromStatus;
-
- /* Transfer process: transfer variables from old to the new active page */
- for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++) {
- if (VirtAddVarTab[VarIdx] != VirtAddress) { /* Check each variable except the one passed as parameter */
- /* Read the other last variable updates */
- ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
- /* In case variable corresponding to the virtual address was found */
- if (ReadStatus != 0x1) {
- /* Transfer the variable to the new active page */
- EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
- /* If program operation was failed, a Flash error code is returned */
- if (EepromStatus != HAL_OK) return EepromStatus;
- }
- }
- }
-
- pEraseInit.TypeErase = TYPEERASE_SECTORS;
- pEraseInit.Sector = OldPageId;
- pEraseInit.NbSectors = 1;
- pEraseInit.VoltageRange = VOLTAGE_RANGE;
-
- /* Erase the old Page: Set old Page status to ERASED status */
- FlashStatus = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
- /* If erase operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
-
- /* Set new Page status to VALID_PAGE status */
- FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, NewPageAddress, VALID_PAGE);
- /* If program operation was failed, a Flash error code is returned */
- if (FlashStatus != HAL_OK) return FlashStatus;
-
- /* Return last operation flash status */
- return FlashStatus;
-}
-
-#endif // STM32F4 || STM32F4xx
-
-/**
- * @}
- */
-
-/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.h b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.h
deleted file mode 100644
index a3e93503d8..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM/EEPROM_Emulation/inc/eeprom.h
- * @author MCD Application Team
- * @version V1.2.6
- * @date 04-November-2016
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation firmware library.
- ******************************************************************************
- * @attention
- *
- * © Copyright � 2016 STMicroelectronics International N.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of other
- * contributors to this software may be used to endorse or promote products
- * derived from this software without specific written permission.
- * 4. This software, including modifications and/or derivative works of this
- * software, must execute solely and exclusively on microcontroller or
- * microprocessor devices manufactured by or for STMicroelectronics.
- * 5. Redistribution and use of this software other than as permitted under
- * this license is void and will automatically terminate your rights under
- * this license.
- *
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-#pragma once
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-#include "../../../inc/MarlinConfig.h"
-#include "../HAL.h"
-
-/* Exported constants --------------------------------------------------------*/
-/* EEPROM emulation firmware error codes */
-#define EE_OK (uint32_t)HAL_OK
-#define EE_ERROR (uint32_t)HAL_ERROR
-#define EE_BUSY (uint32_t)HAL_BUSY
-#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
-
-/* Define the size of the sectors to be used */
-#define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
-
-/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
- be done by word */
-#define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
-
-/* EEPROM start address in Flash */
-#define EEPROM_START_ADDRESS ((uint32_t)0x08078000) /* EEPROM emulation start address:
- after 480KByte of used Flash memory */
-
-/* Pages 0 and 1 base and end addresses */
-#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
-#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
-#define PAGE0_ID FLASH_SECTOR_1
-
-#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
-#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
-#define PAGE1_ID FLASH_SECTOR_2
-
-/* Used Flash pages for EEPROM emulation */
-#define PAGE0 ((uint16_t)0x0000)
-#define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
-
-/* No valid page define */
-#define NO_VALID_PAGE ((uint16_t)0x00AB)
-
-/* Page status definitions */
-#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
-#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
-#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
-
-/* Valid pages in read and write defines */
-#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
-#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
-
-/* Page full define */
-#define PAGE_FULL ((uint8_t)0x80)
-
-/* Variables' number */
-#define NB_OF_VAR ((uint16_t)4096)
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-uint16_t EE_Initialize(void);
-uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
-uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp b/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
deleted file mode 100644
index 1f3d753448..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#if defined(STM32GENERIC) && (defined(STM32F4))
-
-/**
- * Description: functions for I2C connected external EEPROM.
- * Not platform dependent.
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM, SPI_EEPROM)
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-#include "EEPROM_Emul/eeprom_emul.h"
-
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-static bool eeprom_initialized = false;
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
-// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F4
-// #define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
-
-// --------------------------------------------------------------------------
-// EEPROM
-// --------------------------------------------------------------------------
-
-
-void eeprom_init() {
- if (!eeprom_initialized) {
- HAL_FLASH_Unlock();
-
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
-
- /* EEPROM Init */
- if (EE_Initialize() != EE_OK)
- for (;;) HAL_Delay(1); // Spin forever until watchdog reset
-
- HAL_FLASH_Lock();
- eeprom_initialized = true;
- }
-}
-
-void eeprom_write_byte(uint8_t *pos, unsigned char value) {
- uint16_t eeprom_address = (unsigned) pos;
-
- eeprom_init();
-
- HAL_FLASH_Unlock();
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
-
- if (EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK)
- for (;;) HAL_Delay(1); // Spin forever until watchdog reset
-
- HAL_FLASH_Lock();
-}
-
-uint8_t eeprom_read_byte(uint8_t *pos) {
- uint16_t data = 0xFF;
- uint16_t eeprom_address = (unsigned)pos;
-
- eeprom_init();
-
- if (EE_ReadVariable(eeprom_address, &data) != EE_OK) {
- return (unsigned char)data;
- }
- return (unsigned char)data;
-}
-
-void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
- uint16_t data = 0xFF;
- uint16_t eeprom_address = (unsigned) __src;
-
- eeprom_init();
-
- for (uint8_t c = 0; c < __n; c++) {
- EE_ReadVariable(eeprom_address+c, &data);
- *((uint8_t*)__dst + c) = data;
- }
-}
-
-void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
-
-}
-
-#endif // EEPROM_SETTINGS && (!I2C_EEPROM && !SPI_EEPROM)
-#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
deleted file mode 100644
index 2bb443d0cd..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#if defined(STM32GENERIC) && defined(STM32F4)
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-
-//#include
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-/* VGPV Done with defines
-// disable interrupts
-void cli(void) { noInterrupts(); }
-
-// enable interrupts
-void sei(void) { interrupts(); }
-*/
-
-void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
-
-uint8_t HAL_get_reset_source (void) {
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
- return 0;
-}
-
-void _delay_ms(const int delay_ms) { delay(delay_ms); }
-
-extern "C" {
- extern unsigned int _ebss; // end of bss section
-}
-
-// return free memory between end of heap (or end bss) and whatever is current
-
-/*
-#include "wirish/syscalls.c"
-//extern caddr_t _sbrk(int incr);
-#ifndef CONFIG_HEAP_END
-extern char _lm_heap_end;
-#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
-#endif
-
-extern "C" {
- static int freeMemory() {
- char top = 't';
- return &top - reinterpret_cast(sbrk(0));
- }
- int freeMemory() {
- int free_memory;
- int heap_end = (int)_sbrk(0);
- free_memory = ((int)&free_memory) - ((int)heap_end);
- return free_memory;
- }
-}
-*/
-
-// --------------------------------------------------------------------------
-// ADC
-// --------------------------------------------------------------------------
-
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
- HAL_adc_result = analogRead(adc_pin);
-}
-
-uint16_t HAL_adc_get_result(void) {
- return HAL_adc_result;
-}
-
-#endif // // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.h b/Marlin/src/HAL/HAL_STM32F4/HAL.h
deleted file mode 100644
index d009e26af2..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/HAL.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-#define CPU_32_BIT
-
-#ifndef vsnprintf_P
- #define vsnprintf_P vsnprintf
-#endif
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include
-
-#include "Arduino.h"
-
-#ifdef USBCON
- #include
-#endif
-
-#include "../shared/math_32bit.h"
-#include "../shared/HAL_SPI.h"
-#include "fastio_STM32F4.h"
-#include "watchdog_STM32F4.h"
-
-#include "HAL_timers_STM32F4.h"
-
-// --------------------------------------------------------------------------
-// Defines
-// --------------------------------------------------------------------------
-
-//Serial override
-//extern HalSerial usb_serial;
-
-#if SERIAL_PORT == 0
- #error "Serial port 0 does not exist"
-#endif
-
-#if !WITHIN(SERIAL_PORT, -1, 6)
- #error "SERIAL_PORT must be from -1 to 6"
-#endif
-#if SERIAL_PORT == -1
- #define MYSERIAL0 SerialUSB
-#elif SERIAL_PORT == 1
- #define MYSERIAL0 SerialUART1
-#elif SERIAL_PORT == 2
- #define MYSERIAL0 SerialUART2
-#elif SERIAL_PORT == 3
- #define MYSERIAL0 SerialUART3
-#elif SERIAL_PORT == 4
- #define MYSERIAL0 SerialUART4
-#elif SERIAL_PORT == 5
- #define MYSERIAL0 SerialUART5
-#elif SERIAL_PORT == 6
- #define MYSERIAL0 SerialUART6
-#endif
-
-#ifdef SERIAL_PORT_2
- #if SERIAL_PORT_2 == 0
- #error "Serial port 0 does not exist"
- #endif
-
- #if !WITHIN(SERIAL_PORT_2, -1, 6)
- #error "SERIAL_PORT_2 must be from -1 to 6"
- #elif SERIAL_PORT_2 == SERIAL_PORT
- #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
- #endif
- #define NUM_SERIAL 2
- #if SERIAL_PORT_2 == -1
- #define MYSERIAL1 SerialUSB
- #elif SERIAL_PORT_2 == 1
- #define MYSERIAL1 SerialUART1
- #elif SERIAL_PORT_2 == 2
- #define MYSERIAL1 SerialUART2
- #elif SERIAL_PORT_2 == 3
- #define MYSERIAL1 SerialUART3
- #elif SERIAL_PORT_2 == 4
- #define MYSERIAL1 SerialUART4
- #elif SERIAL_PORT_2 == 5
- #define MYSERIAL1 SerialUART5
- #elif SERIAL_PORT_2 == 6
- #define MYSERIAL1 SerialUART6
- #endif
-#else
- #define NUM_SERIAL 1
-#endif
-
-#undef _BV
-#define _BV(b) (1 << (b))
-
-/**
- * TODO: review this to return 1 for pins that are not analog input
- */
-#ifndef analogInputToDigitalPin
- #define analogInputToDigitalPin(p) (p)
-#endif
-
-#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
-#define CRITICAL_SECTION_END if (!primask) __enable_irq()
-#define ISRS_ENABLED() (!__get_PRIMASK())
-#define ENABLE_ISRS() __enable_irq()
-#define DISABLE_ISRS() __disable_irq()
-#define cli() __disable_irq()
-#define sei() __enable_irq()
-
-// On AVR this is in math.h?
-#define square(x) ((x)*(x))
-
-#ifndef strncpy_P
- #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
-#endif
-
-// Fix bug in pgm_read_ptr
-#undef pgm_read_ptr
-#define pgm_read_ptr(addr) (*(addr))
-
-#define RST_POWER_ON 1
-#define RST_EXTERNAL 2
-#define RST_BROWN_OUT 4
-#define RST_WATCHDOG 8
-#define RST_JTAG 16
-#define RST_SOFTWARE 32
-#define RST_BACKUP 64
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-typedef int8_t pin_t;
-
-#define HAL_SERVO_LIB libServo
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-/** result of last ADC conversion */
-extern uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-// Memory related
-#define __bss_end __bss_end__
-
-/** clear reset reason */
-void HAL_clear_reset_source (void);
-
-/** reset reason */
-uint8_t HAL_get_reset_source (void);
-
-void _delay_ms(const int delay);
-
-/*
-extern "C" {
- int freeMemory(void);
-}
-*/
-
-extern "C" char* _sbrk(int incr);
-
-/*
-static int freeMemory() {
- volatile int top;
- top = (int)((char*)&top - reinterpret_cast(_sbrk(0)));
- return top;
-}
-*/
-
-static int freeMemory() {
- volatile char top;
- return &top - reinterpret_cast(_sbrk(0));
-}
-
-//
-// SPI: Extended functions which take a channel number (hardware SPI only)
-//
-
-/** Write single byte to specified SPI channel */
-void spiSend(uint32_t chan, byte b);
-/** Write buffer to specified SPI channel */
-void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
-/** Read single byte from specified SPI channel */
-uint8_t spiRec(uint32_t chan);
-
-//
-// EEPROM
-//
-
-/**
- * TODO: Write all this EEPROM stuff. Can emulate EEPROM in flash as last resort.
- * Wire library should work for i2c EEPROMs.
- */
-void eeprom_write_byte(uint8_t *pos, unsigned char value);
-uint8_t eeprom_read_byte(uint8_t *pos);
-void eeprom_read_block (void *__dst, const void *__src, size_t __n);
-void eeprom_update_block (const void *__src, void *__dst, size_t __n);
-
-//
-// ADC
-//
-
-#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
-
-inline void HAL_adc_init(void) {}
-
-#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
-#define HAL_READ_ADC() HAL_adc_result
-#define HAL_ADC_READY() true
-
-void HAL_adc_start_conversion(const uint8_t adc_pin);
-
-uint16_t HAL_adc_get_result(void);
-
-/* Todo: Confirm none of this is needed.
-uint16_t HAL_getAdcReading(uint8_t chan);
-
-void HAL_startAdcConversion(uint8_t chan);
-uint8_t HAL_pinToAdcChannel(int pin);
-
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
-
-void HAL_enable_AdcFreerun(void);
-//void HAL_disable_AdcFreerun(uint8_t chan);
-
-*/
-
-#define GET_PIN_MAP_PIN(index) index
-#define GET_PIN_MAP_INDEX(pin) pin
-#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
-
-#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY)
-#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
deleted file mode 100644
index 4783736b20..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#if defined(STM32GENERIC) && defined(STM32F4)
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-
-#include "HAL_timers_STM32F4.h"
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-#define NUM_HARDWARE_TIMERS 2
-#define STEP_TIMER_IRQ_ID TIM5_IRQn
-#define TEMP_TIMER_IRQ_ID TIM7_IRQn
-
-//#define PRESCALER 1
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-stm32f4_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-bool timers_initialized[NUM_HARDWARE_TIMERS] = {false};
-
-void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
-
- if (!timers_initialized[timer_num]) {
- constexpr uint32_t step_prescaler = STEPPER_TIMER_PRESCALE - 1,
- temp_prescaler = TEMP_TIMER_PRESCALE - 1;
- switch (timer_num) {
- case STEP_TIMER_NUM:
- // STEPPER TIMER TIM5 - use a 32bit timer
- #ifdef STM32GENERIC
- __HAL_RCC_TIM5_CLK_ENABLE();
- TimerHandle[timer_num].handle.Instance = TIM5;
- TimerHandle[timer_num].handle.Init.Prescaler = step_prescaler;
- TimerHandle[timer_num].handle.Init.CounterMode = TIM_COUNTERMODE_UP;
- TimerHandle[timer_num].handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- TimerHandle[timer_num].callback = (uint32_t)TC5_Handler;
- #else
- TimerHandle[timer_num].timer = TIM5;
- TimerHandle[timer_num].irqHandle = TC5_Handler;
- TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / step_prescaler) / frequency) - 1, step_prescaler);
- #endif
- HAL_NVIC_SetPriority(STEP_TIMER_IRQ_ID, 1, 0);
- break;
-
- case TEMP_TIMER_NUM:
- // TEMP TIMER TIM7 - any available 16bit Timer (1 already used for PWM)
- #ifdef STM32GENERIC
- __HAL_RCC_TIM7_CLK_ENABLE();
- TimerHandle[timer_num].handle.Instance = TIM7;
- TimerHandle[timer_num].handle.Init.Prescaler = temp_prescaler;
- TimerHandle[timer_num].handle.Init.CounterMode = TIM_COUNTERMODE_UP;
- TimerHandle[timer_num].handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- TimerHandle[timer_num].callback = (uint32_t)TC7_Handler;
- #else
- TimerHandle[timer_num].timer = TIM7;
- TimerHandle[timer_num].irqHandle = TC7_Handler;
- TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / temp_prescaler) / frequency) - 1, temp_prescaler);
- #endif
- HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_ID, 2, 0);
- break;
- }
- timers_initialized[timer_num] = true;
- }
-
- #ifdef STM32GENERIC
- TimerHandle[timer_num].handle.Init.Period = (((HAL_TIMER_RATE) / TimerHandle[timer_num].handle.Init.Prescaler) / frequency) - 1;
- if (HAL_TIM_Base_Init(&TimerHandle[timer_num].handle) == HAL_OK)
- HAL_TIM_Base_Start_IT(&TimerHandle[timer_num].handle);
- #endif
-}
-
-#ifdef STM32GENERIC
- extern "C" void TIM5_IRQHandler() {
- ((void(*)(void))TimerHandle[0].callback)();
- }
- extern "C" void TIM7_IRQHandler() {
- ((void(*)(void))TimerHandle[1].callback)();
- }
-#endif
-
-void HAL_timer_enable_interrupt(const uint8_t timer_num) {
- switch (timer_num) {
- case STEP_TIMER_NUM: HAL_NVIC_EnableIRQ(STEP_TIMER_IRQ_ID); break;
- case TEMP_TIMER_NUM: HAL_NVIC_EnableIRQ(TEMP_TIMER_IRQ_ID); break;
- }
-}
-
-void HAL_timer_disable_interrupt(const uint8_t timer_num) {
- switch (timer_num) {
- case STEP_TIMER_NUM: HAL_NVIC_DisableIRQ(STEP_TIMER_IRQ_ID); break;
- case TEMP_TIMER_NUM: HAL_NVIC_DisableIRQ(TEMP_TIMER_IRQ_ID); break;
- }
- // We NEED memory barriers to ensure Interrupts are actually disabled!
- // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
- __DSB();
- __ISB();
-}
-
-bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
- switch (timer_num) {
- case STEP_TIMER_NUM: return NVIC->ISER[(uint32_t)((int32_t)STEP_TIMER_IRQ_ID) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)STEP_TIMER_IRQ_ID) & (uint32_t)0x1F));
- case TEMP_TIMER_NUM: return NVIC->ISER[(uint32_t)((int32_t)TEMP_TIMER_IRQ_ID) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)TEMP_TIMER_IRQ_ID) & (uint32_t)0x1F));
- }
- return false;
-}
-
-#endif // STM32GENERIC && STM32F4
diff --git a/Marlin/src/HAL/HAL_STM32F4/SanityCheck.h b/Marlin/src/HAL/HAL_STM32F4/SanityCheck.h
deleted file mode 100644
index 31e7ce6248..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/SanityCheck.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Test Re-ARM specific configuration values for errors at compile-time.
- */
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
- #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(EMERGENCY_PARSER)
- #error "EMERGENCY_PARSER is not yet implemented for STM32F4. Disable EMERGENCY_PARSER to continue."
-#endif
-
-#if ENABLED(FAST_PWM_FAN)
- #error "FAST_PWM_FAN is not yet implemented for this platform."
-#endif
diff --git a/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h
deleted file mode 100644
index 23eca4bab7..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-#include "../../module/endstops.h"
-
-// One ISR for all EXT-Interrupts
-void endstop_ISR(void) { endstops.update(); }
-
-void setup_endstop_interrupts(void) {
- #if HAS_X_MAX
- attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_X_MIN
- attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MAX
- attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MIN
- attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MAX
- attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN
- attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MAX
- attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MIN
- attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MAX
- attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MIN
- attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN_PROBE_PIN
- attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- #endif
-}
diff --git a/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h b/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h
deleted file mode 100644
index 5ad6227e25..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-/**
- * Fast I/O interfaces for STM32F4
- * These use GPIO functions instead of Direct Port Manipulation, as on AVR.
- */
-
-#undef _BV
-#define _BV(b) (1 << (b))
-
-#define READ(IO) digitalRead(IO)
-#define WRITE(IO,V) digitalWrite(IO,V)
-#define WRITE_VAR(IO,V) WRITE(IO,V)
-
-#define _GET_MODE(IO)
-#define _SET_MODE(IO,M) pinMode(IO, M)
-#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
-
-#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
-
-#define SET_INPUT(IO) _SET_MODE(IO, INPUT) /*!< Input Floating Mode */
-#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) /*!< Input with Pull-up activation */
-#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
-#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
-#define SET_PWM(IO) pinMode(IO, PWM)
-
-#define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
-
-#define IS_INPUT(IO)
-#define IS_OUTPUT(IO)
-#define HAS_TIMER(IO)
-
-#define PWM_PIN(P) true
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
-
-// digitalRead/Write wrappers
-#define extDigitalRead(IO) digitalRead(IO)
-#define extDigitalWrite(IO,V) digitalWrite(IO,V)
-
-//
-// Pins Definitions
-//
-#define PORTA 0
-#define PORTB 1
-#define PORTC 2
-#define PORTD 3
-#define PORTE 4
-
-#define _STM32_PIN(_PORT,_PIN) ((PORT##_PORT * 16) + _PIN)
-
-#define PA0 _STM32_PIN(A, 0)
-#define PA1 _STM32_PIN(A, 1)
-#define PA2 _STM32_PIN(A, 2)
-#define PA3 _STM32_PIN(A, 3)
-#define PA4 _STM32_PIN(A, 4)
-#define PA5 _STM32_PIN(A, 5)
-#define PA6 _STM32_PIN(A, 6)
-#define PA7 _STM32_PIN(A, 7)
-#define PA8 _STM32_PIN(A, 8)
-#define PA9 _STM32_PIN(A, 9)
-#define PA10 _STM32_PIN(A, 10)
-#define PA11 _STM32_PIN(A, 11)
-#define PA12 _STM32_PIN(A, 12)
-#define PA13 _STM32_PIN(A, 13)
-#define PA14 _STM32_PIN(A, 14)
-#define PA15 _STM32_PIN(A, 15)
-
-#define PB0 _STM32_PIN(B, 0)
-#define PB1 _STM32_PIN(B, 1)
-#define PB2 _STM32_PIN(B, 2)
-#define PB3 _STM32_PIN(B, 3)
-#define PB4 _STM32_PIN(B, 4)
-#define PB5 _STM32_PIN(B, 5)
-#define PB6 _STM32_PIN(B, 6)
-#define PB7 _STM32_PIN(B, 7)
-#define PB8 _STM32_PIN(B, 8)
-#define PB9 _STM32_PIN(B, 9)
-#define PB10 _STM32_PIN(B, 10)
-#define PB11 _STM32_PIN(B, 11)
-#define PB12 _STM32_PIN(B, 12)
-#define PB13 _STM32_PIN(B, 13)
-#define PB14 _STM32_PIN(B, 14)
-#define PB15 _STM32_PIN(B, 15)
-
-#define PC0 _STM32_PIN(C, 0)
-#define PC1 _STM32_PIN(C, 1)
-#define PC2 _STM32_PIN(C, 2)
-#define PC3 _STM32_PIN(C, 3)
-#define PC4 _STM32_PIN(C, 4)
-#define PC5 _STM32_PIN(C, 5)
-#define PC6 _STM32_PIN(C, 6)
-#define PC7 _STM32_PIN(C, 7)
-#define PC8 _STM32_PIN(C, 8)
-#define PC9 _STM32_PIN(C, 9)
-#define PC10 _STM32_PIN(C, 10)
-#define PC11 _STM32_PIN(C, 11)
-#define PC12 _STM32_PIN(C, 12)
-#define PC13 _STM32_PIN(C, 13)
-#define PC14 _STM32_PIN(C, 14)
-#define PC15 _STM32_PIN(C, 15)
-
-#define PD0 _STM32_PIN(D, 0)
-#define PD1 _STM32_PIN(D, 1)
-#define PD2 _STM32_PIN(D, 2)
-#define PD3 _STM32_PIN(D, 3)
-#define PD4 _STM32_PIN(D, 4)
-#define PD5 _STM32_PIN(D, 5)
-#define PD6 _STM32_PIN(D, 6)
-#define PD7 _STM32_PIN(D, 7)
-#define PD8 _STM32_PIN(D, 8)
-#define PD9 _STM32_PIN(D, 9)
-#define PD10 _STM32_PIN(D, 10)
-#define PD11 _STM32_PIN(D, 11)
-#define PD12 _STM32_PIN(D, 12)
-#define PD13 _STM32_PIN(D, 13)
-#define PD14 _STM32_PIN(D, 14)
-#define PD15 _STM32_PIN(D, 15)
-
-#define PE0 _STM32_PIN(E, 0)
-#define PE1 _STM32_PIN(E, 1)
-#define PE2 _STM32_PIN(E, 2)
-#define PE3 _STM32_PIN(E, 3)
-#define PE4 _STM32_PIN(E, 4)
-#define PE5 _STM32_PIN(E, 5)
-#define PE6 _STM32_PIN(E, 6)
-#define PE7 _STM32_PIN(E, 7)
-#define PE8 _STM32_PIN(E, 8)
-#define PE9 _STM32_PIN(E, 9)
-#define PE10 _STM32_PIN(E, 10)
-#define PE11 _STM32_PIN(E, 11)
-#define PE12 _STM32_PIN(E, 12)
-#define PE13 _STM32_PIN(E, 13)
-#define PE14 _STM32_PIN(E, 14)
-#define PE15 _STM32_PIN(E, 15)
diff --git a/Marlin/src/HAL/HAL_STM32F4/pinsDebug.h b/Marlin/src/HAL/HAL_STM32F4/pinsDebug.h
deleted file mode 100644
index e5022f79a4..0000000000
--- a/Marlin/src/HAL/HAL_STM32F4/pinsDebug.h
+++ /dev/null
@@ -1 +0,0 @@
-#error Debug pins is not supported on this Platform!
diff --git a/Marlin/src/HAL/HAL_STM32F7/EEPROM_Emul/eeprom_emul.h b/Marlin/src/HAL/HAL_STM32F7/EEPROM_Emul/eeprom_emul.h
deleted file mode 100644
index 441ff1bae1..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/EEPROM_Emul/eeprom_emul.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- ******************************************************************************
- * @file EEPROM/EEPROM_Emulation/inc/eeprom.h
- * @author MCD Application Team
- * @version V1.2.6
- * @date 04-November-2016
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation firmware library.
- ******************************************************************************
- * @attention
- *
- * © Copyright © 2016 STMicroelectronics International N.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of other
- * contributors to this software may be used to endorse or promote products
- * derived from this software without specific written permission.
- * 4. This software, including modifications and/or derivative works of this
- * software, must execute solely and exclusively on microcontroller or
- * microprocessor devices manufactured by or for STMicroelectronics.
- * 5. Redistribution and use of this software other than as permitted under
- * this license is void and will automatically terminate your rights under
- * this license.
- *
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-#pragma once
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-#include "../../../inc/MarlinConfig.h"
-#include "../HAL.h"
-
-/* Exported constants --------------------------------------------------------*/
-/* EEPROM emulation firmware error codes */
-#define EE_OK (uint32_t)HAL_OK
-#define EE_ERROR (uint32_t)HAL_ERROR
-#define EE_BUSY (uint32_t)HAL_BUSY
-#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
-
-/* Define the size of the sectors to be used */
-#define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
-
-/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
- be done by word */
-#define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
-
-/* EEPROM start address in Flash */
-#define EEPROM_START_ADDRESS ((uint32_t)0x08100000) /* EEPROM emulation start address:
- from sector2 : after 16KByte of used
- Flash memory */
-
-/* Pages 0 and 1 base and end addresses */
-#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
-#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
-#define PAGE0_ID FLASH_SECTOR_1
-
-#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
-#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
-#define PAGE1_ID FLASH_SECTOR_2
-
-/* Used Flash pages for EEPROM emulation */
-#define PAGE0 ((uint16_t)0x0000)
-#define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
-
-/* No valid page define */
-#define NO_VALID_PAGE ((uint16_t)0x00AB)
-
-/* Page status definitions */
-#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
-#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
-#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
-
-/* Valid pages in read and write defines */
-#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
-#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
-
-/* Page full define */
-#define PAGE_FULL ((uint8_t)0x80)
-
-/* Variables' number */
-#define NB_OF_VAR ((uint16_t)4096)
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
-uint16_t EE_Initialize(void);
-uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
-uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Marlin/src/HAL/HAL_STM32F7/EmulatedEeprom.cpp b/Marlin/src/HAL/HAL_STM32F7/EmulatedEeprom.cpp
deleted file mode 100644
index 7f9118ee9c..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/EmulatedEeprom.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#ifdef STM32F7
-
-/**
- * Description: functions for I2C connected external EEPROM.
- * Not platform dependent.
- */
-
-#include "../../inc/MarlinConfig.h"
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-#include "EEPROM_Emul/eeprom_emul.h"
-
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-static bool eeprom_initialized = false;
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
-// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F7
-#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
-
-// --------------------------------------------------------------------------
-// EEPROM
-// --------------------------------------------------------------------------
-
-
-void eeprom_init() {
- if (!eeprom_initialized) {
- HAL_FLASH_Unlock();
-
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
-
- /* EEPROM Init */
- if (EE_Initialize() != EE_OK)
- for (;;) HAL_Delay(1); // Spin forever until watchdog reset
-
- HAL_FLASH_Lock();
- eeprom_initialized = true;
- }
-}
-
-void eeprom_write_byte(uint8_t *pos, unsigned char value) {
- uint16_t eeprom_address = (unsigned) pos;
-
- eeprom_init();
-
- HAL_FLASH_Unlock();
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
-
- if (EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK)
- for (;;) HAL_Delay(1); // Spin forever until watchdog reset
-
- HAL_FLASH_Lock();
-}
-
-uint8_t eeprom_read_byte(uint8_t *pos) {
- uint16_t data = 0xFF;
- uint16_t eeprom_address = (unsigned)pos;
-
- eeprom_init();
-
- if (EE_ReadVariable(eeprom_address, &data) != EE_OK) {
- return (unsigned char)data;
- }
- return (unsigned char)data;
-}
-
-void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
- uint16_t data = 0xFF;
- uint16_t eeprom_address = (unsigned) __src;
-
- eeprom_init();
-
- for (uint8_t c = 0; c < __n; c++) {
- EE_ReadVariable(eeprom_address+c, &data);
- *((uint8_t*)__dst + c) = data;
- }
-}
-
-void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
-
-}
-
-#endif // STM32F7
diff --git a/Marlin/src/HAL/HAL_STM32F7/HAL.cpp b/Marlin/src/HAL/HAL_STM32F7/HAL.cpp
deleted file mode 100644
index 01f577cdad..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/HAL.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- *
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
- * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
- * Copyright (c) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#ifdef STM32F7
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-
-//#include
-
-// --------------------------------------------------------------------------
-// Externals
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Local defines
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Types
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-uint16_t HAL_adc_result;
-
-// --------------------------------------------------------------------------
-// Private Variables
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Function prototypes
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Private functions
-// --------------------------------------------------------------------------
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-/* VGPV Done with defines
-// disable interrupts
-void cli(void) { noInterrupts(); }
-
-// enable interrupts
-void sei(void) { interrupts(); }
-*/
-
-void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
-
-uint8_t HAL_get_reset_source (void) {
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)
- return RST_WATCHDOG;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET)
- return RST_SOFTWARE;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
- return RST_EXTERNAL;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
- return RST_POWER_ON;
- return 0;
-}
-
-void _delay_ms(const int delay_ms) { delay(delay_ms); }
-
-extern "C" {
- extern unsigned int _ebss; // end of bss section
-}
-
-// return free memory between end of heap (or end bss) and whatever is current
-
-/*
-#include "wirish/syscalls.c"
-//extern caddr_t _sbrk(int incr);
-#ifndef CONFIG_HEAP_END
-extern char _lm_heap_end;
-#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
-#endif
-
-extern "C" {
- static int freeMemory() {
- char top = 't';
- return &top - reinterpret_cast(sbrk(0));
- }
- int freeMemory() {
- int free_memory;
- int heap_end = (int)_sbrk(0);
- free_memory = ((int)&free_memory) - ((int)heap_end);
- return free_memory;
- }
-}
-*/
-
-// --------------------------------------------------------------------------
-// ADC
-// --------------------------------------------------------------------------
-
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
- HAL_adc_result = analogRead(adc_pin);
-}
-
-uint16_t HAL_adc_get_result(void) {
- return HAL_adc_result;
-}
-
-#endif // STM32F7
diff --git a/Marlin/src/HAL/HAL_STM32F7/HAL_spi_STM32F7.cpp b/Marlin/src/HAL/HAL_STM32F7/HAL_spi_STM32F7.cpp
deleted file mode 100644
index 78b312470a..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/HAL_spi_STM32F7.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Software SPI functions originally from Arduino Sd2Card Library
- * Copyright (C) 2009 by William Greiman
- */
-
-/**
- * Adapted to the STM32F7 HAL
- */
-
-#ifdef STM32F7
-
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
-#include "HAL.h"
-#include "../shared/HAL_SPI.h"
-#include "pins_arduino.h"
-#include "spi_pins.h"
-#include "../../core/macros.h"
-#include
-
-// --------------------------------------------------------------------------
-// Public Variables
-// --------------------------------------------------------------------------
-
-static SPISettings spiConfig;
-
-// --------------------------------------------------------------------------
-// Public functions
-// --------------------------------------------------------------------------
-
-#if ENABLED(SOFTWARE_SPI)
- // --------------------------------------------------------------------------
- // Software SPI
- // --------------------------------------------------------------------------
- #error "Software SPI not supported for STM32F7. Use hardware SPI."
-
-#else
-
-// --------------------------------------------------------------------------
-// Hardware SPI
-// --------------------------------------------------------------------------
-
-/**
- * VGPV SPI speed start and F_CPU/2, by default 72/2 = 36Mhz
- */
-
-/**
- * @brief Begin SPI port setup
- *
- * @return Nothing
- *
- * @details Only configures SS pin since libmaple creates and initialize the SPI object
- */
-void spiBegin(void) {
- #if !PIN_EXISTS(SS)
- #error SS_PIN not defined!
- #endif
-
- SET_OUTPUT(SS_PIN);
- WRITE(SS_PIN, HIGH);
-}
-
-/** Configure SPI for specified SPI speed */
-void spiInit(uint8_t spiRate) {
- // Use datarates Marlin uses
- uint32_t clock;
- switch (spiRate) {
- case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
- case SPI_HALF_SPEED: clock = 5000000; break;
- case SPI_QUARTER_SPEED: clock = 2500000; break;
- case SPI_EIGHTH_SPEED: clock = 1250000; break;
- case SPI_SPEED_5: clock = 625000; break;
- case SPI_SPEED_6: clock = 300000; break;
- default:
- clock = 4000000; // Default from the SPI libarary
- }
- spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
- SPI.begin();
-}
-
-/**
- * @brief Receives a single byte from the SPI port.
- *
- * @return Byte received
- *
- * @details
- */
-uint8_t spiRec(void) {
- SPI.beginTransaction(spiConfig);
- uint8_t returnByte = SPI.transfer(0xFF);
- SPI.endTransaction();
- return returnByte;
-}
-
-/**
- * @brief Receives a number of bytes from the SPI port to a buffer
- *
- * @param buf Pointer to starting address of buffer to write to.
- * @param nbyte Number of bytes to receive.
- * @return Nothing
- *
- * @details Uses DMA
- */
-void spiRead(uint8_t* buf, uint16_t nbyte) {
- SPI.beginTransaction(spiConfig);
- SPI.dmaTransfer(0, const_cast(buf), nbyte);
- SPI.endTransaction();
-}
-
-/**
- * @brief Sends a single byte on SPI port
- *
- * @param b Byte to send
- *
- * @details
- */
-void spiSend(uint8_t b) {
- SPI.beginTransaction(spiConfig);
- SPI.transfer(b);
- SPI.endTransaction();
-}
-
-/**
- * @brief Write token and then write from 512 byte buffer to SPI (for SD card)
- *
- * @param buf Pointer with buffer start address
- * @return Nothing
- *
- * @details Use DMA
- */
-void spiSendBlock(uint8_t token, const uint8_t* buf) {
- SPI.beginTransaction(spiConfig);
- SPI.transfer(token);
- SPI.dmaSend(const_cast(buf), 512);
- SPI.endTransaction();
-}
-
-#endif // SOFTWARE_SPI
-
-#endif // STM32F7
diff --git a/Marlin/src/HAL/HAL_STM32F7/SanityCheck.h b/Marlin/src/HAL/HAL_STM32F7/SanityCheck.h
deleted file mode 100644
index 2192d6ffcf..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/SanityCheck.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-/**
- * Test Re-ARM specific configuration values for errors at compile-time.
- */
-#if ENABLED(SPINDLE_LASER_ENABLE)
- #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
- #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
- #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
- #error "SPINDLE_DIR_PIN not defined."
- #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
- #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
- #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
- #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
- #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
- #elif SPINDLE_LASER_POWERUP_DELAY < 1
- #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
- #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
- #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
- #elif !defined(SPINDLE_LASER_PWM_INVERT)
- #error "SPINDLE_LASER_PWM_INVERT missing."
- #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
- #error "SPINDLE_LASER_PWM equation constant(s) missing."
- #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
- #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
- #elif PIN_EXISTS(E5_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E5_AUTO_FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by E5_AUTO_FAN_PIN."
- #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
- #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
- #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
- #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
- #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
- #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
- #endif
- #endif
-#endif // SPINDLE_LASER_ENABLE
-
-#if ENABLED(EMERGENCY_PARSER)
- #error "EMERGENCY_PARSER is not yet implemented for STM32F7. Disable EMERGENCY_PARSER to continue."
-#endif
-
-#if ENABLED(FAST_PWM_FAN)
- #error "FAST_PWM_FAN is not yet implemented for this platform."
-#endif
diff --git a/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h
deleted file mode 100644
index 23eca4bab7..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- * Copyright (C) 2017 Victor Perez
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-#pragma once
-
-#include "../../module/endstops.h"
-
-// One ISR for all EXT-Interrupts
-void endstop_ISR(void) { endstops.update(); }
-
-void setup_endstop_interrupts(void) {
- #if HAS_X_MAX
- attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_X_MIN
- attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MAX
- attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Y_MIN
- attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MAX
- attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN
- attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MAX
- attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z2_MIN
- attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MAX
- attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z3_MIN
- attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
- #endif
- #if HAS_Z_MIN_PROBE_PIN
- attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- #endif
-}
diff --git a/Marlin/src/HAL/HAL_STM32F7/pinsDebug.h b/Marlin/src/HAL/HAL_STM32F7/pinsDebug.h
deleted file mode 100644
index e5022f79a4..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/pinsDebug.h
+++ /dev/null
@@ -1 +0,0 @@
-#error Debug pins is not supported on this Platform!
diff --git a/Marlin/src/HAL/HAL_STM32F7/watchdog_STM32F7.cpp b/Marlin/src/HAL/HAL_STM32F7/watchdog_STM32F7.cpp
deleted file mode 100644
index 659e4448f3..0000000000
--- a/Marlin/src/HAL/HAL_STM32F7/watchdog_STM32F7.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#ifdef STM32F7
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(USE_WATCHDOG)
-
- #include "watchdog_STM32F7.h"
-
- IWDG_HandleTypeDef hiwdg;
-
- void watchdog_init() {
- hiwdg.Instance = IWDG;
- hiwdg.Init.Prescaler = IWDG_PRESCALER_32; //32kHz LSI clock and 32x prescalar = 1024Hz IWDG clock
- hiwdg.Init.Reload = 4095; //4095 counts = 4 seconds at 1024Hz
- if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
- //Error_Handler();
- }
- }
-
- void watchdog_reset() {
- /* Refresh IWDG: reload counter */
- if (HAL_IWDG_Refresh(&hiwdg) != HAL_OK) {
- /* Refresh Error */
- //Error_Handler();
- }
- }
-
-#endif // USE_WATCHDOG
-
-#endif // STM32F7
diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL_Servo_Teensy.cpp b/Marlin/src/HAL/HAL_TEENSY31_32/HAL_Servo_Teensy.cpp
deleted file mode 100644
index 7864ee715f..0000000000
--- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL_Servo_Teensy.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifdef __MK20DX256__
-
-#include "../../inc/MarlinConfig.h"
-
-#if HAS_SERVOS
-
-#include "HAL_Servo_Teensy.h"
-
-uint8_t servoPin[MAX_SERVOS] = { 0 };
-
-int8_t libServo::attach(const int pin) {
- if (this->servoIndex >= MAX_SERVOS) return -1;
- if (pin > 0) servoPin[this->servoIndex] = pin;
- return Servo::attach(servoPin[this->servoIndex]);
-}
-
-int8_t libServo::attach(const int pin, const int min, const int max) {
- if (pin > 0) servoPin[this->servoIndex] = pin;
- return Servo::attach(servoPin[this->servoIndex], min, max);
-}
-
-void libServo::move(const int value) {
- constexpr uint16_t servo_delay[] = SERVO_DELAY;
- static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
- if (this->attach(0) >= 0) {
- this->write(value);
- safe_delay(servo_delay[this->servoIndex]);
- #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
- this->detach();
- #endif
- }
-}
-
-#endif // HAS_SERVOS
-
-#endif // __MK20DX256__
diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp
deleted file mode 100644
index d746dc9730..0000000000
--- a/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifdef __MK20DX256__
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(EEPROM_SETTINGS)
-
-#include "../persistent_store_api.h"
-
-namespace HAL {
-namespace PersistentStore {
-
-bool access_start() { return true; }
-bool access_finish() { return true; }
-
-bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
- while (size--) {
- uint8_t * const p = (uint8_t * const)pos;
- uint8_t v = *value;
- // EEPROM has only ~100,000 write cycles,
- // so only write bytes that have changed!
- if (v != eeprom_read_byte(p)) {
- eeprom_write_byte(p, v);
- if (eeprom_read_byte(p) != v) {
- SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
- return true;
- }
- }
- crc16(crc, &v, 1);
- pos++;
- value++;
- };
- return false;
-}
-
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
- do {
- uint8_t c = eeprom_read_byte((uint8_t*)pos);
- if (writing) *value = c;
- crc16(crc, &c, 1);
- pos++;
- value++;
- } while (--size);
- return false;
-}
-
-} // PersistentStore
-} // HAL
-
-#endif // EEPROM_SETTINGS
-#endif // __MK20DX256__
diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/pinsDebug.h b/Marlin/src/HAL/HAL_TEENSY31_32/pinsDebug.h
deleted file mode 100644
index 47b99ae317..0000000000
--- a/Marlin/src/HAL/HAL_TEENSY31_32/pinsDebug.h
+++ /dev/null
@@ -1 +0,0 @@
-#error "Debug pins is not supported on the Teensy 3.1 / 3.2 Platform!"
diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp
deleted file mode 100644
index ff56036ccd..0000000000
--- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
-
-#include "../../inc/MarlinConfig.h"
-
-#if HAS_SERVOS
-
-#include "HAL_Servo_Teensy.h"
-
-uint8_t servoPin[MAX_SERVOS] = { 0 };
-
-int8_t libServo::attach(const int pin) {
- if (this->servoIndex >= MAX_SERVOS) return -1;
- if (pin > 0) servoPin[this->servoIndex] = pin;
- return Servo::attach(servoPin[this->servoIndex]);
-}
-
-int8_t libServo::attach(const int pin, const int min, const int max) {
- if (pin > 0) servoPin[this->servoIndex] = pin;
- return Servo::attach(servoPin[this->servoIndex], min, max);
-}
-
-void libServo::move(const int value) {
- constexpr uint16_t servo_delay[] = SERVO_DELAY;
- static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
- if (this->attach(0) >= 0) {
- this->write(value);
- safe_delay(servo_delay[this->servoIndex]);
- #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
- this->detach();
- #endif
- }
-}
-
-#endif // HAS_SERVOS
-
-#endif // __MK64FX512__ || __MK66FX1M0__
diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp
deleted file mode 100644
index 29b4653b3e..0000000000
--- a/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(EEPROM_SETTINGS)
-
-#include "../shared/persistent_store_api.h"
-
-namespace HAL {
-namespace PersistentStore {
-
-bool access_start() { return true; }
-bool access_finish() { return true; }
-
-bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
- while (size--) {
- uint8_t * const p = (uint8_t * const)pos;
- uint8_t v = *value;
- // EEPROM has only ~100,000 write cycles,
- // so only write bytes that have changed!
- if (v != eeprom_read_byte(p)) {
- eeprom_write_byte(p, v);
- if (eeprom_read_byte(p) != v) {
- SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
- return true;
- }
- }
- crc16(crc, &v, 1);
- pos++;
- value++;
- };
- return false;
-}
-
-bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
- do {
- uint8_t c = eeprom_read_byte((uint8_t*)pos);
- if (writing) *value = c;
- crc16(crc, &c, 1);
- pos++;
- value++;
- } while (--size);
- return false;
-}
-
-} // PersistentStore
-} // HAL
-
-#endif // EEPROM_SETTINGS
-#endif // __MK64FX512__ || __MK66FX1M0__
diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.cpp b/Marlin/src/HAL/LINUX/HAL.cpp
similarity index 74%
rename from Marlin/src/HAL/HAL_LINUX/HAL.cpp
rename to Marlin/src/HAL/LINUX/HAL.cpp
index 3d2dd5cd82..dd12d8645f 100644
--- a/Marlin/src/HAL/HAL_LINUX/HAL.cpp
+++ b/Marlin/src/HAL/LINUX/HAL.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "../../inc/MarlinConfig.h"
@@ -31,10 +30,10 @@ HalSerial usb_serial;
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
}
-extern "C" void u8g_MicroDelay(void) {
+extern "C" void u8g_MicroDelay() {
u8g_xMicroDelay(1);
}
-extern "C" void u8g_10MicroDelay(void) {
+extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
@@ -47,15 +46,15 @@ int freeMemory() {
return 0;
}
-// --------------------------------------------------------------------------
+// ------------------------
// ADC
-// --------------------------------------------------------------------------
+// ------------------------
-void HAL_adc_init(void) {
+void HAL_adc_init() {
}
-void HAL_adc_enable_channel(int ch) {
+void HAL_adc_enable_channel(const uint8_t ch) {
}
@@ -64,18 +63,18 @@ void HAL_adc_start_conversion(const uint8_t ch) {
active_ch = ch;
}
-bool HAL_adc_finished(void) {
+bool HAL_adc_finished() {
return true;
}
-uint16_t HAL_adc_get_result(void) {
+uint16_t HAL_adc_get_result() {
pin_t pin = analogInputToDigitalPin(active_ch);
if (!VALID_PIN(pin)) return 0;
uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF);
return data; // return 10bit value as Marlin expects
}
-void HAL_pwm_init(void) {
+void HAL_pwm_init() {
}
diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h
similarity index 62%
rename from Marlin/src/HAL/HAL_LINUX/HAL.h
rename to Marlin/src/HAL/LINUX/HAL.h
index 1057fae995..0475c953c3 100644
--- a/Marlin/src/HAL/HAL_LINUX/HAL.h
+++ b/Marlin/src/HAL/LINUX/HAL.h
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
@@ -23,10 +23,6 @@
#define CPU_32_BIT
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#define F_CPU 100000000
#define SystemCoreClock F_CPU
#include
@@ -47,23 +43,24 @@ uint8_t _getc();
//arduino: Print.h
#define DEC 10
#define HEX 16
-#define OCT 8
-#define BIN 2
+#define OCT 8
+#define BIN 2
//arduino: binary.h (weird defines)
#define B01 1
#define B10 2
#include "hardware/Clock.h"
-#include
-
+#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "fastio.h"
#include "watchdog.h"
-#include "HAL_timers.h"
+#include "timers.h"
#include "serial.h"
+#define SHARED_SERVOS HAS_SERVOS
+
extern HalSerial usb_serial;
#define MYSERIAL0 usb_serial
#define NUM_SERIAL 1
@@ -75,33 +72,35 @@ extern HalSerial usb_serial;
//
// Interrupts
//
-#define CRITICAL_SECTION_START
-#define CRITICAL_SECTION_END
+#define CRITICAL_SECTION_START()
+#define CRITICAL_SECTION_END()
#define ISRS_ENABLED()
#define ENABLE_ISRS()
#define DISABLE_ISRS()
-//Utility functions
-int freeMemory(void);
+inline void HAL_init() {}
-// SPI: Extended functions which take a channel number (hardware SPI only)
-/** Write single byte to specified SPI channel */
-void spiSend(uint32_t chan, byte b);
-/** Write buffer to specified SPI channel */
-void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
-/** Read single byte from specified SPI channel */
-uint8_t spiRec(uint32_t chan);
+// Utility functions
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+int freeMemory();
+#pragma GCC diagnostic pop
// ADC
-#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
-#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
-#define HAL_READ_ADC() HAL_adc_get_result()
-#define HAL_ADC_READY() true
+#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
+#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
+#define HAL_ADC_RESOLUTION 10
+#define HAL_READ_ADC() HAL_adc_get_result()
+#define HAL_ADC_READY() true
-void HAL_adc_init(void);
-void HAL_adc_enable_channel(int pin);
-void HAL_adc_start_conversion(const uint8_t adc_pin);
-uint16_t HAL_adc_get_result(void);
+void HAL_adc_init();
+void HAL_adc_enable_channel(const uint8_t ch);
+void HAL_adc_start_conversion(const uint8_t ch);
+uint16_t HAL_adc_get_result();
+
+// Reset source
+inline void HAL_clear_reset_source(void) {}
+inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
/* ---------------- Delay in cycles */
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
diff --git a/Marlin/src/HAL/HAL_LINUX/arduino.cpp b/Marlin/src/HAL/LINUX/arduino.cpp
similarity index 79%
rename from Marlin/src/HAL/HAL_LINUX/arduino.cpp
rename to Marlin/src/HAL/LINUX/arduino.cpp
index 408c96153d..122a1a4a18 100644
--- a/Marlin/src/HAL/HAL_LINUX/arduino.cpp
+++ b/Marlin/src/HAL/LINUX/arduino.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include
@@ -28,8 +27,8 @@
#include "../shared/Delay.h"
// Interrupts
-void cli(void) { } // Disable
-void sei(void) { } // Enable
+void cli() { } // Disable
+void sei() { } // Enable
// Time functions
void _delay_ms(const int delay_ms) {
@@ -76,21 +75,7 @@ uint16_t analogRead(pin_t adc_pin) {
return Gpio::get(DIGITAL_PIN_TO_ANALOG_PIN(adc_pin));
}
-// **************************
-// Persistent Config Storage
-// **************************
-
-void eeprom_write_byte(unsigned char *pos, unsigned char value) {
-
-}
-
-unsigned char eeprom_read_byte(uint8_t * pos) { return '\0'; }
-
-void eeprom_read_block(void *__dst, const void *__src, size_t __n) { }
-
-void eeprom_update_block(const void *__src, void *__dst, size_t __n) { }
-
-char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s) {
+char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) {
char format_string[20];
snprintf(format_string, 20, "%%%d.%df", __width, __prec);
sprintf(__s, format_string, __val);
diff --git a/Marlin/src/HAL/HAL_LINUX/persistent_store_impl.cpp b/Marlin/src/HAL/LINUX/eeprom.cpp
similarity index 83%
rename from Marlin/src/HAL/HAL_LINUX/persistent_store_impl.cpp
rename to Marlin/src/HAL/LINUX/eeprom.cpp
index 5e0b4a4f28..7a9a1db381 100644
--- a/Marlin/src/HAL/HAL_LINUX/persistent_store_impl.cpp
+++ b/Marlin/src/HAL/LINUX/eeprom.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,29 +19,29 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "../../inc/MarlinConfig.h"
#if ENABLED(EEPROM_SETTINGS)
-#include "../shared/persistent_store_api.h"
+#include "../shared/eeprom_api.h"
#include
-uint8_t buffer[E2END];
+#define LINUX_EEPROM_SIZE (E2END + 1)
+uint8_t buffer[LINUX_EEPROM_SIZE];
char filename[] = "eeprom.dat";
bool PersistentStore::access_start() {
const char eeprom_erase_value = 0xFF;
FILE * eeprom_file = fopen(filename, "rb");
- if (eeprom_file == NULL) return false;
+ if (eeprom_file == nullptr) return false;
fseek(eeprom_file, 0L, SEEK_END);
std::size_t file_size = ftell(eeprom_file);
- if (file_size < E2END) {
- memset(buffer + file_size, eeprom_erase_value, E2END - file_size);
+ if (file_size < LINUX_EEPROM_SIZE) {
+ memset(buffer + file_size, eeprom_erase_value, LINUX_EEPROM_SIZE - file_size);
}
else {
fseek(eeprom_file, 0L, SEEK_SET);
@@ -54,13 +54,13 @@ bool PersistentStore::access_start() {
bool PersistentStore::access_finish() {
FILE * eeprom_file = fopen(filename, "wb");
- if (eeprom_file == NULL) return false;
+ if (eeprom_file == nullptr) return false;
fwrite(buffer, sizeof(uint8_t), sizeof(buffer), eeprom_file);
fclose(eeprom_file);
return true;
}
-bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
+bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
std::size_t bytes_written = 0;
for (std::size_t i = 0; i < size; i++) {
diff --git a/Marlin/src/HAL/HAL_LINUX/fastio.h b/Marlin/src/HAL/LINUX/fastio.h
similarity index 79%
rename from Marlin/src/HAL/HAL_LINUX/fastio.h
rename to Marlin/src/HAL/LINUX/fastio.h
index 8eae771a4f..8b0526710d 100644
--- a/Marlin/src/HAL/HAL_LINUX/fastio.h
+++ b/Marlin/src/HAL/LINUX/fastio.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
* Fast I/O Routines for X86_64
*/
-#include
+#include "../shared/Marduino.h"
#include
#define SET_DIR_INPUT(IO) Gpio::setDir(IO, 1)
@@ -51,8 +51,6 @@
#define _READ(IO) READ_PIN(IO)
/// Write to a pin
-#define _WRITE_VAR(IO,V) digitalWrite(IO,V)
-
#define _WRITE(IO,V) WRITE_PIN(IO,V)
/// toggle a pin
@@ -80,21 +78,10 @@
/// check if pin is an output
#define _IS_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
-// hg42: HAS_TIMER is used only to check if it's a PWM pin
-// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
-// hg42: instead use PWM bit from the #define
-
-/// check if pin is a timer
-#define _HAS_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
-// hg42: could be this:
-// #define _HAS_TIMER(IO) LPC1768_PIN_PWM(IO)
-// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
-
/// Read a pin wrapper
#define READ(IO) _READ(IO)
/// Write to a pin wrapper
-#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
#define WRITE(IO,V) _WRITE(IO,V)
/// toggle a pin wrapper
@@ -116,14 +103,9 @@
/// check if pin is an output wrapper
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
-/// check if pin is a timer (wrapper)
-#define HAS_TIMER(IO) _HAS_TIMER(IO)
-
// Shorthand
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
-
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Clock.cpp b/Marlin/src/HAL/LINUX/hardware/Clock.cpp
similarity index 89%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Clock.cpp
rename to Marlin/src/HAL/LINUX/hardware/Clock.cpp
index 961f5c5d98..8fd4825b35 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Clock.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/Clock.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "../../../inc/MarlinConfig.h"
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Clock.h b/Marlin/src/HAL/LINUX/hardware/Clock.h
similarity index 95%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Clock.h
rename to Marlin/src/HAL/LINUX/hardware/Clock.h
index e3dafe250a..17c2fd9501 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Clock.h
+++ b/Marlin/src/HAL/LINUX/hardware/Clock.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Gpio.cpp b/Marlin/src/HAL/LINUX/hardware/Gpio.cpp
similarity index 87%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Gpio.cpp
rename to Marlin/src/HAL/LINUX/hardware/Gpio.cpp
index 0aeeb9c674..b7b12ceb16 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Gpio.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/Gpio.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "Gpio.h"
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Gpio.h b/Marlin/src/HAL/LINUX/hardware/Gpio.h
similarity index 96%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Gpio.h
rename to Marlin/src/HAL/LINUX/hardware/Gpio.h
index a53ad029c4..33eea77731 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Gpio.h
+++ b/Marlin/src/HAL/LINUX/hardware/Gpio.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Heater.cpp b/Marlin/src/HAL/LINUX/hardware/Heater.cpp
similarity index 89%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Heater.cpp
rename to Marlin/src/HAL/LINUX/hardware/Heater.cpp
index 0e2f94c356..8fc8555243 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Heater.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/Heater.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "Clock.h"
@@ -49,7 +48,7 @@ void Heater::update() {
last = now;
heat += (heater_state - heat) * (delta / 1000000000.0);
- if (heat < room_temp_raw) heat = room_temp_raw;
+ NOLESS(heat, room_temp_raw);
Gpio::pin_map[analogInputToDigitalPin(adc_pin)].value = 0xFFFF - (uint16_t)heat;
}
}
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Heater.h b/Marlin/src/HAL/LINUX/hardware/Heater.h
similarity index 91%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Heater.h
rename to Marlin/src/HAL/LINUX/hardware/Heater.h
index 90e9da21df..bb759da090 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Heater.h
+++ b/Marlin/src/HAL/LINUX/hardware/Heater.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.cpp b/Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.cpp
similarity index 91%
rename from Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.cpp
rename to Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.cpp
index 8fc2dc95c5..fe6e130f36 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "IOLoggerCSV.h"
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.h b/Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.h
similarity index 89%
rename from Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.h
rename to Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.h
index 61cce9c106..f8bca83e30 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/IOLoggerCSV.h
+++ b/Marlin/src/HAL/LINUX/hardware/IOLoggerCSV.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.cpp b/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp
similarity index 93%
rename from Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.cpp
rename to Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp
index c50390d736..ee7602db62 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.h b/Marlin/src/HAL/LINUX/hardware/LinearAxis.h
similarity index 90%
rename from Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.h
rename to Marlin/src/HAL/LINUX/hardware/LinearAxis.h
index 0e3b4b7503..04a5f3d0f7 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/LinearAxis.h
+++ b/Marlin/src/HAL/LINUX/hardware/LinearAxis.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Timer.cpp b/Marlin/src/HAL/LINUX/hardware/Timer.cpp
similarity index 90%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Timer.cpp
rename to Marlin/src/HAL/LINUX/hardware/Timer.cpp
index 10f725ae68..e213cc2683 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Timer.cpp
+++ b/Marlin/src/HAL/LINUX/hardware/Timer.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "Timer.h"
@@ -51,7 +50,7 @@ void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = Timer::handler;
sigemptyset(&sa.sa_mask);
- if (sigaction(SIGRTMIN, &sa, NULL) == -1) {
+ if (sigaction(SIGRTMIN, &sa, nullptr) == -1) {
return; // todo: handle error
}
@@ -74,7 +73,7 @@ void Timer::start(uint32_t frequency) {
}
void Timer::enable() {
- if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == -1) {
+ if (sigprocmask(SIG_UNBLOCK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = true;
@@ -82,7 +81,7 @@ void Timer::enable() {
}
void Timer::disable() {
- if (sigprocmask(SIG_SETMASK, &mask, NULL) == -1) {
+ if (sigprocmask(SIG_SETMASK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = false;
@@ -102,7 +101,7 @@ void Timer::setCompare(uint32_t compare) {
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
- if (timer_settime(timerid, 0, &its, NULL) == -1) {
+ if (timer_settime(timerid, 0, &its, nullptr) == -1) {
printf("timer(%ld) failed, compare: %d(%ld)\n", getID(), compare, its.it_value.tv_nsec);
return; // todo: handle error
}
diff --git a/Marlin/src/HAL/HAL_LINUX/hardware/Timer.h b/Marlin/src/HAL/LINUX/hardware/Timer.h
similarity index 94%
rename from Marlin/src/HAL/HAL_LINUX/hardware/Timer.h
rename to Marlin/src/HAL/LINUX/hardware/Timer.h
index 6aadbcbcb1..ebfe8e8b9b 100644
--- a/Marlin/src/HAL/HAL_LINUX/hardware/Timer.h
+++ b/Marlin/src/HAL/LINUX/hardware/Timer.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h b/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/LINUX/inc/Conditionals_adv.h b/Marlin/src/HAL/LINUX/inc/Conditionals_adv.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/LINUX/inc/Conditionals_adv.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/LINUX/inc/Conditionals_post.h b/Marlin/src/HAL/LINUX/inc/Conditionals_post.h
new file mode 100644
index 0000000000..0285c52ee3
--- /dev/null
+++ b/Marlin/src/HAL/LINUX/inc/Conditionals_post.h
@@ -0,0 +1,22 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
diff --git a/Marlin/src/HAL/LINUX/inc/SanityCheck.h b/Marlin/src/HAL/LINUX/inc/SanityCheck.h
new file mode 100644
index 0000000000..a3238b088b
--- /dev/null
+++ b/Marlin/src/HAL/LINUX/inc/SanityCheck.h
@@ -0,0 +1,39 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+/**
+ * Test X86_64-specific configuration values for errors at compile-time.
+ */
+
+// Emulating RAMPS
+#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
+ #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
+#endif
+
+#if ENABLED(FAST_PWM_FAN)
+ #error "FAST_PWM_FAN is not yet implemented for this platform."
+#endif
+
+#if HAS_TMC_SW_SERIAL
+ #error "TMC220x Software Serial is not supported on this platform."
+#endif
diff --git a/Marlin/src/HAL/HAL_LINUX/include/Arduino.h b/Marlin/src/HAL/LINUX/include/Arduino.h
similarity index 81%
rename from Marlin/src/HAL/HAL_LINUX/include/Arduino.h
rename to Marlin/src/HAL/LINUX/include/Arduino.h
index 60f14cc44f..928f551fb4 100644
--- a/Marlin/src/HAL/HAL_LINUX/include/Arduino.h
+++ b/Marlin/src/HAL/LINUX/include/Arduino.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,16 +43,12 @@
#define FALLING 0x03
#define RISING 0x04
-#define E2END 0xFFF // EEPROM end address
-
typedef uint8_t byte;
#define PROGMEM
#define PSTR(v) (v)
#define PGM_P const char *
// Used for libraries, preprocessor, and constants
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#ifndef isnan
@@ -67,9 +63,9 @@ typedef uint8_t byte;
#define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value)))
//Interrupts
-void cli(void); // Disable
-void sei(void); // Enable
-void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode);
+void cli(); // Disable
+void sei(); // Enable
+void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode);
void detachInterrupt(uint32_t pin);
extern "C" void GpioEnableInt(uint32_t port, uint32_t pin, uint32_t mode);
extern "C" void GpioDisableInt(uint32_t port, uint32_t pin);
@@ -110,16 +106,10 @@ bool digitalRead(pin_t);
void analogWrite(pin_t, int);
uint16_t analogRead(pin_t);
-// EEPROM
-void eeprom_write_byte(unsigned char *pos, unsigned char value);
-unsigned char eeprom_read_byte(unsigned char *pos);
-void eeprom_read_block (void *__dst, const void *__src, size_t __n);
-void eeprom_update_block (const void *__src, void *__dst, size_t __n);
-
int32_t random(int32_t);
int32_t random(int32_t, int32_t);
void randomSeed(uint32_t);
-char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s);
+char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
int map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
diff --git a/Marlin/src/HAL/HAL_LINUX/include/pinmapping.cpp b/Marlin/src/HAL/LINUX/include/pinmapping.cpp
similarity index 93%
rename from Marlin/src/HAL/HAL_LINUX/include/pinmapping.cpp
rename to Marlin/src/HAL/LINUX/include/pinmapping.cpp
index dca18a676b..66d8acd2f6 100644
--- a/Marlin/src/HAL/HAL_LINUX/include/pinmapping.cpp
+++ b/Marlin/src/HAL/LINUX/include/pinmapping.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include
diff --git a/Marlin/src/HAL/HAL_LINUX/include/pinmapping.h b/Marlin/src/HAL/LINUX/include/pinmapping.h
similarity index 93%
rename from Marlin/src/HAL/HAL_LINUX/include/pinmapping.h
rename to Marlin/src/HAL/LINUX/include/pinmapping.h
index effc464c73..0d99a38116 100644
--- a/Marlin/src/HAL/HAL_LINUX/include/pinmapping.h
+++ b/Marlin/src/HAL/LINUX/include/pinmapping.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/include/serial.h b/Marlin/src/HAL/LINUX/include/serial.h
similarity index 92%
rename from Marlin/src/HAL/HAL_LINUX/include/serial.h
rename to Marlin/src/HAL/LINUX/include/serial.h
index 9b439de985..c881d5dbda 100644
--- a/Marlin/src/HAL/HAL_LINUX/include/serial.h
+++ b/Marlin/src/HAL/LINUX/include/serial.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(EMERGENCY_PARSER)
- #include "../../../feature/emergency_parser.h"
+ #include "../../../feature/e_parser.h"
#endif
#include
@@ -83,8 +83,9 @@ public:
HalSerial() { host_connected = true; }
- void begin(int32_t baud) {
- }
+ void begin(int32_t) {}
+
+ void end() {}
int peek() {
uint8_t value;
@@ -107,11 +108,11 @@ public:
void flush() { receive_buffer.clear(); }
- uint8_t availableForWrite(void){
+ uint8_t availableForWrite() {
return transmit_buffer.free() > 255 ? 255 : (uint8_t)transmit_buffer.free();
}
- void flushTX(void){
+ void flushTX() {
if (host_connected)
while (transmit_buffer.available()) { /* nada */ }
}
@@ -141,10 +142,10 @@ public:
void print_bin(uint32_t value, uint8_t num_digits) {
uint32_t mask = 1 << (num_digits -1);
for (uint8_t i = 0; i < num_digits; i++) {
- if (!(i % 4) && i) write(' ');
- if (!(i % 16) && i) write(' ');
- if (value & mask) write('1');
- else write('0');
+ if (!(i % 4) && i) write(' ');
+ if (!(i % 16) && i) write(' ');
+ if (value & mask) write('1');
+ else write('0');
value <<= 1;
}
}
@@ -199,7 +200,7 @@ public:
void println(unsigned long value, int nbase = 0) { print(value, nbase); println(); }
void println(float value, int round = 6) { printf("%f\n" , value); }
void println(double value, int round = 6) { printf("%f\n" , value); }
- void println(void) { print('\n'); }
+ void println() { print('\n'); }
volatile RingBuffer receive_buffer;
volatile RingBuffer transmit_buffer;
diff --git a/Marlin/src/HAL/HAL_LINUX/main.cpp b/Marlin/src/HAL/LINUX/main.cpp
similarity index 94%
rename from Marlin/src/HAL/HAL_LINUX/main.cpp
rename to Marlin/src/HAL/LINUX/main.cpp
index 71aab05b1e..1217da3905 100644
--- a/Marlin/src/HAL/HAL_LINUX/main.cpp
+++ b/Marlin/src/HAL/LINUX/main.cpp
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
extern void setup();
@@ -49,7 +48,7 @@ void write_serial_thread() {
void read_serial_thread() {
char buffer[255] = {};
for (;;) {
- std::size_t len = MIN(usb_serial.receive_buffer.free(), 254U);
+ std::size_t len = _MIN(usb_serial.receive_buffer.free(), 254U);
if (fgets(buffer, len, stdin))
for (std::size_t i = 0; i < strlen(buffer); i++)
usb_serial.receive_buffer.write(buffer[i]);
@@ -104,13 +103,13 @@ void simulation_loop() {
}
}
-int main(void) {
+int main() {
std::thread write_serial (write_serial_thread);
std::thread read_serial (read_serial_thread);
#if NUM_SERIAL > 0
MYSERIAL0.begin(BAUDRATE);
- SERIAL_PRINTF("x86_64 Initialised\n");
+ SERIAL_ECHOLNPGM("x86_64 Initialized");
SERIAL_FLUSHTX();
#endif
diff --git a/Marlin/src/HAL/HAL_LINUX/pinsDebug.h b/Marlin/src/HAL/LINUX/pinsDebug.h
similarity index 81%
rename from Marlin/src/HAL/HAL_LINUX/pinsDebug.h
rename to Marlin/src/HAL/LINUX/pinsDebug.h
index cead56c30a..e373d37067 100644
--- a/Marlin/src/HAL/HAL_LINUX/pinsDebug.h
+++ b/Marlin/src/HAL/LINUX/pinsDebug.h
@@ -1,9 +1,6 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,9 +32,8 @@
#define digitalRead_mod(p) digitalRead(p)
#define PRINT_PORT(p)
#define GET_ARRAY_PIN(p) pin_array[p].pin
-#define NAME_FORMAT(p) PSTR("%-##p##s")
-#define PRINT_ARRAY_NAME(x) do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer);} while (0)
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
// active ADC function/mode/code values for PINSEL registers
diff --git a/Marlin/src/HAL/HAL_LINUX/servo_private.h b/Marlin/src/HAL/LINUX/servo_private.h
similarity index 95%
rename from Marlin/src/HAL/HAL_LINUX/servo_private.h
rename to Marlin/src/HAL/LINUX/servo_private.h
index c0e0a0c710..d576ff9266 100644
--- a/Marlin/src/HAL/HAL_LINUX/servo_private.h
+++ b/Marlin/src/HAL/LINUX/servo_private.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/Marlin/src/HAL/HAL_LINUX/spi_pins.h b/Marlin/src/HAL/LINUX/spi_pins.h
similarity index 79%
rename from Marlin/src/HAL/HAL_LINUX/spi_pins.h
rename to Marlin/src/HAL/LINUX/spi_pins.h
index fe510ddcff..0020e8cb79 100644
--- a/Marlin/src/HAL/HAL_LINUX/spi_pins.h
+++ b/Marlin/src/HAL/LINUX/spi_pins.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,11 +21,12 @@
*/
#pragma once
-#include "src/core/macros.h"
+#include "../../core/macros.h"
+#include "../../inc/MarlinConfigPre.h"
-#if BOTH(SDSUPPORT, DOGLCD) && (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 requred for communicating with each device being different.
+ // 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
// spiBeginTransaction.
#endif
diff --git a/Marlin/src/HAL/HAL_LINUX/HAL_timers.cpp b/Marlin/src/HAL/LINUX/timers.cpp
similarity index 94%
rename from Marlin/src/HAL/HAL_LINUX/HAL_timers.cpp
rename to Marlin/src/HAL/LINUX/timers.cpp
index f7b46725af..4ccffa63c5 100644
--- a/Marlin/src/HAL/HAL_LINUX/HAL_timers.cpp
+++ b/Marlin/src/HAL/LINUX/timers.cpp
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
@@ -19,13 +19,12 @@
* along with this program. If not, see .
*
*/
-
#ifdef __PLAT_LINUX__
#include "hardware/Timer.h"
#include "../../inc/MarlinConfig.h"
-#include "HAL_timers.h"
+#include "timers.h"
/**
* Use POSIX signals to attempt to emulate Interrupts
@@ -37,7 +36,7 @@ HAL_TEMP_TIMER_ISR();
Timer timers[2];
-void HAL_timer_init(void) {
+void HAL_timer_init() {
timers[0].init(0, STEPPER_TIMER_RATE, TIMER0_IRQHandler);
timers[1].init(1, TEMP_TIMER_RATE, TIMER1_IRQHandler);
}
diff --git a/Marlin/src/HAL/HAL_LINUX/HAL_timers.h b/Marlin/src/HAL/LINUX/timers.h
similarity index 88%
rename from Marlin/src/HAL/HAL_LINUX/HAL_timers.h
rename to Marlin/src/HAL/LINUX/timers.h
index 9505fc568a..b657584922 100644
--- a/Marlin/src/HAL/HAL_LINUX/HAL_timers.h
+++ b/Marlin/src/HAL/LINUX/timers.h
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
@@ -24,15 +24,11 @@
* HAL timers for Linux X86_64
*/
-// --------------------------------------------------------------------------
-// Includes
-// --------------------------------------------------------------------------
-
#include
-// --------------------------------------------------------------------------
+// ------------------------
// Defines
-// --------------------------------------------------------------------------
+// ------------------------
#define FORCE_INLINE __attribute__((always_inline)) inline
@@ -63,16 +59,16 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
-#define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler(void)
-#define HAL_TEMP_TIMER_ISR() extern "C" void TIMER1_IRQHandler(void)
+#define HAL_STEP_TIMER_ISR() extern "C" void TIMER0_IRQHandler()
+#define HAL_TEMP_TIMER_ISR() extern "C" void TIMER1_IRQHandler()
// PWM timer
#define HAL_PWM_TIMER
-#define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler(void)
+#define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler()
#define HAL_PWM_TIMER_IRQn
-void HAL_timer_init(void);
+void HAL_timer_init();
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare);
diff --git a/Marlin/src/HAL/LINUX/watchdog.cpp b/Marlin/src/HAL/LINUX/watchdog.cpp
new file mode 100644
index 0000000000..03af3cae7b
--- /dev/null
+++ b/Marlin/src/HAL/LINUX/watchdog.cpp
@@ -0,0 +1,35 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#ifdef __PLAT_LINUX__
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(USE_WATCHDOG)
+
+#include "watchdog.h"
+
+void watchdog_init() {}
+void HAL_watchdog_refresh() {}
+
+#endif
+
+#endif // __PLAT_LINUX__
diff --git a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.h b/Marlin/src/HAL/LINUX/watchdog.h
similarity index 79%
rename from Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.h
rename to Marlin/src/HAL/LINUX/watchdog.h
index 4076c2b03a..4771426a0b 100644
--- a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.h
+++ b/Marlin/src/HAL/LINUX/watchdog.h
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
*/
#pragma once
-extern IWDG_HandleTypeDef hiwdg;
+#define WDT_TIMEOUT 4000000 // 4 second timeout
void watchdog_init();
-void watchdog_reset();
+void HAL_watchdog_refresh();
diff --git a/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp b/Marlin/src/HAL/LPC1768/DebugMonitor.cpp
similarity index 91%
rename from Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp
rename to Marlin/src/HAL/LPC1768/DebugMonitor.cpp
index 998e56b6de..5df527bdb3 100644
--- a/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp
+++ b/Marlin/src/HAL/LPC1768/DebugMonitor.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*
*/
-
#ifdef TARGET_LPC1768
#include "../../core/macros.h"
@@ -44,7 +43,7 @@
#define sw_barrier() __asm__ volatile("": : :"memory");
// (re)initialize UART0 as a monitor output to 250000,n,8,1
-static void TXBegin(void) {
+static void TXBegin() {
}
// Send character through UART with no interrupts
@@ -199,18 +198,23 @@ void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause
// Clear cause of reset to prevent entering smoothie bootstrap
HAL_clear_reset_source();
+
// Restart watchdog
- //WDT_Restart(WDT);
- watchdog_init();
+ #if ENABLED(USE_WATCHDOG)
+ //WDT_Restart(WDT);
+ watchdog_init();
+ #endif
// Reset controller
NVIC_SystemReset();
- for (;;) watchdog_init();
+ // Nothing below here is compiled because NVIC_SystemReset loops forever
+
+ for (;;) { TERN_(USE_WATCHDOG, watchdog_init()); }
}
extern "C" {
-__attribute__((naked)) void NMI_Handler(void) {
+__attribute__((naked)) void NMI_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -223,7 +227,7 @@ __attribute__((naked)) void NMI_Handler(void) {
);
}
-__attribute__((naked)) void HardFault_Handler(void) {
+__attribute__((naked)) void HardFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -236,7 +240,7 @@ __attribute__((naked)) void HardFault_Handler(void) {
);
}
-__attribute__((naked)) void MemManage_Handler(void) {
+__attribute__((naked)) void MemManage_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -249,7 +253,7 @@ __attribute__((naked)) void MemManage_Handler(void) {
);
}
-__attribute__((naked)) void BusFault_Handler(void) {
+__attribute__((naked)) void BusFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -262,7 +266,7 @@ __attribute__((naked)) void BusFault_Handler(void) {
);
}
-__attribute__((naked)) void UsageFault_Handler(void) {
+__attribute__((naked)) void UsageFault_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -275,7 +279,7 @@ __attribute__((naked)) void UsageFault_Handler(void) {
);
}
-__attribute__((naked)) void DebugMon_Handler(void) {
+__attribute__((naked)) void DebugMon_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -289,7 +293,7 @@ __attribute__((naked)) void DebugMon_Handler(void) {
}
/* This is NOT an exception, it is an interrupt handler - Nevertheless, the framing is the same */
-__attribute__((naked)) void WDT_IRQHandler(void) {
+__attribute__((naked)) void WDT_IRQHandler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
@@ -302,7 +306,7 @@ __attribute__((naked)) void WDT_IRQHandler(void) {
);
}
-__attribute__((naked)) void RSTC_Handler(void) {
+__attribute__((naked)) void RSTC_Handler() {
__asm__ __volatile__ (
".syntax unified" "\n\t"
A("tst lr, #4")
diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp
similarity index 60%
rename from Marlin/src/HAL/HAL_LPC1768/HAL.cpp
rename to Marlin/src/HAL/LPC1768/HAL.cpp
index fedca7a1ff..5a7e55eb10 100644
--- a/Marlin/src/HAL/HAL_LPC1768/HAL.cpp
+++ b/Marlin/src/HAL/LPC1768/HAL.cpp
@@ -1,9 +1,9 @@
/**
* Marlin 3D Printer Firmware
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
- * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,21 +19,26 @@
* along with this program. If not, see .
*
*/
-
#ifdef TARGET_LPC1768
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"
#include "../../../gcode/parser.h"
+#if ENABLED(USE_WATCHDOG)
+ #include "watchdog.h"
+#endif
+
+uint32_t HAL_adc_reading = 0;
+
// U8glib required functions
extern "C" void u8g_xMicroDelay(uint16_t val) {
DELAY_US(val);
}
-extern "C" void u8g_MicroDelay(void) {
+extern "C" void u8g_MicroDelay() {
u8g_xMicroDelay(1);
}
-extern "C" void u8g_10MicroDelay(void) {
+extern "C" void u8g_10MicroDelay() {
u8g_xMicroDelay(10);
}
extern "C" void u8g_Delay(uint16_t val) {
@@ -52,15 +57,26 @@ int freeMemory() {
return result;
}
+// scan command line for code
+// return index into pin map array if found and the pin is valid.
+// return dval if not found or not a valid pin.
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
- const uint16_t val = (uint16_t)parser.intval(code), port = val / 100, pin = val % 100;
- const int16_t ind = (port < (NUM_DIGITAL_PINS >> 5) && (pin < 32))
- ? GET_PIN_MAP_INDEX(port << 5 | pin) : -2;
- return ind > -2 ? ind : dval;
+ const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
+ const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2;
+ return ind > -1 ? ind : dval;
}
-void flashFirmware(int16_t value) {
- NVIC_SystemReset();
+void flashFirmware(const int16_t) { NVIC_SystemReset(); }
+
+void HAL_clear_reset_source(void) {
+ TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
+}
+
+uint8_t HAL_get_reset_source(void) {
+ #if ENABLED(USE_WATCHDOG)
+ if (watchdog_timed_out()) return RST_WATCHDOG;
+ #endif
+ return RST_POWER_ON;
}
#endif // TARGET_LPC1768
diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h
similarity index 57%
rename from Marlin/src/HAL/HAL_LPC1768/HAL.h
rename to Marlin/src/HAL/LPC1768/HAL.h
index 0ac6db167e..2d385fd16c 100644
--- a/Marlin/src/HAL/HAL_LPC1768/HAL.h
+++ b/Marlin/src/HAL/LPC1768/HAL.h
@@ -1,7 +1,7 @@
/**
* Marlin 3D Printer Firmware
*
- * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
@@ -27,7 +27,6 @@
*/
#define CPU_32_BIT
-#define HAL_INIT
void HAL_init();
@@ -35,20 +34,23 @@ void HAL_init();
#include
#include
-extern "C" volatile millis_t _millis;
-
-#include
-#include
-#include
+extern "C" volatile uint32_t _millis;
+#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "fastio.h"
-#include
#include "watchdog.h"
-#include "HAL_timers.h"
+#include "timers.h"
#include "MarlinSerial.h"
+#include
+#include