Compare commits

..

No commits in common. "2.0.x" and "2.0.6" have entirely different histories.
2.0.x ... 2.0.6

1084 changed files with 23016 additions and 79097 deletions

View file

@ -9,51 +9,35 @@ assignees: ''
<!-- <!--
Please follow the instructions below. Failure to do so may result in your issue being closed. Have you read Marlin's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md
### Before Reporting a Bug Do you want to ask a question? Are you looking for support? Please don't post here. Instead please use one of the support links at https://github.com/MarlinFirmware/Marlin/issues/new/choose
1. Test with the `bugfix-2.0.x` branch to see whether the issue still exists. Before filing an issue be sure to test the "bugfix" branches to see whether the issue has been resolved.
2. Get troubleshooting help from the Marlin community to confirm it's a bug and not just a configuration error. Links at https://github.com/MarlinFirmware/Marlin/issues/new/choose
### Instructions
1. Fill out every section of the template below.
2. Always attach configuration files, regardless of whether you think they are involved.
3. Read and understand Marlin's Code of Conduct. By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md
--> -->
### Bug Description ### Bug Description
<!-- Describe the bug in this section. (You can remove this invisible comment.) --> <!-- Description of the bug -->
### Configuration Files ### My Configurations
**Required:** Include a ZIP file containing `Configuration.h` and `Configuration_adv.h`. **Required:** Please include a ZIP file containing your `Configuration.h` and `Configuration_adv.h` files.
If you've made any other modifications describe them in detail here.
### Steps to Reproduce ### Steps to Reproduce
<!-- Describe the steps needed to reproduce the issue. (You can remove this invisible comment.) --> <!-- Please describe the steps needed to reproduce the issue -->
1. [First Step] 1. [First Step]
2. [Second Step] 2. [Second Step]
3. [and so on...] 3. [and so on...]
**Expected behavior:** **Expected behavior:** [What you expect to happen]
<!-- Describe what you expected to happen here. (You can remove this invisible comment.) --> **Actual behavior:** [What actually happens]
**Actual behavior:**
<!-- Describe what actually happens here. (You can remove this invisible comment.) -->
#### Additional Information #### Additional Information
* Provide pictures or links to videos that clearly demonstrate the issue. * Provide pictures or links to videos that clearly demonstrate the issue.
* See [Contributing to Marlin](https://github.com/MarlinFirmware/Marlin/blob/2.0.x/.github/contributing.md) for additional guidelines. * See [How Can I Contribute](#how-can-i-contribute) for additional guidelines.

View file

@ -2,7 +2,7 @@
name: Feature request name: Feature request
about: Request a Feature about: Request a Feature
title: "[FR] (feature request title)" title: "[FR] (feature request title)"
labels: 'T: Feature Request' labels: ''
assignees: '' assignees: ''
--- ---

View file

@ -14,10 +14,6 @@ We must be able to understand your proposed change from this description. If we
<!-- What does this fix or improve? --> <!-- What does this fix or improve? -->
### Configurations
<!-- Attach any Configuration.h, Configuration_adv.h, or platformio.ini files needed to compile/test your Pull Request. -->
### Related Issues ### Related Issues
<!-- Whether this fixes a bug or fulfills a feature request, please list any related Issues here. --> <!-- Whether this fixes a bug or fulfills a feature request, please list any related Issues here. -->

View file

@ -20,8 +20,8 @@ jobs:
- uses: actions/stale@v3 - uses: actions/stale@v3
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has had no activity in the last 30 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 7 days.' stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.'
days-before-stale: 30 days-before-stale: 30
days-before-close: 7 days-before-close: 5
stale-issue-label: 'stale-closing-soon' stale-issue-label: 'stale-closing-soon'
exempt-issue-labels: 'T: Feature Request' exempt-issue-labels: 'T: Feature Request'

View file

@ -41,7 +41,6 @@ jobs:
- mega2560 - mega2560
- teensy31 - teensy31
- teensy35 - teensy35
- teensy41
- SAMD51_grandcentral_m4 - SAMD51_grandcentral_m4
# Extended AVR Environments # Extended AVR Environments
@ -68,10 +67,8 @@ jobs:
- BIGTREE_SKR_PRO - BIGTREE_SKR_PRO
- BIGTREE_GTR_V1_0 - BIGTREE_GTR_V1_0
- mks_robin - mks_robin
- mks_robin_stm32
- ARMED - ARMED
- FYSETC_S6 - FYSETC_S6
- STM32F070CB_malyan
- STM32F070RB_malyan - STM32F070RB_malyan
- malyan_M300 - malyan_M300
- mks_robin_lite - mks_robin_lite
@ -80,7 +77,6 @@ jobs:
- mks_robin_pro - mks_robin_pro
- STM32F103RET6_creality - STM32F103RET6_creality
- LERDGEX - LERDGEX
- mks_robin_nano35
# Put lengthy tests last # Put lengthy tests last
@ -97,6 +93,7 @@ jobs:
#- at90usb1286_dfu #- at90usb1286_dfu
#- STM32F103CB_malyan #- STM32F103CB_malyan
#- mks_robin_mini #- mks_robin_mini
#- mks_robin_nano
steps: steps:

View file

@ -3,7 +3,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (c) 2007 Free Software Foundation, Inc. <https://www.fsf.org/> Copyright (c) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -673,4 +673,5 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>. <https://www.gnu.org/philosophy/why-not-lgpl.html>.

View file

@ -34,8 +34,9 @@
* - Extra features * - Extra features
* *
* Advanced settings can be found in Configuration_adv.h * Advanced settings can be found in Configuration_adv.h
*
*/ */
#define CONFIGURATION_H_VERSION 020007 #define CONFIGURATION_H_VERSION 020006
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================
@ -176,7 +177,7 @@
#endif #endif
/** /**
* Průša Multi-Material Unit v2 * Prusa Multi-Material Unit v2
* *
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* Requires EXTRUDERS = 5 * Requires EXTRUDERS = 5
@ -234,8 +235,8 @@
#elif ENABLED(MAGNETIC_PARKING_EXTRUDER) #elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
#define MPE_FAST_SPEED 9000 // (mm/min) Speed for travel before last distance point #define MPE_FAST_SPEED 9000 // (mm/m) Speed for travel before last distance point
#define MPE_SLOW_SPEED 4500 // (mm/min) Speed for last distance travel to park and couple #define MPE_SLOW_SPEED 4500 // (mm/m) Speed for last distance travel to park and couple
#define MPE_TRAVEL_DISTANCE 10 // (mm) Last distance point #define MPE_TRAVEL_DISTANCE 10 // (mm) Last distance point
#define MPE_COMPENSATION 0 // Offset Compensation -1 , 0 , 1 (multiplier) only for coupling #define MPE_COMPENSATION 0 // Offset Compensation -1 , 0 , 1 (multiplier) only for coupling
@ -283,8 +284,8 @@
#if ENABLED(PRIME_BEFORE_REMOVE) #if ENABLED(PRIME_BEFORE_REMOVE)
#define SWITCHING_TOOLHEAD_PRIME_MM 20 // (mm) Extruder prime length #define SWITCHING_TOOLHEAD_PRIME_MM 20 // (mm) Extruder prime length
#define SWITCHING_TOOLHEAD_RETRACT_MM 10 // (mm) Retract after priming length #define SWITCHING_TOOLHEAD_RETRACT_MM 10 // (mm) Retract after priming length
#define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/min) Extruder prime feedrate #define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/m) Extruder prime feedrate
#define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/min) Extruder retract feedrate #define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/m) Extruder retract feedrate
#endif #endif
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Z_HOP 2 // (mm) Z raise for switching #define SWITCHING_TOOLHEAD_Z_HOP 2 // (mm) Z raise for switching
@ -329,7 +330,7 @@
//#define PSU_NAME "Power Supply" //#define PSU_NAME "Power Supply"
#if ENABLED(PSU_CONTROL) #if ENABLED(PSU_CONTROL)
#define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box #define PSU_ACTIVE_HIGH false // Set 'false' for ATX, 'true' for X-Box
//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
//#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power
@ -346,10 +347,11 @@
#endif #endif
#endif #endif
// @section temperature
//=========================================================================== //===========================================================================
//============================= Thermal Settings ============================ //============================= Thermal Settings ============================
//=========================================================================== //===========================================================================
// @section temperature
/** /**
* --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table * --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
@ -371,7 +373,7 @@
* 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! * 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, and E3D) (4.7k pullup) * 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup)
* 501 : 100K Zonestar (Tronxy X3A) Thermistor * 501 : 100K Zonestar (Tronxy X3A) Thermistor
* 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Průša P802M * 502 : 100K Zonestar Thermistor used by hot bed in Zonestar Prusa P802M
* 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup) * 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) * 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) * 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
@ -388,7 +390,6 @@
* 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....) * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
* 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB) * 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB)
* 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB) * 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB)
* 30 : Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K / B3950 (4.7k pullup)
* 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
* 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 * 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
* 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup * 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
@ -431,12 +432,6 @@
#define DUMMY_THERMISTOR_998_VALUE 25 #define DUMMY_THERMISTOR_998_VALUE 25
#define DUMMY_THERMISTOR_999_VALUE 100 #define DUMMY_THERMISTOR_999_VALUE 100
// Resistor values when using a MAX31865 (sensor -5)
// Sensor value is typically 100 (PT100) or 1000 (PT1000)
// Calibration value is typically 430 ohm for AdaFruit PT100 modules and 4300 ohm for AdaFruit PT1000 modules.
//#define MAX31865_SENSOR_OHMS 100
//#define MAX31865_CALIBRATION_OHMS 430
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
// from the two sensors differ too much the print will be aborted. // from the two sensors differ too much the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT //#define TEMP_SENSOR_1_AS_REDUNDANT
@ -492,17 +487,23 @@
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2] // Set/get with gcode: M301 E[extruder number, 0-2]
#if ENABLED(PID_PARAMS_PER_HOTEND) // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// Specify between 1 and HOTENDS values per array.
// If fewer than EXTRUDER values are provided, the last element will be repeated. // Ultimaker
#define DEFAULT_Kp_LIST { 22.20, 22.20 } #define DEFAULT_Kp 22.2
#define DEFAULT_Ki_LIST { 1.08, 1.08 } #define DEFAULT_Ki 1.08
#define DEFAULT_Kd_LIST { 114.00, 114.00 } #define DEFAULT_Kd 114
#else
#define DEFAULT_Kp 22.20 // MakerGear
#define DEFAULT_Ki 1.08 //#define DEFAULT_Kp 7.0
#define DEFAULT_Kd 114.00 //#define DEFAULT_Ki 0.1
#endif //#define DEFAULT_Kd 12
// Mendel Parts V9 on 12V
//#define DEFAULT_Kp 63.0
//#define DEFAULT_Ki 2.25
//#define DEFAULT_Kd 440
#endif // PIDTEMP #endif // PIDTEMP
//=========================================================================== //===========================================================================
@ -538,12 +539,18 @@
//#define MIN_BED_POWER 0 //#define MIN_BED_POWER 0
//#define PID_BED_DEBUG // Sends debug data to the serial port. //#define PID_BED_DEBUG // Sends debug data to the serial port.
// 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
// from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00 #define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023 #define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4 #define DEFAULT_bedKd 305.4
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune
//#define DEFAULT_bedKp 97.1
//#define DEFAULT_bedKi 1.41
//#define DEFAULT_bedKd 1675.16
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED #endif // PIDTEMPBED
@ -601,7 +608,7 @@
// @section machine // @section machine
// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics, // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics
// either in the usual order or reversed // either in the usual order or reversed
//#define COREXY //#define COREXY
//#define COREXZ //#define COREXZ
@ -609,7 +616,6 @@
//#define COREYX //#define COREYX
//#define COREZX //#define COREZX
//#define COREZY //#define COREZY
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
//=========================================================================== //===========================================================================
//============================== Endstop Settings =========================== //============================== Endstop Settings ===========================
@ -860,6 +866,7 @@
* - For simple switches connect... * - For simple switches connect...
* - normally-closed switches to GND and D32. * - normally-closed switches to GND and D32.
* - normally-open switches to 5V and D32. * - normally-open switches to 5V and D32.
*
*/ */
//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default //#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
@ -957,34 +964,24 @@
// //
/** /**
* Nozzle-to-Probe offsets { X, Y, Z } * Z Probe to nozzle (X,Y) offset, relative to (0, 0).
* *
* - Use a caliper or ruler to measure the distance from the tip of * In the following example the X and Y offsets are both positive:
* the Nozzle to the center-point of the Probe in the X and Y axes.
* - For the Z offset use your best known value and adjust at runtime.
* - Probe Offsets can be tuned at runtime with 'M851', LCD menus, babystepping, etc.
* *
* Assuming the typical work area orientation: * #define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
* - Probe to RIGHT of the Nozzle has a Positive X offset
* - Probe to LEFT of the Nozzle has a Negative X offset
* - Probe in BACK of the Nozzle has a Positive Y offset
* - Probe in FRONT of the Nozzle has a Negative Y offset
*
* Some examples:
* #define NOZZLE_TO_PROBE_OFFSET { 10, 10, -1 } // Example "1"
* #define NOZZLE_TO_PROBE_OFFSET {-10, 5, -1 } // Example "2"
* #define NOZZLE_TO_PROBE_OFFSET { 5, -5, -1 } // Example "3"
* #define NOZZLE_TO_PROBE_OFFSET {-15,-10, -1 } // Example "4"
* *
* +-- BACK ---+ * +-- BACK ---+
* | [+] | * | |
* L | 1 | R <-- Example "1" (right+, back+) * L | (+) P | R <-- probe (20,20)
* E | 2 | I <-- Example "2" ( left-, back+) * E | | I
* F |[-] N [+]| G <-- Nozzle * F | (-) N (+) | G <-- nozzle (10,10)
* T | 3 | H <-- Example "3" (right+, front-) * T | | H
* | 4 | T <-- Example "4" ( left-, front-) * | (-) | T
* | [-] | * | |
* O-- FRONT --+ * O-- FRONT --+
* (0,0)
*
* Specify a Probe position as { X, Y, Z }
*/ */
#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } #define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
@ -992,13 +989,13 @@
// with NOZZLE_AS_PROBE this can be negative for a wider probing area. // with NOZZLE_AS_PROBE this can be negative for a wider probing area.
#define PROBING_MARGIN 10 #define PROBING_MARGIN 10
// X and Y axis travel speed (mm/min) between probes // X and Y axis travel speed (mm/m) between probes
#define XY_PROBE_SPEED (133*60) #define XY_PROBE_SPEED 8000
// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) // Feedrate (mm/m) for the first approach when double-probing (MULTIPLE_PROBING == 2)
#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
// Feedrate (mm/min) for the "accurate" probe of each point // Feedrate (mm/m) for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
/** /**
@ -1069,18 +1066,18 @@
#define Z_ENABLE_ON 0 #define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders #define E_ENABLE_ON 0 // For all extruders
// Disable axis steppers immediately when they're not being stepped. // Disables axis stepper immediately when it's not being used.
// WARNING: When motors turn off there is a chance of losing position accuracy! // WARNING: When motors turn off there is a chance of losing position accuracy!
#define DISABLE_X false #define DISABLE_X false
#define DISABLE_Y false #define DISABLE_Y false
#define DISABLE_Z false #define DISABLE_Z false
// Turn off the display blinking that warns about possible accuracy reduction // Warn on display about possibly reduced accuracy
//#define DISABLE_REDUCED_ACCURACY_WARNING //#define DISABLE_REDUCED_ACCURACY_WARNING
// @section extruder // @section extruder
#define DISABLE_E false // Disable the extruder when not stepping #define DISABLE_E false // For all extruders
#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled #define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled
// @section machine // @section machine
@ -1171,11 +1168,10 @@
*/ */
//#define FILAMENT_RUNOUT_SENSOR //#define FILAMENT_RUNOUT_SENSOR
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
#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_PULLDOWN // Use internal pulldown for filament runout pins.
// Set one or more commands to execute on filament runout. // Set one or more commands to execute on filament runout.
// (After 'M412 H' Marlin will ask the host to handle the process.) // (After 'M412 H' Marlin will ask the host to handle the process.)
@ -1392,7 +1388,7 @@
#define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing #define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing
#endif #endif
// Homing speeds (mm/min) // Homing speeds (mm/m)
#define HOMING_FEEDRATE_XY (50*60) #define HOMING_FEEDRATE_XY (50*60)
#define HOMING_FEEDRATE_Z (4*60) #define HOMING_FEEDRATE_Z (4*60)
@ -1571,6 +1567,7 @@
* *
* Caveats: The ending Z should be the same as starting Z. * Caveats: The ending Z should be the same as starting Z.
* Attention: EXPERIMENTAL. G-code arguments may change. * Attention: EXPERIMENTAL. G-code arguments may change.
*
*/ */
//#define NOZZLE_CLEAN_FEATURE //#define NOZZLE_CLEAN_FEATURE
@ -1596,12 +1593,9 @@
// Move the nozzle to the initial position after cleaning // Move the nozzle to the initial position after cleaning
#define NOZZLE_CLEAN_GOBACK #define NOZZLE_CLEAN_GOBACK
// For a purge/clean station that's always at the gantry height (thus no Z move) // Enable for a purge/clean station that's always at the gantry height (thus no Z move)
//#define NOZZLE_CLEAN_NO_Z //#define NOZZLE_CLEAN_NO_Z
// For a purge/clean station mounted on the X axis
//#define NOZZLE_CLEAN_NO_Y
// Explicit wipe G-code script applies to a G12 with no arguments. // Explicit wipe G-code script applies to a G12 with no arguments.
//#define WIPE_SEQUENCE_COMMANDS "G1 X-17 Y25 Z10 F4000\nG1 Z1\nM114\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 Z15\nM400\nG0 X-10.0 Y-9.0" //#define WIPE_SEQUENCE_COMMANDS "G1 X-17 Y25 Z10 F4000\nG1 Z1\nM114\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 X-17 Y25\nG1 X-17 Y95\nG1 Z15\nM400\nG0 X-10.0 Y-9.0"
@ -1638,37 +1632,6 @@
*/ */
//#define PRINTCOUNTER //#define PRINTCOUNTER
/**
* Password
*
* Set a numerical password for the printer which can be requested:
*
* - When the printer boots up
* - Upon opening the 'Print from Media' Menu
* - When SD printing is completed or aborted
*
* The following G-codes can be used:
*
* M510 - Lock Printer. Blocks all commands except M511.
* M511 - Unlock Printer.
* M512 - Set, Change and Remove Password.
*
* If you forget the password and get locked out you'll need to re-flash
* the firmware with the feature disabled, reset EEPROM, and (optionally)
* re-flash the firmware again with this feature enabled.
*/
//#define PASSWORD_FEATURE
#if ENABLED(PASSWORD_FEATURE)
#define PASSWORD_LENGTH 4 // (#) Number of digits (1-9). 3 or 4 is recommended
#define PASSWORD_ON_STARTUP
#define PASSWORD_UNLOCK_GCODE // Unlock with the M511 P<password> command. Disable to prevent brute-force attack.
#define PASSWORD_CHANGE_GCODE // Change the password with M512 P<old> S<new>.
//#define PASSWORD_ON_SD_PRINT_MENU // This does not prevent gcodes from running
//#define PASSWORD_AFTER_SD_PRINT_END
//#define PASSWORD_AFTER_SD_PRINT_ABORT
//#include "Configuration_Secure.h" // External file with PASSWORD_DEFAULT_VALUE
#endif
//============================================================================= //=============================================================================
//============================= LCD and SD support ============================ //============================= LCD and SD support ============================
//============================================================================= //=============================================================================
@ -1681,7 +1644,7 @@
* Select the language to display on the LCD. These languages are available: * 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, hu, it, * en, an, bg, ca, cz, da, de, el, el_gr, es, eu, fi, fr, gl, hr, hu, it,
* jp_kana, ko_KR, nl, pl, pt, pt_br, ro, ru, sk, tr, uk, vi, zh_CN, zh_TW, test * jp_kana, ko_KR, nl, pl, pt, pt_br, ro 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', 'hu':'Hungarian', 'it':'Italian', 'jp_kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt_br':'Portuguese (Brazilian)', 'ro':'Romanian', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'vi':'Vietnamese', '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', 'hu':'Hungarian', 'it':'Italian', 'jp_kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt_br':'Portuguese (Brazilian)', 'ro':'Romanian', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'vi':'Vietnamese', 'zh_CN':'Chinese (Simplified)', 'zh_TW':'Chinese (Traditional)', 'test':'TEST' }
*/ */
@ -1712,9 +1675,9 @@
#define DISPLAY_CHARSET_HD44780 JAPANESE #define DISPLAY_CHARSET_HD44780 JAPANESE
/** /**
* Info Screen Style (0:Classic, 1:Průša) * Info Screen Style (0:Classic, 1:Prusa)
* *
* :[0:'Classic', 1:'Průša'] * :[0:'Classic', 1:'Prusa']
*/ */
#define LCD_INFO_SCREEN_STYLE 0 #define LCD_INFO_SCREEN_STYLE 0
@ -1723,6 +1686,7 @@
* *
* SD Card support is disabled by default. If your controller has an SD slot, * SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work. * you must uncomment the following option or it won't work.
*
*/ */
//#define SDSUPPORT //#define SDSUPPORT
@ -1959,14 +1923,6 @@
// //
//#define FF_INTERFACEBOARD //#define FF_INTERFACEBOARD
//
// TFT GLCD Panel with Marlin UI
// Panel connected to main board by SPI or I2C interface.
// See https://github.com/Serhiy-K/TFTGLCDAdapter
//
//#define TFTGLCD_PANEL_SPI
//#define TFTGLCD_PANEL_I2C
//============================================================================= //=============================================================================
//======================= LCD / Controller Selection ======================= //======================= LCD / Controller Selection =======================
//========================= (Graphical LCDs) ======================== //========================= (Graphical LCDs) ========================
@ -2061,7 +2017,7 @@
//#define FYSETC_MINI_12864_X_X // Type C/D/E/F. No tunable RGB Backlight by default //#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_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_0 // Type A/B. Discreet RGB Backlight
//#define FYSETC_MINI_12864_2_1 // Type A/B. NeoPixel 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. //#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
// //
@ -2123,7 +2079,7 @@
//#define OLED_PANEL_TINYBOY2 //#define OLED_PANEL_TINYBOY2
// //
// MKS OLED 1.3" 128×64 FULL GRAPHICS CONTROLLER // MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
// https://reprap.org/wiki/MKS_12864OLED // https://reprap.org/wiki/MKS_12864OLED
// //
// Tiny, but very sharp OLED display // Tiny, but very sharp OLED display
@ -2131,13 +2087,6 @@
//#define MKS_12864OLED // Uses the SH1106 controller (default) //#define MKS_12864OLED // Uses the SH1106 controller (default)
//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller //#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
//
// Zonestar OLED 128×64 FULL GRAPHICS CONTROLLER
//
//#define ZONESTAR_12864LCD // Graphical (DOGM) with ST7920 controller
//#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller (default)
//#define ZONESTAR_12864OLED_SSD1306 // 0.96" OLED with SSD1306 controller
// //
// Einstart S OLED SSD1306 // Einstart S OLED SSD1306
// //
@ -2149,7 +2098,7 @@
//#define OVERLORD_OLED //#define OVERLORD_OLED
// //
// FYSETC OLED 2.42" 128×64 FULL GRAPHICS CONTROLLER with WS2812 RGB // FYSETC OLED 2.42" 128 × 64 FULL GRAPHICS CONTROLLER with WS2812 RGB
// Where to find : https://www.aliexpress.com/item/4000345255731.html // Where to find : https://www.aliexpress.com/item/4000345255731.html
//#define FYSETC_242_OLED_12864 // Uses the SSD1309 controller //#define FYSETC_242_OLED_12864 // Uses the SSD1309 controller
@ -2170,9 +2119,6 @@
// Touch-screen LCD for Malyan M200/M300 printers // Touch-screen LCD for Malyan M200/M300 printers
// //
//#define MALYAN_LCD //#define MALYAN_LCD
#if ENABLED(MALYAN_LCD)
#define LCD_SERIAL_PORT 1 // Default is 1 for Malyan M200
#endif
// //
// Touch UI for FTDI EVE (FT800/FT810) displays // Touch UI for FTDI EVE (FT800/FT810) displays
@ -2180,16 +2126,6 @@
// //
//#define TOUCH_UI_FTDI_EVE //#define TOUCH_UI_FTDI_EVE
//
// Touch-screen LCD for Anycubic printers
//
//#define ANYCUBIC_LCD_I3MEGA
//#define ANYCUBIC_LCD_CHIRON
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
#define LCD_SERIAL_PORT 3 // Default is 3 for Anycubic
//#define ANYCUBIC_LCD_DEBUG
#endif
// //
// Third-party or vendor-customized controller interfaces. // Third-party or vendor-customized controller interfaces.
// Sources should be installed in 'src/lcd/extensible_ui'. // Sources should be installed in 'src/lcd/extensible_ui'.
@ -2204,47 +2140,27 @@
//=============================== Graphical TFTs ============================== //=============================== Graphical TFTs ==============================
//============================================================================= //=============================================================================
/** //
* TFT Type - Select your Display type // FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
* // Upscaled 128x64 Marlin UI
* Available options are: //
* MKS_TS35_V2_0, //#define FSMC_GRAPHICAL_TFT
* MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35,
* MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R
* TFT_TRONXY_X5SA, ANYCUBIC_TFT35, LONGER_LK_TFT28
* TFT_GENERIC
*
* For TFT_GENERIC, you need to configure these 3 options:
* Driver: TFT_DRIVER
* Current Drivers are: AUTO, ST7735, ST7789, ST7796, R61505, ILI9328, ILI9341, ILI9488
* Resolution: TFT_WIDTH and TFT_HEIGHT
* Interface: TFT_INTERFACE_FSMC or TFT_INTERFACE_SPI
*/
//#define TFT_GENERIC
/** //
* TFT UI - User Interface Selection. Enable one of the following options: // TFT LVGL UI
* //
* TFT_CLASSIC_UI - Emulated DOGM - 128x64 Upscaled // Using default MKS icons and fonts from: https://git.io/JJvzK
* TFT_COLOR_UI - Marlin Default Menus, Touch Friendly, using full TFT capabilities // Just copy the 'assets' folder from the build directory to the
* TFT_LVGL_UI - A Modern UI using LVGL // root of your SD card, together with the compiled firmware.
* //
* For LVGL_UI also copy the 'assets' folder from the build directory to the //#define TFT_LVGL_UI_FSMC // Robin nano v1.2 uses FSMC
* root of your SD card, together with the compiled firmware. //#define TFT_LVGL_UI_SPI // Robin nano v2.0 uses SPI
*/
//#define TFT_CLASSIC_UI
//#define TFT_COLOR_UI
//#define TFT_LVGL_UI
/** //
* TFT Rotation. Set to one of the following values: // Anycubic Mega TFT (AI3M)
* //
* TFT_ROTATE_90, TFT_ROTATE_90_MIRROR_X, TFT_ROTATE_90_MIRROR_Y, //#define ANYCUBIC_TFT_MODEL
* TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y, //#define ANYCUBIC_TFT_DEBUG
* TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
* TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
*/
//#define TFT_ROTATION TFT_NO_ROTATION
//============================================================================= //=============================================================================
//============================ Other Controllers ============================ //============================ Other Controllers ============================
@ -2258,22 +2174,20 @@
// //
// ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8 // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
// //
//#define TOUCH_SCREEN //#define TOUCH_BUTTONS
#if ENABLED(TOUCH_SCREEN) #if ENABLED(TOUCH_BUTTONS)
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
#define TOUCH_SCREEN_CALIBRATION #define XPT2046_X_CALIBRATION 12316
#define XPT2046_Y_CALIBRATION -8981
//#define XPT2046_X_CALIBRATION 12316 #define XPT2046_X_OFFSET -43
//#define XPT2046_Y_CALIBRATION -8981 #define XPT2046_Y_OFFSET 257
//#define XPT2046_X_OFFSET -43
//#define XPT2046_Y_OFFSET 257
#endif #endif
// //
// RepRapWorld REPRAPWORLD_KEYPAD v1.1 // RepRapWorld REPRAPWORLD_KEYPAD v1.1
// https://reprapworld.com/products/electronics/ramps/keypad_v1_0_fully_assembled/ // https://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
// //
//#define REPRAPWORLD_KEYPAD //#define REPRAPWORLD_KEYPAD
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press //#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
@ -2284,10 +2198,6 @@
// @section extras // @section extras
// Set number of user-controlled fans. Disable to use all board-defined fans.
// :[1,2,3,4,5,6,7,8]
//#define NUM_M106_FANS 1
// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino // Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN //#define FAST_PWM_FAN
@ -2314,6 +2224,9 @@
// then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis) // then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
//#define TEMP_STAT_LEDS //#define TEMP_STAT_LEDS
// SkeinForge sends the wrong arc G-codes when using Arc Point as fillet procedure
//#define SF_ARC_FIX
// Support for the BariCUDA Paste Extruder // Support for the BariCUDA Paste Extruder
//#define BARICUDA //#define BARICUDA
@ -2335,17 +2248,18 @@
* Adds the M150 command to set the LED (or LED strip) color. * Adds the M150 command to set the LED (or LED strip) color.
* If pins are PWM capable (e.g., 4, 5, 6, 11) then a range of * If pins are PWM capable (e.g., 4, 5, 6, 11) then a range of
* luminance values can be set from 0 to 255. * luminance values can be set from 0 to 255.
* For NeoPixel LED an overall brightness parameter is also available. * For Neopixel LED an overall brightness parameter is also available.
* *
* *** CAUTION *** * *** CAUTION ***
* LED Strips require a MOSFET Chip between PWM lines and LEDs, * LED Strips require a MOSFET Chip between PWM lines and LEDs,
* as the Arduino cannot handle the current the LEDs will require. * as the Arduino cannot handle the current the LEDs will require.
* Failure to follow this precaution can destroy your Arduino! * Failure to follow this precaution can destroy your Arduino!
* NOTE: A separate 5V power supply is required! The NeoPixel LED needs * NOTE: A separate 5V power supply is required! The Neopixel LED needs
* more current than the Arduino 5V linear regulator can produce. * more current than the Arduino 5V linear regulator can produce.
* *** CAUTION *** * *** CAUTION ***
* *
* LED Type. Enable only one of the following two options. * LED Type. Enable only one of the following two options.
*
*/ */
//#define RGB_LED //#define RGB_LED
//#define RGBW_LED //#define RGBW_LED
@ -2357,29 +2271,19 @@
//#define RGB_LED_W_PIN -1 //#define RGB_LED_W_PIN -1
#endif #endif
// Support for Adafruit NeoPixel LED driver // Support for Adafruit Neopixel LED driver
//#define NEOPIXEL_LED //#define NEOPIXEL_LED
#if ENABLED(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_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
#define NEOPIXEL_PIN 4 // LED driving pin #define NEOPIXEL_PIN 4 // LED driving pin
//#define NEOPIXEL2_TYPE NEOPIXEL_TYPE //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
//#define NEOPIXEL2_PIN 5 //#define NEOPIXEL2_PIN 5
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) #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_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_BRIGHTNESS 127 // Initial brightness (0-255)
//#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup
// Support for second Adafruit NeoPixel LED driver controlled with M150 S1 ... // Use a single Neopixel LED for static (background) lighting
//#define NEOPIXEL2_SEPARATE
#if ENABLED(NEOPIXEL2_SEPARATE)
#define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip
#define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255)
#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup
#else
//#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel
#endif
// Use a single NeoPixel LED for static (background) lighting
//#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
#endif #endif
@ -2399,12 +2303,17 @@
#define PRINTER_EVENT_LEDS #define PRINTER_EVENT_LEDS
#endif #endif
/**
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas
*/
/** /**
* Number of servos * Number of servos
* *
* For some servo-related options NUM_SERVOS will be set automatically. * For some servo-related options NUM_SERVOS will be set automatically.
* Set this manually if there are extra servos needing manual control. * Set this manually if there are extra servos needing manual control.
* Set to 0 to turn off servo support. * Leave undefined or set to 0 to entirely disable the servo subsystem.
*/ */
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
@ -2416,5 +2325,5 @@
// Only power servos during movement, otherwise leave off to prevent jitter // Only power servos during movement, otherwise leave off to prevent jitter
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
// Edit servo angles with M281 and save to EEPROM with M500 // Allow servo angle to be edited and saved to EEPROM
//#define EDITABLE_SERVO_ANGLES //#define EDITABLE_SERVO_ANGLES

View file

@ -29,13 +29,15 @@
* Some of these settings can damage your printer if improperly set! * Some of these settings can damage your printer if improperly set!
* *
* Basic settings can be found in Configuration.h * Basic settings can be found in Configuration.h
*
*/ */
#define CONFIGURATION_ADV_H_VERSION 020007 #define CONFIGURATION_ADV_H_VERSION 020006
// @section temperature
//=========================================================================== //===========================================================================
//============================= Thermal Settings ============================ //============================= Thermal Settings ============================
//=========================================================================== //===========================================================================
// @section temperature
/** /**
* Thermocouple sensors are quite sensitive to noise. Any noise induced in * Thermocouple sensors are quite sensitive to noise. Any noise induced in
@ -124,19 +126,9 @@
#define HEATER_BED_INVERTING true #define HEATER_BED_INVERTING true
#endif #endif
// /**
// Heated Bed Bang-Bang options * Heated Chamber settings
// */
#if DISABLED(PIDTEMPBED)
#define BED_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control
#if ENABLED(BED_LIMIT_SWITCHING)
#define BED_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > BED_HYSTERESIS
#endif
#endif
//
// Heated Chamber options
//
#if TEMP_SENSOR_CHAMBER #if TEMP_SENSOR_CHAMBER
#define CHAMBER_MINTEMP 5 #define CHAMBER_MINTEMP 5
#define CHAMBER_MAXTEMP 60 #define CHAMBER_MAXTEMP 60
@ -144,28 +136,12 @@
//#define CHAMBER_LIMIT_SWITCHING //#define CHAMBER_LIMIT_SWITCHING
//#define HEATER_CHAMBER_PIN 44 // Chamber heater on/off pin //#define HEATER_CHAMBER_PIN 44 // Chamber heater on/off pin
//#define HEATER_CHAMBER_INVERTING false //#define HEATER_CHAMBER_INVERTING false
#endif
//#define CHAMBER_FAN // Enable a fan on the chamber #if DISABLED(PIDTEMPBED)
#if ENABLED(CHAMBER_FAN) #define BED_CHECK_INTERVAL 5000 // ms between checks in bang-bang control
#define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve. #if ENABLED(BED_LIMIT_SWITCHING)
#if CHAMBER_FAN_MODE == 0 #define BED_HYSTERESIS 2 // Only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
#define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255)
#elif CHAMBER_FAN_MODE == 1
#define CHAMBER_FAN_BASE 128 // Base chamber fan PWM (0-255); turns on when chamber temperature is above the target
#define CHAMBER_FAN_FACTOR 25 // PWM increase per °C above target
#elif CHAMBER_FAN_MODE == 2
#define CHAMBER_FAN_BASE 128 // Minimum chamber fan PWM (0-255)
#define CHAMBER_FAN_FACTOR 25 // PWM increase per °C difference from target
#endif
#endif
//#define CHAMBER_VENT // Enable a servo-controlled vent on the chamber
#if ENABLED(CHAMBER_VENT)
#define CHAMBER_VENT_SERVO_NR 1 // Index of the vent servo
#define HIGH_EXCESS_HEAT_LIMIT 5 // How much above target temp to consider there is excess heat in the chamber
#define LOW_EXCESS_HEAT_LIMIT 3
#define MIN_COOLING_SLOPE_TIME_CHAMBER_VENT 20
#define MIN_COOLING_SLOPE_DEG_CHAMBER_VENT 1.5
#endif #endif
#endif #endif
@ -363,7 +339,7 @@
#if ENABLED(EXTRUDER_RUNOUT_PREVENT) #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
#define EXTRUDER_RUNOUT_MINTEMP 190 #define EXTRUDER_RUNOUT_MINTEMP 190
#define EXTRUDER_RUNOUT_SECONDS 30 #define EXTRUDER_RUNOUT_SECONDS 30
#define EXTRUDER_RUNOUT_SPEED 1500 // (mm/min) #define EXTRUDER_RUNOUT_SPEED 1500 // (mm/m)
#define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm) #define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm)
#endif #endif
@ -512,7 +488,7 @@
//#define CASE_LIGHT_MAX_PWM 128 // Limit pwm //#define CASE_LIGHT_MAX_PWM 128 // Limit pwm
//#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu //#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_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting.
//#define CASE_LIGHT_USE_NEOPIXEL // Use NeoPixel LED as case light, requires NEOPIXEL_LED. //#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED.
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL) #if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White } #define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White }
#endif #endif
@ -704,7 +680,7 @@
* Danger: Don't activate 5V mode unless attached to a 5V-tolerant controller! * 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. * 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 * If disabled, OD mode is the hard-coded default on 3.0
* On startup, Marlin will compare its eeprom to this value. If the selected mode * 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. * 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. * Use the option below to force an eeprom write to a V3.1 probe regardless.
*/ */
@ -762,6 +738,7 @@
* | 4 3 | 1 4 | 2 1 | 3 2 | * | 4 3 | 1 4 | 2 1 | 3 2 |
* | | | | | * | | | | |
* | 1 2 | 2 3 | 3 4 | 4 1 | * | 1 2 | 2 3 | 3 4 | 4 1 |
*
*/ */
#ifndef Z_STEPPER_ALIGN_XY #ifndef Z_STEPPER_ALIGN_XY
//#define Z_STEPPERS_ORIENTATION 0 //#define Z_STEPPERS_ORIENTATION 0
@ -792,7 +769,7 @@
#endif #endif
// //
// Add the G35 command to read bed corners to help adjust screws. Requires a bed probe. // Add the G35 command to read bed corners to help adjust screws.
// //
//#define ASSISTED_TRAMMING //#define ASSISTED_TRAMMING
#if ENABLED(ASSISTED_TRAMMING) #if ENABLED(ASSISTED_TRAMMING)
@ -806,9 +783,8 @@
#define TRAMMING_POINT_NAME_3 "Back-Right" #define TRAMMING_POINT_NAME_3 "Back-Right"
#define TRAMMING_POINT_NAME_4 "Back-Left" #define TRAMMING_POINT_NAME_4 "Back-Left"
#define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation // Enable to restore leveling setup after operation
//#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first #define RESTORE_LEVELING_AFTER_G35
//#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item for Assisted Tramming
/** /**
* Screw thread: * Screw thread:
@ -833,30 +809,24 @@
#define INVERT_Z_STEP_PIN false #define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false #define INVERT_E_STEP_PIN false
/** // Default stepper release if idle. Set to 0 to deactivate.
* Idle Stepper Shutdown // Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true.
* Set DISABLE_INACTIVE_? 'true' to shut down axis steppers after an idle period. // Time can be set by M18 and M84.
* The Deactive Time can be overridden with M18 and M84. Set to 0 for No Timeout.
*/
#define DEFAULT_STEPPER_DEACTIVE_TIME 120 #define DEFAULT_STEPPER_DEACTIVE_TIME 120
#define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Y true
#define DISABLE_INACTIVE_Z true // Set 'false' if the nozzle could fall onto your printed part! #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 DISABLE_INACTIVE_E true
// If the Nozzle or Bed falls when the Z stepper is disabled, set its resting position here. #define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
//#define Z_AFTER_DEACTIVATE Z_HOME_POS #define DEFAULT_MINTRAVELFEEDRATE 0.0
//#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated //#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated
// Default Minimum Feedrates for printing and travel moves // Minimum time that a segment needs to take if the buffer is emptied
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S. #define DEFAULT_MINSEGMENTTIME 20000 // (µs)
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T.
// Minimum time that a segment needs to take as the buffer gets emptied // Slow down the machine if the look ahead buffer is (by default) half full.
#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B.
// Slow down the machine if the lookahead buffer is (by default) half full.
// Increase the slowdown divisor for larger buffer sizes. // Increase the slowdown divisor for larger buffer sizes.
#define SLOWDOWN #define SLOWDOWN
#if ENABLED(SLOWDOWN) #if ENABLED(SLOWDOWN)
@ -907,7 +877,7 @@
// increments while checking for the contact to be broken. // increments while checking for the contact to be broken.
#define BACKLASH_MEASUREMENT_LIMIT 0.5 // (mm) #define BACKLASH_MEASUREMENT_LIMIT 0.5 // (mm)
#define BACKLASH_MEASUREMENT_RESOLUTION 0.005 // (mm) #define BACKLASH_MEASUREMENT_RESOLUTION 0.005 // (mm)
#define BACKLASH_MEASUREMENT_FEEDRATE Z_PROBE_SPEED_SLOW // (mm/min) #define BACKLASH_MEASUREMENT_FEEDRATE Z_PROBE_SPEED_SLOW // (mm/m)
#endif #endif
#endif #endif
#endif #endif
@ -933,9 +903,9 @@
#define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm #define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm
#define CALIBRATION_FEEDRATE_SLOW 60 // mm/min #define CALIBRATION_FEEDRATE_SLOW 60 // mm/m
#define CALIBRATION_FEEDRATE_FAST 1200 // mm/min #define CALIBRATION_FEEDRATE_FAST 1200 // mm/m
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/m
// The following parameters refer to the conical section of the nozzle tip. // The following parameters refer to the conical section of the nozzle tip.
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm #define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm
@ -1049,7 +1019,7 @@
// @section lcd // @section lcd
#if EITHER(ULTIPANEL, EXTENSIBLE_UI) #if EITHER(ULTIPANEL, EXTENSIBLE_UI)
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel #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) #define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm)
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
#define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position" #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position"
@ -1073,14 +1043,6 @@
#if HAS_LCD_MENU #if HAS_LCD_MENU
// Add Probe Z Offset calibration to the Z Probe Offsets menu
#if HAS_BED_PROBE
//#define PROBE_OFFSET_WIZARD
#if ENABLED(PROBE_OFFSET_WIZARD)
#define PROBE_OFFSET_START -4.0 // Estimated nozzle-to-probe Z offset, plus a little extra
#endif
#endif
// Include a page of printer information in the LCD Main Menu // Include a page of printer information in the LCD Main Menu
//#define LCD_INFO_MENU //#define LCD_INFO_MENU
#if ENABLED(LCD_INFO_MENU) #if ENABLED(LCD_INFO_MENU)
@ -1097,7 +1059,6 @@
//#define LED_CONTROL_MENU //#define LED_CONTROL_MENU
#if ENABLED(LED_CONTROL_MENU) #if ENABLED(LED_CONTROL_MENU)
#define LED_COLOR_PRESETS // Enable the Preset Color menu option #define LED_COLOR_PRESETS // Enable the Preset Color menu option
//#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option
#if ENABLED(LED_COLOR_PRESETS) #if ENABLED(LED_COLOR_PRESETS)
#define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_RED 255 // User defined RED value
#define LED_USER_PRESET_GREEN 128 // User defined GREEN value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value
@ -1106,14 +1067,6 @@
#define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
#endif #endif
#if ENABLED(NEO2_COLOR_PRESETS)
#define NEO2_USER_PRESET_RED 255 // User defined RED value
#define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value
#define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value
#define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value
#define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip
#endif
#endif #endif
#endif // HAS_LCD_MENU #endif // HAS_LCD_MENU
@ -1137,26 +1090,23 @@
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif #endif
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
//#define SHOW_REMAINING_TIME // Display estimated time to completion //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
//#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME) #if ENABLED(SHOW_REMAINING_TIME)
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
#endif #endif
#endif
#if HAS_MARLINUI_U8GLIB #if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
#endif #if ENABLED(LCD_PROGRESS_BAR)
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
#if ENABLED(LCD_PROGRESS_BAR) //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
#define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
#endif
#endif #endif
#endif #endif
@ -1181,7 +1131,7 @@
//#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files //#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files
#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") #define EVENT_GCODE_SD_STOP "G28XY" // G-code to run on Stop Print (e.g., "G28XY" or "G27")
#if ENABLED(PRINTER_EVENT_LEDS) #if ENABLED(PRINTER_EVENT_LEDS)
#define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination #define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination
@ -1199,7 +1149,6 @@
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) #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 BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
//#define POWER_LOSS_RECOVER_ZHOME // Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS) //#define POWER_LOSS_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_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_STATE HIGH // State of pin indicating power loss
@ -1360,7 +1309,7 @@
* controller events, as there is a trade-off between reliable * controller events, as there is a trade-off between reliable
* printing performance versus fast display updates. * printing performance versus fast display updates.
*/ */
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
// Show SD percentage next to the progress bar // Show SD percentage next to the progress bar
//#define DOGM_SD_PERCENT //#define DOGM_SD_PERCENT
@ -1375,7 +1324,7 @@
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese. // 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 2434 bytes of PROGMEM. // A smaller font may be used on the Info Screen. Costs 2300 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese. // Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_SMALL_INFOFONT //#define USE_SMALL_INFOFONT
@ -1430,18 +1379,18 @@
//#define MARLIN_SNAKE //#define MARLIN_SNAKE
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu //#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
// //
// Additional options for DGUS / DWIN displays // Additional options for DGUS / DWIN displays
// //
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define LCD_SERIAL_PORT 3 #define DGUS_SERIAL_PORT 3
#define LCD_BAUDRATE 115200 #define DGUS_BAUDRATE 115200
#define DGUS_RX_BUFFER_SIZE 128 #define DGUS_RX_BUFFER_SIZE 128
#define DGUS_TX_BUFFER_SIZE 48 #define DGUS_TX_BUFFER_SIZE 48
//#define SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR) //#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates #define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
@ -1560,9 +1509,9 @@
#endif #endif
// //
// Classic UI Options // FSMC Graphical TFT
// //
#if TFT_SCALED_DOGLCD #if ENABLED(FSMC_GRAPHICAL_TFT)
//#define TFT_MARLINUI_COLOR 0xFFFF // White //#define TFT_MARLINUI_COLOR 0xFFFF // White
//#define TFT_MARLINBG_COLOR 0x0000 // Black //#define TFT_MARLINBG_COLOR 0x0000 // Black
//#define TFT_DISABLED_COLOR 0x0003 // Almost black //#define TFT_DISABLED_COLOR 0x0003 // Almost black
@ -1607,7 +1556,6 @@
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
//#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR //#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
//#define BABYSTEP_WITHOUT_HOMING //#define BABYSTEP_WITHOUT_HOMING
//#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! //#define BABYSTEP_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_INVERT_Z false // Change if Z babysteps should go the other way
//#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps
@ -1618,6 +1566,7 @@
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
// Note: Extra time may be added to mitigate controller latency. // 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. //#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle.
#if ENABLED(MOVE_Z_WHEN_IDLE) #if ENABLED(MOVE_Z_WHEN_IDLE)
#define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size. #define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size.
@ -1800,7 +1749,6 @@
#define N_ARC_CORRECTION 25 // Number of interpolated segments between corrections #define N_ARC_CORRECTION 25 // Number of interpolated segments between corrections
//#define ARC_P_CIRCLES // Enable the 'P' parameter to specify complete circles //#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 CNC_WORKSPACE_PLANES // Allow G2/G3 to operate in XY, ZX, or YZ planes
//#define SF_ARC_FIX // Enable only if using SkeinForge with "Arc Point" fillet procedure
#endif #endif
// Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes. // Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes.
@ -1986,6 +1934,7 @@
* Be sure to turn off auto-retract during filament change. * Be sure to turn off auto-retract during filament change.
* *
* Note that M207 / M208 / M209 settings are saved to EEPROM. * Note that M207 / M208 / M209 settings are saved to EEPROM.
*
*/ */
//#define FWRETRACT //#define FWRETRACT
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
@ -2011,7 +1960,7 @@
* Universal tool change settings. * Universal tool change settings.
* Applies to all types of extruders except where explicitly noted. * Applies to all types of extruders except where explicitly noted.
*/ */
#if HAS_MULTI_EXTRUDER #if EXTRUDERS > 1
// Z raise distance for tool-change, as needed for some extruders // 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_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
@ -2029,13 +1978,13 @@
// Load / Unload // Load / Unload
#define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length #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_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode)
#define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/m) (Unloading)
#define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) #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 // Longer prime to clean out a SINGLENOZZLE
#define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length
#define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/m) Extra priming feedrate
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/min) Retract before cooling for less stringing, better wipe, etc. #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/m) Retract before cooling for less stringing, better wipe, etc.
// Cool after prime to reduce stringing // Cool after prime to reduce stringing
#define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip
@ -2071,11 +2020,11 @@
//#define TOOLCHANGE_PARK //#define TOOLCHANGE_PARK
#if ENABLED(TOOLCHANGE_PARK) #if ENABLED(TOOLCHANGE_PARK)
#define TOOLCHANGE_PARK_XY { X_MIN_POS + 10, Y_MIN_POS + 10 } #define TOOLCHANGE_PARK_XY { X_MIN_POS + 10, Y_MIN_POS + 10 }
#define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/min) #define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/m)
//#define TOOLCHANGE_PARK_X_ONLY // X axis only move //#define TOOLCHANGE_PARK_X_ONLY // X axis only move
//#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move
#endif #endif
#endif // HAS_MULTI_EXTRUDER #endif // EXTRUDERS > 1
/** /**
* Advanced Pause * Advanced Pause
@ -2468,7 +2417,7 @@
* CHOPPER_DEFAULT_24V * CHOPPER_DEFAULT_24V
* CHOPPER_DEFAULT_36V * CHOPPER_DEFAULT_36V
* CHOPPER_09STEP_24V // 0.9 degree steppers (24V) * CHOPPER_09STEP_24V // 0.9 degree steppers (24V)
* CHOPPER_PRUSAMK3_24V // Imported parameters from the official Průša firmware for MK3 (24V) * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Prusa firmware for MK3 (24V)
* CHOPPER_MARLIN_119 // Old defaults from Marlin v1.1.9 * CHOPPER_MARLIN_119 // Old defaults from Marlin v1.1.9
* *
* Define you own with * Define you own with
@ -2522,7 +2471,7 @@
#define E7_HYBRID_THRESHOLD 30 #define E7_HYBRID_THRESHOLD 30
/** /**
* Use StallGuard to home / probe X, Y, Z. * Use StallGuard2 to home / probe X, Y, Z.
* *
* TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only * TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
* Connect the stepper driver's DIAG1 pin to the X/Y endstop pin. * Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
@ -2543,8 +2492,6 @@
* *
* IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when * IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
* homing and adds a guard period for endstop triggering. * homing and adds a guard period for endstop triggering.
*
* Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis.
*/ */
//#define SENSORLESS_HOMING // StallGuard capable drivers only //#define SENSORLESS_HOMING // StallGuard capable drivers only
@ -2897,7 +2844,7 @@
//#define SPINDLE_FEATURE //#define SPINDLE_FEATURE
//#define LASER_FEATURE //#define LASER_FEATURE
#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) #if EITHER(SPINDLE_FEATURE, LASER_FEATURE)
#define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if the on/off function is active HIGH #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 true // Set to "true" if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower
@ -3197,7 +3144,7 @@
//#define GCODE_MOTION_MODES // Remember the motion mode (G0 G1 G2 G3 G5 G38.X) and apply for X Y Z E F, etc. //#define GCODE_MOTION_MODES // Remember the motion mode (G0 G1 G2 G3 G5 G38.X) and apply for X Y Z E F, etc.
// Enable and set a (default) feedrate for all G0 moves // Enable and set a (default) feedrate for all G0 moves
//#define G0_FEEDRATE 3000 // (mm/min) //#define G0_FEEDRATE 3000 // (mm/m)
#ifdef G0_FEEDRATE #ifdef G0_FEEDRATE
//#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode //#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode
#endif #endif
@ -3264,7 +3211,6 @@
//#define HOST_ACTION_COMMANDS //#define HOST_ACTION_COMMANDS
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
//#define HOST_PROMPT_SUPPORT //#define HOST_PROMPT_SUPPORT
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
#endif #endif
/** /**
@ -3372,26 +3318,6 @@
#define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max #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_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 } #define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
//#define JOYSTICK_DEBUG
#endif
/**
* Mechanical Gantry Calibration
* Modern replacement for the Prusa TMC_Z_CALIBRATION.
* Adds capability to work with any adjustable current drivers.
* Implemented as G34 because M915 is deprecated.
*/
//#define MECHANICAL_GANTRY_CALIBRATION
#if ENABLED(MECHANICAL_GANTRY_CALIBRATION)
#define GANTRY_CALIBRATION_CURRENT 600 // Default calibration current in ma
#define GANTRY_CALIBRATION_EXTRA_HEIGHT 15 // Extra distance in mm past Z_###_POS to move
#define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move
//#define GANTRY_CALIBRATION_TO_MIN // Enable to calibrate Z in the MIN direction
//#define GANTRY_CALIBRATION_SAFE_POSITION { X_CENTER, Y_CENTER } // Safe position for nozzle
//#define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM
//#define GANTRY_CALIBRATION_COMMANDS_PRE ""
#define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position
#endif #endif
/** /**
@ -3463,16 +3389,16 @@
#endif #endif
/** /**
* Průša Multi-Material Unit v2 * Prusa Multi-Material Unit v2
* Enable in Configuration.h * Enable in Configuration.h
*/ */
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
// Serial port used for communication with MMU2. // Serial port used for communication with MMU2.
// For AVR enable the UART port used for the MMU. (e.g., mmuSerial) // For AVR enable the UART port used for the MMU. (e.g., internalSerial)
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2) // For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
#define MMU2_SERIAL_PORT 2 #define INTERNAL_SERIAL_PORT 2
#define MMU2_SERIAL mmuSerial #define MMU2_SERIAL internalSerial
// Use hardware reset for MMU if a pin is defined for it // Use hardware reset for MMU if a pin is defined for it
//#define MMU2_RST_PIN 23 //#define MMU2_RST_PIN 23
@ -3487,7 +3413,7 @@
//#define MMU2_MENUS //#define MMU2_MENUS
#if ENABLED(MMU2_MENUS) #if ENABLED(MMU2_MENUS)
// Settings for filament load / unload from the LCD menu. // Settings for filament load / unload from the LCD menu.
// This is for Průša MK3-style extruders. Customize for your hardware. // This is for Prusa MK3-style extruders. Customize for your hardware.
#define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0 #define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0
#define MMU2_LOAD_TO_NOZZLE_SEQUENCE \ #define MMU2_LOAD_TO_NOZZLE_SEQUENCE \
{ 7.2, 1145 }, \ { 7.2, 1145 }, \
@ -3513,7 +3439,7 @@
/** /**
* MMU Extruder Sensor * MMU Extruder Sensor
* *
* Support for a Průša (or other) IR Sensor to detect filament near the extruder * Support for a Prusa (or other) IR Sensor to detect filament near the extruder
* and make loading more reliable. Suitable for an extruder equipped with a filament * and make loading more reliable. Suitable for an extruder equipped with a filament
* sensor less than 38mm from the gears. * sensor less than 38mm from the gears.
* *
@ -3523,7 +3449,7 @@
*/ */
//#define MMU_EXTRUDER_SENSOR //#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU_EXTRUDER_SENSOR) #if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail #define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail
#endif #endif
/** /**
@ -3535,7 +3461,7 @@
#if ENABLED(PRUSA_MMU2_S_MODE) #if ENABLED(PRUSA_MMU2_S_MODE)
#define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries)
#define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min) #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/m)
#define MMU2_CAN_LOAD_SEQUENCE \ #define MMU2_CAN_LOAD_SEQUENCE \
{ 0.1, MMU2_CAN_LOAD_FEEDRATE }, \ { 0.1, MMU2_CAN_LOAD_FEEDRATE }, \
{ 60.0, MMU2_CAN_LOAD_FEEDRATE }, \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \
@ -3575,11 +3501,6 @@
// //
//#define M100_FREE_MEMORY_WATCHER //#define M100_FREE_MEMORY_WATCHER
//
// M42 - Set pin states
//
//#define DIRECT_PIN_CONTROL
// //
// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
// //

View file

@ -22,10 +22,8 @@
# (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file # (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
# changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*). # changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*).
# #
# 3. Set the line containing "MCU" to match your board's processor. Set # 3. Set the line containing "MCU" to match your board's processor.
# "PROG_MCU" as the AVR part name corresponding to "MCU". You can use the # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
# following command to get a list of correspondences: `avrdude -c alf -p x`
# Older boards are atmega8 based, newer ones like Arduino Mini, Bluetooth
# or Diecimila have the atmega168. If you're using a LilyPad Arduino, # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
# change F_CPU to 8000000. If you are using Gen7 electronics, you # change F_CPU to 8000000. If you are using Gen7 electronics, you
# probably need to use 20000000. Either way, you must regenerate # probably need to use 20000000. Either way, you must regenerate
@ -36,18 +34,18 @@
# 5. Type "make upload", reset your Arduino board, and press enter to # 5. Type "make upload", reset your Arduino board, and press enter to
# upload your program to the Arduino board. # upload your program to the Arduino board.
# #
# Note that all settings at the top of this file can be overridden from # Note that all settings at the top of this file can be overriden from
# the command line with, for example, "make HARDWARE_MOTHERBOARD=71" # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
# #
# To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use... # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
# #
# make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \ # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
# HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino
# #
# To compile and upload simply add "upload" to the end of the line... # To compile and upload simply add "upload" to the end of the line...
# #
# make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \ # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
# HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino upload # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino upload
# #
# If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
# start upload manually (using stk500) like so: # start upload manually (using stk500) like so:
@ -59,26 +57,7 @@
# #
# This defines the board to compile for (see boards.h for your board's ID) # This defines the board to compile for (see boards.h for your board's ID)
HARDWARE_MOTHERBOARD ?= 1020 HARDWARE_MOTHERBOARD ?= 11
ifeq ($(OS),Windows_NT)
# Windows
ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
ARDUINO_USER_DIR ?= ${HOME}/Arduino
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
# Linux
ARDUINO_INSTALL_DIR ?= /usr/share/arduino
ARDUINO_USER_DIR ?= ${HOME}/Arduino
endif
ifeq ($(UNAME_S),Darwin)
# Darwin (macOS)
ARDUINO_INSTALL_DIR ?= /Applications/Arduino.app/Contents/Java
ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
AVR_TOOLS_PATH ?= /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/
endif
endif
# Arduino source install directory, and version number # Arduino source install directory, and version number
# On most linuxes this will be /usr/share/arduino # On most linuxes this will be /usr/share/arduino
@ -88,38 +67,32 @@ ARDUINO_VERSION ?= 106
# The installed Libraries are in the User folder # The installed Libraries are in the User folder
ARDUINO_USER_DIR ?= ${HOME}/Arduino ARDUINO_USER_DIR ?= ${HOME}/Arduino
# You can optionally set a path to the avr-gcc tools. # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
# Requires a trailing slash. For example, /usr/local/avr-gcc/bin/
AVR_TOOLS_PATH ?= AVR_TOOLS_PATH ?=
# Programmer configuration #Programmer configuration
UPLOAD_RATE ?= 57600 UPLOAD_RATE ?= 57600
AVRDUDE_PROGRAMMER ?= arduino AVRDUDE_PROGRAMMER ?= arduino
# On most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1 # on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
UPLOAD_PORT ?= /dev/ttyUSB0 UPLOAD_PORT ?= /dev/ttyUSB0
# Directory used to build files in, contains all the build files, from object #Directory used to build files in, contains all the build files, from object files to the final hex file
# files to the final hex file on linux it is best to put an absolute path #on linux it is best to put an absolute path like /home/username/tmp .
# like /home/username/tmp .
BUILD_DIR ?= applet BUILD_DIR ?= applet
# This defines whether Liquid_TWI2 support will be built # This defines whether Liquid_TWI2 support will be built
LIQUID_TWI2 ?= 0 LIQUID_TWI2 ?= 0
# This defines if Wire is needed # this defines if Wire is needed
WIRE ?= 0 WIRE ?= 0
# This defines if Tone is needed (i.e SPEAKER is defined in Configuration.h) # this defines if U8GLIB is needed (may require RELOC_WORKAROUND)
# Disabling this (and SPEAKER) saves approximatively 350 bytes of memory. U8GLIB ?= 1
TONE ?= 1
# This defines if U8GLIB is needed (may require RELOC_WORKAROUND) # this defines whether to include the Trinamic TMCStepper library
U8GLIB ?= 0 TMC ?= 1
# This defines whether to include the Trinamic TMCStepper library # this defines whether to include the AdaFruit NeoPixel library
TMC ?= 0
# This defines whether to include the AdaFruit NeoPixel library
NEOPIXEL ?= 0 NEOPIXEL ?= 0
############ ############
@ -197,115 +170,110 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1100)
else ifeq ($(HARDWARE_MOTHERBOARD),1101) else ifeq ($(HARDWARE_MOTHERBOARD),1101)
# Velleman K8400 Controller (derived from 3Drag Controller) # Velleman K8400 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1102) else ifeq ($(HARDWARE_MOTHERBOARD),1102)
# Velleman K8600 Controller (Vertex Nano) # Velleman K8600 Controller (derived from 3Drag Controller)
else ifeq ($(HARDWARE_MOTHERBOARD),1103) else ifeq ($(HARDWARE_MOTHERBOARD),1103)
# Velleman K8800 Controller (Vertex Delta)
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# 2PrintBeta BAM&DICE with STK drivers # 2PrintBeta BAM&DICE with STK drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1105) else ifeq ($(HARDWARE_MOTHERBOARD),1104)
# 2PrintBeta BAM&DICE Due with STK drivers # 2PrintBeta BAM&DICE Due with STK drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1106) else ifeq ($(HARDWARE_MOTHERBOARD),1105)
# MKS BASE v1.0 # MKS BASE v1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1107) else ifeq ($(HARDWARE_MOTHERBOARD),1106)
# MKS v1.4 with A4982 stepper drivers # MKS v1.4 with A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1108) else ifeq ($(HARDWARE_MOTHERBOARD),1107)
# MKS v1.5 with Allegro A4982 stepper drivers # MKS v1.5 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1109) else ifeq ($(HARDWARE_MOTHERBOARD),1108)
# MKS v1.6 with Allegro A4982 stepper drivers # MKS v1.6 with Allegro A4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1110) else ifeq ($(HARDWARE_MOTHERBOARD),1109)
# MKS BASE 1.0 with Heroic HR4982 stepper drivers # MKS BASE 1.0 with Heroic HR4982 stepper drivers
else ifeq ($(HARDWARE_MOTHERBOARD),1111) else ifeq ($(HARDWARE_MOTHERBOARD),1110)
# MKS GEN v1.3 or 1.4 # MKS GEN v1.3 or 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1112) else ifeq ($(HARDWARE_MOTHERBOARD),1111)
# MKS GEN L # MKS GEN L
else ifeq ($(HARDWARE_MOTHERBOARD),1113) else ifeq ($(HARDWARE_MOTHERBOARD),1112)
# zrib V2.0 control board (Chinese knock off RAMPS replica) # zrib V2.0 control board (Chinese knock off RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1114) else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# BigTreeTech or BIQU KFB2.0 # BigTreeTech or BIQU KFB2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1115) else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# Felix 2.0+ Electronics Board (RAMPS like) # Felix 2.0+ Electronics Board (RAMPS like)
else ifeq ($(HARDWARE_MOTHERBOARD),1116) else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# Invent-A-Part RigidBoard # Invent-A-Part RigidBoard
else ifeq ($(HARDWARE_MOTHERBOARD),1117) else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Invent-A-Part RigidBoard V2 # Invent-A-Part RigidBoard V2
else ifeq ($(HARDWARE_MOTHERBOARD),1118) else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Sainsmart 2-in-1 board # Sainsmart 2-in-1 board
else ifeq ($(HARDWARE_MOTHERBOARD),1119) else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Ultimaker # Ultimaker
else ifeq ($(HARDWARE_MOTHERBOARD),1120) else ifeq ($(HARDWARE_MOTHERBOARD),1119)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare) # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
else ifeq ($(HARDWARE_MOTHERBOARD),1121) else ifeq ($(HARDWARE_MOTHERBOARD),1120)
MCU ?= atmega1280 MCU ?= atmega1280
PROG_MCU ?= m1280
# Azteeg X3 # Azteeg X3
else ifeq ($(HARDWARE_MOTHERBOARD),1122) else ifeq ($(HARDWARE_MOTHERBOARD),1121)
# Azteeg X3 Pro # Azteeg X3 Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1123) else ifeq ($(HARDWARE_MOTHERBOARD),1122)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20) # Ultimainboard 2.x (Uses TEMP_SENSOR 20)
else ifeq ($(HARDWARE_MOTHERBOARD),1124) else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Rumba # Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1125) else ifeq ($(HARDWARE_MOTHERBOARD),1124)
# Raise3D Rumba # Raise3D Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1126) else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Rapide Lite RL200 Rumba # Rapide Lite RL200 Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1127) else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Formbot T-Rex 2 Plus # Formbot T-Rex 2 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1128) else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Formbot T-Rex 3 # Formbot T-Rex 3
else ifeq ($(HARDWARE_MOTHERBOARD),1129) else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot Raptor # Formbot Raptor
else ifeq ($(HARDWARE_MOTHERBOARD),1130) else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# Formbot Raptor 2 # Formbot Raptor 2
else ifeq ($(HARDWARE_MOTHERBOARD),1131) else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# bq ZUM Mega 3D # bq ZUM Mega 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1132) else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake # MakeBoard Mini v2.1.2 is a control board sold by MicroMake
else ifeq ($(HARDWARE_MOTHERBOARD),1133) else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# TriGorilla Anycubic version 1.3 based on RAMPS EFB # TriGorilla Anycubic version 1.3 based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1134) else ifeq ($(HARDWARE_MOTHERBOARD),1133)
# TriGorilla Anycubic version 1.4 based on RAMPS EFB # TriGorilla Anycubic version 1.4 based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1135) else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# TriGorilla Anycubic version 1.4 Rev 1.1 # TriGorilla Anycubic version 1.4 Rev 1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1136) else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# Creality: Ender-4, CR-8 # Creality: Ender-4, CR-8
else ifeq ($(HARDWARE_MOTHERBOARD),1137) else ifeq ($(HARDWARE_MOTHERBOARD),1136)
# Creality: CR10S, CR20, CR-X # Creality: CR10S, CR20, CR-X
else ifeq ($(HARDWARE_MOTHERBOARD),1138) else ifeq ($(HARDWARE_MOTHERBOARD),1137)
# Dagoma F5 # Dagoma F5
else ifeq ($(HARDWARE_MOTHERBOARD),1139) else ifeq ($(HARDWARE_MOTHERBOARD),1138)
# FYSETC F6 1.3 # FYSETC F6 1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1140) else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# FYSETC F6 1.5 # FYSETC F6 1.5
else ifeq ($(HARDWARE_MOTHERBOARD),1141) else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# Duplicator i3 Plus # Duplicator i3 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1142) else ifeq ($(HARDWARE_MOTHERBOARD),1141)
# VORON # VORON
else ifeq ($(HARDWARE_MOTHERBOARD),1143) else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# TRONXY V3 1.0 # TRONXY V3 1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1144) else ifeq ($(HARDWARE_MOTHERBOARD),1143)
# Z-Bolt X Series # Z-Bolt X Series
else ifeq ($(HARDWARE_MOTHERBOARD),1145) else ifeq ($(HARDWARE_MOTHERBOARD),1144)
# TT OSCAR # TT OSCAR
else ifeq ($(HARDWARE_MOTHERBOARD),1146) else ifeq ($(HARDWARE_MOTHERBOARD),1145)
# Overlord/Overlord Pro # Overlord/Overlord Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1147) else ifeq ($(HARDWARE_MOTHERBOARD),1146)
# ADIMLab Gantry v1 # ADIMLab Gantry v1
else ifeq ($(HARDWARE_MOTHERBOARD),1148) else ifeq ($(HARDWARE_MOTHERBOARD),1147)
# ADIMLab Gantry v2 # ADIMLab Gantry v2
else ifeq ($(HARDWARE_MOTHERBOARD),1149) else ifeq ($(HARDWARE_MOTHERBOARD),1148)
# BIQU Tango V1 # BIQU Tango V1
else ifeq ($(HARDWARE_MOTHERBOARD),1150) else ifeq ($(HARDWARE_MOTHERBOARD),1149)
# MKS GEN L V2 # MKS GEN L V2
else ifeq ($(HARDWARE_MOTHERBOARD),1151) else ifeq ($(HARDWARE_MOTHERBOARD),1150)
# MKS GEN L V2.1
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# Copymaster 3D # Copymaster 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1153) else ifeq ($(HARDWARE_MOTHERBOARD),1151)
# Ortur 4 # Ortur 4
else ifeq ($(HARDWARE_MOTHERBOARD),1154) else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# Tenlog D3 Hero # Tenlog D3 Hero
else ifeq ($(HARDWARE_MOTHERBOARD),1155) else ifeq ($(HARDWARE_MOTHERBOARD),1153)
# #
# RAMBo and derivatives # RAMBo and derivatives
@ -378,11 +346,9 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1320)
# Minitronics v1.0/1.1 # Minitronics v1.0/1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1400) else ifeq ($(HARDWARE_MOTHERBOARD),1400)
MCU ?= atmega1281 MCU ?= atmega1281
PROG_MCU ?= m1281
# Silvergate v1.0 # Silvergate v1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1401) else ifeq ($(HARDWARE_MOTHERBOARD),1401)
MCU ?= atmega1281 MCU ?= atmega1281
PROG_MCU ?= m1281
# #
# Sanguinololu and Derivatives - ATmega644P, ATmega1284P # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
@ -392,57 +358,46 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1401)
else ifeq ($(HARDWARE_MOTHERBOARD),1500) else ifeq ($(HARDWARE_MOTHERBOARD),1500)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Sanguinololu 1.2 and above # Sanguinololu 1.2 and above
else ifeq ($(HARDWARE_MOTHERBOARD),1501) else ifeq ($(HARDWARE_MOTHERBOARD),1501)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Melzi # Melzi
else ifeq ($(HARDWARE_MOTHERBOARD),1502) else ifeq ($(HARDWARE_MOTHERBOARD),1502)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Melzi V2.0 # Melzi V2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1503) else ifeq ($(HARDWARE_MOTHERBOARD),1503)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Melzi with ATmega1284 (MaKr3d version) # Melzi with ATmega1284 (MaKr3d version)
else ifeq ($(HARDWARE_MOTHERBOARD),1504) else ifeq ($(HARDWARE_MOTHERBOARD),1504)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Melzi Creality3D board (for CR-10 etc) # Melzi Creality3D board (for CR-10 etc)
else ifeq ($(HARDWARE_MOTHERBOARD),1505) else ifeq ($(HARDWARE_MOTHERBOARD),1505)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Melzi Malyan M150 board # Melzi Malyan M150 board
else ifeq ($(HARDWARE_MOTHERBOARD),1506) else ifeq ($(HARDWARE_MOTHERBOARD),1506)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Tronxy X5S # Tronxy X5S
else ifeq ($(HARDWARE_MOTHERBOARD),1507) else ifeq ($(HARDWARE_MOTHERBOARD),1507)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# STB V1.1 # STB V1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1508) else ifeq ($(HARDWARE_MOTHERBOARD),1508)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Azteeg X1 # Azteeg X1
else ifeq ($(HARDWARE_MOTHERBOARD),1509) else ifeq ($(HARDWARE_MOTHERBOARD),1509)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Anet 1.0 (Melzi clone) # Anet 1.0 (Melzi clone)
else ifeq ($(HARDWARE_MOTHERBOARD),1510) else ifeq ($(HARDWARE_MOTHERBOARD),1510)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
# #
# Other ATmega644P, ATmega644, ATmega1284P # Other ATmega644P, ATmega644, ATmega1284P
@ -452,61 +407,50 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1510)
else ifeq ($(HARDWARE_MOTHERBOARD),1600) else ifeq ($(HARDWARE_MOTHERBOARD),1600)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Gen3+ # Gen3+
else ifeq ($(HARDWARE_MOTHERBOARD),1601) else ifeq ($(HARDWARE_MOTHERBOARD),1601)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Gen6 # Gen6
else ifeq ($(HARDWARE_MOTHERBOARD),1602) else ifeq ($(HARDWARE_MOTHERBOARD),1602)
HARDWARE_VARIANT ?= Gen6 HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Gen6 deluxe # Gen6 deluxe
else ifeq ($(HARDWARE_MOTHERBOARD),1603) else ifeq ($(HARDWARE_MOTHERBOARD),1603)
HARDWARE_VARIANT ?= Gen6 HARDWARE_VARIANT ?= Gen6
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Gen7 custom (Alfons3 Version) # Gen7 custom (Alfons3 Version)
else ifeq ($(HARDWARE_MOTHERBOARD),1604) else ifeq ($(HARDWARE_MOTHERBOARD),1604)
HARDWARE_VARIANT ?= Gen7 HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644 MCU ?= atmega644
PROG_MCU ?= m644
F_CPU ?= 20000000 F_CPU ?= 20000000
# Gen7 v1.1, v1.2 # Gen7 v1.1, v1.2
else ifeq ($(HARDWARE_MOTHERBOARD),1605) else ifeq ($(HARDWARE_MOTHERBOARD),1605)
HARDWARE_VARIANT ?= Gen7 HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
F_CPU ?= 20000000 F_CPU ?= 20000000
# Gen7 v1.3 # Gen7 v1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1606) else ifeq ($(HARDWARE_MOTHERBOARD),1606)
HARDWARE_VARIANT ?= Gen7 HARDWARE_VARIANT ?= Gen7
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
F_CPU ?= 20000000 F_CPU ?= 20000000
# Gen7 v1.4 # Gen7 v1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1607) else ifeq ($(HARDWARE_MOTHERBOARD),1607)
HARDWARE_VARIANT ?= Gen7 HARDWARE_VARIANT ?= Gen7
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p
F_CPU ?= 20000000 F_CPU ?= 20000000
# Alpha OMCA board # Alpha OMCA board
else ifeq ($(HARDWARE_MOTHERBOARD),1608) else ifeq ($(HARDWARE_MOTHERBOARD),1608)
HARDWARE_VARIANT ?= SanguinoA HARDWARE_VARIANT ?= SanguinoA
MCU ?= atmega644 MCU ?= atmega644
PROG_MCU ?= m644
# Final OMCA board # Final OMCA board
else ifeq ($(HARDWARE_MOTHERBOARD),1609) else ifeq ($(HARDWARE_MOTHERBOARD),1609)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# Sethi 3D_1 # Sethi 3D_1
else ifeq ($(HARDWARE_MOTHERBOARD),1610) else ifeq ($(HARDWARE_MOTHERBOARD),1610)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p
# #
# Teensyduino - AT90USB1286, AT90USB1286P # Teensyduino - AT90USB1286, AT90USB1286P
@ -516,60 +460,51 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1610)
else ifeq ($(HARDWARE_MOTHERBOARD),1700) else ifeq ($(HARDWARE_MOTHERBOARD),1700)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# Printrboard (AT90USB1286) # Printrboard (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1701) else ifeq ($(HARDWARE_MOTHERBOARD),1701)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# Printrboard Revision F (AT90USB1286) # Printrboard Revision F (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1702) else ifeq ($(HARDWARE_MOTHERBOARD),1702)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# Brainwave (AT90USB646) # Brainwave (AT90USB646)
else ifeq ($(HARDWARE_MOTHERBOARD),1703) else ifeq ($(HARDWARE_MOTHERBOARD),1703)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb646 MCU ?= at90usb646
PROG_MCU ?= usb646
# Brainwave Pro (AT90USB1286) # Brainwave Pro (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1704) else ifeq ($(HARDWARE_MOTHERBOARD),1704)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# SAV Mk-I (AT90USB1286) # SAV Mk-I (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1705) else ifeq ($(HARDWARE_MOTHERBOARD),1705)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# Teensy++2.0 (AT90USB1286) # Teensy++2.0 (AT90USB1286)
else ifeq ($(HARDWARE_MOTHERBOARD),1706) else ifeq ($(HARDWARE_MOTHERBOARD),1706)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# 5DPrint D8 Driver Board # 5DPrint D8 Driver Board
else ifeq ($(HARDWARE_MOTHERBOARD),1707) else ifeq ($(HARDWARE_MOTHERBOARD),1707)
HARDWARE_VARIANT ?= Teensy HARDWARE_VARIANT ?= Teensy
MCU ?= at90usb1286 MCU ?= at90usb1286
PROG_MCU ?= usb1286
# UltiMachine Archim1 (with DRV8825 drivers) # UltiMachine Archim1 (with DRV8825 drivers)
else ifeq ($(HARDWARE_MOTHERBOARD),3023) else ifeq ($(HARDWARE_MOTHERBOARD),3023)
HARDWARE_VARIANT ?= archim HARDWARE_VARIANT ?= archim
MCPU = cortex-m3 MCPU = cortex-m3
F_CPU = 84000000 F_CPU = 84000000L
IS_MCU = 0 IS_MCU = 0
# UltiMachine Archim2 (with TMC2130 drivers) # UltiMachine Archim2 (with TMC2130 drivers)
else ifeq ($(HARDWARE_MOTHERBOARD),3024) else ifeq ($(HARDWARE_MOTHERBOARD),3024)
HARDWARE_VARIANT ?= archim HARDWARE_VARIANT ?= archim
MCPU = cortex-m3 MCPU = cortex-m3
F_CPU = 84000000 F_CPU = 84000000L
IS_MCU = 0 IS_MCU = 0
endif endif
# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
# if you are setting this to something other than 16MHz # if you are setting this to something other than 16MHz
# Do not put the UL suffix, it's done later on.
# Set to 16Mhz if not yet set. # Set to 16Mhz if not yet set.
F_CPU ?= 16000000 F_CPU ?= 16000000
@ -579,8 +514,7 @@ IS_MCU ?= 1
ifeq ($(IS_MCU),1) ifeq ($(IS_MCU),1)
# Set to arduino, ATmega2560 if not yet set. # Set to arduino, ATmega2560 if not yet set.
HARDWARE_VARIANT ?= arduino HARDWARE_VARIANT ?= arduino
MCU ?= atmega2560 MCU ?= atmega2560
PROG_MCU ?= m2560
TOOL_PREFIX = avr TOOL_PREFIX = avr
MCU_FLAGS = -mmcu=$(MCU) MCU_FLAGS = -mmcu=$(MCU)
@ -611,36 +545,27 @@ VPATH += $(BUILD_DIR)
VPATH += $(HARDWARE_SRC) VPATH += $(HARDWARE_SRC)
ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino)) ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
# Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8) VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI
# New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
endif endif
ifeq ($(IS_MCU),1) ifeq ($(IS_MCU),1)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
# Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial
# New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial/src
endif endif
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
ifeq ($(LIQUID_TWI2), 1) ifeq ($(LIQUID_TWI2), 1)
WIRE = 1 VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2 VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
endif endif
ifeq ($(WIRE), 1) ifeq ($(WIRE), 1)
# Old libraries (avr-core 1.6.21 / Arduino < 1.6.8) VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility
# New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/src/utility
endif endif
ifeq ($(NEOPIXEL), 1) ifeq ($(NEOPIXEL), 1)
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
@ -712,23 +637,13 @@ ifeq ($(WIRE), 1)
LIB_CXXSRC += Wire.cpp LIB_CXXSRC += Wire.cpp
endif endif
ifeq ($(TONE), 1)
LIB_CXXSRC += Tone.cpp
endif
ifeq ($(U8GLIB), 1) ifeq ($(U8GLIB), 1)
LIB_CXXSRC += U8glib.cpp LIB_CXXSRC += U8glib.cpp
LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c \ LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c \
u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
endif endif
ifeq ($(TMC), 1) ifeq ($(TMC), 1)
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.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
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 endif
ifeq ($(RELOC_WORKAROUND), 1) ifeq ($(RELOC_WORKAROUND), 1)
@ -770,23 +685,17 @@ REMOVE = rm -f
MV = mv -f MV = mv -f
# Place -D or -U options here # Place -D or -U options here
CDEFS = -DF_CPU=$(F_CPU)UL ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION) CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
CXXDEFS = $(CDEFS) CXXDEFS = $(CDEFS)
ifeq ($(HARDWARE_VARIANT), Teensy) ifeq ($(HARDWARE_VARIANT), Teensy)
CDEFS += -DUSB_SERIAL CDEFS += -DUSB_SERIAL
LIB_SRC += usb.c pins_teensy.c LIB_SRC += usb.c pins_teensy.c
LIB_CXXSRC += usb_api.cpp LIB_CXXSRC += usb_api.cpp
else ifeq ($(HARDWARE_VARIANT), archim) else ifeq ($(HARDWARE_VARIANT), archim)
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
CDEFS += -DUSB_VID=0x27B1 -DUSB_PID=0x0001 -DUSBCON LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp \
UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp \
PluggableUSB.cpp USBCore.cpp
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
ifeq ($(U8GLIB), 1) ifeq ($(U8GLIB), 1)
@ -812,20 +721,16 @@ CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
ifneq ($(HARDWARE_MOTHERBOARD),) ifneq ($(HARDWARE_MOTHERBOARD),)
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
endif endif
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD) CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD)
CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD) CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
ASFLAGS := $(CDEFS) ASFLAGS := $(CDEFS)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ifeq ($(HARDWARE_VARIANT), archim) 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_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) LD_SUFFIX = $(LDLIBS)
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
LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty
LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
else else
LD_PREFIX = -Wl,--gc-sections,--relax LD_PREFIX = -Wl,--gc-sections,--relax
LDFLAGS = -lm LDFLAGS = -lm
@ -841,7 +746,7 @@ else
AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
endif endif
AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \ AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
-p$(PROG_MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \ -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
-b$(UPLOAD_RATE) -b$(UPLOAD_RATE)
# Since Marlin 2.0, the source files may be distributed into several # Since Marlin 2.0, the source files may be distributed into several
@ -942,7 +847,7 @@ extcoff: $(TARGET).elf
.elf.eep: .elf.eep:
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file. # Create extended listing file from ELF output file.
.elf.lss: .elf.lss:
@ -956,7 +861,7 @@ extcoff: $(TARGET).elf
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
$(Pecho) " CXX $@" $(Pecho) " CXX $@"
$P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX) $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
# Object files that were found in "src" will be stored in $(BUILD_DIR) # Object files that were found in "src" will be stored in $(BUILD_DIR)
# in directories that mirror the structure of "src" # in directories that mirror the structure of "src"

View file

@ -28,7 +28,7 @@
/** /**
* Marlin release version identifier * Marlin release version identifier
*/ */
//#define SHORT_BUILD_VERSION "2.0.7.2" //#define SHORT_BUILD_VERSION "2.0.6"
/** /**
* Verbose version identifier which should contain a reference to the location * Verbose version identifier which should contain a reference to the location

View file

@ -15,7 +15,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
#pragma once #pragma once
@ -25,7 +24,7 @@
#include "watchdog.h" #include "watchdog.h"
#include "math.h" #include "math.h"
#ifdef IS_AT90USB #ifdef USBCON
#include <HardwareSerial.h> #include <HardwareSerial.h>
#else #else
#define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
@ -81,30 +80,44 @@ typedef int8_t pin_t;
//extern uint8_t MCUSR; //extern uint8_t MCUSR;
// Serial ports // Serial ports
#ifdef IS_AT90USB #ifdef USBCON
#define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial) #if ENABLED(BLUETOOTH)
#define MYSERIAL0 bluetoothSerial
#else
#define MYSERIAL0 Serial
#endif
#define NUM_SERIAL 1
#else #else
#if !WITHIN(SERIAL_PORT, -1, 3) #if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#define MYSERIAL0 customizedSerial1 #define MYSERIAL0 customizedSerial1
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3) #if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif #endif
#define MYSERIAL1 customizedSerial2 #define MYSERIAL1 customizedSerial2
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif #endif
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef DGUS_SERIAL_PORT
#if !WITHIN(LCD_SERIAL_PORT, -1, 3) #if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #elif DGUS_SERIAL_PORT == SERIAL_PORT
#define LCD_SERIAL lcdSerial #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#if HAS_DGUS_LCD #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free() #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif #endif
#define DGUS_SERIAL internalDgusSerial
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
#endif #endif
// ------------------------ // ------------------------
@ -120,8 +133,6 @@ void HAL_init();
inline void HAL_clear_reset_source() { MCUSR = 0; } inline void HAL_clear_reset_source() { MCUSR = 0; }
inline uint8_t HAL_get_reset_source() { return MCUSR; } inline uint8_t HAL_get_reset_source() { return MCUSR; }
inline void HAL_reboot() {} // reboot the board or restart the bootloader
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
extern "C" { extern "C" {

File diff suppressed because it is too large Load diff

View file

@ -48,11 +48,11 @@
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly) // requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) _SERIAL_REGNAME(registerbase,number,suffix) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary #if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##suffix #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else #else
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##number##suffix #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif #endif
// Registers used by MarlinSerial class (expanded depending on selected serial port) // Registers used by MarlinSerial class (expanded depending on selected serial port)
@ -217,12 +217,10 @@
static ring_buffer_pos_t available(); static ring_buffer_pos_t available();
static void write(const uint8_t c); static void write(const uint8_t c);
static void flushTX(); static void flushTX();
#if HAS_DGUS_LCD #ifdef DGUS_SERIAL_PORT
static ring_buffer_pos_t get_tx_buffer_free(); static ring_buffer_pos_t get_tx_buffer_free();
#endif #endif
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; } FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
@ -280,53 +278,41 @@
#endif // !USBCON #endif // !USBCON
#ifdef MMU2_SERIAL_PORT #ifdef INTERNAL_SERIAL_PORT
template <uint8_t serial> template <uint8_t serial>
struct MMU2SerialCfg { struct MarlinInternalSerialCfg {
static constexpr int PORT = serial; static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = 32;
static constexpr unsigned int TX_SIZE = 32;
static constexpr bool XONOFF = false; static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false; static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false; static constexpr bool DROPPED_RX = false;
static constexpr bool RX_OVERRUNS = false;
static constexpr bool RX_FRAMING_ERRORS = false; static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false; static constexpr bool MAX_RX_QUEUED = false;
static constexpr unsigned int RX_SIZE = 32;
static constexpr unsigned int TX_SIZE = 32;
static constexpr bool RX_OVERRUNS = false;
}; };
extern MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial; extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef DGUS_SERIAL_PORT
template <uint8_t serial> template <uint8_t serial>
struct LCDSerialCfg { struct MarlinInternalSerialCfg {
static constexpr int PORT = serial; static constexpr int PORT = serial;
static constexpr bool XONOFF = false; static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER); static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
static constexpr bool DROPPED_RX = false; static constexpr bool XONOFF = false;
static constexpr bool RX_FRAMING_ERRORS = false; static constexpr bool EMERGENCYPARSER = false;
static constexpr bool MAX_RX_QUEUED = false; static constexpr bool DROPPED_RX = false;
#if HAS_DGUS_LCD static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE; static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE; static constexpr bool MAX_RX_QUEUED = false;
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
static constexpr unsigned int RX_SIZE = 64;
static constexpr unsigned int TX_SIZE = 128;
static constexpr bool RX_OVERRUNS = false;
#else
static constexpr unsigned int RX_SIZE = 64;
static constexpr unsigned int TX_SIZE = 128;
static constexpr bool RX_OVERRUNS = false
#endif
}; };
extern MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial; extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
#endif #endif
// Use the UART for Bluetooth in AT90USB configurations // Use the UART for Bluetooth in AT90USB configurations
#if BOTH(IS_AT90USB, BLUETOOTH) #if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial; extern HardwareSerial bluetoothSerial;
#endif #endif

View file

@ -48,6 +48,7 @@
* readMicroseconds() - Get the last-written servo pulse width in microseconds. * readMicroseconds() - Get the last-written servo pulse width in microseconds.
* attached() - Return true if a servo is attached. * attached() - Return true if a servo is attached.
* detach() - Stop an attached servo from pulsing its i/o pin. * detach() - Stop an attached servo from pulsing its i/o pin.
*
*/ */
#ifdef __AVR__ #ifdef __AVR__

View file

@ -59,12 +59,10 @@
// Say which 16 bit timers can be used and in what order // Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
//#define _useTimer1 //#define _useTimer1
#define _useTimer3
#define _useTimer4 #define _useTimer4
#if NUM_SERVOS > SERVOS_PER_TIMER #if !HAS_MOTOR_CURRENT_PWM
#define _useTimer3 #define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos.
#if !HAS_MOTOR_CURRENT_PWM && SERVOS > 2 * SERVOS_PER_TIMER
#define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos.
#endif
#endif #endif
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
#define _useTimer3 #define _useTimer3

View file

@ -185,8 +185,8 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
res_temp_phase_correct = rtf / 2; res_temp_phase_correct = rtf / 2;
} }
LIMIT(res_temp_fast, 1U, size); LIMIT(res_temp_fast, 1u, size);
LIMIT(res_temp_phase_correct, 1U, size); LIMIT(res_temp_phase_correct, 1u, size);
// Calculate frequencies of test prescaler and resolution values // Calculate frequencies of test prescaler and resolution values
const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)), 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_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct),

View file

@ -29,17 +29,11 @@
#include <avr/io.h> #include <avr/io.h>
#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__) #define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
#define AVR_AT90USB1286_FAMILY 1 #define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) #define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
#define AVR_ATmega1284_FAMILY 1 #define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__))
#define AVR_ATmega2560_FAMILY 1
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
#define AVR_ATmega2561_FAMILY 1
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
#define AVR_ATmega328_FAMILY 1
#endif
/** /**
* Include Ports and Functions * Include Ports and Functions

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/AVR."
#endif

View file

@ -36,10 +36,9 @@
* Sanity checks for Spindle / Laser PWM * Sanity checks for Spindle / Laser PWM
*/ */
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
#include "../ServoTimers.h" // Needed to check timer availability (_useTimer3)
#if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13) #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." #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt."
#elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #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." #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
#endif #endif
#elif defined(SPINDLE_LASER_FREQUENCY) #elif defined(SPINDLE_LASER_FREQUENCY)

View file

@ -26,9 +26,7 @@
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14) #define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H)
#define AVR_ATmega2560_FAMILY_PLUS_70 1
#endif
#if AVR_AT90USB1286_FAMILY #if AVR_AT90USB1286_FAMILY

View file

@ -22,12 +22,15 @@
* Structures for 2560 family boards that use more than 70 pins * Structures for 2560 family boards that use more than 70 pins
*/ */
#if MB(BQ_ZUM_MEGA_3D, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14) #undef NUM_DIGITAL_PINS
#undef NUM_DIGITAL_PINS #if MB(BQ_ZUM_MEGA_3D)
#define NUM_DIGITAL_PINS 85 #define NUM_DIGITAL_PINS 85
#elif MB(MIGHTYBOARD_REVE) #elif MB(MIGHTYBOARD_REVE)
#undef NUM_DIGITAL_PINS
#define NUM_DIGITAL_PINS 80 #define NUM_DIGITAL_PINS 80
#elif MB(MINIRAMBO)
#define NUM_DIGITAL_PINS 85
#elif MB(SCOOVO_X9H)
#define NUM_DIGITAL_PINS 85
#endif #endif
#define PA 1 #define PA 1

View file

@ -15,7 +15,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
#pragma once #pragma once

View file

@ -57,7 +57,7 @@
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include "../shared/Marduino.h" #include "../shared/Marduino.h"
#include "../shared/Delay.h" #include "../shared/Delay.h"
@ -189,5 +189,5 @@ uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // ARDUINO_ARCH_SAM #endif // ARDUINO_ARCH_SAM

View file

@ -15,11 +15,12 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
/** /**
* HAL for Arduino Due and compatible (SAM3X8E) * Description: HAL for Arduino Due and compatible (SAM3X8E)
*
* For ARDUINO_ARCH_SAM
*/ */
#ifdef ARDUINO_ARCH_SAM #ifdef ARDUINO_ARCH_SAM

View file

@ -22,7 +22,9 @@
#pragma once #pragma once
/** /**
* HAL for Arduino Due and compatible (SAM3X8E) * Description: HAL for Arduino Due and compatible (SAM3X8E)
*
* For ARDUINO_ARCH_SAM
*/ */
#define CPU_32_BIT #define CPU_32_BIT
@ -36,36 +38,59 @@
#include <stdint.h> #include <stdint.h>
#define _MSERIAL(X) Serial##X
#define MSERIAL(X) _MSERIAL(X)
#define Serial0 Serial
// Define MYSERIAL0/1 before MarlinSerial includes! // Define MYSERIAL0/1 before MarlinSerial includes!
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
#define MYSERIAL0 customizedSerial1 #define MYSERIAL0 customizedSerial1
#elif WITHIN(SERIAL_PORT, 0, 3) #elif SERIAL_PORT == 0
#define MYSERIAL0 MSERIAL(SERIAL_PORT) #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 #else
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER) #if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
#define MYSERIAL1 customizedSerial2 #define MYSERIAL1 customizedSerial2
#elif WITHIN(SERIAL_PORT_2, 0, 3) #elif SERIAL_PORT_2 == 0
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #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 #else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif #endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef DGUS_SERIAL_PORT
#if LCD_SERIAL_PORT == -1 #if DGUS_SERIAL_PORT == SERIAL_PORT
#define LCD_SERIAL lcdSerial #error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
#elif WITHIN(LCD_SERIAL_PORT, 0, 3) #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #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 #else
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#endif #endif
@ -105,15 +130,13 @@ void sei(); // Enable interrupts
void HAL_clear_reset_source(); // clear reset reason void HAL_clear_reset_source(); // clear reset reason
uint8_t HAL_get_reset_source(); // get reset reason uint8_t HAL_get_reset_source(); // get reset reason
inline void HAL_reboot() {} // reboot the board or restart the bootloader
// //
// ADC // ADC
// //
extern uint16_t HAL_adc_result; // result of last ADC conversion extern uint16_t HAL_adc_result; // result of last ADC conversion
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
#endif #endif
#define HAL_ANALOG_SELECT(ch) #define HAL_ANALOG_SELECT(ch)

View file

@ -30,7 +30,7 @@
*/ */
/** /**
* HAL for Arduino Due and compatible (SAM3X8E) * Description: HAL for Arduino Due and compatible (SAM3X8E)
* *
* For ARDUINO_ARCH_SAM * For ARDUINO_ARCH_SAM
*/ */
@ -595,7 +595,7 @@
SPI_Enable(SPI0); SPI_Enable(SPI0);
SET_OUTPUT(DAC0_SYNC); SET_OUTPUT(DAC0_SYNC);
#if HAS_MULTI_EXTRUDER #if EXTRUDERS > 1
SET_OUTPUT(DAC1_SYNC); SET_OUTPUT(DAC1_SYNC);
WRITE(DAC1_SYNC, HIGH); WRITE(DAC1_SYNC, HIGH);
#endif #endif
@ -759,6 +759,7 @@
* *
* All of the above can be avoided by defining FORCE_SOFT_SPI to force the * All of the above can be avoided by defining FORCE_SOFT_SPI to force the
* display to use software SPI. * display to use software SPI.
*
*/ */
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified) void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)

View file

@ -122,8 +122,6 @@ public:
static void write(const uint8_t c); static void write(const uint8_t c);
static void flushTX(); static void flushTX();
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; } FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }

View file

@ -52,13 +52,14 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#ifdef __SAM3X8E__ #ifdef __SAM3X8E__
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include <U8glib.h> #include <U8glib.h>
@ -144,6 +145,6 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // __SAM3X8E__ #endif //__SAM3X8E__

View file

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920) #if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
#undef SPI_SPEED #undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz #define SPI_SPEED 2 // About 2 MHz
@ -144,5 +144,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920 #endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM #endif // ARDUINO_ARCH_SAM

View file

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include "../../shared/Delay.h" #include "../../shared/Delay.h"
@ -108,5 +108,5 @@ void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
} }
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // ARDUINO_ARCH_SAM #endif // ARDUINO_ARCH_SAM

View file

@ -53,6 +53,7 @@
* per page. We can't emulate EE endurance with FLASH for all * per page. We can't emulate EE endurance with FLASH for all
* bytes, but we can emulate endurance for a given percent of * bytes, but we can emulate endurance for a given percent of
* bytes. * bytes.
*
*/ */
//#define EE_EMU_DEBUG //#define EE_EMU_DEBUG
@ -60,7 +61,7 @@
#define EEPROMSize 4096 #define EEPROMSize 4096
#define PagesPerGroup 128 #define PagesPerGroup 128
#define GroupCount 2 #define GroupCount 2
#define PageSize 256U #define PageSize 256u
/* Flash storage */ /* Flash storage */
typedef struct FLASH_SECTOR { typedef struct FLASH_SECTOR {

View file

@ -154,7 +154,7 @@ void Stepper::digipot_init() {
NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals) NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0)); // normal priority for PWM module (can stand some jitter on the Vref signals)
} }
void Stepper::set_digipot_current(const uint8_t driver, const int16_t current) { void Stepper::digipot_current(const uint8_t driver, const int16_t current) {
if (!(PWM->PWM_CH_NUM[0].PWM_CPRD == PWM_PERIOD_US)) digipot_init(); // Init PWM system if needed if (!(PWM->PWM_CH_NUM[0].PWM_CPRD == PWM_PERIOD_US)) digipot_init(); // Init PWM system if needed

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/DUE."
#endif

View file

@ -52,8 +52,8 @@
#endif #endif
#endif #endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on DUE." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if HAS_TMC_SW_SERIAL #if HAS_TMC_SW_SERIAL

View file

@ -179,4 +179,5 @@ void pwm_details(int32_t pin) {
* ----------------+-------- * ----------------+--------
* ID | PB11 * ID | PB11
* VBOF | PB10 * VBOF | PB10
*
*/ */

View file

@ -21,7 +21,9 @@
*/ */
/** /**
* HAL Timers for Arduino Due and compatible (SAM3X8E) * Description: HAL for Arduino Due and compatible (SAM3X8E)
*
* For ARDUINO_ARCH_SAM
*/ */
#ifdef ARDUINO_ARCH_SAM #ifdef ARDUINO_ARCH_SAM

View file

@ -21,7 +21,9 @@
#pragma once #pragma once
/** /**
* HAL Timers for Arduino Due and compatible (SAM3X8E) * HAL for Arduino Due and compatible (SAM3X8E)
*
* For ARDUINO_ARCH_SAM
*/ */
#include <stdint.h> #include <stdint.h>

View file

@ -14,5 +14,5 @@ if current_OS == 'Windows':
# Use bossac.exe on Windows # Use bossac.exe on Windows
env.Replace( env.Replace(
UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot"
) )

View file

@ -93,5 +93,5 @@
#define USB_VBOF_GPIO (PIO_PB10_IDX) #define USB_VBOF_GPIO (PIO_PB10_IDX)
#define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) #define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT)
/*! Active level of the USB_VBOF output pin. */ /*! Active level of the USB_VBOF output pin. */
#define USB_VBOF_ACTIVE_STATE LOW #define USB_VBOF_ACTIVE_LEVEL LOW
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */

View file

@ -173,11 +173,11 @@
# define __always_inline __forceinline # define __always_inline __forceinline
#elif (defined __GNUC__) #elif (defined __GNUC__)
#ifdef __always_inline #ifdef __always_inline
# undef __always_inline # undef __always_inline
#endif #endif
# define __always_inline inline __attribute__((__always_inline__)) # define __always_inline inline __attribute__((__always_inline__))
#elif (defined __ICCARM__) #elif (defined __ICCARM__)
# define __always_inline _Pragma("inline=forced") # define __always_inline _Pragma("inline=forced")
#endif #endif
/** /**
@ -188,11 +188,11 @@
* heuristics and not inline the function. * heuristics and not inline the function.
*/ */
#ifdef __CC_ARM #ifdef __CC_ARM
# define __no_inline __attribute__((noinline)) # define __no_inline __attribute__((noinline))
#elif (defined __GNUC__) #elif (defined __GNUC__)
# define __no_inline __attribute__((__noinline__)) # define __no_inline __attribute__((__noinline__))
#elif (defined __ICCARM__) #elif (defined __ICCARM__)
# define __no_inline _Pragma("inline=never") # define __no_inline _Pragma("inline=never")
#endif #endif
/*! \brief This macro is used to test fatal errors. /*! \brief This macro is used to test fatal errors.
@ -211,9 +211,9 @@
# else # else
#undef TEST_SUITE_DEFINE_ASSERT_MACRO #undef TEST_SUITE_DEFINE_ASSERT_MACRO
# define Assert(expr) \ # define Assert(expr) \
{\ {\
if (!(expr)) while (true);\ if (!(expr)) while (true);\
} }
# endif # endif
#else #else
# define Assert(expr) ((void) 0) # define Assert(expr) ((void) 0)
@ -609,37 +609,37 @@ typedef struct
# define clz(u) ((u) ? __CLZ(u) : 32) # define clz(u) ((u) ? __CLZ(u) : 32)
#else #else
# define clz(u) (((u) == 0) ? 32 : \ # define clz(u) (((u) == 0) ? 32 : \
((u) & (1UL << 31)) ? 0 : \ ((u) & (1ul << 31)) ? 0 : \
((u) & (1UL << 30)) ? 1 : \ ((u) & (1ul << 30)) ? 1 : \
((u) & (1UL << 29)) ? 2 : \ ((u) & (1ul << 29)) ? 2 : \
((u) & (1UL << 28)) ? 3 : \ ((u) & (1ul << 28)) ? 3 : \
((u) & (1UL << 27)) ? 4 : \ ((u) & (1ul << 27)) ? 4 : \
((u) & (1UL << 26)) ? 5 : \ ((u) & (1ul << 26)) ? 5 : \
((u) & (1UL << 25)) ? 6 : \ ((u) & (1ul << 25)) ? 6 : \
((u) & (1UL << 24)) ? 7 : \ ((u) & (1ul << 24)) ? 7 : \
((u) & (1UL << 23)) ? 8 : \ ((u) & (1ul << 23)) ? 8 : \
((u) & (1UL << 22)) ? 9 : \ ((u) & (1ul << 22)) ? 9 : \
((u) & (1UL << 21)) ? 10 : \ ((u) & (1ul << 21)) ? 10 : \
((u) & (1UL << 20)) ? 11 : \ ((u) & (1ul << 20)) ? 11 : \
((u) & (1UL << 19)) ? 12 : \ ((u) & (1ul << 19)) ? 12 : \
((u) & (1UL << 18)) ? 13 : \ ((u) & (1ul << 18)) ? 13 : \
((u) & (1UL << 17)) ? 14 : \ ((u) & (1ul << 17)) ? 14 : \
((u) & (1UL << 16)) ? 15 : \ ((u) & (1ul << 16)) ? 15 : \
((u) & (1UL << 15)) ? 16 : \ ((u) & (1ul << 15)) ? 16 : \
((u) & (1UL << 14)) ? 17 : \ ((u) & (1ul << 14)) ? 17 : \
((u) & (1UL << 13)) ? 18 : \ ((u) & (1ul << 13)) ? 18 : \
((u) & (1UL << 12)) ? 19 : \ ((u) & (1ul << 12)) ? 19 : \
((u) & (1UL << 11)) ? 20 : \ ((u) & (1ul << 11)) ? 20 : \
((u) & (1UL << 10)) ? 21 : \ ((u) & (1ul << 10)) ? 21 : \
((u) & (1UL << 9)) ? 22 : \ ((u) & (1ul << 9)) ? 22 : \
((u) & (1UL << 8)) ? 23 : \ ((u) & (1ul << 8)) ? 23 : \
((u) & (1UL << 7)) ? 24 : \ ((u) & (1ul << 7)) ? 24 : \
((u) & (1UL << 6)) ? 25 : \ ((u) & (1ul << 6)) ? 25 : \
((u) & (1UL << 5)) ? 26 : \ ((u) & (1ul << 5)) ? 26 : \
((u) & (1UL << 4)) ? 27 : \ ((u) & (1ul << 4)) ? 27 : \
((u) & (1UL << 3)) ? 28 : \ ((u) & (1ul << 3)) ? 28 : \
((u) & (1UL << 2)) ? 29 : \ ((u) & (1ul << 2)) ? 29 : \
((u) & (1UL << 1)) ? 30 : \ ((u) & (1ul << 1)) ? 30 : \
31) 31)
#endif #endif
#endif #endif
@ -654,38 +654,38 @@ typedef struct
#if (defined __GNUC__) || (defined __CC_ARM) #if (defined __GNUC__) || (defined __CC_ARM)
# define ctz(u) ((u) ? __builtin_ctz(u) : 32) # define ctz(u) ((u) ? __builtin_ctz(u) : 32)
#else #else
# define ctz(u) ((u) & (1UL << 0) ? 0 : \ # define ctz(u) ((u) & (1ul << 0) ? 0 : \
(u) & (1UL << 1) ? 1 : \ (u) & (1ul << 1) ? 1 : \
(u) & (1UL << 2) ? 2 : \ (u) & (1ul << 2) ? 2 : \
(u) & (1UL << 3) ? 3 : \ (u) & (1ul << 3) ? 3 : \
(u) & (1UL << 4) ? 4 : \ (u) & (1ul << 4) ? 4 : \
(u) & (1UL << 5) ? 5 : \ (u) & (1ul << 5) ? 5 : \
(u) & (1UL << 6) ? 6 : \ (u) & (1ul << 6) ? 6 : \
(u) & (1UL << 7) ? 7 : \ (u) & (1ul << 7) ? 7 : \
(u) & (1UL << 8) ? 8 : \ (u) & (1ul << 8) ? 8 : \
(u) & (1UL << 9) ? 9 : \ (u) & (1ul << 9) ? 9 : \
(u) & (1UL << 10) ? 10 : \ (u) & (1ul << 10) ? 10 : \
(u) & (1UL << 11) ? 11 : \ (u) & (1ul << 11) ? 11 : \
(u) & (1UL << 12) ? 12 : \ (u) & (1ul << 12) ? 12 : \
(u) & (1UL << 13) ? 13 : \ (u) & (1ul << 13) ? 13 : \
(u) & (1UL << 14) ? 14 : \ (u) & (1ul << 14) ? 14 : \
(u) & (1UL << 15) ? 15 : \ (u) & (1ul << 15) ? 15 : \
(u) & (1UL << 16) ? 16 : \ (u) & (1ul << 16) ? 16 : \
(u) & (1UL << 17) ? 17 : \ (u) & (1ul << 17) ? 17 : \
(u) & (1UL << 18) ? 18 : \ (u) & (1ul << 18) ? 18 : \
(u) & (1UL << 19) ? 19 : \ (u) & (1ul << 19) ? 19 : \
(u) & (1UL << 20) ? 20 : \ (u) & (1ul << 20) ? 20 : \
(u) & (1UL << 21) ? 21 : \ (u) & (1ul << 21) ? 21 : \
(u) & (1UL << 22) ? 22 : \ (u) & (1ul << 22) ? 22 : \
(u) & (1UL << 23) ? 23 : \ (u) & (1ul << 23) ? 23 : \
(u) & (1UL << 24) ? 24 : \ (u) & (1ul << 24) ? 24 : \
(u) & (1UL << 25) ? 25 : \ (u) & (1ul << 25) ? 25 : \
(u) & (1UL << 26) ? 26 : \ (u) & (1ul << 26) ? 26 : \
(u) & (1UL << 27) ? 27 : \ (u) & (1ul << 27) ? 27 : \
(u) & (1UL << 28) ? 28 : \ (u) & (1ul << 28) ? 28 : \
(u) & (1UL << 29) ? 29 : \ (u) & (1ul << 29) ? 29 : \
(u) & (1UL << 30) ? 30 : \ (u) & (1ul << 30) ? 30 : \
(u) & (1UL << 31) ? 31 : \ (u) & (1ul << 31) ? 31 : \
32) 32)
#endif #endif
#endif #endif
@ -1106,16 +1106,17 @@ static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data)
/* Converts a 8 Byte array into a 32-Bit value */ /* Converts a 8 Byte array into a 32-Bit value */
static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
{ {
union union
{ {
uint32_t u32; uint32_t u32;
uint8_t u8[8]; uint8_t u8[8];
}long_addr; }long_addr;
uint8_t index; uint8_t index;
for (index = 0; index < 4; index++) { for (index = 0; index < 4; index++)
long_addr.u8[index] = *data++; {
} long_addr.u8[index] = *data++;
return long_addr.u32; }
return long_addr.u32;
} }
/** /**

View file

@ -15,12 +15,11 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
#pragma once #pragma once
/** /**
* HAL for Espressif ESP32 WiFi * Description: HAL for Espressif ESP32 WiFi
*/ */
#define CPU_32_BIT #define CPU_32_BIT
@ -59,6 +58,9 @@ extern portMUX_TYPE spinlock;
#else #else
#define MYSERIAL1 webSocketSerial #define MYSERIAL1 webSocketSerial
#endif #endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif #endif
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
@ -96,8 +98,6 @@ void HAL_clear_reset_source();
// reset reason // reset reason
uint8_t HAL_get_reset_source(); uint8_t HAL_get_reset_source();
inline void HAL_reboot() {} // reboot the board or restart the bootloader
void _delay_ms(int delay); void _delay_ms(int delay);
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -157,14 +157,14 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
if (stop >= start) { if (stop >= start) {
// no overflow, so only loop while in between start and stop: // no overflow, so only loop while in between start and stop:
// 0x00000000 -----------------start****stop-- 0xFFFFFFFF // 0x00000000 -----------------start****stop-- 0xffffffff
while (ccount >= start && ccount < stop) { while (ccount >= start && ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) ); __asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
} }
} }
else { else {
// stop did overflow, so only loop while outside of stop and start: // stop did overflow, so only loop while outside of stop and start:
// 0x00000000 **stop-------------------start** 0xFFFFFFFF // 0x00000000 **stop-------------------start** 0xffffffff
while (ccount >= start || ccount < stop) { while (ccount >= start || ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) ); __asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
} }

View file

@ -86,7 +86,7 @@ int RingBuffer::read() {
ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) { ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
ring_buffer_pos_t len = available(); ring_buffer_pos_t len = available();
for (ring_buffer_pos_t i = 0; read_index != write_index; i++) { for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
buffer[i] = data[read_index]; buffer[i] = data[read_index];
read_index = NEXT_INDEX(read_index, size); read_index = NEXT_INDEX(read_index, size);
} }
@ -139,8 +139,9 @@ size_t WebSocketSerial::write(const uint8_t c) {
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) { size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
size_t written = 0; size_t written = 0;
for (size_t i = 0; i < size; i++) for(size_t i = 0; i < size; i++) {
written += write(buffer[i]); written += write(buffer[i]);
}
return written; return written;
} }

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/ESP32."
#endif

View file

@ -25,8 +25,8 @@
#error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue." #error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue."
#endif #endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on ESP32." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if HAS_TMC_SW_SERIAL #if HAS_TMC_SW_SERIAL

View file

@ -15,7 +15,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32

View file

@ -15,7 +15,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
#pragma once #pragma once

View file

@ -25,16 +25,10 @@
#include HAL_PATH(.,HAL.h) #include HAL_PATH(.,HAL.h)
#ifdef SERIAL_PORT_2
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
#ifndef I2C_ADDRESS #ifndef I2C_ADDRESS
#define I2C_ADDRESS(A) uint8_t(A) #define I2C_ADDRESS(A) (A)
#endif #endif
// Needed for AVR sprintf_P PROGMEM extension // Needed for AVR sprintf_P PROGMEM extension
@ -44,7 +38,7 @@
// String helper // String helper
#ifndef PGMSTR #ifndef PGMSTR
#define PGMSTR(NAM,STR) const char NAM[] = STR #define PGMSTR(NAM,STR) constexpr char NAM[] = STR
#endif #endif
inline void watchdog_refresh() { inline void watchdog_refresh() {

View file

@ -62,6 +62,7 @@ uint8_t _getc();
extern HalSerial usb_serial; extern HalSerial usb_serial;
#define MYSERIAL0 usb_serial #define MYSERIAL0 usb_serial
#define NUM_SERIAL 1
#define ST7920_DELAY_1 DELAY_NS(600) #define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750) #define ST7920_DELAY_2 DELAY_NS(750)
@ -101,8 +102,6 @@ uint16_t HAL_adc_get_result();
inline void HAL_clear_reset_source(void) {} inline void HAL_clear_reset_source(void) {}
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
inline void HAL_reboot() {} // reboot the board or restart the bootloader
/* ---------------- Delay in cycles */ /* ---------------- Delay in cycles */
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) { FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
Clock::delayCycles(x); Clock::delayCycles(x);

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/LINUX."
#endif

View file

@ -30,8 +30,8 @@
#error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector" #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
#endif #endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on LINUX." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if HAS_TMC_SW_SERIAL #if HAS_TMC_SW_SERIAL

View file

@ -33,6 +33,7 @@
* Generic RingBuffer * Generic RingBuffer
* T type of the buffer array * T type of the buffer array
* S size of the buffer (must be power of 2) * S size of the buffer (must be power of 2)
*
*/ */
template <typename T, uint32_t S> class RingBuffer { template <typename T, uint32_t S> class RingBuffer {
public: public:
@ -78,7 +79,6 @@ public:
#if ENABLED(EMERGENCY_PARSER) #if ENABLED(EMERGENCY_PARSER)
EmergencyParser::State emergency_state; EmergencyParser::State emergency_state;
static inline bool emergency_parser_enabled() { return true; }
#endif #endif
HalSerial() { host_connected = true; } HalSerial() { host_connected = true; }

View file

@ -107,7 +107,7 @@ int main() {
std::thread write_serial (write_serial_thread); std::thread write_serial (write_serial_thread);
std::thread read_serial (read_serial_thread); std::thread read_serial (read_serial_thread);
#ifdef MYSERIAL0 #if NUM_SERIAL > 0
MYSERIAL0.begin(BAUDRATE); MYSERIAL0.begin(BAUDRATE);
SERIAL_ECHOLNPGM("x86_64 Initialized"); SERIAL_ECHOLNPGM("x86_64 Initialized");
SERIAL_FLUSHTX(); SERIAL_FLUSHTX();

View file

@ -45,6 +45,7 @@
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. * Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
* *
* The only modification was to update/delete macros to match the LPC176x. * The only modification was to update/delete macros to match the LPC176x.
*
*/ */
#include <stdint.h> #include <stdint.h>

View file

@ -24,7 +24,7 @@
#include "../../core/macros.h" #include "../../core/macros.h"
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN) #if BOTH(HAS_GRAPHICAL_LCD, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different. // 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 // This requirement can be removed if the SPI access to these devices is updated to use

View file

@ -63,35 +63,58 @@ extern "C" volatile uint32_t _millis;
#define ST7920_DELAY_3 DELAY_NS(750) #define ST7920_DELAY_3 DELAY_NS(750)
#endif #endif
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
#define MSerial0 MSerial
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
#define MYSERIAL0 UsbSerial #define MYSERIAL0 UsbSerial
#elif WITHIN(SERIAL_PORT, 0, 3) #elif SERIAL_PORT == 0
#define MYSERIAL0 MSERIAL(SERIAL_PORT) #define MYSERIAL0 MSerial
#elif SERIAL_PORT == 1
#define MYSERIAL0 MSerial1
#elif SERIAL_PORT == 2
#define MYSERIAL0 MSerial2
#elif SERIAL_PORT == 3
#define MYSERIAL0 MSerial3
#else #else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 UsbSerial #define MYSERIAL1 UsbSerial
#elif WITHIN(SERIAL_PORT_2, 0, 3) #elif SERIAL_PORT_2 == 0
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #define MYSERIAL1 MSerial
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 MSerial1
#elif SERIAL_PORT_2 == 2
#define MYSERIAL1 MSerial2
#elif SERIAL_PORT_2 == 3
#define MYSERIAL1 MSerial3
#else #else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif #endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef DGUS_SERIAL_PORT
#if LCD_SERIAL_PORT == -1 #if DGUS_SERIAL_PORT == SERIAL_PORT
#define LCD_SERIAL UsbSerial #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif WITHIN(LCD_SERIAL_PORT, 0, 3) #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL MSerial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#else #else
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#endif #endif
@ -200,8 +223,6 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255,
void HAL_clear_reset_source(void); void HAL_clear_reset_source(void);
uint8_t HAL_get_reset_source(void); uint8_t HAL_get_reset_source(void);
inline void HAL_reboot() {} // reboot the board or restart the bootloader
// Add strcmp_P if missing // Add strcmp_P if missing
#ifndef strcmp_P #ifndef strcmp_P
#define strcmp_P(a, b) strcmp((a), (b)) #define strcmp_P(a, b) strcmp((a), (b))

View file

@ -30,7 +30,7 @@
*/ */
/** /**
* Hardware SPI and Software SPI implementations are included in this file. * Hardware SPI and a software SPI implementations are included in this file.
* The hardware SPI runs faster and has higher throughput but is not compatible * The hardware SPI runs faster and has higher throughput but is not compatible
* with some LCD interfaces/adapters. * with some LCD interfaces/adapters.
* *
@ -39,10 +39,10 @@
* Some of the LCD interfaces/adapters result in the LCD SPI and the SD card * Some of the LCD interfaces/adapters result in the LCD SPI and the SD card
* SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with * SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is * WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
* active. If any of these pins are shared then the software SPI must be used. * active. If any of these pins are shared then the software SPI must be used.
* *
* A more sophisticated hardware SPI can be found at the following link. * A more sophisticated hardware SPI can be found at the following link. This
* This implementation has not been fully debugged. * implementation has not been fully debugged.
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e * https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
*/ */
@ -51,10 +51,6 @@
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#include <SPI.h> #include <SPI.h>
// Hardware SPI and SPIClass
#include <lpc17xx_pinsel.h>
#include <lpc17xx_clkpwr.h>
// ------------------------ // ------------------------
// Public functions // Public functions
// ------------------------ // ------------------------
@ -100,25 +96,78 @@
#else #else
// Hardware SPI
#include <lpc17xx_pinsel.h>
#include <lpc17xx_ssp.h>
#include <lpc17xx_clkpwr.h>
// decide which HW SPI device to use
#ifndef LPC_HW_SPI_DEV
#if (SCK_PIN == P0_07 && MISO_PIN == P0_08 && MOSI_PIN == P0_09)
#define LPC_HW_SPI_DEV 1
#else
#if (SCK_PIN == P0_15 && MISO_PIN == P0_17 && MOSI_PIN == P0_18)
#define LPC_HW_SPI_DEV 0
#else
#error "Invalid pins selected for hardware SPI"
#endif
#endif
#endif
#if (LPC_HW_SPI_DEV == 0)
#define LPC_SSPn LPC_SSP0
#else
#define LPC_SSPn LPC_SSP1
#endif
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0 void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
spiInit(SPI_SPEED); PINSEL_CFG_Type PinCfg; // data structure to hold init values
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(SCK_PIN);
PinCfg.Portnum = LPC176x::pin_port(SCK_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(SCK_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(MISO_PIN);
PinCfg.Portnum = LPC176x::pin_port(MISO_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(MISO_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(MOSI_PIN);
PinCfg.Portnum = LPC176x::pin_port(MOSI_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(MOSI_PIN);
// divide PCLK by 2 for SSP0
CLKPWR_SetPCLKDiv(LPC_HW_SPI_DEV == 0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
spiInit(0);
SSP_Cmd(LPC_SSPn, ENABLE); // start SSP running
} }
void spiInit(uint8_t spiRate) { void spiInit(uint8_t spiRate) {
#if MISO_PIN == BOARD_SPI1_MISO_PIN // table to convert Marlin spiRates (0-5 plus default) into bit rates
SPI.setModule(1); uint32_t Marlin_speed[7]; // CPSR is always 2
#elif MISO_PIN == BOARD_SPI2_MISO_PIN Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
SPI.setModule(2); Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
#endif Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
SPI.setDataSize(DATA_SIZE_8BIT); Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
SPI.setDataMode(SPI_MODE0); Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
SPI.setClock(SPISettings::spiRate2Clock(spiRate)); Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
SPI.begin(); // setup for SPI mode
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
HW_SPI_init.ClockRate = Marlin_speed[_MIN(spiRate, 6)]; // put in the specified bit rate
HW_SPI_init.Mode |= SSP_CR1_SSP_EN;
SSP_Init(LPC_SSPn, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
} }
static uint8_t doio(uint8_t b) { static uint8_t doio(uint8_t b) {
return SPI.transfer(b & 0x00FF) & 0x00FF; /* send and receive a single byte */
SSP_SendData(LPC_SSPn, b & 0x00FF);
while (SSP_GetStatus(LPC_SSPn, SSP_STAT_BUSY)); // wait for it to finish
return SSP_ReceiveData(LPC_SSPn) & 0x00FF;
} }
void spiSend(uint8_t b) { doio(b); } void spiSend(uint8_t b) { doio(b); }
@ -143,7 +192,7 @@
for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF); for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF);
} }
uint8_t spiTransfer(uint8_t b) { static uint8_t spiTransfer(uint8_t b) {
return doio(b); return doio(b);
} }
@ -162,244 +211,30 @@
#endif // LPC_SOFTWARE_SPI #endif // LPC_SOFTWARE_SPI
/** void SPIClass::begin() { spiBegin(); }
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
*/
static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
}
// Retain the pin init state of the SPI, to avoid init more than once,
// even if more instances of SPIClass exist
static bool spiInitialised[BOARD_NR_SPI] = { false };
SPIClass::SPIClass(uint8_t device) {
// Init things specific to each SPI device
// clock divider setup is a bit of hack, and needs to be improved at a later date.
#if BOARD_NR_SPI >= 1
_settings[0].spi_d = LPC_SSP0;
_settings[0].dataMode = SPI_MODE0;
_settings[0].dataSize = DATA_SIZE_8BIT;
_settings[0].clock = SPI_CLOCK_MAX;
//_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
#endif
#if BOARD_NR_SPI >= 2
_settings[1].spi_d = LPC_SSP1;
_settings[1].dataMode = SPI_MODE0;
_settings[1].dataSize = DATA_SIZE_8BIT;
_settings[1].clock = SPI_CLOCK_MAX;
//_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
#endif
setModule(device);
// Init the GPDMA controller
// TODO: call once in the constructor? or each time?
GPDMA_Init();
}
void SPIClass::begin() {
// Init the SPI pins in the first begin call
if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
(_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) {
pin_t sck, miso, mosi;
if (_currentSetting->spi_d == LPC_SSP0) {
sck = BOARD_SPI1_SCK_PIN;
miso = BOARD_SPI1_MISO_PIN;
mosi = BOARD_SPI1_MOSI_PIN;
spiInitialised[0] = true;
}
else if (_currentSetting->spi_d == LPC_SSP1) {
sck = BOARD_SPI2_SCK_PIN;
miso = BOARD_SPI2_MISO_PIN;
mosi = BOARD_SPI2_MOSI_PIN;
spiInitialised[1] = true;
}
PINSEL_CFG_Type PinCfg; // data structure to hold init values
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(sck);
PinCfg.Portnum = LPC176x::pin_port(sck);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(sck);
PinCfg.Pinnum = LPC176x::pin_bit(miso);
PinCfg.Portnum = LPC176x::pin_port(miso);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(miso);
PinCfg.Pinnum = LPC176x::pin_bit(mosi);
PinCfg.Portnum = LPC176x::pin_port(mosi);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(mosi);
}
updateSettings();
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
}
void SPIClass::beginTransaction(const SPISettings &cfg) { void SPIClass::beginTransaction(const SPISettings &cfg) {
setBitOrder(cfg.bitOrder); uint8_t spiRate;
setDataMode(cfg.dataMode); switch (cfg.spiRate()) {
setDataSize(cfg.dataSize); case 8000000: spiRate = 0; break;
//setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock)); case 4000000: spiRate = 1; break;
begin(); case 2000000: spiRate = 2; break;
case 1000000: spiRate = 3; break;
case 500000: spiRate = 4; break;
case 250000: spiRate = 5; break;
case 125000: spiRate = 6; break;
default: spiRate = 2; break;
}
spiInit(spiRate);
} }
uint8_t SPIClass::transfer(const uint16_t b) { uint8_t SPIClass::transfer(const uint8_t B) { return spiTransfer(B); }
// Send and receive a single byte
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
SSP_SendData(_currentSetting->spi_d, b);
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
return SSP_ReceiveData(_currentSetting->spi_d);
}
uint16_t SPIClass::transfer16(const uint16_t data) { uint16_t SPIClass::transfer16(const uint16_t data) {
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF); return (transfer((data >> 8) & 0xFF) << 8)
| (transfer(data & 0xFF) & 0xFF);
} }
void SPIClass::end() { SPIClass SPI;
// SSP_Cmd(_currentSetting->spi_d, DISABLE); // stop device or SSP_DeInit?
SSP_DeInit(_currentSetting->spi_d);
}
void SPIClass::send(uint8_t data) {
SSP_SendData(_currentSetting->spi_d, data);
}
void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
//TODO: LPC dma can only write 0xFFF bytes at once.
GPDMA_Channel_CFG_Type GPDMACfg;
/* Configure GPDMA channel 0 -------------------------------------------------------------*/
/* DMA Channel 0 */
GPDMACfg.ChannelNum = 0;
// Source memory
GPDMACfg.SrcMemAddr = (uint32_t)buf;
// Destination memory - Not used
GPDMACfg.DstMemAddr = 0;
// Transfer size
GPDMACfg.TransferSize = length;
// Transfer width
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
// Transfer type
GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
// Source connection - unused
GPDMACfg.SrcConn = 0;
// Destination connection
GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx;
GPDMACfg.DMALLI = 0;
// Enable dma on SPI
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
// Only increase memory if minc is true
GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
// Setup channel with given parameter
GPDMA_Setup(&GPDMACfg);
// Enable DMA
GPDMA_ChannelCmd(0, ENABLE);
// Wait for data transfer
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
// Clear err and int
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
// Disable DMA
GPDMA_ChannelCmd(0, DISABLE);
waitSpiTxEnd(_currentSetting->spi_d);
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
}
uint16_t SPIClass::read() {
return SSP_ReceiveData(_currentSetting->spi_d);
}
void SPIClass::read(uint8_t *buf, uint32_t len) {
for (uint16_t i = 0; i < len; i++) buf[i] = transfer(0xFF);
}
void SPIClass::setClock(uint32_t clock) {
_currentSetting->clock = clock;
}
void SPIClass::setModule(uint8_t device) {
_currentSetting = &_settings[device - 1];// SPI channels are called 1 2 and 3 but the array is zero indexed
}
void SPIClass::setBitOrder(uint8_t bitOrder) {
_currentSetting->bitOrder = bitOrder;
}
void SPIClass::setDataMode(uint8_t dataMode) {
_currentSetting->dataMode = dataMode;
}
void SPIClass::setDataSize(uint32_t ds) {
_currentSetting->dataSize = ds;
}
/**
* Set up/tear down
*/
void SPIClass::updateSettings() {
//SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?!
// divide PCLK by 2 for SSP0
CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
HW_SPI_init.ClockRate = _currentSetting->clock;
HW_SPI_init.Databit = _currentSetting->dataSize;
/**
* SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge
* 0 0 0 Falling Rising
* 1 0 1 Rising Falling
* 2 1 0 Rising Falling
* 3 1 1 Falling Rising
*/
switch (_currentSetting->dataMode) {
case SPI_MODE0:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE1:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE2:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
case SPI_MODE3:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
default:
break;
}
// TODO: handle bitOrder
SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
}
#if MISO_PIN == BOARD_SPI1_MISO_PIN
SPIClass SPI(1);
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
SPIClass SPI(2);
#endif
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -24,28 +24,28 @@
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#include "MarlinSerial.h" #include "MarlinSerial.h"
#if USING_SERIAL_0 #if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
MarlinSerial MSerial(LPC_UART0); MarlinSerial MSerial(LPC_UART0);
extern "C" void UART0_IRQHandler() { extern "C" void UART0_IRQHandler() {
MSerial.IRQHandler(); MSerial.IRQHandler();
} }
#endif #endif
#if USING_SERIAL_1 #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1); MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
extern "C" void UART1_IRQHandler() { extern "C" void UART1_IRQHandler() {
MSerial1.IRQHandler(); MSerial1.IRQHandler();
} }
#endif #endif
#if USING_SERIAL_2 #if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
MarlinSerial MSerial2(LPC_UART2); MarlinSerial MSerial2(LPC_UART2);
extern "C" void UART2_IRQHandler() { extern "C" void UART2_IRQHandler() {
MSerial2.IRQHandler(); MSerial2.IRQHandler();
} }
#endif #endif
#if USING_SERIAL_3 #if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
MarlinSerial MSerial3(LPC_UART3); MarlinSerial MSerial3(LPC_UART3);
extern "C" void UART3_IRQHandler() { extern "C" void UART3_IRQHandler() {
MSerial3.IRQHandler(); MSerial3.IRQHandler();

View file

@ -57,7 +57,6 @@ public:
} }
EmergencyParser::State emergency_state; EmergencyParser::State emergency_state;
static inline bool emergency_parser_enabled() { return true; }
#endif #endif
}; };

View file

@ -46,6 +46,7 @@
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. * Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
* *
* The only modification was to update/delete macros to match the LPC176x. * The only modification was to update/delete macros to match the LPC176x.
*
*/ */
#include <Servo.h> #include <Servo.h>

View file

@ -35,5 +35,5 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
} }
#endif // NEEDS_HARDWARE_PWM #endif // FAST_PWM_FAN || SPINDLE_LASER_PWM
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_FSMC_TFT
#error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768."
#endif

View file

@ -24,7 +24,7 @@
#if PIO_PLATFORM_VERSION < 1001 #if PIO_PLATFORM_VERSION < 1001
#error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically." #error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
#endif #endif
#if PIO_FRAMEWORK_VERSION < 2005 #if PIO_FRAMEWORK_VERSION < 2002
#error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries." #error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
#endif #endif
@ -59,10 +59,6 @@
*/ */
static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards."); static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards.");
#if SPINDLE_LASER_FREQUENCY
static_assert(!NUM_SERVOS, "BLTOUCH and Servos are incompatible with SPINDLE_LASER_FREQUENCY on LPC176x boards.");
#endif
/** /**
* Test LPC176x-specific configuration values for errors at compile-time. * Test LPC176x-specific configuration values for errors at compile-time.
*/ */
@ -89,10 +85,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
* Serial2 | P0_10 | P0_11 | * Serial2 | P0_10 | P0_11 |
* Serial3 | P0_00 | P0_01 | * Serial3 | P0_00 | P0_01 |
*/ */
#define ANY_TX(N,V...) DO(IS_TX##N,||,V) #if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
#if USING_SERIAL_0
#define IS_TX0(P) (P == P0_02) #define IS_TX0(P) (P == P0_02)
#define IS_RX0(P) (P == P0_03) #define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI) #if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
@ -106,67 +99,60 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#undef IS_RX0 #undef IS_RX0
#endif #endif
#if USING_SERIAL_1 #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
#define IS_TX1(P) (P == P0_15) #define IS_TX1(P) (P == P0_15)
#define IS_RX1(P) (P == P0_16) #define IS_RX1(P) (P == P0_16)
#define _IS_TX1_1 IS_TX1
#define _IS_RX1_1 IS_RX1
#if IS_TX1(TMC_SW_SCK) #if IS_TX1(TMC_SW_SCK)
#error "Serial port pins (1) conflict with other pins!" #error "Serial port pins (1) conflict with other pins!"
#elif HAS_WIRED_LCD #elif HAS_SPI_LCD
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1) #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
#error "Serial port pins (1) conflict with Encoder Buttons!" #error "Serial port pins (1) conflict with Encoder Buttons!"
#elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \ #elif IS_TX1(SCK_PIN) || IS_TX1(LCD_PINS_D4) || IS_TX1(DOGLCD_SCK) || IS_TX1(LCD_RESET_PIN) || IS_TX1(LCD_PINS_RS) || IS_TX1(SHIFT_CLK) \
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(LCD_PINS_RS) || IS_RX1(MISO_PIN) || IS_RX1(DOGLCD_A0) || IS_RX1(SS_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(DOGLCD_CS) || IS_RX1(LCD_RESET_PIN) || IS_RX1(LCD_BACKLIGHT_PIN)
#error "Serial port pins (1) conflict with LCD pins!" #error "Serial port pins (1) conflict with LCD pins!"
#endif #endif
#endif #endif
#undef IS_TX1 #undef IS_TX1
#undef IS_RX1 #undef IS_RX1
#undef _IS_TX1_1
#undef _IS_RX1_1
#endif #endif
#if USING_SERIAL_2 #if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
#define IS_TX2(P) (P == P0_10) #define IS_TX2(P) (P == P0_10)
#define IS_RX2(P) (P == P0_11) #define IS_RX2(P) (P == P0_11)
#define _IS_TX2_1 IS_TX2 #if IS_TX2(X2_ENABLE_PIN) || IS_RX2(X2_DIR_PIN) || IS_RX2(X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
#define _IS_RX2_1 IS_RX2
#if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
#error "Serial port pins (2) conflict with X2 pins!" #error "Serial port pins (2) conflict with X2 pins!"
#elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN)) #elif IS_TX2(Y2_ENABLE_PIN) || IS_RX2(Y2_DIR_PIN) || IS_RX2(Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
#error "Serial port pins (2) conflict with Y2 pins!" #error "Serial port pins (2) conflict with Y2 pins!"
#elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN)) #elif IS_TX2(Z2_ENABLE_PIN) || IS_RX2(Z2_DIR_PIN) || IS_RX2(Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
#error "Serial port pins (2) conflict with Z2 pins!" #error "Serial port pins (2) conflict with Z2 pins!"
#elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN)) #elif IS_TX2(Z3_ENABLE_PIN) || IS_RX2(Z3_DIR_PIN) || IS_RX2(Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
#error "Serial port pins (2) conflict with Z3 pins!" #error "Serial port pins (2) conflict with Z3 pins!"
#elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN)) #elif IS_TX2(Z4_ENABLE_PIN) || IS_RX2(Z4_DIR_PIN) || IS_RX2(Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
#error "Serial port pins (2) conflict with Z4 pins!" #error "Serial port pins (2) conflict with Z4 pins!"
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #elif IS_RX2(X_DIR_PIN) || IS_RX2(Y_DIR_PIN)
#error "Serial port pins (2) conflict with other pins!" #error "Serial port pins (2) conflict with other pins!"
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN) #elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
#error "Serial port pins (2) conflict with Y endstop pin!" #error "Serial port pins (2) conflict with Y endstop pin!"
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN) #elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
#error "Serial port pins (2) conflict with probe pin!" #error "Serial port pins (2) conflict with probe pin!"
#elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN)
#error "Serial port pins (2) conflict with X/Y stepper pins!" #error "Serial port pins (2) conflict with X/Y stepper pins!"
#elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) #elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
#error "Serial port pins (2) conflict with E1 stepper pins!" #error "Serial port pins (2) conflict with E1 stepper pins!"
#elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN) #elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN))
#error "Serial port pins (2) conflict with E stepper pins!" #error "Serial port pins (2) conflict with E stepper pins!"
#endif #endif
#undef IS_TX2 #undef IS_TX2
#undef IS_RX2 #undef IS_RX2
#undef _IS_TX2_1
#undef _IS_RX2_1
#endif #endif
#if USING_SERIAL_3 #if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00) #define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
#define PIN_IS_RX3(P) (P##_PIN == P0_01) #define PIN_IS_RX3(P) (P##_PIN == P0_01)
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX) #if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
#error "Serial port pins (3) conflict with X endstop pins!" #error "Serial port pins (3) conflict with X endstop pins!"
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX) #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) \
|| PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
#error "Serial port pins (3) conflict with X/Y axis UART pins!" #error "Serial port pins (3) conflict with X/Y axis UART pins!"
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP) #elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
#error "Serial port pins (3) conflict with X2 pins!" #error "Serial port pins (3) conflict with X2 pins!"
@ -178,20 +164,17 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "Serial port pins (3) conflict with Z3 pins!" #error "Serial port pins (3) conflict with Z3 pins!"
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP) #elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
#error "Serial port pins (3) conflict with Z4 pins!" #error "Serial port pins (3) conflict with Z4 pins!"
#elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP)) #elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
#error "Serial port pins (3) conflict with E1 pins!" #error "Serial port pins (3) conflict with E1 pins!"
#endif #endif
#undef PIN_IS_TX3 #undef PIN_IS_TX3
#undef PIN_IS_RX3 #undef PIN_IS_RX3
#endif #endif
#undef ANY_TX
#undef ANY_RX
// //
// Flag any i2c pin conflicts // Flag any i2c pin conflicts
// //
#if ANY(HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM) #if ANY(HAS_I2C_DIGIPOT, DAC_STEPPER_CURRENT, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM)
#define USEDI2CDEV_M 1 // <Arduino>/Wire.cpp #define USEDI2CDEV_M 1 // <Arduino>/Wire.cpp
#if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1) #if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1)
@ -227,7 +210,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals." #error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP) #elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals." #error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP)) #elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals." #error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
#endif #endif
#undef PIN_IS_SDA1 #undef PIN_IS_SDA1
@ -253,9 +236,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals." #error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Z4_ENABLE) #elif PIN_IS_SDA2(Z4_ENABLE)
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals." #error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE) #elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE)
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals." #error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS) #elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals." #error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR)) #elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals." #error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."

View file

@ -24,153 +24,25 @@
#include "../../shared/HAL_SPI.h" #include "../../shared/HAL_SPI.h"
#include <stdint.h> #include <stdint.h>
#include <lpc17xx_ssp.h>
#include <lpc17xx_gpdma.h>
//#define MSBFIRST 1 #define MSBFIRST 1
#define SPI_MODE3 0
#define SPI_MODE0 0
#define SPI_MODE1 1
#define SPI_MODE2 2
#define SPI_MODE3 3
#define DATA_SIZE_8BIT SSP_DATABIT_8
#define DATA_SIZE_16BIT SSP_DATABIT_16
#define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
#define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
#define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
#define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
#define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
#define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
#define BOARD_NR_SPI 2
//#define BOARD_SPI1_NSS_PIN PA4 ?!
#define BOARD_SPI1_SCK_PIN P0_15
#define BOARD_SPI1_MISO_PIN P0_17
#define BOARD_SPI1_MOSI_PIN P0_18
//#define BOARD_SPI2_NSS_PIN PB12 ?!
#define BOARD_SPI2_SCK_PIN P0_07
#define BOARD_SPI2_MISO_PIN P0_08
#define BOARD_SPI2_MOSI_PIN P0_09
class SPISettings { class SPISettings {
public: public:
SPISettings(uint32_t spiRate, int inBitOrder, int inDataMode) { SPISettings(uint32_t speed, int, int) : spi_speed(speed) {};
init_AlwaysInline(spiRate2Clock(spiRate), inBitOrder, inDataMode, DATA_SIZE_8BIT); uint32_t spiRate() const { return spi_speed; }
} private:
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) { uint32_t spi_speed;
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
else
init_MightInline(inClock, inBitOrder, inDataMode, inDataSize);
}
SPISettings() {
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
}
//uint32_t spiRate() const { return spi_speed; }
static inline uint32_t spiRate2Clock(uint32_t spiRate) {
uint32_t Marlin_speed[7]; // CPSR is always 2
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
return Marlin_speed[spiRate > 6 ? 6 : spiRate];
}
private:
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
}
void init_AlwaysInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) __attribute__((__always_inline__)) {
clock = inClock;
bitOrder = inBitOrder;
dataMode = inDataMode;
dataSize = inDataSize;
}
//uint32_t spi_speed;
uint32_t clock;
uint32_t dataSize;
//uint32_t clockDivider;
uint8_t bitOrder;
uint8_t dataMode;
LPC_SSP_TypeDef *spi_d;
friend class SPIClass;
}; };
/**
* @brief Wirish SPI interface.
*
* This is the same interface is available across HAL
*
* This implementation uses software slave management, so the caller
* is responsible for controlling the slave select line.
*/
class SPIClass { class SPIClass {
public: public:
/** void begin();
* @param spiPortNumber Number of the SPI port to manage. void beginTransaction(const SPISettings&);
*/ void endTransaction() {};
SPIClass(uint8_t spiPortNumber); uint8_t transfer(uint8_t data);
uint16_t transfer16(uint16_t data);
/**
* Select and configure the current selected SPI device to use
*/
void begin();
/**
* Disable the current SPI device
*/
void end();
void beginTransaction(const SPISettings&);
void endTransaction() {}
// Transfer using 1 "Data Size"
uint8_t transfer(uint16_t data);
// Transfer 2 bytes in 8 bit mode
uint16_t transfer16(uint16_t data);
void send(uint8_t data);
uint16_t read();
void read(uint8_t *buf, uint32_t len);
void dmaSend(void *buf, uint16_t length, bool minc);
/**
* @brief Sets the number of the SPI peripheral to be used by
* this HardwareSPI instance.
*
* @param spi_num Number of the SPI port. 1-2 in low density devices
* or 1-3 in high density devices.
*/
void setModule(uint8_t device);
void setClock(uint32_t clock);
void setBitOrder(uint8_t bitOrder);
void setDataMode(uint8_t dataMode);
void setDataSize(uint32_t ds);
inline uint32_t getDataSize() { return _currentSetting->dataSize; }
private:
SPISettings _settings[BOARD_NR_SPI];
SPISettings *_currentSetting;
void updateSettings();
}; };
extern SPIClass SPI; extern SPIClass SPI;

View file

@ -23,7 +23,7 @@
#include "../../core/macros.h" #include "../../core/macros.h"
#if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN) #if BOTH(SDSUPPORT, HAS_GRAPHICAL_LCD) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different. // 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 // This requirement can be removed if the SPI access to these devices is updated to use

View file

@ -1,153 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_SPI_TFT
#include "tft_spi.h"
//TFT_SPI tft;
SPIClass TFT_SPI::SPIx(1);
#define TFT_CS_H WRITE(TFT_CS_PIN, HIGH)
#define TFT_CS_L WRITE(TFT_CS_PIN, LOW)
#define TFT_DC_H WRITE(TFT_DC_PIN, HIGH)
#define TFT_DC_L WRITE(TFT_DC_PIN, LOW)
#define TFT_RST_H WRITE(TFT_RESET_PIN, HIGH)
#define TFT_RST_L WRITE(TFT_RESET_PIN, LOW)
#define TFT_BLK_H WRITE(TFT_BACKLIGHT_PIN, HIGH)
#define TFT_BLK_L WRITE(TFT_BACKLIGHT_PIN, LOW)
void TFT_SPI::Init() {
#if PIN_EXISTS(TFT_RESET)
SET_OUTPUT(TFT_RESET_PIN);
TFT_RST_H;
delay(100);
#endif
#if PIN_EXISTS(TFT_BACKLIGHT)
SET_OUTPUT(TFT_BACKLIGHT_PIN);
TFT_BLK_H;
#endif
SET_OUTPUT(TFT_DC_PIN);
SET_OUTPUT(TFT_CS_PIN);
TFT_DC_H;
TFT_CS_H;
/**
* STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz
* STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
*/
#if 0
#if SPI_DEVICE == 1
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
#else
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
#endif
uint8_t clock;
uint8_t spiRate = SPI_FULL_SPEED;
switch (spiRate) {
case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; 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
}
#endif
#if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN
SPIx.setModule(1);
#elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN
SPIx.setModule(2);
#endif
SPIx.setClock(SPI_CLOCK_MAX);
SPIx.setBitOrder(MSBFIRST);
SPIx.setDataMode(SPI_MODE0);
}
void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
SPIx.setDataSize(DataSize);
SPIx.begin();
TFT_CS_L;
}
uint32_t TFT_SPI::GetID() {
uint32_t id;
id = ReadID(LCD_READ_ID);
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = ReadID(LCD_READ_ID4);
return id;
}
uint32_t TFT_SPI::ReadID(uint16_t Reg) {
uint32_t data = 0;
#if PIN_EXISTS(TFT_MISO)
uint8_t d = 0;
SPIx.setDataSize(DATASIZE_8BIT);
SPIx.setClock(SPI_CLOCK_DIV64);
SPIx.begin();
TFT_CS_L;
WriteReg(Reg);
LOOP_L_N(i, 4) {
SPIx.read((uint8_t*)&d, 1);
data = (data << 8) | d;
}
DataTransferEnd();
SPIx.setClock(SPI_CLOCK_MAX);
#endif
return data >> 7;
}
bool TFT_SPI::isBusy() {
return false;
}
void TFT_SPI::Abort() {
DataTransferEnd();
}
void TFT_SPI::Transmit(uint16_t Data) {
SPIx.transfer(Data);
}
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DataTransferBegin(DATASIZE_16BIT); //16
TFT_DC_H;
SPIx.dmaSend(Data, Count, MemoryIncrease);
DataTransferEnd();
}
#endif // HAS_SPI_TFT

View file

@ -1,77 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../../inc/MarlinConfig.h"
#include <SPI.h>
#include <lpc17xx_ssp.h>
// #include <lpc17xx_gpdma.h>
#ifndef LCD_READ_ID
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
#endif
#ifndef LCD_READ_ID4
#define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
#endif
#define DATASIZE_8BIT SSP_DATABIT_8
#define DATASIZE_16BIT SSP_DATABIT_16
#define TFT_IO_DRIVER TFT_SPI
#define DMA_MINC_ENABLE 1
#define DMA_MINC_DISABLE 0
class TFT_SPI {
private:
static uint32_t ReadID(uint16_t Reg);
static void Transmit(uint16_t Data);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
public:
static SPIClass SPIx;
static void Init();
static uint32_t GetID();
static bool isBusy();
static void Abort();
static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT);
static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); };
static void DataTransferAbort();
static void WriteData(uint16_t Data) { Transmit(Data); }
static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
static void WriteMultiple(uint16_t Color, uint32_t Count) {
static uint16_t Data; Data = Color;
//LPC dma can only write 0xFFF bytes at once.
#define MAX_DMA_SIZE (0xFFF - 1)
while (Count > 0) {
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count);
Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0;
}
#undef MAX_DMA_SIZE
}
};

View file

@ -1,128 +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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
#include "xpt2046.h"
#include <SPI.h>
uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; }
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
#include <SPI.h>
SPIClass XPT2046::SPIx(TOUCH_BUTTONS_HW_SPI_DEVICE);
static void touch_spi_init(uint8_t spiRate) {
XPT2046::SPIx.setModule(TOUCH_BUTTONS_HW_SPI_DEVICE);
XPT2046::SPIx.setClock(SPI_CLOCK_DIV128);
XPT2046::SPIx.setBitOrder(MSBFIRST);
XPT2046::SPIx.setDataMode(SPI_MODE0);
XPT2046::SPIx.setDataSize(DATA_SIZE_8BIT);
}
#endif
void XPT2046::Init() {
SET_INPUT(TOUCH_MISO_PIN);
SET_OUTPUT(TOUCH_MOSI_PIN);
SET_OUTPUT(TOUCH_SCK_PIN);
OUT_WRITE(TOUCH_CS_PIN, HIGH);
#if PIN_EXISTS(TOUCH_INT)
// Optional Pendrive interrupt pin
SET_INPUT(TOUCH_INT_PIN);
#endif
TERN_(TOUCH_BUTTONS_HW_SPI, touch_spi_init(SPI_SPEED_6));
// Read once to enable pendrive status pin
getRawData(XPT2046_X);
}
bool XPT2046::isTouched() {
return isBusy() ? false : (
#if PIN_EXISTS(TOUCH_INT)
READ(TOUCH_INT_PIN) != HIGH
#else
getRawData(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD
#endif
);
}
bool XPT2046::getRawPoint(int16_t *x, int16_t *y) {
if (isBusy()) return false;
if (!isTouched()) return false;
*x = getRawData(XPT2046_X);
*y = getRawData(XPT2046_Y);
return isTouched();
}
uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) {
uint16_t data[3];
DataTransferBegin();
TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.begin());
for (uint16_t i = 0; i < 3 ; i++) {
IO(coordinate);
data[i] = (IO() << 4) | (IO() >> 4);
}
TERN_(TOUCH_BUTTONS_HW_SPI, SPIx.end());
DataTransferEnd();
uint16_t delta01 = delta(data[0], data[1]),
delta02 = delta(data[0], data[2]),
delta12 = delta(data[1], data[2]);
if (delta01 > delta02 || delta01 > delta12)
data[delta02 > delta12 ? 0 : 1] = data[2];
return (data[0] + data[1]) >> 1;
}
uint16_t XPT2046::IO(uint16_t data) {
return TERN(TOUCH_BUTTONS_HW_SPI, HardwareIO, SoftwareIO)(data);
}
extern uint8_t spiTransfer(uint8_t b);
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
uint16_t XPT2046::HardwareIO(uint16_t data) {
return SPIx.transfer(data & 0xFF);
}
#endif
uint16_t XPT2046::SoftwareIO(uint16_t data) {
uint16_t result = 0;
for (uint8_t j = 0x80; j; j >>= 1) {
WRITE(TOUCH_SCK_PIN, LOW);
WRITE(TOUCH_MOSI_PIN, data & j ? HIGH : LOW);
if (READ(TOUCH_MISO_PIN)) result |= j;
WRITE(TOUCH_SCK_PIN, HIGH);
}
WRITE(TOUCH_SCK_PIN, LOW);
return result;
}
#endif // HAS_TFT_XPT2046

View file

@ -1,80 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../../inc/MarlinConfig.h"
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
#include <SPI.h>
#endif
#ifndef TOUCH_MISO_PIN
#define TOUCH_MISO_PIN MISO_PIN
#endif
#ifndef TOUCH_MOSI_PIN
#define TOUCH_MOSI_PIN MOSI_PIN
#endif
#ifndef TOUCH_SCK_PIN
#define TOUCH_SCK_PIN SCK_PIN
#endif
#ifndef TOUCH_CS_PIN
#define TOUCH_CS_PIN CS_PIN
#endif
#ifndef TOUCH_INT_PIN
#define TOUCH_INT_PIN -1
#endif
#define XPT2046_DFR_MODE 0x00
#define XPT2046_SER_MODE 0x04
#define XPT2046_CONTROL 0x80
enum XPTCoordinate : uint8_t {
XPT2046_X = 0x10 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Y = 0x50 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Z1 = 0x30 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#define XPT2046_Z1_THRESHOLD 10
#endif
class XPT2046 {
private:
static bool isBusy() { return false; }
static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched();
static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); };
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
static uint16_t HardwareIO(uint16_t data);
#endif
static uint16_t SoftwareIO(uint16_t data);
static uint16_t IO(uint16_t data = 0);
public:
#if ENABLED(TOUCH_BUTTONS_HW_SPI)
static SPIClass SPIx;
#endif
static void Init();
static bool getRawPoint(int16_t *x, int16_t *y);
};

View file

@ -21,6 +21,7 @@
#pragma once #pragma once
/** /**
*
* HAL For LPC1768 * HAL For LPC1768
*/ */

View file

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include <U8glib.h> #include <U8glib.h>
#include "../../shared/HAL_SPI.h" #include "../../shared/HAL_SPI.h"
@ -124,6 +124,6 @@ uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -77,7 +77,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include <U8glib.h> #include <U8glib.h>
@ -193,6 +193,6 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_GRAPHICAL_LCD
#include <U8glib.h> #include <U8glib.h>
#include "../../shared/HAL_SPI.h" #include "../../shared/HAL_SPI.h"
@ -133,6 +133,6 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB #endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -57,7 +57,7 @@
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920) #if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
#include <SoftwareSPI.h> #include <SoftwareSPI.h>
@ -203,5 +203,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1; return 1;
} }
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920 #endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
#endif // TARGET_LPC1768 #endif // TARGET_LPC1768

View file

@ -26,9 +26,7 @@
#if ENABLED(EMERGENCY_PARSER) #if ENABLED(EMERGENCY_PARSER)
#include "../../feature/e_parser.h" #include "../../feature/e_parser.h"
EmergencyParser::State emergency_state; EmergencyParser::State emergency_state;
bool CDC_RecvCallback(const char buffer) { bool CDC_RecvCallback(const char buffer) {
emergency_parser.update(emergency_state, buffer); emergency_parser.update(emergency_state, buffer);
return true; return true;

View file

@ -35,35 +35,58 @@
// MYSERIAL0 required before MarlinSerial includes! // MYSERIAL0 required before MarlinSerial includes!
#define __MSERIAL(X) Serial##X
#define _MSERIAL(X) __MSERIAL(X)
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
#define MYSERIAL0 Serial #define MYSERIAL0 Serial
#elif WITHIN(SERIAL_PORT, 0, 3) #elif SERIAL_PORT == 0
#define MYSERIAL0 MSERIAL(SERIAL_PORT) #define MYSERIAL0 Serial1
#elif SERIAL_PORT == 1
#define MYSERIAL0 Serial2
#elif SERIAL_PORT == 2
#define MYSERIAL0 Serial3
#elif SERIAL_PORT == 3
#define MYSERIAL0 Serial4
#else #else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 Serial #define MYSERIAL1 Serial
#elif WITHIN(SERIAL_PORT_2, 0, 3) #elif SERIAL_PORT_2 == 0
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #define MYSERIAL1 Serial1
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 Serial2
#elif SERIAL_PORT_2 == 2
#define MYSERIAL1 Serial3
#elif SERIAL_PORT_2 == 3
#define MYSERIAL1 Serial4
#else #else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif #endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef DGUS_SERIAL_PORT
#if LCD_SERIAL_PORT == -1 #if DGUS_SERIAL_PORT == SERIAL_PORT
#define LCD_SERIAL Serial #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif WITHIN(LCD_SERIAL_PORT, 0, 3) #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial3
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial4
#else #else
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif #endif
#endif #endif
@ -89,8 +112,6 @@ typedef int8_t pin_t;
void HAL_clear_reset_source(); // clear reset reason void HAL_clear_reset_source(); // clear reset reason
uint8_t HAL_get_reset_source(); // get reset reason uint8_t HAL_get_reset_source(); // get reset reason
inline void HAL_reboot() {} // reboot the board or restart the bootloader
// //
// ADC // ADC
// //

View file

@ -26,7 +26,7 @@
#include "QSPIFlash.h" #include "QSPIFlash.h"
#define INVALID_ADDR 0xFFFFFFFF #define INVALID_ADDR 0xffffffff
#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1)) #define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1))
#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1)) #define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1))

View file

@ -24,6 +24,7 @@
* THE SOFTWARE. * THE SOFTWARE.
* *
* Derived from Adafruit_SPIFlash class with no SdFat references * Derived from Adafruit_SPIFlash class with no SdFat references
*
*/ */
#pragma once #pragma once

View file

@ -126,83 +126,82 @@
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
#if HAS_X_MAX #if HAS_X_MAX
#if !AVAILABLE_EILINE(X_MAX_PIN) #if !AVAILABLE_EILINE(X_MAX_PIN)
#error "X_MAX_PIN has no EXTINT line available." #error "X_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(X_MAX_PIN); attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_X_MIN #if HAS_X_MIN
#if !AVAILABLE_EILINE(X_MIN_PIN) #if !AVAILABLE_EILINE(X_MIN_PIN)
#error "X_MIN_PIN has no EXTINT line available." #error "X_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(X_MIN_PIN); attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Y_MAX #if HAS_Y_MAX
#if !AVAILABLE_EILINE(Y_MAX_PIN) #if !AVAILABLE_EILINE(Y_MAX_PIN)
#error "Y_MAX_PIN has no EXTINT line available." #error "Y_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Y_MAX_PIN); attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Y_MIN #if HAS_Y_MIN
#if !AVAILABLE_EILINE(Y_MIN_PIN) #if !AVAILABLE_EILINE(Y_MIN_PIN)
#error "Y_MIN_PIN has no EXTINT line available." #error "Y_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Y_MIN_PIN); attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z_MAX #if HAS_Z_MAX
#if !AVAILABLE_EILINE(Z_MAX_PIN) #if !AVAILABLE_EILINE(Z_MAX_PIN)
#error "Z_MAX_PIN has no EXTINT line available." #error "Z_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z_MAX_PIN); attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z_MIN #if HAS_Z_MIN
#if !AVAILABLE_EILINE(Z_MIN_PIN) #if !AVAILABLE_EILINE(Z_MIN_PIN)
#error "Z_MIN_PIN has no EXTINT line available." #error "Z_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z_MIN_PIN); attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z2_MAX #if HAS_Z2_MAX
#if !AVAILABLE_EILINE(Z2_MAX_PIN) #if !AVAILABLE_EILINE(Z2_MAX_PIN)
#error "Z2_MAX_PIN has no EXTINT line available." #error "Z2_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z2_MAX_PIN); attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z2_MIN #if HAS_Z2_MIN
#if !AVAILABLE_EILINE(Z2_MIN_PIN) #if !AVAILABLE_EILINE(Z2_MIN_PIN)
#error "Z2_MIN_PIN has no EXTINT line available." #error "Z2_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z2_MIN_PIN); attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z3_MAX #if HAS_Z3_MAX
#if !AVAILABLE_EILINE(Z3_MAX_PIN) #if !AVAILABLE_EILINE(Z3_MAX_PIN)
#error "Z3_MAX_PIN has no EXTINT line available." #error "Z3_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z3_MAX_PIN); attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z3_MIN #if HAS_Z3_MIN
#if !AVAILABLE_EILINE(Z3_MIN_PIN) #if !AVAILABLE_EILINE(Z3_MIN_PIN)
#error "Z3_MIN_PIN has no EXTINT line available." #error "Z3_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z3_MIN_PIN); attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z4_MAX #if HAS_Z4_MAX
#if !AVAILABLE_EILINE(Z4_MAX_PIN) #if !AVAILABLE_EILINE(Z4_MAX_PIN)
#error "Z4_MAX_PIN has no EXTINT line available." #error "Z4_MAX_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z4_MAX_PIN); attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z4_MIN #if HAS_Z4_MIN
#if !AVAILABLE_EILINE(Z4_MIN_PIN) #if !AVAILABLE_EILINE(Z4_MIN_PIN)
#error "Z4_MIN_PIN has no EXTINT line available." #error "Z4_MIN_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z4_MIN_PIN); attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif #endif
#if HAS_Z_MIN_PROBE_PIN #if HAS_Z_MIN_PROBE_PIN
#if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN) #if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN)
#error "Z_MIN_PROBE_PIN has no EXTINT line available." #error "Z_MIN_PROBE_PIN has no EXTINT line available."
#endif #endif
_ATTACH(Z_MIN_PROBE_PIN); attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif #endif
} }

View file

@ -20,7 +20,3 @@
* *
*/ */
#pragma once #pragma once
#if HAS_SPI_TFT || HAS_FSMC_TFT
#error "Sorry! TFT displays are not available for HAL/SAMD51."
#endif

View file

@ -47,6 +47,6 @@
#error "SDIO_SUPPORT is not supported on SAMD51." #error "SDIO_SUPPORT is not supported on SAMD51."
#endif #endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on SAMD51." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif

View file

@ -150,4 +150,5 @@ void pwm_details(int32_t pin) {
* 93 | PA10 | QSPI: IO2 * 93 | PA10 | QSPI: IO2
* 94 | PA11 | QSPI: IO3 * 94 | PA11 | QSPI: IO3
* 95 | PB31 | SD: DETECT * 95 | PB31 | SD: DETECT
*
*/ */

View file

@ -63,7 +63,7 @@ uint16_t HAL_adc_result;
void HAL_init() { void HAL_init() {
FastIO_init(); FastIO_init();
#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1) #if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT)
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif #endif
@ -122,14 +122,9 @@ extern "C" {
// TODO: Make sure this doesn't cause any delay // TODO: Make sure this doesn't cause any delay
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
uint16_t HAL_adc_get_result() { return HAL_adc_result; } uint16_t HAL_adc_get_result() { return HAL_adc_result; }
// Reset the system (to initiate a firmware flash)
void flashFirmware(const int16_t) { NVIC_SystemReset(); } void flashFirmware(const int16_t) { NVIC_SystemReset(); }
// Maple Compatibility
systickCallback_t systick_user_callback;
void systick_attach_callback(systickCallback_t cb) { systick_user_callback = cb; }
void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); }
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

View file

@ -43,40 +43,83 @@
// ------------------------ // ------------------------
// Defines // Defines
// ------------------------ // ------------------------
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
#if SERIAL_PORT == -1 #if SERIAL_PORT == 0
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#define MYSERIAL0 SerialUSB #define MYSERIAL0 SerialUSB
#elif WITHIN(SERIAL_PORT, 1, 6) #elif SERIAL_PORT == 1
#define MYSERIAL0 MSERIAL(SERIAL_PORT) #define MYSERIAL0 MSerial1
#elif SERIAL_PORT == 2
#define MYSERIAL0 MSerial2
#elif SERIAL_PORT == 3
#define MYSERIAL0 MSerial3
#elif SERIAL_PORT == 4
#define MYSERIAL0 MSerial4
#elif SERIAL_PORT == 5
#define MYSERIAL0 MSerial5
#elif SERIAL_PORT == 6
#define MYSERIAL0 MSerial6
#else #else
#error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1 #define NUM_SERIAL 2
#if SERIAL_PORT_2 == 0
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 SerialUSB #define MYSERIAL1 SerialUSB
#elif WITHIN(SERIAL_PORT_2, 1, 6) #elif SERIAL_PORT_2 == 1
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #define MYSERIAL1 MSerial1
#elif SERIAL_PORT_2 == 2
#define MYSERIAL1 MSerial2
#elif SERIAL_PORT_2 == 3
#define MYSERIAL1 MSerial3
#elif SERIAL_PORT_2 == 4
#define MYSERIAL1 MSerial4
#elif SERIAL_PORT_2 == 5
#define MYSERIAL1 MSerial5
#elif SERIAL_PORT_2 == 6
#define MYSERIAL1 MSerial6
#else #else
#error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration." #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
#endif #endif
#else
#define NUM_SERIAL 1
#endif #endif
#ifdef LCD_SERIAL_PORT #if HAS_DGUS_LCD
#if LCD_SERIAL_PORT == -1 #if DGUS_SERIAL_PORT == 0
#define LCD_SERIAL SerialUSB #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif WITHIN(LCD_SERIAL_PORT, 1, 6) #elif DGUS_SERIAL_PORT == SERIAL_PORT
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL SerialUSB
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL MSerial4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL MSerial5
#elif DGUS_SERIAL_PORT == 6
#define DGUS_SERIAL MSerial6
#else #else
#error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif #endif
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
#endif #endif
/** /**
* TODO: review this to return 1 for pins that are not analog input * TODO: review this to return 1 for pins that are not analog input
*/ */
@ -134,8 +177,6 @@ void HAL_clear_reset_source();
// Reset reason // Reset reason
uint8_t HAL_get_reset_source(); uint8_t HAL_get_reset_source();
inline void HAL_reboot() {} // reboot the board or restart the bootloader
void _delay_ms(const int delay); void _delay_ms(const int delay);
extern "C" char* _sbrk(int incr); extern "C" char* _sbrk(int incr);
@ -172,15 +213,5 @@ uint16_t HAL_adc_get_result();
#define GET_PIN_MAP_INDEX(pin) pin #define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
#ifdef STM32F1xx
#define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE)
#define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE)
#endif
#define PLATFORM_M997_SUPPORT #define PLATFORM_M997_SUPPORT
void flashFirmware(const int16_t); void flashFirmware(const int16_t);
// Maple Compatibility
typedef void (*systickCallback_t)(void);
void systick_attach_callback(systickCallback_t cb);
void HAL_SYSTICK_Callback();

View file

@ -132,9 +132,11 @@ static SPISettings spiConfig;
* @details Only configures SS pin since stm32duino creates and initialize the SPI object * @details Only configures SS pin since stm32duino creates and initialize the SPI object
*/ */
void spiBegin() { void spiBegin() {
#if PIN_EXISTS(SS) #if !PIN_EXISTS(SS)
OUT_WRITE(SS_PIN, HIGH); #error "SS_PIN not defined!"
#endif #endif
OUT_WRITE(SS_PIN, HIGH);
} }
// Configure SPI for specified SPI speed // Configure SPI for specified SPI speed
@ -171,7 +173,9 @@ static SPISettings spiConfig;
* @details * @details
*/ */
uint8_t spiRec() { uint8_t spiRec() {
SPI.beginTransaction(spiConfig);
uint8_t returnByte = SPI.transfer(0xFF); uint8_t returnByte = SPI.transfer(0xFF);
SPI.endTransaction();
return returnByte; return returnByte;
} }
@ -187,7 +191,9 @@ static SPISettings spiConfig;
void spiRead(uint8_t* buf, uint16_t nbyte) { void spiRead(uint8_t* buf, uint16_t nbyte) {
if (nbyte == 0) return; if (nbyte == 0) return;
memset(buf, 0xFF, nbyte); memset(buf, 0xFF, nbyte);
SPI.beginTransaction(spiConfig);
SPI.transfer(buf, nbyte); SPI.transfer(buf, nbyte);
SPI.endTransaction();
} }
/** /**
@ -198,7 +204,9 @@ static SPISettings spiConfig;
* @details * @details
*/ */
void spiSend(uint8_t b) { void spiSend(uint8_t b) {
SPI.beginTransaction(spiConfig);
SPI.transfer(b); SPI.transfer(b);
SPI.endTransaction();
} }
/** /**
@ -211,8 +219,10 @@ static SPISettings spiConfig;
*/ */
void spiSendBlock(uint8_t token, const uint8_t* buf) { void spiSendBlock(uint8_t token, const uint8_t* buf) {
uint8_t rxBuf[512]; uint8_t rxBuf[512];
SPI.beginTransaction(spiConfig);
SPI.transfer(token); SPI.transfer(token);
SPI.transfer((uint8_t*)buf, &rxBuf, 512); SPI.transfer((uint8_t*)buf, &rxBuf, 512);
SPI.endTransaction();
} }
#endif // SOFTWARE_SPI #endif // SOFTWARE_SPI

View file

@ -49,14 +49,16 @@
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2) DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
#endif #endif
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0 #if defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT >= 0
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT) DECLARE_SERIAL_PORT_EXP(DGUS_SERIAL_PORT)
#endif #endif
void MarlinSerial::begin(unsigned long baud, uint8_t config) { void MarlinSerial::begin(unsigned long baud, uint8_t config) {
HardwareSerial::begin(baud, config); HardwareSerial::begin(baud, config);
// Replace the IRQ callback with the one we have defined // replace the IRQ callback with the one we have defined
TERN_(EMERGENCY_PARSER, _serial.rx_callback = _rx_callback); #if ENABLED(EMERGENCY_PARSER)
_serial.rx_callback = _rx_callback;
#endif
} }
// This function is Copyright (c) 2006 Nicholas Zambetti. // This function is Copyright (c) 2006 Nicholas Zambetti.

View file

@ -35,10 +35,6 @@ public:
#endif #endif
{ } { }
#if ENABLED(EMERGENCY_PARSER)
static inline bool emergency_parser_enabled() { return true; }
#endif
void begin(unsigned long baud, uint8_t config); void begin(unsigned long baud, uint8_t config);
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }

View file

@ -76,24 +76,7 @@
SD_HandleTypeDef hsd; // create SDIO structure SD_HandleTypeDef hsd; // create SDIO structure
/* #define TRANSFER_CLOCK_DIV (uint8_t(SDIO_INIT_CLK_DIV) / 40)
SDIO_INIT_CLK_DIV is 118
SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2)
SDIO init clock frequency should not exceed 400KHz = 48MHz / (118 + 2)
Default TRANSFER_CLOCK_DIV is 2 (118 / 40)
Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz
This might be too fast for stable SDIO operations
MKS Robin board seems to have stable SDIO with BusWide 1bit and ClockDiv 8 i.e. 4.8MHz SDIO clock frequency
Additional testing is required as there are clearly some 4bit initialization problems
Add -DTRANSFER_CLOCK_DIV=8 to build parameters to improve SDIO stability
*/
#ifndef TRANSFER_CLOCK_DIV
#define TRANSFER_CLOCK_DIV (uint8_t(SDIO_INIT_CLK_DIV) / 40)
#endif
#ifndef USBD_OK #ifndef USBD_OK
#define USBD_OK 0 #define USBD_OK 0
@ -117,25 +100,24 @@
void SD_LowLevel_Init(void) { void SD_LowLevel_Init(void) {
uint32_t tempreg; uint32_t tempreg;
__HAL_RCC_SDIO_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks
__HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks
GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = 1; //GPIO_NOPULL; GPIO_InitStruct.Pull = 1; //GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
#if DISABLED(STM32F1xx)
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
#endif
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus
GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3 GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = 1; // GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
#endif #endif
@ -143,13 +125,10 @@
GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
RCC->APB2ENR |= RCC_APB2RSTR_SDIORST_Msk; // enable SDIO clock
#if DISABLED(STM32F1xx) // Enable the DMA2 Clock
// TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE();
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
RCC->APB2ENR |= RCC_APB2RSTR_SDIORST_Msk; // enable SDIO clock
// Enable the DMA2 Clock
#endif
//Initialize the SDIO (with initial <400Khz Clock) //Initialize the SDIO (with initial <400Khz Clock)
tempreg = 0; //Reset value tempreg = 0; //Reset value
@ -177,21 +156,10 @@
bool status; bool status;
hsd.Instance = SDIO; hsd.Instance = SDIO;
hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET
/*
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 8;
*/
SD_LowLevel_Init(); SD_LowLevel_Init();
uint8_t retry_Cnt = retryCnt; uint8_t retry_Cnt = retryCnt;
for (;;) { for (;;) {
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
status = (bool) HAL_SD_Init(&hsd); status = (bool) HAL_SD_Init(&hsd);
if (!status) break; if (!status) break;
if (!--retry_Cnt) return false; // return failing status if retries are exhausted if (!--retry_Cnt) return false; // return failing status if retries are exhausted
@ -202,7 +170,6 @@
#if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
retry_Cnt = retryCnt; retry_Cnt = retryCnt;
for (;;) { for (;;) {
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required
if (!--retry_Cnt) break; if (!--retry_Cnt) break;
} }
@ -211,7 +178,6 @@
SD_LowLevel_Init(); SD_LowLevel_Init();
retry_Cnt = retryCnt; retry_Cnt = retryCnt;
for (;;) { for (;;) {
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
status = (bool) HAL_SD_Init(&hsd); status = (bool) HAL_SD_Init(&hsd);
if (!status) break; if (!status) break;
if (!--retry_Cnt) return false; // return failing status if retries are exhausted if (!--retry_Cnt) return false; // return failing status if retries are exhausted
@ -221,15 +187,15 @@
return true; return true;
} }
/*
void init_SDIO_pins(void) { void init_SDIO_pins(void) {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
// SDIO GPIO Configuration /**SDIO GPIO Configuration
// PC8 ------> SDIO_D0 PC8 ------> SDIO_D0
// PC12 ------> SDIO_CK PC12 ------> SDIO_CK
// PD2 ------> SDIO_CMD PD2 ------> SDIO_CMD
*/
GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
@ -251,7 +217,7 @@
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
} }
*/
//bool SDIO_init() { return (bool) (SD_SDIO_Init() ? 1 : 0);} //bool SDIO_init() { return (bool) (SD_SDIO_Init() ? 1 : 0);}
//bool SDIO_Init_C() { return (bool) (SD_SDIO_Init() ? 1 : 0);} //bool SDIO_Init_C() { return (bool) (SD_SDIO_Init() ? 1 : 0);}
@ -261,7 +227,6 @@
bool status; bool status;
for (;;) { for (;;) {
TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
status = (bool) HAL_SD_ReadBlocks(&hsd, (uint8_t*)dst, block, 1, 1000); // read one 512 byte block with 500mS timeout status = (bool) HAL_SD_ReadBlocks(&hsd, (uint8_t*)dst, block, 1, 1000); // read one 512 byte block with 500mS timeout
status |= (bool) HAL_SD_GetCardState(&hsd); // make sure all is OK status |= (bool) HAL_SD_GetCardState(&hsd); // make sure all is OK
if (!status) break; // return passing status if (!status) break; // return passing status

View file

@ -0,0 +1,396 @@
/*
* SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
*
* Multi-instance software serial library for Arduino/Wiring
* -- Interrupt-driven receive and other improvements by ladyada
* (https://ladyada.net)
* -- Tuning, circular buffer, derivation from class Print/Stream,
* multi-instance support, porting to 8MHz processors,
* various optimizations, PROGMEM delay tables, inverse logic and
* direct port writing by Mikal Hart (http://www.arduiniana.org)
* -- Pin change interrupt macros by Paul Stoffregen (https://www.pjrc.com)
* -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
* -- ATmega1280/2560 support by Brett Hagman (https://www.roguerobotics.com/)
* -- STM32 support by Armin van der Togt
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* The latest version of this library can always be found at
* http://arduiniana.org.
*/
//
// Includes
//
#if defined(PLATFORMIO) && defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#include "../../inc/MarlinConfig.h"
#include "SoftwareSerial.h"
#define OVERSAMPLE 3 // in RX, Timer will generate interruption OVERSAMPLE time during a bit. Thus OVERSAMPLE ticks in a bit. (interrupt not synchonized with edge).
// defined in bit-periods
#define HALFDUPLEX_SWITCH_DELAY 5
// It's best to define TIMER_SERIAL in variant.h. If not defined, we choose one here
// The order is based on (lack of) features and compare channels, we choose the simplest available
// because we only need an update interrupt
#if !defined(TIMER_SERIAL)
#if defined(TIM18_BASE)
#define TIMER_SERIAL TIM18
#elif defined(TIM7_BASE)
#define TIMER_SERIAL TIM7
#elif defined(TIM6_BASE)
#define TIMER_SERIAL TIM6
#elif defined(TIM22_BASE)
#define TIMER_SERIAL TIM22
#elif defined(TIM21_BASE)
#define TIMER_SERIAL TIM21
#elif defined(TIM17_BASE)
#define TIMER_SERIAL TIM17
#elif defined(TIM16_BASE)
#define TIMER_SERIAL TIM16
#elif defined(TIM15_BASE)
#define TIMER_SERIAL TIM15
#elif defined(TIM14_BASE)
#define TIMER_SERIAL TIM14
#elif defined(TIM13_BASE)
#define TIMER_SERIAL TIM13
#elif defined(TIM11_BASE)
#define TIMER_SERIAL TIM11
#elif defined(TIM10_BASE)
#define TIMER_SERIAL TIM10
#elif defined(TIM12_BASE)
#define TIMER_SERIAL TIM12
#elif defined(TIM19_BASE)
#define TIMER_SERIAL TIM19
#elif defined(TIM9_BASE)
#define TIMER_SERIAL TIM9
#elif defined(TIM5_BASE)
#define TIMER_SERIAL TIM5
#elif defined(TIM4_BASE)
#define TIMER_SERIAL TIM4
#elif defined(TIM3_BASE)
#define TIMER_SERIAL TIM3
#elif defined(TIM2_BASE)
#define TIMER_SERIAL TIM2
#elif defined(TIM20_BASE)
#define TIMER_SERIAL TIM20
#elif defined(TIM8_BASE)
#define TIMER_SERIAL TIM8
#elif defined(TIM1_BASE)
#define TIMER_SERIAL TIM1
#else
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
#endif
#endif
//
// Statics
//
HardwareTimer SoftwareSerial::timer(TIMER_SERIAL);
const IRQn_Type SoftwareSerial::timer_interrupt_number = static_cast<IRQn_Type>(getTimerUpIrq(TIMER_SERIAL));
uint32_t SoftwareSerial::timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), TIM_IRQ_PRIO, TIM_IRQ_SUBPRIO);
SoftwareSerial *SoftwareSerial::active_listener = nullptr;
SoftwareSerial *volatile SoftwareSerial::active_out = nullptr;
SoftwareSerial *volatile SoftwareSerial::active_in = nullptr;
int32_t SoftwareSerial::tx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
int32_t volatile SoftwareSerial::rx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
uint32_t SoftwareSerial::tx_buffer = 0;
int32_t SoftwareSerial::tx_bit_cnt = 0;
uint32_t SoftwareSerial::rx_buffer = 0;
int32_t SoftwareSerial::rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
uint32_t SoftwareSerial::cur_speed = 0;
void SoftwareSerial::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority) {
timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority);
}
//
// Private methods
//
void SoftwareSerial::setSpeed(uint32_t speed) {
if (speed != cur_speed) {
timer.pause();
if (speed != 0) {
// Disable the timer
uint32_t clock_rate, cmp_value;
// Get timer clock
clock_rate = timer.getTimerClkFreq();
int pre = 1;
// Calculate prescale an compare value
do {
cmp_value = clock_rate / (speed * OVERSAMPLE);
if (cmp_value >= UINT16_MAX) {
clock_rate /= 2;
pre *= 2;
}
} while (cmp_value >= UINT16_MAX);
timer.setPrescaleFactor(pre);
timer.setOverflow(cmp_value);
timer.setCount(0);
timer.attachInterrupt(&handleInterrupt);
timer.resume();
NVIC_SetPriority(timer_interrupt_number, timer_interrupt_priority);
}
else
timer.detachInterrupt();
cur_speed = speed;
}
}
// This function sets the current object as the "listening"
// one and returns true if it replaces another
bool SoftwareSerial::listen() {
if (active_listener != this) {
// wait for any transmit to complete as we may change speed
while (active_out);
active_listener->stopListening();
rx_tick_cnt = 1; // 1 : next interrupt will decrease rx_tick_cnt to 0 which means RX pin level will be considered.
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
setSpeed(_speed);
active_listener = this;
if (!_half_duplex) active_in = this;
return true;
}
return false;
}
// Stop listening. Returns true if we were actually listening.
bool SoftwareSerial::stopListening() {
if (active_listener == this) {
// wait for any output to complete
while (active_out);
if (_half_duplex) setRXTX(false);
active_listener = nullptr;
active_in = nullptr;
// turn off ints
setSpeed(0);
return true;
}
return false;
}
inline void SoftwareSerial::setTX() {
if (_inverse_logic)
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
else
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
pinMode(_transmitPin, OUTPUT);
}
inline void SoftwareSerial::setRX() {
pinMode(_receivePin, _inverse_logic ? INPUT_PULLDOWN : INPUT_PULLUP); // pullup for normal logic!
}
inline void SoftwareSerial::setRXTX(bool input) {
if (_half_duplex) {
if (input) {
if (active_in != this) {
setRX();
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
rx_tick_cnt = 2; // 2 : next interrupt will be discarded. 2 interrupts required to consider RX pin level
active_in = this;
}
}
else {
if (active_in == this) {
setTX();
active_in = nullptr;
}
}
}
}
inline void SoftwareSerial::send() {
if (--tx_tick_cnt <= 0) { // if tx_tick_cnt > 0 interrupt is discarded. Only when tx_tick_cnt reaches 0 is TX pin set.
if (tx_bit_cnt++ < 10) { // tx_bit_cnt < 10 transmission is not finished (10 = 1 start +8 bits + 1 stop)
// Send data (including start and stop bits)
if (tx_buffer & 1)
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
else
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
tx_buffer >>= 1;
tx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks to send next bit
}
else { // Transmission finished
tx_tick_cnt = 1;
if (_output_pending) {
active_out = nullptr;
// In half-duplex mode wait HALFDUPLEX_SWITCH_DELAY bit-periods after the byte has
// been transmitted before allowing the switch to RX mode
}
else if (tx_bit_cnt > 10 + OVERSAMPLE * HALFDUPLEX_SWITCH_DELAY) {
if (_half_duplex && active_listener == this) setRXTX(true);
active_out = nullptr;
}
}
}
}
//
// The receive routine called by the interrupt handler
//
inline void SoftwareSerial::recv() {
if (--rx_tick_cnt <= 0) { // if rx_tick_cnt > 0 interrupt is discarded. Only when rx_tick_cnt reaches 0 is RX pin considered
bool inbit = LL_GPIO_IsInputPinSet(_receivePinPort, _receivePinNumber) ^ _inverse_logic;
if (rx_bit_cnt == -1) { // rx_bit_cnt = -1 : waiting for start bit
if (!inbit) {
// got start bit
rx_bit_cnt = 0; // rx_bit_cnt == 0 : start bit received
rx_tick_cnt = OVERSAMPLE + 1; // Wait 1 bit (OVERSAMPLE ticks) + 1 tick in order to sample RX pin in the middle of the edge (and not too close to the edge)
rx_buffer = 0;
}
else
rx_tick_cnt = 1; // Waiting for start bit, but wrong level. Wait for next Interrupt to check RX pin level
}
else if (rx_bit_cnt >= 8) { // rx_bit_cnt >= 8 : waiting for stop bit
if (inbit) {
// Stop-bit read complete. Add to buffer.
uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
if (next != _receive_buffer_head) {
// save new data in buffer: tail points to byte destination
_receive_buffer[_receive_buffer_tail] = rx_buffer; // save new byte
_receive_buffer_tail = next;
}
else // rx_bit_cnt = x with x = [0..7] correspond to new bit x received
_buffer_overflow = true;
}
// Full trame received. Restart waiting for start bit at next interrupt
rx_tick_cnt = 1;
rx_bit_cnt = -1;
}
else {
// data bits
rx_buffer >>= 1;
if (inbit) rx_buffer |= 0x80;
rx_bit_cnt++; // Prepare for next bit
rx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks before sampling next bit
}
}
}
//
// Interrupt handling
//
/* static */
inline void SoftwareSerial::handleInterrupt(HardwareTimer*) {
if (active_in) active_in->recv();
if (active_out) active_out->send();
}
//
// Constructor
//
SoftwareSerial::SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic /* = false */) :
_receivePin(receivePin),
_transmitPin(transmitPin),
_receivePinPort(digitalPinToPort(receivePin)),
_receivePinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(receivePin))),
_transmitPinPort(digitalPinToPort(transmitPin)),
_transmitPinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(transmitPin))),
_speed(0),
_buffer_overflow(false),
_inverse_logic(inverse_logic),
_half_duplex(receivePin == transmitPin),
_output_pending(0),
_receive_buffer_tail(0),
_receive_buffer_head(0)
{
if ((receivePin < NUM_DIGITAL_PINS) || (transmitPin < NUM_DIGITAL_PINS)) {
/* Enable GPIO clock for tx and rx pin*/
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(transmitPin)));
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(receivePin)));
}
else
_Error_Handler("ERROR: invalid pin number\n", -1);
}
//
// Destructor
//
SoftwareSerial::~SoftwareSerial() { end(); }
//
// Public methods
//
void SoftwareSerial::begin(long speed) {
#ifdef FORCE_BAUD_RATE
speed = FORCE_BAUD_RATE;
#endif
_speed = speed;
if (!_half_duplex) {
setTX();
setRX();
listen();
}
else
setTX();
}
void SoftwareSerial::end() {
stopListening();
}
// Read data from buffer
int SoftwareSerial::read() {
// Empty buffer?
if (_receive_buffer_head == _receive_buffer_tail) return -1;
// Read from "head"
uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
_receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
return d;
}
int SoftwareSerial::available() {
return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
}
size_t SoftwareSerial::write(uint8_t b) {
// wait for previous transmit to complete
_output_pending = 1;
while (active_out) { /* nada */ }
// add start and stop bits.
tx_buffer = b << 1 | 0x200;
if (_inverse_logic) tx_buffer = ~tx_buffer;
tx_bit_cnt = 0;
tx_tick_cnt = OVERSAMPLE;
setSpeed(_speed);
if (_half_duplex) setRXTX(false);
_output_pending = 0;
// make us active
active_out = this;
return 1;
}
void SoftwareSerial::flush() {
noInterrupts();
_receive_buffer_head = _receive_buffer_tail = 0;
interrupts();
}
int SoftwareSerial::peek() {
// Empty buffer?
if (_receive_buffer_head == _receive_buffer_tail) return -1;
// Read from "head"
return _receive_buffer[_receive_buffer_head];
}
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

View file

@ -0,0 +1,114 @@
/**
* SoftwareSerial.h (formerly NewSoftSerial.h)
*
* Multi-instance software serial library for Arduino/Wiring
* -- Interrupt-driven receive and other improvements by ladyada
* (https://ladyada.net)
* -- Tuning, circular buffer, derivation from class Print/Stream,
* multi-instance support, porting to 8MHz processors,
* various optimizations, PROGMEM delay tables, inverse logic and
* direct port writing by Mikal Hart (http://www.arduiniana.org)
* -- Pin change interrupt macros by Paul Stoffregen (https://www.pjrc.com)
* -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
* -- ATmega1280/2560 support by Brett Hagman (https://www.roguerobotics.com/)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* The latest version of this library can always be found at
* http://arduiniana.org.
*/
#pragma once
#include <Arduino.h>
/******************************************************************************
* Definitions
******************************************************************************/
#define _SS_MAX_RX_BUFF 64 // RX buffer size
class SoftwareSerial : public Stream {
private:
// per object data
uint16_t _receivePin;
uint16_t _transmitPin;
GPIO_TypeDef *_receivePinPort;
uint32_t _receivePinNumber;
GPIO_TypeDef *_transmitPinPort;
uint32_t _transmitPinNumber;
uint32_t _speed;
uint16_t _buffer_overflow: 1;
uint16_t _inverse_logic: 1;
uint16_t _half_duplex: 1;
uint16_t _output_pending: 1;
unsigned char _receive_buffer[_SS_MAX_RX_BUFF];
volatile uint8_t _receive_buffer_tail;
volatile uint8_t _receive_buffer_head;
uint32_t delta_start = 0;
// static data
static HardwareTimer timer;
static const IRQn_Type timer_interrupt_number;
static uint32_t timer_interrupt_priority;
static SoftwareSerial *active_listener;
static SoftwareSerial *volatile active_out;
static SoftwareSerial *volatile active_in;
static int32_t tx_tick_cnt;
static volatile int32_t rx_tick_cnt;
static uint32_t tx_buffer;
static int32_t tx_bit_cnt;
static uint32_t rx_buffer;
static int32_t rx_bit_cnt;
static uint32_t cur_speed;
// private methods
void send();
void recv();
void setTX();
void setRX();
void setSpeed(uint32_t speed);
void setRXTX(bool input);
static void handleInterrupt(HardwareTimer *timer);
public:
// public methods
SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic=false);
virtual ~SoftwareSerial();
void begin(long speed);
bool listen();
void end();
bool isListening() { return active_listener == this; }
bool stopListening();
bool overflow() {
bool ret = _buffer_overflow;
if (ret) _buffer_overflow = false;
return ret;
}
int peek();
virtual size_t write(uint8_t byte);
virtual int read();
virtual int available();
virtual void flush();
operator bool() { return true; }
static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
using Print::write;
};

View file

@ -51,19 +51,19 @@ void FastIO_init(); // Must be called before using fast io macros
#if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx) #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx)
#define _WRITE(IO, V) do { \ #define _WRITE(IO, V) do { \
if (V) FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \
else FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(STM_PIN(digitalPin[IO])) ; \
}while(0) }while(0)
#else #else
#define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO)) + ((V) ? 0 : 16))) #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO]) + ((V) ? 0 : 16)))
#endif #endif
#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO))))) #define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPin[IO])]->IDR, _BV32(STM_PIN(digitalPin[IO]))))
#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO)))) #define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(STM_PIN(digitalPin[IO])))
#define _GET_MODE(IO) #define _GET_MODE(IO)
#define _SET_MODE(IO,M) pinMode(IO, M) #define _SET_MODE(IO,M) pinMode(IO, M)
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL #define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
#define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN) #define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN)
#define WRITE(IO,V) _WRITE(IO,V) #define WRITE(IO,V) _WRITE(IO,V)
@ -73,9 +73,9 @@ void FastIO_init(); // Must be called before using fast io macros
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0) #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
#define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0) #define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
#define SET_INPUT(IO) _SET_MODE(IO, INPUT) //!< Input Floating Mode #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_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_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW) #define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
#define SET_PWM(IO) _SET_MODE(IO, PWM) #define SET_PWM(IO) _SET_MODE(IO, PWM)

View file

@ -28,8 +28,8 @@
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector" // #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
//#endif //#endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN)
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on STM32." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT) #if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)

View file

@ -98,7 +98,7 @@ static inline void pwm_details(const pin_t pin) {
timer_dev * const tdev = PIN_MAP[pin].timer_device; timer_dev * const tdev = PIN_MAP[pin].timer_device;
const uint8_t channel = PIN_MAP[pin].timer_channel; const uint8_t channel = PIN_MAP[pin].timer_channel;
const char num = ( const char num = (
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
tdev == &timer8 ? '8' : tdev == &timer8 ? '8' :
tdev == &timer5 ? '5' : tdev == &timer5 ? '5' :
#endif #endif

View file

@ -51,8 +51,8 @@
* It contains: * It contains:
* - name of the signal * - name of the signal
* - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines. * - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines.
* EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as the * EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as an
* argument to digitalPinToPinName(IO) to get the Port_pin number * index into digitalPin[] to get the Port_pin number
* - if it is a digital or analog signal. PWMs are considered digital here. * - if it is a digital or analog signal. PWMs are considered digital here.
* *
* pin_xref is a structure generated by this header file. It is generated by the * pin_xref is a structure generated by this header file. It is generated by the
@ -68,6 +68,8 @@
* signal. The Arduino pin number is listed by the M43 I command. * signal. The Arduino pin number is listed by the M43 I command.
*/ */
extern const PinName digitalPin[]; // provided by the platform
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// //
// make a list of the Arduino pin numbers in the Port/Pin order // make a list of the Arduino pin numbers in the Port/Pin order
@ -135,7 +137,7 @@ const XrefInfo pin_xref[] PROGMEM = {
uint8_t get_pin_mode(const pin_t Ard_num) { uint8_t get_pin_mode(const pin_t Ard_num) {
uint32_t mode_all = 0; uint32_t mode_all = 0;
const PinName dp = digitalPinToPinName(Ard_num); const PinName dp = digitalPin[Ard_num];
switch (PORT_ALPHA(dp)) { switch (PORT_ALPHA(dp)) {
case 'A' : mode_all = GPIOA->MODER; break; case 'A' : mode_all = GPIOA->MODER; break;
case 'B' : mode_all = GPIOB->MODER; break; case 'B' : mode_all = GPIOB->MODER; break;
@ -216,7 +218,7 @@ bool pwm_status(const pin_t Ard_num) {
void pwm_details(const pin_t Ard_num) { void pwm_details(const pin_t Ard_num) {
if (pwm_status(Ard_num)) { if (pwm_status(Ard_num)) {
uint32_t alt_all = 0; uint32_t alt_all = 0;
const PinName dp = digitalPinToPinName(Ard_num); const PinName dp = digitalPin[Ard_num];
pin_t pin_number = uint8_t(PIN_NUM(dp)); pin_t pin_number = uint8_t(PIN_NUM(dp));
const bool over_7 = pin_number >= 8; const bool over_7 = pin_number >= 8;
const uint8_t ind = over_7 ? 1 : 0; const uint8_t ind = over_7 ? 1 : 0;

View file

@ -1,180 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_FSMC_TFT
#include "tft_fsmc.h"
#include "pinconfig.h"
SRAM_HandleTypeDef TFT_FSMC::SRAMx;
DMA_HandleTypeDef TFT_FSMC::DMAtx;
LCD_CONTROLLER_TypeDef *TFT_FSMC::LCD;
void TFT_FSMC::Init() {
uint32_t controllerAddress;
#if PIN_EXISTS(TFT_RESET)
OUT_WRITE(TFT_RESET_PIN, HIGH);
HAL_Delay(100);
#endif
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif
FSMC_NORSRAM_TimingTypeDef Timing, ExtTiming;
uint32_t NSBank = (uint32_t)pinmap_peripheral(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
SRAMx.Instance = FSMC_NORSRAM_DEVICE;
SRAMx.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* SRAMx.Init */
SRAMx.Init.NSBank = NSBank;
SRAMx.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
SRAMx.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
SRAMx.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
SRAMx.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
SRAMx.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
SRAMx.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
SRAMx.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
SRAMx.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
SRAMx.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
SRAMx.Init.ExtendedMode = FSMC_EXTENDED_MODE_ENABLE;
SRAMx.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
SRAMx.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
#ifdef STM32F4xx
SRAMx.Init.PageSize = FSMC_PAGE_SIZE_NONE;
#endif
/* Read Timing - relatively slow to ensure ID information is correctly read from TFT controller */
/* Can be decreases from 15-15-24 to 4-4-8 with risk of stability loss */
Timing.AddressSetupTime = 15;
Timing.AddressHoldTime = 15;
Timing.DataSetupTime = 24;
Timing.BusTurnAroundDuration = 0;
Timing.CLKDivision = 16;
Timing.DataLatency = 17;
Timing.AccessMode = FSMC_ACCESS_MODE_A;
/* Write Timing */
/* Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss */
ExtTiming.AddressSetupTime = 8;
ExtTiming.AddressHoldTime = 15;
ExtTiming.DataSetupTime = 8;
ExtTiming.BusTurnAroundDuration = 0;
ExtTiming.CLKDivision = 16;
ExtTiming.DataLatency = 17;
ExtTiming.AccessMode = FSMC_ACCESS_MODE_A;
__HAL_RCC_FSMC_CLK_ENABLE();
for (uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++)
pinmap_pinout(PinMap_FSMC[i].pin, PinMap_FSMC);
pinmap_pinout(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
pinmap_pinout(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS);
controllerAddress = FSMC_BANK1_1;
#ifdef PF0
switch (NSBank) {
case FSMC_NORSRAM_BANK2: controllerAddress = FSMC_BANK1_2 ; break;
case FSMC_NORSRAM_BANK3: controllerAddress = FSMC_BANK1_3 ; break;
case FSMC_NORSRAM_BANK4: controllerAddress = FSMC_BANK1_4 ; break;
}
#endif
controllerAddress |= (uint32_t)pinmap_peripheral(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS);
HAL_SRAM_Init(&SRAMx, &Timing, &ExtTiming);
__HAL_RCC_DMA2_CLK_ENABLE();
#ifdef STM32F1xx
DMAtx.Instance = DMA2_Channel1;
#elif defined(STM32F4xx)
DMAtx.Instance = DMA2_Stream0;
DMAtx.Init.Channel = DMA_CHANNEL_0;
DMAtx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
DMAtx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
DMAtx.Init.MemBurst = DMA_MBURST_SINGLE;
DMAtx.Init.PeriphBurst = DMA_PBURST_SINGLE;
#endif
DMAtx.Init.Direction = DMA_MEMORY_TO_MEMORY;
DMAtx.Init.MemInc = DMA_MINC_DISABLE;
DMAtx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
DMAtx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
DMAtx.Init.Mode = DMA_NORMAL;
DMAtx.Init.Priority = DMA_PRIORITY_HIGH;
LCD = (LCD_CONTROLLER_TypeDef *)controllerAddress;
}
uint32_t TFT_FSMC::GetID() {
uint32_t id;
WriteReg(0x0000);
id = LCD->RAM;
if (id == 0)
id = ReadID(LCD_READ_ID);
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = ReadID(LCD_READ_ID4);
return id;
}
uint32_t TFT_FSMC::ReadID(uint16_t Reg) {
uint32_t id;
WriteReg(Reg);
id = LCD->RAM; // dummy read
id = Reg << 24;
id |= (LCD->RAM & 0x00FF) << 16;
id |= (LCD->RAM & 0x00FF) << 8;
id |= LCD->RAM & 0x00FF;
return id;
}
bool TFT_FSMC::isBusy() {
if (__IS_DMA_ENABLED(&DMAtx))
if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0)
Abort();
return __IS_DMA_ENABLED(&DMAtx);
}
void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DMAtx.Init.PeriphInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
__HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx));
__HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx));
#ifdef STM32F1xx
DMAtx.Instance->CNDTR = Count;
DMAtx.Instance->CPAR = (uint32_t)Data;
DMAtx.Instance->CMAR = (uint32_t)&(LCD->RAM);
#elif defined(STM32F4xx)
DMAtx.Instance->NDTR = Count;
DMAtx.Instance->PAR = (uint32_t)Data;
DMAtx.Instance->M0AR = (uint32_t)&(LCD->RAM);
#endif
__HAL_DMA_ENABLE(&DMAtx);
}
#endif // HAS_FSMC_TFT

View file

@ -1,160 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef STM32F1xx
#include "stm32f1xx_hal.h"
#elif defined(STM32F4xx)
#include "stm32f4xx_hal.h"
#else
#error FSMC TFT is currently only supported on STM32F1 and STM32F4 hardware.
#endif
#ifndef LCD_READ_ID
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
#endif
#ifndef LCD_READ_ID4
#define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
#endif
#define DATASIZE_8BIT SPI_DATASIZE_8BIT
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
#define TFT_IO_DRIVER TFT_FSMC
#ifdef STM32F1xx
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
#elif defined(STM32F4xx)
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
#endif
typedef struct {
__IO uint16_t REG;
__IO uint16_t RAM;
} LCD_CONTROLLER_TypeDef;
class TFT_FSMC {
private:
static SRAM_HandleTypeDef SRAMx;
static DMA_HandleTypeDef DMAtx;
static LCD_CONTROLLER_TypeDef *LCD;
static uint32_t ReadID(uint16_t Reg);
static void Transmit(uint16_t Data) { LCD->RAM = Data; __DSB(); }
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
public:
static void Init();
static uint32_t GetID();
static bool isBusy();
static void Abort() { __HAL_DMA_DISABLE(&DMAtx); }
static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) {}
static void DataTransferEnd() {};
static void WriteData(uint16_t Data) { Transmit(Data); }
static void WriteReg(uint16_t Reg) { LCD->REG = Reg; __DSB(); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
};
#ifdef STM32F1xx
#define FSMC_PIN_DATA STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)
#elif defined(STM32F4xx)
#define FSMC_PIN_DATA STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_FSMC)
#define FSMC_BANK1_1 0x60000000U
#define FSMC_BANK1_2 0x64000000U
#define FSMC_BANK1_3 0x68000000U
#define FSMC_BANK1_4 0x6C000000U
#else
#error No configuration for this MCU
#endif
const PinMap PinMap_FSMC[] = {
{PD_14, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D00
{PD_15, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D01
{PD_0, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D02
{PD_1, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D03
{PE_7, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D04
{PE_8, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D05
{PE_9, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D06
{PE_10, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D07
{PE_11, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D08
{PE_12, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D09
{PE_13, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D10
{PE_14, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D11
{PE_15, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D12
{PD_8, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D13
{PD_9, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D14
{PD_10, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D15
{PD_4, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NOE
{PD_5, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NWE
{NC, NP, 0}
};
const PinMap PinMap_FSMC_CS[] = {
{PD_7, (void *)FSMC_NORSRAM_BANK1, FSMC_PIN_DATA}, // FSMC_NE1
#ifdef PF0
{PG_9, (void *)FSMC_NORSRAM_BANK2, FSMC_PIN_DATA}, // FSMC_NE2
{PG_10, (void *)FSMC_NORSRAM_BANK3, FSMC_PIN_DATA}, // FSMC_NE3
{PG_12, (void *)FSMC_NORSRAM_BANK4, FSMC_PIN_DATA}, // FSMC_NE4
#endif
{NC, NP, 0}
};
#define FSMC_RS(A) (void *)((2 << A) - 2)
const PinMap PinMap_FSMC_RS[] = {
#ifdef PF0
{PF_0, FSMC_RS( 0), FSMC_PIN_DATA}, // FSMC_A0
{PF_1, FSMC_RS( 1), FSMC_PIN_DATA}, // FSMC_A1
{PF_2, FSMC_RS( 2), FSMC_PIN_DATA}, // FSMC_A2
{PF_3, FSMC_RS( 3), FSMC_PIN_DATA}, // FSMC_A3
{PF_4, FSMC_RS( 4), FSMC_PIN_DATA}, // FSMC_A4
{PF_5, FSMC_RS( 5), FSMC_PIN_DATA}, // FSMC_A5
{PF_12, FSMC_RS( 6), FSMC_PIN_DATA}, // FSMC_A6
{PF_13, FSMC_RS( 7), FSMC_PIN_DATA}, // FSMC_A7
{PF_14, FSMC_RS( 8), FSMC_PIN_DATA}, // FSMC_A8
{PF_15, FSMC_RS( 9), FSMC_PIN_DATA}, // FSMC_A9
{PG_0, FSMC_RS(10), FSMC_PIN_DATA}, // FSMC_A10
{PG_1, FSMC_RS(11), FSMC_PIN_DATA}, // FSMC_A11
{PG_2, FSMC_RS(12), FSMC_PIN_DATA}, // FSMC_A12
{PG_3, FSMC_RS(13), FSMC_PIN_DATA}, // FSMC_A13
{PG_4, FSMC_RS(14), FSMC_PIN_DATA}, // FSMC_A14
{PG_5, FSMC_RS(15), FSMC_PIN_DATA}, // FSMC_A15
#endif
{PD_11, FSMC_RS(16), FSMC_PIN_DATA}, // FSMC_A16
{PD_12, FSMC_RS(17), FSMC_PIN_DATA}, // FSMC_A17
{PD_13, FSMC_RS(18), FSMC_PIN_DATA}, // FSMC_A18
{PE_3, FSMC_RS(19), FSMC_PIN_DATA}, // FSMC_A19
{PE_4, FSMC_RS(20), FSMC_PIN_DATA}, // FSMC_A20
{PE_5, FSMC_RS(21), FSMC_PIN_DATA}, // FSMC_A21
{PE_6, FSMC_RS(22), FSMC_PIN_DATA}, // FSMC_A22
{PE_2, FSMC_RS(23), FSMC_PIN_DATA}, // FSMC_A23
#ifdef PF0
{PG_13, FSMC_RS(24), FSMC_PIN_DATA}, // FSMC_A24
{PG_14, FSMC_RS(25), FSMC_PIN_DATA}, // FSMC_A25
#endif
{NC, NP, 0}
};

View file

@ -1,212 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_SPI_TFT
#include "tft_spi.h"
#include "pinconfig.h"
SPI_HandleTypeDef TFT_SPI::SPIx;
DMA_HandleTypeDef TFT_SPI::DMAtx;
void TFT_SPI::Init() {
SPI_TypeDef *spiInstance;
#if PIN_EXISTS(TFT_RESET)
OUT_WRITE(TFT_RESET_PIN, HIGH);
HAL_Delay(100);
#endif
#if PIN_EXISTS(TFT_BACKLIGHT)
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
#endif
OUT_WRITE(TFT_A0_PIN, HIGH);
OUT_WRITE(TFT_CS_PIN, HIGH);
if ((spiInstance = (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_SCK_PIN), PinMap_SPI_SCLK)) == NP) return;
if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_MOSI_PIN), PinMap_SPI_MOSI)) return;
#if PIN_EXISTS(TFT_MISO) && (TFT_MISO_PIN != TFT_MOSI_PIN)
if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO)) return;
#endif
SPIx.Instance = spiInstance;
SPIx.State = HAL_SPI_STATE_RESET;
SPIx.Init.NSS = SPI_NSS_SOFT;
SPIx.Init.Mode = SPI_MODE_MASTER;
SPIx.Init.Direction =
#if TFT_MISO_PIN == TFT_MOSI_PIN
SPI_DIRECTION_1LINE;
#else
SPI_DIRECTION_2LINES;
#endif
SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
SPIx.Init.CLKPhase = SPI_PHASE_1EDGE;
SPIx.Init.CLKPolarity = SPI_POLARITY_LOW;
SPIx.Init.DataSize = SPI_DATASIZE_8BIT;
SPIx.Init.FirstBit = SPI_FIRSTBIT_MSB;
SPIx.Init.TIMode = SPI_TIMODE_DISABLE;
SPIx.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SPIx.Init.CRCPolynomial = 10;
pinmap_pinout(digitalPinToPinName(TFT_SCK_PIN), PinMap_SPI_SCLK);
pinmap_pinout(digitalPinToPinName(TFT_MOSI_PIN), PinMap_SPI_MOSI);
#if PIN_EXISTS(TFT_MISO) && (TFT_MISO_PIN != TFT_MOSI_PIN)
pinmap_pinout(digitalPinToPinName(TFT_MISO_PIN), PinMap_SPI_MISO);
#endif
pin_PullConfig(get_GPIO_Port(STM_PORT(digitalPinToPinName(TFT_SCK_PIN))), STM_LL_GPIO_PIN(digitalPinToPinName(TFT_SCK_PIN)), GPIO_PULLDOWN);
#ifdef SPI1_BASE
if (SPIx.Instance == SPI1) {
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
DMAtx.Instance = DMA1_Channel3;
}
#endif
#ifdef SPI2_BASE
if (SPIx.Instance == SPI2) {
__HAL_RCC_SPI2_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
DMAtx.Instance = DMA1_Channel5;
}
#endif
#ifdef SPI3_BASE
if (SPIx.Instance == SPI3) {
__HAL_RCC_SPI3_CLK_ENABLE();
__HAL_RCC_DMA2_CLK_ENABLE();
DMAtx.Instance = DMA2_Channel2;
}
#endif
HAL_SPI_Init(&SPIx);
DMAtx.Init.Direction = DMA_MEMORY_TO_PERIPH;
DMAtx.Init.PeriphInc = DMA_PINC_DISABLE;
DMAtx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
DMAtx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
DMAtx.Init.Mode = DMA_NORMAL;
DMAtx.Init.Priority = DMA_PRIORITY_LOW;
}
void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
SPIx.Init.DataSize = DataSize == DATASIZE_8BIT ? SPI_DATASIZE_8BIT : SPI_DATASIZE_16BIT;
HAL_SPI_Init(&SPIx);
WRITE(TFT_CS_PIN, LOW);
}
uint32_t TFT_SPI::GetID() {
uint32_t id;
id = ReadID(LCD_READ_ID);
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = ReadID(LCD_READ_ID4);
return id;
}
uint32_t TFT_SPI::ReadID(uint16_t Reg) {
#if !PIN_EXISTS(TFT_MISO)
return 0;
#else
uint32_t BaudRatePrescaler = SPIx.Init.BaudRatePrescaler;
uint32_t i, Data = 0;
SPIx.Init.BaudRatePrescaler = SPIx.Instance == SPI1 ? SPI_BAUDRATEPRESCALER_8 : SPI_BAUDRATEPRESCALER_4;
DataTransferBegin(DATASIZE_8BIT);
WriteReg(Reg);
if (SPIx.Init.Direction == SPI_DIRECTION_1LINE) SPI_1LINE_RX(&SPIx);
__HAL_SPI_ENABLE(&SPIx);
for (i = 0; i < 4; i++) {
#if TFT_MISO_PIN != TFT_MOSI_PIN
//if (hspi->Init.Direction == SPI_DIRECTION_2LINES) {
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
SPIx.Instance->DR = 0;
//}
#endif
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
Data = (Data << 8) | SPIx.Instance->DR;
}
__HAL_SPI_DISABLE(&SPIx);
DataTransferEnd();
SPIx.Init.BaudRatePrescaler = BaudRatePrescaler;
return Data >> 7;
#endif
}
bool TFT_SPI::isBusy() {
if (DMAtx.Instance->CCR & DMA_CCR_EN)
if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0)
Abort();
return DMAtx.Instance->CCR & DMA_CCR_EN;
}
void TFT_SPI::Abort() {
__HAL_DMA_DISABLE(&DMAtx);
DataTransferEnd();
}
void TFT_SPI::Transmit(uint16_t Data) {
#if TFT_MISO_PIN == TFT_MOSI_PIN
SPI_1LINE_TX(&SPIx);
#endif
__HAL_SPI_ENABLE(&SPIx);
SPIx.Instance->DR = Data;
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
#if TFT_MISO_PIN != TFT_MOSI_PIN
__HAL_SPI_CLEAR_OVRFLAG(&SPIx); /* Clear overrun flag in 2 Lines communication mode because received is not read */
#endif
}
void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
DMAtx.Init.MemInc = MemoryIncrease;
HAL_DMA_Init(&DMAtx);
DataTransferBegin();
#if TFT_MISO_PIN == TFT_MOSI_PIN
SPI_1LINE_TX(&SPIx);
#endif
DMAtx.DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << DMAtx.ChannelIndex);
DMAtx.Instance->CNDTR = Count;
DMAtx.Instance->CPAR = (uint32_t)&(SPIx.Instance->DR);
DMAtx.Instance->CMAR = (uint32_t)Data;
__HAL_DMA_ENABLE(&DMAtx);
__HAL_SPI_ENABLE(&SPIx);
SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
}
#endif // HAS_SPI_TFT

View file

@ -1,67 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef STM32F1xx
#include "stm32f1xx_hal.h"
#elif defined(STM32F4xx)
#include "stm32f4xx_hal.h"
#else
#error SPI TFT is currently only supported on STM32F1 and STM32F4 hardware.
#endif
#ifndef LCD_READ_ID
#define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
#endif
#ifndef LCD_READ_ID4
#define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
#endif
#define DATASIZE_8BIT SPI_DATASIZE_8BIT
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
#define TFT_IO_DRIVER TFT_SPI
class TFT_SPI {
private:
static SPI_HandleTypeDef SPIx;
static DMA_HandleTypeDef DMAtx;
static uint32_t ReadID(uint16_t Reg);
static void Transmit(uint16_t Data);
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
public:
static void Init();
static uint32_t GetID();
static bool isBusy();
static void Abort();
static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT);
static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); };
static void DataTransferAbort();
static void WriteData(uint16_t Data) { Transmit(Data); }
static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); }
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
};

View file

@ -1,185 +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 <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_TFT_XPT2046
#include "xpt2046.h"
#include "pinconfig.h"
uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; }
SPI_HandleTypeDef XPT2046::SPIx;
DMA_HandleTypeDef XPT2046::DMAtx;
void XPT2046::Init() {
SPI_TypeDef *spiInstance;
OUT_WRITE(TOUCH_CS_PIN, HIGH);
#if PIN_EXISTS(TOUCH_INT)
// Optional Pendrive interrupt pin
SET_INPUT(TOUCH_INT_PIN);
#endif
spiInstance = (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TOUCH_SCK_PIN), PinMap_SPI_SCLK);
if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TOUCH_MOSI_PIN), PinMap_SPI_MOSI)) spiInstance = NP;
if (spiInstance != (SPI_TypeDef *)pinmap_peripheral(digitalPinToPinName(TOUCH_MISO_PIN), PinMap_SPI_MISO)) spiInstance = NP;
SPIx.Instance = spiInstance;
if (SPIx.Instance) {
SPIx.State = HAL_SPI_STATE_RESET;
SPIx.Init.NSS = SPI_NSS_SOFT;
SPIx.Init.Mode = SPI_MODE_MASTER;
SPIx.Init.Direction = SPI_DIRECTION_2LINES;
SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
SPIx.Init.CLKPhase = SPI_PHASE_2EDGE;
SPIx.Init.CLKPolarity = SPI_POLARITY_HIGH;
SPIx.Init.DataSize = SPI_DATASIZE_8BIT;
SPIx.Init.FirstBit = SPI_FIRSTBIT_MSB;
SPIx.Init.TIMode = SPI_TIMODE_DISABLE;
SPIx.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SPIx.Init.CRCPolynomial = 10;
pinmap_pinout(digitalPinToPinName(TOUCH_SCK_PIN), PinMap_SPI_SCLK);
pinmap_pinout(digitalPinToPinName(TOUCH_MOSI_PIN), PinMap_SPI_MOSI);
pinmap_pinout(digitalPinToPinName(TOUCH_MISO_PIN), PinMap_SPI_MISO);
#ifdef SPI1_BASE
if (SPIx.Instance == SPI1) {
__HAL_RCC_SPI1_CLK_ENABLE();
SPIx.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
#ifdef STM32F1xx
DMAtx.Instance = DMA1_Channel3;
#elif defined(STM32F4xx)
DMAtx.Instance = DMA2_Stream3; // DMA2_Stream5
#endif
//SERIAL_ECHO_MSG(" Touch Screen on SPI1");
}
#endif
#ifdef SPI2_BASE
if (SPIx.Instance == SPI2) {
__HAL_RCC_SPI2_CLK_ENABLE();
#ifdef STM32F1xx
DMAtx.Instance = DMA1_Channel5;
#elif defined(STM32F4xx)
DMAtx.Instance = DMA1_Stream4;
#endif
//SERIAL_ECHO_MSG(" Touch Screen on SPI2");
}
#endif
#ifdef SPI3_BASE
if (SPIx.Instance == SPI3) {
__HAL_RCC_SPI3_CLK_ENABLE();
#ifdef STM32F1xx
DMAtx.Instance = DMA2_Channel2;
#elif defined(STM32F4xx)
DMAtx.Instance = DMA1_Stream5; // DMA1_Stream7
#endif
//SERIAL_ECHO_MSG(" Touch Screen on SPI3");
}
#endif
}
else {
SPIx.Instance = NULL;
SET_INPUT(TOUCH_MISO_PIN);
SET_OUTPUT(TOUCH_MOSI_PIN);
SET_OUTPUT(TOUCH_SCK_PIN);
//SERIAL_ECHO_MSG(" Touch Screen on Software SPI");
}
getRawData(XPT2046_Z1);
}
bool XPT2046::isTouched() {
return isBusy() ? false : (
#if PIN_EXISTS(TOUCH_INT)
READ(TOUCH_INT_PIN) != HIGH
#else
getRawData(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD
#endif
);
}
bool XPT2046::getRawPoint(int16_t *x, int16_t *y) {
if (isBusy()) return false;
if (!isTouched()) return false;
*x = getRawData(XPT2046_X);
*y = getRawData(XPT2046_Y);
return isTouched();
}
uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) {
uint16_t data[3];
DataTransferBegin();
for (uint16_t i = 0; i < 3 ; i++) {
IO(coordinate);
data[i] = (IO() << 4) | (IO() >> 4);
}
DataTransferEnd();
uint16_t delta01 = delta(data[0], data[1]);
uint16_t delta02 = delta(data[0], data[2]);
uint16_t delta12 = delta(data[1], data[2]);
if (delta01 > delta02 || delta01 > delta12) {
if (delta02 > delta12)
data[0] = data[2];
else
data[1] = data[2];
}
return (data[0] + data[1]) >> 1;
}
uint16_t XPT2046::HardwareIO(uint16_t data) {
__HAL_SPI_ENABLE(&SPIx);
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
SPIx.Instance->DR = data;
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
__HAL_SPI_DISABLE(&SPIx);
return SPIx.Instance->DR;
}
uint16_t XPT2046::SoftwareIO(uint16_t data) {
uint16_t result = 0;
for (uint8_t j = 0x80; j > 0; j >>= 1) {
WRITE(TOUCH_SCK_PIN, LOW);
__DSB();
WRITE(TOUCH_MOSI_PIN, data & j ? HIGH : LOW);
__DSB();
if (READ(TOUCH_MISO_PIN)) result |= j;
__DSB();
WRITE(TOUCH_SCK_PIN, HIGH);
__DSB();
}
WRITE(TOUCH_SCK_PIN, LOW);
__DSB();
return result;
}
#endif // HAS_TFT_XPT2046

View file

@ -1,86 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef STM32F1xx
#include <stm32f1xx_hal.h>
#elif defined(STM32F4xx)
#include <stm32f4xx_hal.h>
#endif
#include "../../../inc/MarlinConfig.h"
// Not using regular SPI interface by default to avoid SPI mode conflicts with other SPI devices
#if !PIN_EXISTS(TOUCH_MISO)
#error "TOUCH_MISO_PIN is not defined."
#elif !PIN_EXISTS(TOUCH_MOSI)
#error "TOUCH_MOSI_PIN is not defined."
#elif !PIN_EXISTS(TOUCH_SCK)
#error "TOUCH_SCK_PIN is not defined."
#elif !PIN_EXISTS(TOUCH_CS)
#error "TOUCH_CS_PIN is not defined."
#endif
#ifndef TOUCH_INT_PIN
#define TOUCH_INT_PIN -1
#endif
#define XPT2046_DFR_MODE 0x00
#define XPT2046_SER_MODE 0x04
#define XPT2046_CONTROL 0x80
enum XPTCoordinate : uint8_t {
XPT2046_X = 0x10 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Y = 0x50 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Z1 = 0x30 | XPT2046_CONTROL | XPT2046_DFR_MODE,
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#define XPT2046_Z1_THRESHOLD 10
#endif
#ifdef STM32F1xx
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
#elif defined(STM32F4xx)
#define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
#endif
class XPT2046 {
private:
static SPI_HandleTypeDef SPIx;
static DMA_HandleTypeDef DMAtx;
static bool isBusy() { return SPIx.Instance ? __IS_DMA_ENABLED(&DMAtx) : false; }
static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched();
static inline void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); };
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
static uint16_t HardwareIO(uint16_t data);
static uint16_t SoftwareIO(uint16_t data);
static uint16_t IO(uint16_t data = 0) { return SPIx.Instance ? HardwareIO(data) : SoftwareIO(data); }
public:
static void Init();
static bool getRawPoint(int16_t *x, int16_t *y);
};

View file

@ -110,6 +110,7 @@
// ------------------------ // ------------------------
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL }; HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
bool timer_enabled[NUM_HARDWARE_TIMERS] = { false };
// ------------------------ // ------------------------
// Public functions // Public functions
@ -134,7 +135,6 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
* which changes the prescaler when an IRQ frequency change is needed * which changes the prescaler when an IRQ frequency change is needed
* (for example when steppers are turned on) * (for example when steppers are turned on)
*/ */
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT); timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
break; break;
@ -145,13 +145,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
break; break;
} }
// Disable preload. Leaving it default-enabled can cause the timer to stop if it happens
// to exit the ISR after the start time for the next interrupt has already passed.
timer_instance[timer_num]->setPreloadEnable(false);
HAL_timer_enable_interrupt(timer_num); HAL_timer_enable_interrupt(timer_num);
// Start the timer. /*
* Initializes (and unfortunately starts) the timer.
* This is needed to set correct IRQ priority at the moment but causes
* no harm since every call to HAL_timer_start() is actually followed by
* a call to HAL_timer_enable_interrupt() which means that there isn't
* a case in which you want the timer to run without a callback.
*/
timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt() timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
// This is fixed in Arduino_Core_STM32 1.8. // This is fixed in Arduino_Core_STM32 1.8.
@ -159,34 +161,47 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
// timer_instance[timer_num]->setInterruptPriority // timer_instance[timer_num]->setInterruptPriority
switch (timer_num) { switch (timer_num) {
case STEP_TIMER_NUM: case STEP_TIMER_NUM:
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0); HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0);
break; break;
case TEMP_TIMER_NUM: case TEMP_TIMER_NUM:
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0); HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_NAME, TEMP_TIMER_IRQ_PRIO, 0);
break; break;
} }
} }
} }
void HAL_timer_enable_interrupt(const uint8_t timer_num) { void HAL_timer_enable_interrupt(const uint8_t timer_num) {
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) { if (HAL_timer_initialized(timer_num) && !timer_enabled[timer_num]) {
timer_enabled[timer_num] = true;
switch (timer_num) { switch (timer_num) {
case STEP_TIMER_NUM: case STEP_TIMER_NUM:
timer_instance[timer_num]->attachInterrupt(Step_Handler); timer_instance[timer_num]->attachInterrupt(Step_Handler);
break; break;
case TEMP_TIMER_NUM: case TEMP_TIMER_NUM:
timer_instance[timer_num]->attachInterrupt(Temp_Handler); timer_instance[timer_num]->attachInterrupt(Temp_Handler);
break; break;
} }
} }
} }
void HAL_timer_disable_interrupt(const uint8_t timer_num) { void HAL_timer_disable_interrupt(const uint8_t timer_num) {
if (HAL_timer_initialized(timer_num)) timer_instance[timer_num]->detachInterrupt(); if (HAL_timer_interrupt_enabled(timer_num)) {
timer_instance[timer_num]->detachInterrupt();
timer_enabled[timer_num] = false;
}
} }
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
return HAL_timer_initialized(timer_num) && timer_instance[timer_num]->hasInterrupt(); return HAL_timer_initialized(timer_num) && timer_enabled[timer_num];
}
// Only for use within the HAL
TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM: return STEP_TIMER_DEV;
case TEMP_TIMER_NUM: return TEMP_TIMER_DEV;
}
return nullptr;
} }
void SetTimerInterruptPriorities() { void SetTimerInterruptPriorities() {
@ -194,87 +209,4 @@ void SetTimerInterruptPriorities() {
TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0)); TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
} }
// This is a terrible hack to replicate the behavior used in the framework's SoftwareSerial.cpp
// to choose a serial timer. It will select TIM7 on most boards used by Marlin, but this is more
// resiliant to new MCUs which may not have a TIM7. Best practice is to explicitly specify
// TIMER_SERIAL to avoid relying on framework selections which may not be predictable.
#if !defined(TIMER_SERIAL)
#if defined (TIM18_BASE)
#define TIMER_SERIAL TIM18
#elif defined (TIM7_BASE)
#define TIMER_SERIAL TIM7
#elif defined (TIM6_BASE)
#define TIMER_SERIAL TIM6
#elif defined (TIM22_BASE)
#define TIMER_SERIAL TIM22
#elif defined (TIM21_BASE)
#define TIMER_SERIAL TIM21
#elif defined (TIM17_BASE)
#define TIMER_SERIAL TIM17
#elif defined (TIM16_BASE)
#define TIMER_SERIAL TIM16
#elif defined (TIM15_BASE)
#define TIMER_SERIAL TIM15
#elif defined (TIM14_BASE)
#define TIMER_SERIAL TIM14
#elif defined (TIM13_BASE)
#define TIMER_SERIAL TIM13
#elif defined (TIM11_BASE)
#define TIMER_SERIAL TIM11
#elif defined (TIM10_BASE)
#define TIMER_SERIAL TIM10
#elif defined (TIM12_BASE)
#define TIMER_SERIAL TIM12
#elif defined (TIM19_BASE)
#define TIMER_SERIAL TIM19
#elif defined (TIM9_BASE)
#define TIMER_SERIAL TIM9
#elif defined (TIM5_BASE)
#define TIMER_SERIAL TIM5
#elif defined (TIM4_BASE)
#define TIMER_SERIAL TIM4
#elif defined (TIM3_BASE)
#define TIMER_SERIAL TIM3
#elif defined (TIM2_BASE)
#define TIMER_SERIAL TIM2
#elif defined (TIM20_BASE)
#define TIMER_SERIAL TIM20
#elif defined (TIM8_BASE)
#define TIMER_SERIAL TIM8
#elif defined (TIM1_BASE)
#define TIMER_SERIAL TIM1
#else
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
#endif
#endif
// Place all timers used into an array, then recursively check for duplicates during compilation.
// This does not currently account for timers used for PWM, such as for fans.
// Timers are actually pointers. Convert to integers to simplify constexpr logic.
static constexpr uintptr_t timers_in_use[] = {
uintptr_t(TEMP_TIMER_DEV), // Override in pins file
uintptr_t(STEP_TIMER_DEV), // Override in pins file
#if HAS_TMC_SW_SERIAL
uintptr_t(TIMER_SERIAL), // Set in variant.h, or as a define in platformio.h if not present in variant.h
#endif
#if ENABLED(SPEAKER)
uintptr_t(TIMER_TONE), // Set in variant.h, or as a define in platformio.h if not present in variant.h
#endif
#if HAS_SERVOS
uintptr_t(TIMER_SERVO), // Set in variant.h, or as a define in platformio.h if not present in variant.h
#endif
};
static constexpr bool verify_no_duplicate_timers() {
LOOP_L_N(i, COUNT(timers_in_use))
LOOP_S_L_N(j, i + 1, COUNT(timers_in_use))
if (timers_in_use[i] == timers_in_use[j]) return false;
return true;
}
// If this assertion fails at compile time, review the timers_in_use array. If default_envs is
// defined properly in platformio.ini, VS Code can evaluate the array when hovering over it,
// making it easy to identify the conflicting timers.
static_assert(verify_no_duplicate_timers(), "One or more timer conflict detected");
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

Some files were not shown because too many files have changed in this diff Show more