Merge branch 'bugfix-2.1.x' into ParseSafetyCommandsEvenWithEParser
This commit is contained in:
@@ -151,6 +151,12 @@ jobs:
|
||||
# HC32
|
||||
- HC32F460C_aquila_101
|
||||
|
||||
# GD32F3
|
||||
- GD32F303RE_creality_mfl
|
||||
|
||||
# GD32F1
|
||||
- GD32F103RC_aquila_mfl
|
||||
|
||||
# LPC176x - Lengthy tests
|
||||
- LPC1768
|
||||
- LPC1769
|
||||
@@ -164,15 +170,20 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
key: ${{ runner.os }}-pip-build-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-pip-build-
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
path: |
|
||||
~/.platformio
|
||||
.pio/build
|
||||
.pio/libdeps
|
||||
key: ${{ runner.os }}-pio-build-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pio-build-
|
||||
|
||||
- name: Select Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
|
||||
@@ -46,15 +46,20 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
key: ${{ runner.os }}-pip-unit-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-pip-unit-
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
path: |
|
||||
~/.platformio
|
||||
.pio/build
|
||||
.pio/libdeps
|
||||
key: ${{ runner.os }}-pio-tests-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pio-tests-
|
||||
|
||||
- name: Select Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
|
||||
@@ -33,9 +33,9 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
key: ${{ runner.os }}-pip-boards-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-pip-boards-
|
||||
|
||||
- name: Select Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
|
||||
@@ -36,9 +36,9 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
key: ${{ runner.os }}-pip-pins-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-pip-pins-
|
||||
|
||||
- name: Select Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
|
||||
@@ -17,7 +17,7 @@ help:
|
||||
@echo "make tests-all-local-docker : Run all tests locally, using docker"
|
||||
@echo "make unit-test-single-local : Run unit tests for a single config locally"
|
||||
@echo "make unit-test-single-local-docker : Run unit tests for a single config locally, using docker"
|
||||
@echo "make unit-test-all-local : Run all code tests locally"
|
||||
@echo "make unit-test-all-local : Run all code tests locally"
|
||||
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker"
|
||||
@echo "make setup-local-docker : Setup local docker using buildx"
|
||||
@echo ""
|
||||
|
||||
+26
-13
@@ -696,8 +696,9 @@
|
||||
#define PID_K1 0.95 // Smoothing factor within any PID loop
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
//#define MIN_POWER 0
|
||||
//#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation.
|
||||
//#define MIN_POWER 0 // Min power to improve PID stability (0..PID_MAX).
|
||||
// Get the power from the temperature report ('M105' => @:nnn) and try P*2-20 to P*2-10.
|
||||
//#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to enable/disable.
|
||||
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
|
||||
// Set/get with G-code: M301 E[extruder number, 0-2]
|
||||
|
||||
@@ -796,8 +797,9 @@
|
||||
//#define PIDTEMPBED
|
||||
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
//#define MIN_BED_POWER 0
|
||||
//#define PID_BED_DEBUG // Print Bed PID debug data to the serial port.
|
||||
//#define MIN_BED_POWER 0 // Min power to improve PID stability (0..MAX_BED_POWER).
|
||||
// Get the power from the temperature report ('M105' => B@:nnn) and try P*2-20 to P*2-10.
|
||||
//#define PID_BED_DEBUG // Print Bed PID debug data to the serial port. Use 'M303 D' to enable/disable.
|
||||
|
||||
// 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)
|
||||
@@ -878,12 +880,12 @@
|
||||
#define MAX_CHAMBER_POWER 255 // limits duty cycle to chamber heater; 255=full current
|
||||
|
||||
#if ENABLED(PIDTEMPCHAMBER)
|
||||
#define MIN_CHAMBER_POWER 0
|
||||
//#define PID_CHAMBER_DEBUG // Print Chamber PID debug data to the serial port.
|
||||
//#define MIN_CHAMBER_POWER 0 // Min power to improve PID stability. (0..MAX_CHAMBER_POWER)
|
||||
// Get the power from the temperature report ('M105' => C@:nnn) and try P*2-20 to P*2-10.
|
||||
//#define PID_CHAMBER_DEBUG // Print Chamber PID debug data to the serial port. Use 'M303 D' to enable/disable.
|
||||
|
||||
// Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element
|
||||
// and placed inside the small Creality printer enclosure tent.
|
||||
//
|
||||
#define DEFAULT_chamberKp 37.04
|
||||
#define DEFAULT_chamberKi 1.40
|
||||
#define DEFAULT_chamberKd 655.17
|
||||
@@ -897,7 +899,7 @@
|
||||
#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER)
|
||||
//#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
|
||||
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
|
||||
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
|
||||
#define PID_FUNCTIONAL_RANGE 20 // If the temperature difference between the target temperature and the actual temperature
|
||||
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
|
||||
|
||||
//#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash)
|
||||
@@ -1025,9 +1027,6 @@
|
||||
// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
|
||||
#define PRINTABLE_RADIUS 140.0 // (mm)
|
||||
|
||||
// Maximum reachable area
|
||||
#define DELTA_MAX_RADIUS 140.0 // (mm)
|
||||
|
||||
// Center-to-center distance of the holes in the diagonal push rods.
|
||||
#define DELTA_DIAGONAL_ROD 250.0 // (mm)
|
||||
|
||||
@@ -1540,6 +1539,20 @@
|
||||
#define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed
|
||||
#define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed
|
||||
|
||||
/**
|
||||
* Magnetically Mounted Probe with a Servo mechanism
|
||||
* Probe Deploy and Stow both follow the same basic sequence:
|
||||
* - Rotate the SERVO to its Deployed angle
|
||||
* - Perform XYZ moves to deploy or stow the PROBE
|
||||
* - Rotate the SERVO to its Stowed angle
|
||||
*/
|
||||
//#define MAG_MOUNTED_PROBE_SERVO_NR 0 // Servo Number for this probe
|
||||
#ifdef MAG_MOUNTED_PROBE_SERVO_NR
|
||||
#define MAG_MOUNTED_PROBE_SERVO_ANGLES { 90, 0 } // Servo Angles for Deployed, Stowed
|
||||
#define MAG_MOUNTED_PRE_DEPLOY { PROBE_DEPLOY_FEEDRATE, { 15, 160, 30 } } // Safe position for servo activation
|
||||
#define MAG_MOUNTED_PRE_STOW { PROBE_DEPLOY_FEEDRATE, { 15, 160, 30 } } // Safe position for servo deactivation
|
||||
#endif
|
||||
|
||||
#define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe
|
||||
#define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock
|
||||
#define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed
|
||||
@@ -2263,7 +2276,7 @@
|
||||
//===========================================================================
|
||||
|
||||
#define MESH_INSET 10 // Set Mesh bounds as an inset region of the bed
|
||||
#define GRID_MAX_POINTS_X 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define GRID_MAX_POINTS_X 3
|
||||
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
@@ -3269,7 +3282,7 @@
|
||||
#endif
|
||||
|
||||
//
|
||||
// Touch-screen LCD for Malyan M200/M300 printers
|
||||
// LCD for Malyan M200/M300 printers
|
||||
//
|
||||
//#define MALYAN_LCD
|
||||
|
||||
|
||||
@@ -1342,20 +1342,20 @@
|
||||
//#define CALIBRATION_SCRIPT_PRE "M117 Starting Auto-Calibration\nT0\nG28\nG12\nM117 Calibrating..."
|
||||
//#define CALIBRATION_SCRIPT_POST "M500\nM117 Calibration data saved"
|
||||
|
||||
#define CALIBRATION_FEEDRATE_SLOW 60 // mm/min
|
||||
#define CALIBRATION_FEEDRATE_FAST 1200 // mm/min
|
||||
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min
|
||||
#define CALIBRATION_FEEDRATE_SLOW 60 // (mm/min)
|
||||
#define CALIBRATION_FEEDRATE_FAST 1200 // (mm/min)
|
||||
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // (mm/min)
|
||||
|
||||
// The following parameters refer to the conical section of the nozzle tip.
|
||||
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm
|
||||
#define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // mm
|
||||
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // (mm)
|
||||
#define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // (mm)
|
||||
|
||||
// Uncomment to enable reporting (required for "G425 V", but consumes flash).
|
||||
//#define CALIBRATION_REPORTING
|
||||
|
||||
// The true location and dimension the cube/bolt/washer on the bed.
|
||||
#define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // mm
|
||||
#define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // mm
|
||||
#define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // (mm)
|
||||
#define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // (mm)
|
||||
|
||||
// Comment out any sides which are unreachable by the probe. For best
|
||||
// auto-calibration results, all sides must be reachable.
|
||||
@@ -2268,6 +2268,8 @@
|
||||
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (count) Increase if buttons bounce or repeat too fast
|
||||
#endif
|
||||
|
||||
//#define FAST_BUTTON_POLLING // Poll buttons at ~1kHz on 8-bit AVR. Set to 'false' for slow polling on 32-bit.
|
||||
|
||||
// @section safety
|
||||
|
||||
/**
|
||||
@@ -2995,6 +2997,8 @@
|
||||
|
||||
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
|
||||
|
||||
//#define EDITABLE_HOMING_CURRENT // Add a G-code and menu to modify the Homing Current
|
||||
|
||||
/**
|
||||
* Interpolate microsteps to 256
|
||||
* Override for each driver with <driver>_INTERPOLATE settings below
|
||||
@@ -3680,6 +3684,8 @@
|
||||
#define SPEED_POWER_MIN 5000 // (RPM)
|
||||
#define SPEED_POWER_MAX 30000 // (RPM) SuperPID router controller 0 - 30,000 RPM
|
||||
#define SPEED_POWER_STARTUP 25000 // (RPM) M3/M4 speed/power default (with no arguments)
|
||||
|
||||
//#define DEFAULT_ACCELERATION_SPINDLE 1000 // (°/s/s) Default spindle acceleration (speed change with time)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
+5
-5
@@ -127,9 +127,9 @@ NEOPIXEL ?= 0
|
||||
# on GCC versions:
|
||||
# https://www.avrfreaks.net/comment/1789106#comment-1789106
|
||||
|
||||
CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d\ )
|
||||
CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
|
||||
CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
|
||||
CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d' ' )
|
||||
CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d' ' )
|
||||
CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d' ' )
|
||||
CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
|
||||
ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
|
||||
$(warning This GCC version $(CC_VER) is likely broken. Enabling relocation workaround.)
|
||||
@@ -868,8 +868,8 @@ else ifeq ($(HARDWARE_VARIANT), archim)
|
||||
endif
|
||||
|
||||
# Add all the source directories as include directories too
|
||||
CINCS = ${addprefix -I ,${VPATH}}
|
||||
CXXINCS = ${addprefix -I ,${VPATH}}
|
||||
CINCS = ${addprefix -I, ${VPATH}}
|
||||
CXXINCS = ${addprefix -I, ${VPATH}}
|
||||
|
||||
# Silence warnings for library code (won't work for .h files, unfortunately)
|
||||
LIBWARN = -w -Wno-packed-bitfield-compat
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
//#define STRING_DISTRIBUTION_DATE "2025-03-17"
|
||||
//#define STRING_DISTRIBUTION_DATE "2025-04-18"
|
||||
|
||||
/**
|
||||
* The protocol for communication to the host. Protocol indicates communication
|
||||
|
||||
@@ -48,92 +48,92 @@
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
|
||||
// PORTLIST
|
||||
// ------------------------
|
||||
PE , // PE 0 ** 0 ** USART0_RX
|
||||
PE , // PE 1 ** 1 ** USART0_TX
|
||||
PE , // PE 4 ** 2 ** PWM2
|
||||
PE , // PE 5 ** 3 ** PWM3
|
||||
PG , // PG 5 ** 4 ** PWM4
|
||||
PE , // PE 3 ** 5 ** PWM5
|
||||
PH , // PH 3 ** 6 ** PWM6
|
||||
PH , // PH 4 ** 7 ** PWM7
|
||||
PH , // PH 5 ** 8 ** PWM8
|
||||
PH , // PH 6 ** 9 ** PWM9
|
||||
PB , // PB 4 ** 10 ** PWM10
|
||||
PB , // PB 5 ** 11 ** PWM11
|
||||
PB , // PB 6 ** 12 ** PWM12
|
||||
PB , // PB 7 ** 13 ** PWM13
|
||||
PJ , // PJ 1 ** 14 ** USART3_TX
|
||||
PJ , // PJ 0 ** 15 ** USART3_RX
|
||||
PH , // PH 1 ** 16 ** USART2_TX
|
||||
PH , // PH 0 ** 17 ** USART2_RX
|
||||
PD , // PD 3 ** 18 ** USART1_TX
|
||||
PD , // PD 2 ** 19 ** USART1_RX
|
||||
PD , // PD 1 ** 20 ** I2C_SDA
|
||||
PD , // PD 0 ** 21 ** I2C_SCL
|
||||
PA , // PA 0 ** 22 ** D22
|
||||
PA , // PA 1 ** 23 ** D23
|
||||
PA , // PA 2 ** 24 ** D24
|
||||
PA , // PA 3 ** 25 ** D25
|
||||
PA , // PA 4 ** 26 ** D26
|
||||
PA , // PA 5 ** 27 ** D27
|
||||
PA , // PA 6 ** 28 ** D28
|
||||
PA , // PA 7 ** 29 ** D29
|
||||
PC , // PC 7 ** 30 ** D30
|
||||
PC , // PC 6 ** 31 ** D31
|
||||
PC , // PC 5 ** 32 ** D32
|
||||
PC , // PC 4 ** 33 ** D33
|
||||
PC , // PC 3 ** 34 ** D34
|
||||
PC , // PC 2 ** 35 ** D35
|
||||
PC , // PC 1 ** 36 ** D36
|
||||
PC , // PC 0 ** 37 ** D37
|
||||
PD , // PD 7 ** 38 ** D38
|
||||
PG , // PG 2 ** 39 ** D39
|
||||
PG , // PG 1 ** 40 ** D40
|
||||
PG , // PG 0 ** 41 ** D41
|
||||
PL , // PL 7 ** 42 ** D42
|
||||
PL , // PL 6 ** 43 ** D43
|
||||
PL , // PL 5 ** 44 ** D44
|
||||
PL , // PL 4 ** 45 ** D45
|
||||
PL , // PL 3 ** 46 ** D46
|
||||
PL , // PL 2 ** 47 ** D47
|
||||
PL , // PL 1 ** 48 ** D48
|
||||
PL , // PL 0 ** 49 ** D49
|
||||
PB , // PB 3 ** 50 ** SPI_MISO
|
||||
PB , // PB 2 ** 51 ** SPI_MOSI
|
||||
PB , // PB 1 ** 52 ** SPI_SCK
|
||||
PB , // PB 0 ** 53 ** SPI_SS
|
||||
PF , // PF 0 ** 54 ** A0
|
||||
PF , // PF 1 ** 55 ** A1
|
||||
PF , // PF 2 ** 56 ** A2
|
||||
PF , // PF 3 ** 57 ** A3
|
||||
PF , // PF 4 ** 58 ** A4
|
||||
PF , // PF 5 ** 59 ** A5
|
||||
PF , // PF 6 ** 60 ** A6
|
||||
PF , // PF 7 ** 61 ** A7
|
||||
PK , // PK 0 ** 62 ** A8
|
||||
PK , // PK 1 ** 63 ** A9
|
||||
PK , // PK 2 ** 64 ** A10
|
||||
PK , // PK 3 ** 65 ** A11
|
||||
PK , // PK 4 ** 66 ** A12
|
||||
PK , // PK 5 ** 67 ** A13
|
||||
PK , // PK 6 ** 68 ** A14
|
||||
PK , // PK 7 ** 69 ** A15
|
||||
PG , // PG 4 ** 70 **
|
||||
PG , // PG 3 ** 71 **
|
||||
PJ , // PJ 2 ** 72 **
|
||||
PJ , // PJ 3 ** 73 **
|
||||
PJ , // PJ 7 ** 74 **
|
||||
PJ , // PJ 4 ** 75 **
|
||||
PJ , // PJ 5 ** 76 **
|
||||
PJ , // PJ 6 ** 77 **
|
||||
PE , // PE 2 ** 78 **
|
||||
PE , // PE 6 ** 79 **
|
||||
PE , // PE 7 ** 80 **
|
||||
PD , // PD 4 ** 81 **
|
||||
PD , // PD 5 ** 82 **
|
||||
PD , // PD 6 ** 83 **
|
||||
PH , // PH 2 ** 84 **
|
||||
PH , // PH 7 ** 85 **
|
||||
PE, // PE 0 ** 0 ** USART0_RX
|
||||
PE, // PE 1 ** 1 ** USART0_TX
|
||||
PE, // PE 4 ** 2 ** PWM2
|
||||
PE, // PE 5 ** 3 ** PWM3
|
||||
PG, // PG 5 ** 4 ** PWM4
|
||||
PE, // PE 3 ** 5 ** PWM5
|
||||
PH, // PH 3 ** 6 ** PWM6
|
||||
PH, // PH 4 ** 7 ** PWM7
|
||||
PH, // PH 5 ** 8 ** PWM8
|
||||
PH, // PH 6 ** 9 ** PWM9
|
||||
PB, // PB 4 ** 10 ** PWM10
|
||||
PB, // PB 5 ** 11 ** PWM11
|
||||
PB, // PB 6 ** 12 ** PWM12
|
||||
PB, // PB 7 ** 13 ** PWM13
|
||||
PJ, // PJ 1 ** 14 ** USART3_TX
|
||||
PJ, // PJ 0 ** 15 ** USART3_RX
|
||||
PH, // PH 1 ** 16 ** USART2_TX
|
||||
PH, // PH 0 ** 17 ** USART2_RX
|
||||
PD, // PD 3 ** 18 ** USART1_TX
|
||||
PD, // PD 2 ** 19 ** USART1_RX
|
||||
PD, // PD 1 ** 20 ** I2C_SDA
|
||||
PD, // PD 0 ** 21 ** I2C_SCL
|
||||
PA, // PA 0 ** 22 ** D22
|
||||
PA, // PA 1 ** 23 ** D23
|
||||
PA, // PA 2 ** 24 ** D24
|
||||
PA, // PA 3 ** 25 ** D25
|
||||
PA, // PA 4 ** 26 ** D26
|
||||
PA, // PA 5 ** 27 ** D27
|
||||
PA, // PA 6 ** 28 ** D28
|
||||
PA, // PA 7 ** 29 ** D29
|
||||
PC, // PC 7 ** 30 ** D30
|
||||
PC, // PC 6 ** 31 ** D31
|
||||
PC, // PC 5 ** 32 ** D32
|
||||
PC, // PC 4 ** 33 ** D33
|
||||
PC, // PC 3 ** 34 ** D34
|
||||
PC, // PC 2 ** 35 ** D35
|
||||
PC, // PC 1 ** 36 ** D36
|
||||
PC, // PC 0 ** 37 ** D37
|
||||
PD, // PD 7 ** 38 ** D38
|
||||
PG, // PG 2 ** 39 ** D39
|
||||
PG, // PG 1 ** 40 ** D40
|
||||
PG, // PG 0 ** 41 ** D41
|
||||
PL, // PL 7 ** 42 ** D42
|
||||
PL, // PL 6 ** 43 ** D43
|
||||
PL, // PL 5 ** 44 ** D44
|
||||
PL, // PL 4 ** 45 ** D45
|
||||
PL, // PL 3 ** 46 ** D46
|
||||
PL, // PL 2 ** 47 ** D47
|
||||
PL, // PL 1 ** 48 ** D48
|
||||
PL, // PL 0 ** 49 ** D49
|
||||
PB, // PB 3 ** 50 ** SPI_MISO
|
||||
PB, // PB 2 ** 51 ** SPI_MOSI
|
||||
PB, // PB 1 ** 52 ** SPI_SCK
|
||||
PB, // PB 0 ** 53 ** SPI_SS
|
||||
PF, // PF 0 ** 54 ** A0
|
||||
PF, // PF 1 ** 55 ** A1
|
||||
PF, // PF 2 ** 56 ** A2
|
||||
PF, // PF 3 ** 57 ** A3
|
||||
PF, // PF 4 ** 58 ** A4
|
||||
PF, // PF 5 ** 59 ** A5
|
||||
PF, // PF 6 ** 60 ** A6
|
||||
PF, // PF 7 ** 61 ** A7
|
||||
PK, // PK 0 ** 62 ** A8
|
||||
PK, // PK 1 ** 63 ** A9
|
||||
PK, // PK 2 ** 64 ** A10
|
||||
PK, // PK 3 ** 65 ** A11
|
||||
PK, // PK 4 ** 66 ** A12
|
||||
PK, // PK 5 ** 67 ** A13
|
||||
PK, // PK 6 ** 68 ** A14
|
||||
PK, // PK 7 ** 69 ** A15
|
||||
PG, // PG 4 ** 70 **
|
||||
PG, // PG 3 ** 71 **
|
||||
PJ, // PJ 2 ** 72 **
|
||||
PJ, // PJ 3 ** 73 **
|
||||
PJ, // PJ 7 ** 74 **
|
||||
PJ, // PJ 4 ** 75 **
|
||||
PJ, // PJ 5 ** 76 **
|
||||
PJ, // PJ 6 ** 77 **
|
||||
PE, // PE 2 ** 78 **
|
||||
PE, // PE 6 ** 79 **
|
||||
PE, // PE 7 ** 80 **
|
||||
PD, // PD 4 ** 81 **
|
||||
PD, // PD 5 ** 82 **
|
||||
PD, // PD 6 ** 83 **
|
||||
PH, // PH 2 ** 84 **
|
||||
PH, // PH 7 ** 85 **
|
||||
};
|
||||
|
||||
#define digitalPinToPort_plus_70(P) ( pgm_read_byte( digital_pin_to_port_PGM_plus_70 + (P) ) )
|
||||
@@ -141,92 +141,92 @@ const uint8_t PROGMEM digital_pin_to_port_PGM_plus_70[] = {
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
|
||||
// PIN IN PORT
|
||||
// ------------------------
|
||||
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
|
||||
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
|
||||
_BV( 4 ) , // PE 4 ** 2 ** PWM2
|
||||
_BV( 5 ) , // PE 5 ** 3 ** PWM3
|
||||
_BV( 5 ) , // PG 5 ** 4 ** PWM4
|
||||
_BV( 3 ) , // PE 3 ** 5 ** PWM5
|
||||
_BV( 3 ) , // PH 3 ** 6 ** PWM6
|
||||
_BV( 4 ) , // PH 4 ** 7 ** PWM7
|
||||
_BV( 5 ) , // PH 5 ** 8 ** PWM8
|
||||
_BV( 6 ) , // PH 6 ** 9 ** PWM9
|
||||
_BV( 4 ) , // PB 4 ** 10 ** PWM10
|
||||
_BV( 5 ) , // PB 5 ** 11 ** PWM11
|
||||
_BV( 6 ) , // PB 6 ** 12 ** PWM12
|
||||
_BV( 7 ) , // PB 7 ** 13 ** PWM13
|
||||
_BV( 1 ) , // PJ 1 ** 14 ** USART3_TX
|
||||
_BV( 0 ) , // PJ 0 ** 15 ** USART3_RX
|
||||
_BV( 1 ) , // PH 1 ** 16 ** USART2_TX
|
||||
_BV( 0 ) , // PH 0 ** 17 ** USART2_RX
|
||||
_BV( 3 ) , // PD 3 ** 18 ** USART1_TX
|
||||
_BV( 2 ) , // PD 2 ** 19 ** USART1_RX
|
||||
_BV( 1 ) , // PD 1 ** 20 ** I2C_SDA
|
||||
_BV( 0 ) , // PD 0 ** 21 ** I2C_SCL
|
||||
_BV( 0 ) , // PA 0 ** 22 ** D22
|
||||
_BV( 1 ) , // PA 1 ** 23 ** D23
|
||||
_BV( 2 ) , // PA 2 ** 24 ** D24
|
||||
_BV( 3 ) , // PA 3 ** 25 ** D25
|
||||
_BV( 4 ) , // PA 4 ** 26 ** D26
|
||||
_BV( 5 ) , // PA 5 ** 27 ** D27
|
||||
_BV( 6 ) , // PA 6 ** 28 ** D28
|
||||
_BV( 7 ) , // PA 7 ** 29 ** D29
|
||||
_BV( 7 ) , // PC 7 ** 30 ** D30
|
||||
_BV( 6 ) , // PC 6 ** 31 ** D31
|
||||
_BV( 5 ) , // PC 5 ** 32 ** D32
|
||||
_BV( 4 ) , // PC 4 ** 33 ** D33
|
||||
_BV( 3 ) , // PC 3 ** 34 ** D34
|
||||
_BV( 2 ) , // PC 2 ** 35 ** D35
|
||||
_BV( 1 ) , // PC 1 ** 36 ** D36
|
||||
_BV( 0 ) , // PC 0 ** 37 ** D37
|
||||
_BV( 7 ) , // PD 7 ** 38 ** D38
|
||||
_BV( 2 ) , // PG 2 ** 39 ** D39
|
||||
_BV( 1 ) , // PG 1 ** 40 ** D40
|
||||
_BV( 0 ) , // PG 0 ** 41 ** D41
|
||||
_BV( 7 ) , // PL 7 ** 42 ** D42
|
||||
_BV( 6 ) , // PL 6 ** 43 ** D43
|
||||
_BV( 5 ) , // PL 5 ** 44 ** D44
|
||||
_BV( 4 ) , // PL 4 ** 45 ** D45
|
||||
_BV( 3 ) , // PL 3 ** 46 ** D46
|
||||
_BV( 2 ) , // PL 2 ** 47 ** D47
|
||||
_BV( 1 ) , // PL 1 ** 48 ** D48
|
||||
_BV( 0 ) , // PL 0 ** 49 ** D49
|
||||
_BV( 3 ) , // PB 3 ** 50 ** SPI_MISO
|
||||
_BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI
|
||||
_BV( 1 ) , // PB 1 ** 52 ** SPI_SCK
|
||||
_BV( 0 ) , // PB 0 ** 53 ** SPI_SS
|
||||
_BV( 0 ) , // PF 0 ** 54 ** A0
|
||||
_BV( 1 ) , // PF 1 ** 55 ** A1
|
||||
_BV( 2 ) , // PF 2 ** 56 ** A2
|
||||
_BV( 3 ) , // PF 3 ** 57 ** A3
|
||||
_BV( 4 ) , // PF 4 ** 58 ** A4
|
||||
_BV( 5 ) , // PF 5 ** 59 ** A5
|
||||
_BV( 6 ) , // PF 6 ** 60 ** A6
|
||||
_BV( 7 ) , // PF 7 ** 61 ** A7
|
||||
_BV( 0 ) , // PK 0 ** 62 ** A8
|
||||
_BV( 1 ) , // PK 1 ** 63 ** A9
|
||||
_BV( 2 ) , // PK 2 ** 64 ** A10
|
||||
_BV( 3 ) , // PK 3 ** 65 ** A11
|
||||
_BV( 4 ) , // PK 4 ** 66 ** A12
|
||||
_BV( 5 ) , // PK 5 ** 67 ** A13
|
||||
_BV( 6 ) , // PK 6 ** 68 ** A14
|
||||
_BV( 7 ) , // PK 7 ** 69 ** A15
|
||||
_BV( 4 ) , // PG 4 ** 70 **
|
||||
_BV( 3 ) , // PG 3 ** 71 **
|
||||
_BV( 2 ) , // PJ 2 ** 72 **
|
||||
_BV( 3 ) , // PJ 3 ** 73 **
|
||||
_BV( 7 ) , // PJ 7 ** 74 **
|
||||
_BV( 4 ) , // PJ 4 ** 75 **
|
||||
_BV( 5 ) , // PJ 5 ** 76 **
|
||||
_BV( 6 ) , // PJ 6 ** 77 **
|
||||
_BV( 2 ) , // PE 2 ** 78 **
|
||||
_BV( 6 ) , // PE 6 ** 79 **
|
||||
_BV( 7 ) , // PE 7 ** 80 **
|
||||
_BV( 4 ) , // PD 4 ** 81 **
|
||||
_BV( 5 ) , // PD 5 ** 82 **
|
||||
_BV( 6 ) , // PD 6 ** 83 **
|
||||
_BV( 2 ) , // PH 2 ** 84 **
|
||||
_BV( 7 ) , // PH 7 ** 85 **
|
||||
_BV( 0 ), // PE 0 ** 0 ** USART0_RX
|
||||
_BV( 1 ), // PE 1 ** 1 ** USART0_TX
|
||||
_BV( 4 ), // PE 4 ** 2 ** PWM2
|
||||
_BV( 5 ), // PE 5 ** 3 ** PWM3
|
||||
_BV( 5 ), // PG 5 ** 4 ** PWM4
|
||||
_BV( 3 ), // PE 3 ** 5 ** PWM5
|
||||
_BV( 3 ), // PH 3 ** 6 ** PWM6
|
||||
_BV( 4 ), // PH 4 ** 7 ** PWM7
|
||||
_BV( 5 ), // PH 5 ** 8 ** PWM8
|
||||
_BV( 6 ), // PH 6 ** 9 ** PWM9
|
||||
_BV( 4 ), // PB 4 ** 10 ** PWM10
|
||||
_BV( 5 ), // PB 5 ** 11 ** PWM11
|
||||
_BV( 6 ), // PB 6 ** 12 ** PWM12
|
||||
_BV( 7 ), // PB 7 ** 13 ** PWM13
|
||||
_BV( 1 ), // PJ 1 ** 14 ** USART3_TX
|
||||
_BV( 0 ), // PJ 0 ** 15 ** USART3_RX
|
||||
_BV( 1 ), // PH 1 ** 16 ** USART2_TX
|
||||
_BV( 0 ), // PH 0 ** 17 ** USART2_RX
|
||||
_BV( 3 ), // PD 3 ** 18 ** USART1_TX
|
||||
_BV( 2 ), // PD 2 ** 19 ** USART1_RX
|
||||
_BV( 1 ), // PD 1 ** 20 ** I2C_SDA
|
||||
_BV( 0 ), // PD 0 ** 21 ** I2C_SCL
|
||||
_BV( 0 ), // PA 0 ** 22 ** D22
|
||||
_BV( 1 ), // PA 1 ** 23 ** D23
|
||||
_BV( 2 ), // PA 2 ** 24 ** D24
|
||||
_BV( 3 ), // PA 3 ** 25 ** D25
|
||||
_BV( 4 ), // PA 4 ** 26 ** D26
|
||||
_BV( 5 ), // PA 5 ** 27 ** D27
|
||||
_BV( 6 ), // PA 6 ** 28 ** D28
|
||||
_BV( 7 ), // PA 7 ** 29 ** D29
|
||||
_BV( 7 ), // PC 7 ** 30 ** D30
|
||||
_BV( 6 ), // PC 6 ** 31 ** D31
|
||||
_BV( 5 ), // PC 5 ** 32 ** D32
|
||||
_BV( 4 ), // PC 4 ** 33 ** D33
|
||||
_BV( 3 ), // PC 3 ** 34 ** D34
|
||||
_BV( 2 ), // PC 2 ** 35 ** D35
|
||||
_BV( 1 ), // PC 1 ** 36 ** D36
|
||||
_BV( 0 ), // PC 0 ** 37 ** D37
|
||||
_BV( 7 ), // PD 7 ** 38 ** D38
|
||||
_BV( 2 ), // PG 2 ** 39 ** D39
|
||||
_BV( 1 ), // PG 1 ** 40 ** D40
|
||||
_BV( 0 ), // PG 0 ** 41 ** D41
|
||||
_BV( 7 ), // PL 7 ** 42 ** D42
|
||||
_BV( 6 ), // PL 6 ** 43 ** D43
|
||||
_BV( 5 ), // PL 5 ** 44 ** D44
|
||||
_BV( 4 ), // PL 4 ** 45 ** D45
|
||||
_BV( 3 ), // PL 3 ** 46 ** D46
|
||||
_BV( 2 ), // PL 2 ** 47 ** D47
|
||||
_BV( 1 ), // PL 1 ** 48 ** D48
|
||||
_BV( 0 ), // PL 0 ** 49 ** D49
|
||||
_BV( 3 ), // PB 3 ** 50 ** SPI_MISO
|
||||
_BV( 2 ), // PB 2 ** 51 ** SPI_MOSI
|
||||
_BV( 1 ), // PB 1 ** 52 ** SPI_SCK
|
||||
_BV( 0 ), // PB 0 ** 53 ** SPI_SS
|
||||
_BV( 0 ), // PF 0 ** 54 ** A0
|
||||
_BV( 1 ), // PF 1 ** 55 ** A1
|
||||
_BV( 2 ), // PF 2 ** 56 ** A2
|
||||
_BV( 3 ), // PF 3 ** 57 ** A3
|
||||
_BV( 4 ), // PF 4 ** 58 ** A4
|
||||
_BV( 5 ), // PF 5 ** 59 ** A5
|
||||
_BV( 6 ), // PF 6 ** 60 ** A6
|
||||
_BV( 7 ), // PF 7 ** 61 ** A7
|
||||
_BV( 0 ), // PK 0 ** 62 ** A8
|
||||
_BV( 1 ), // PK 1 ** 63 ** A9
|
||||
_BV( 2 ), // PK 2 ** 64 ** A10
|
||||
_BV( 3 ), // PK 3 ** 65 ** A11
|
||||
_BV( 4 ), // PK 4 ** 66 ** A12
|
||||
_BV( 5 ), // PK 5 ** 67 ** A13
|
||||
_BV( 6 ), // PK 6 ** 68 ** A14
|
||||
_BV( 7 ), // PK 7 ** 69 ** A15
|
||||
_BV( 4 ), // PG 4 ** 70 **
|
||||
_BV( 3 ), // PG 3 ** 71 **
|
||||
_BV( 2 ), // PJ 2 ** 72 **
|
||||
_BV( 3 ), // PJ 3 ** 73 **
|
||||
_BV( 7 ), // PJ 7 ** 74 **
|
||||
_BV( 4 ), // PJ 4 ** 75 **
|
||||
_BV( 5 ), // PJ 5 ** 76 **
|
||||
_BV( 6 ), // PJ 6 ** 77 **
|
||||
_BV( 2 ), // PE 2 ** 78 **
|
||||
_BV( 6 ), // PE 6 ** 79 **
|
||||
_BV( 7 ), // PE 7 ** 80 **
|
||||
_BV( 4 ), // PD 4 ** 81 **
|
||||
_BV( 5 ), // PD 5 ** 82 **
|
||||
_BV( 6 ), // PD 6 ** 83 **
|
||||
_BV( 2 ), // PH 2 ** 84 **
|
||||
_BV( 7 ), // PH 7 ** 85 **
|
||||
};
|
||||
|
||||
#define digitalPinToBitMask_plus_70(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM_plus_70 + (P) ) )
|
||||
@@ -234,86 +234,86 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM_plus_70[] = {
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM_plus_70[] = {
|
||||
// TIMERS
|
||||
// ------------------------
|
||||
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
|
||||
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
|
||||
TIMER3B , // PE 4 ** 2 ** PWM2
|
||||
TIMER3C , // PE 5 ** 3 ** PWM3
|
||||
TIMER0B , // PG 5 ** 4 ** PWM4
|
||||
TIMER3A , // PE 3 ** 5 ** PWM5
|
||||
TIMER4A , // PH 3 ** 6 ** PWM6
|
||||
TIMER4B , // PH 4 ** 7 ** PWM7
|
||||
TIMER4C , // PH 5 ** 8 ** PWM8
|
||||
TIMER2B , // PH 6 ** 9 ** PWM9
|
||||
TIMER2A , // PB 4 ** 10 ** PWM10
|
||||
TIMER1A , // PB 5 ** 11 ** PWM11
|
||||
TIMER1B , // PB 6 ** 12 ** PWM12
|
||||
TIMER0A , // PB 7 ** 13 ** PWM13
|
||||
NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX
|
||||
NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX
|
||||
NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX
|
||||
NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX
|
||||
NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX
|
||||
NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX
|
||||
NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA
|
||||
NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL
|
||||
NOT_ON_TIMER , // PA 0 ** 22 ** D22
|
||||
NOT_ON_TIMER , // PA 1 ** 23 ** D23
|
||||
NOT_ON_TIMER , // PA 2 ** 24 ** D24
|
||||
NOT_ON_TIMER , // PA 3 ** 25 ** D25
|
||||
NOT_ON_TIMER , // PA 4 ** 26 ** D26
|
||||
NOT_ON_TIMER , // PA 5 ** 27 ** D27
|
||||
NOT_ON_TIMER , // PA 6 ** 28 ** D28
|
||||
NOT_ON_TIMER , // PA 7 ** 29 ** D29
|
||||
NOT_ON_TIMER , // PC 7 ** 30 ** D30
|
||||
NOT_ON_TIMER , // PC 6 ** 31 ** D31
|
||||
NOT_ON_TIMER , // PC 5 ** 32 ** D32
|
||||
NOT_ON_TIMER , // PC 4 ** 33 ** D33
|
||||
NOT_ON_TIMER , // PC 3 ** 34 ** D34
|
||||
NOT_ON_TIMER , // PC 2 ** 35 ** D35
|
||||
NOT_ON_TIMER , // PC 1 ** 36 ** D36
|
||||
NOT_ON_TIMER , // PC 0 ** 37 ** D37
|
||||
NOT_ON_TIMER , // PD 7 ** 38 ** D38
|
||||
NOT_ON_TIMER , // PG 2 ** 39 ** D39
|
||||
NOT_ON_TIMER , // PG 1 ** 40 ** D40
|
||||
NOT_ON_TIMER , // PG 0 ** 41 ** D41
|
||||
NOT_ON_TIMER , // PL 7 ** 42 ** D42
|
||||
NOT_ON_TIMER , // PL 6 ** 43 ** D43
|
||||
TIMER5C , // PL 5 ** 44 ** D44
|
||||
TIMER5B , // PL 4 ** 45 ** D45
|
||||
TIMER5A , // PL 3 ** 46 ** D46
|
||||
NOT_ON_TIMER , // PL 2 ** 47 ** D47
|
||||
NOT_ON_TIMER , // PL 1 ** 48 ** D48
|
||||
NOT_ON_TIMER , // PL 0 ** 49 ** D49
|
||||
NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO
|
||||
NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI
|
||||
NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK
|
||||
NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS
|
||||
NOT_ON_TIMER , // PF 0 ** 54 ** A0
|
||||
NOT_ON_TIMER , // PF 1 ** 55 ** A1
|
||||
NOT_ON_TIMER , // PF 2 ** 56 ** A2
|
||||
NOT_ON_TIMER , // PF 3 ** 57 ** A3
|
||||
NOT_ON_TIMER , // PF 4 ** 58 ** A4
|
||||
NOT_ON_TIMER , // PF 5 ** 59 ** A5
|
||||
NOT_ON_TIMER , // PF 6 ** 60 ** A6
|
||||
NOT_ON_TIMER , // PF 7 ** 61 ** A7
|
||||
NOT_ON_TIMER , // PK 0 ** 62 ** A8
|
||||
NOT_ON_TIMER , // PK 1 ** 63 ** A9
|
||||
NOT_ON_TIMER , // PK 2 ** 64 ** A10
|
||||
NOT_ON_TIMER , // PK 3 ** 65 ** A11
|
||||
NOT_ON_TIMER , // PK 4 ** 66 ** A12
|
||||
NOT_ON_TIMER , // PK 5 ** 67 ** A13
|
||||
NOT_ON_TIMER , // PK 6 ** 68 ** A14
|
||||
NOT_ON_TIMER , // PK 7 ** 69 ** A15
|
||||
NOT_ON_TIMER , // PG 4 ** 70 **
|
||||
NOT_ON_TIMER , // PG 3 ** 71 **
|
||||
NOT_ON_TIMER , // PJ 2 ** 72 **
|
||||
NOT_ON_TIMER , // PJ 3 ** 73 **
|
||||
NOT_ON_TIMER , // PJ 7 ** 74 **
|
||||
NOT_ON_TIMER , // PJ 4 ** 75 **
|
||||
NOT_ON_TIMER , // PJ 5 ** 76 **
|
||||
NOT_ON_TIMER , // PJ 6 ** 77 **
|
||||
NOT_ON_TIMER , // PE 2 ** 78 **
|
||||
NOT_ON_TIMER , // PE 6 ** 79 **
|
||||
NOT_ON_TIMER, // PE 0 ** 0 ** USART0_RX
|
||||
NOT_ON_TIMER, // PE 1 ** 1 ** USART0_TX
|
||||
TIMER3B, // PE 4 ** 2 ** PWM2
|
||||
TIMER3C, // PE 5 ** 3 ** PWM3
|
||||
TIMER0B, // PG 5 ** 4 ** PWM4
|
||||
TIMER3A, // PE 3 ** 5 ** PWM5
|
||||
TIMER4A, // PH 3 ** 6 ** PWM6
|
||||
TIMER4B, // PH 4 ** 7 ** PWM7
|
||||
TIMER4C, // PH 5 ** 8 ** PWM8
|
||||
TIMER2B, // PH 6 ** 9 ** PWM9
|
||||
TIMER2A, // PB 4 ** 10 ** PWM10
|
||||
TIMER1A, // PB 5 ** 11 ** PWM11
|
||||
TIMER1B, // PB 6 ** 12 ** PWM12
|
||||
TIMER0A, // PB 7 ** 13 ** PWM13
|
||||
NOT_ON_TIMER, // PJ 1 ** 14 ** USART3_TX
|
||||
NOT_ON_TIMER, // PJ 0 ** 15 ** USART3_RX
|
||||
NOT_ON_TIMER, // PH 1 ** 16 ** USART2_TX
|
||||
NOT_ON_TIMER, // PH 0 ** 17 ** USART2_RX
|
||||
NOT_ON_TIMER, // PD 3 ** 18 ** USART1_TX
|
||||
NOT_ON_TIMER, // PD 2 ** 19 ** USART1_RX
|
||||
NOT_ON_TIMER, // PD 1 ** 20 ** I2C_SDA
|
||||
NOT_ON_TIMER, // PD 0 ** 21 ** I2C_SCL
|
||||
NOT_ON_TIMER, // PA 0 ** 22 ** D22
|
||||
NOT_ON_TIMER, // PA 1 ** 23 ** D23
|
||||
NOT_ON_TIMER, // PA 2 ** 24 ** D24
|
||||
NOT_ON_TIMER, // PA 3 ** 25 ** D25
|
||||
NOT_ON_TIMER, // PA 4 ** 26 ** D26
|
||||
NOT_ON_TIMER, // PA 5 ** 27 ** D27
|
||||
NOT_ON_TIMER, // PA 6 ** 28 ** D28
|
||||
NOT_ON_TIMER, // PA 7 ** 29 ** D29
|
||||
NOT_ON_TIMER, // PC 7 ** 30 ** D30
|
||||
NOT_ON_TIMER, // PC 6 ** 31 ** D31
|
||||
NOT_ON_TIMER, // PC 5 ** 32 ** D32
|
||||
NOT_ON_TIMER, // PC 4 ** 33 ** D33
|
||||
NOT_ON_TIMER, // PC 3 ** 34 ** D34
|
||||
NOT_ON_TIMER, // PC 2 ** 35 ** D35
|
||||
NOT_ON_TIMER, // PC 1 ** 36 ** D36
|
||||
NOT_ON_TIMER, // PC 0 ** 37 ** D37
|
||||
NOT_ON_TIMER, // PD 7 ** 38 ** D38
|
||||
NOT_ON_TIMER, // PG 2 ** 39 ** D39
|
||||
NOT_ON_TIMER, // PG 1 ** 40 ** D40
|
||||
NOT_ON_TIMER, // PG 0 ** 41 ** D41
|
||||
NOT_ON_TIMER, // PL 7 ** 42 ** D42
|
||||
NOT_ON_TIMER, // PL 6 ** 43 ** D43
|
||||
TIMER5C, // PL 5 ** 44 ** D44
|
||||
TIMER5B, // PL 4 ** 45 ** D45
|
||||
TIMER5A, // PL 3 ** 46 ** D46
|
||||
NOT_ON_TIMER, // PL 2 ** 47 ** D47
|
||||
NOT_ON_TIMER, // PL 1 ** 48 ** D48
|
||||
NOT_ON_TIMER, // PL 0 ** 49 ** D49
|
||||
NOT_ON_TIMER, // PB 3 ** 50 ** SPI_MISO
|
||||
NOT_ON_TIMER, // PB 2 ** 51 ** SPI_MOSI
|
||||
NOT_ON_TIMER, // PB 1 ** 52 ** SPI_SCK
|
||||
NOT_ON_TIMER, // PB 0 ** 53 ** SPI_SS
|
||||
NOT_ON_TIMER, // PF 0 ** 54 ** A0
|
||||
NOT_ON_TIMER, // PF 1 ** 55 ** A1
|
||||
NOT_ON_TIMER, // PF 2 ** 56 ** A2
|
||||
NOT_ON_TIMER, // PF 3 ** 57 ** A3
|
||||
NOT_ON_TIMER, // PF 4 ** 58 ** A4
|
||||
NOT_ON_TIMER, // PF 5 ** 59 ** A5
|
||||
NOT_ON_TIMER, // PF 6 ** 60 ** A6
|
||||
NOT_ON_TIMER, // PF 7 ** 61 ** A7
|
||||
NOT_ON_TIMER, // PK 0 ** 62 ** A8
|
||||
NOT_ON_TIMER, // PK 1 ** 63 ** A9
|
||||
NOT_ON_TIMER, // PK 2 ** 64 ** A10
|
||||
NOT_ON_TIMER, // PK 3 ** 65 ** A11
|
||||
NOT_ON_TIMER, // PK 4 ** 66 ** A12
|
||||
NOT_ON_TIMER, // PK 5 ** 67 ** A13
|
||||
NOT_ON_TIMER, // PK 6 ** 68 ** A14
|
||||
NOT_ON_TIMER, // PK 7 ** 69 ** A15
|
||||
NOT_ON_TIMER, // PG 4 ** 70 **
|
||||
NOT_ON_TIMER, // PG 3 ** 71 **
|
||||
NOT_ON_TIMER, // PJ 2 ** 72 **
|
||||
NOT_ON_TIMER, // PJ 3 ** 73 **
|
||||
NOT_ON_TIMER, // PJ 7 ** 74 **
|
||||
NOT_ON_TIMER, // PJ 4 ** 75 **
|
||||
NOT_ON_TIMER, // PJ 5 ** 76 **
|
||||
NOT_ON_TIMER, // PJ 6 ** 77 **
|
||||
NOT_ON_TIMER, // PE 2 ** 78 **
|
||||
NOT_ON_TIMER, // PE 6 ** 79 **
|
||||
};
|
||||
|
||||
#define digitalPinToTimer_plus_70(P) ( pgm_read_byte( digital_pin_to_timer_PGM_plus_70 + (P) ) )
|
||||
|
||||
+3
-3
@@ -55,12 +55,12 @@
|
||||
|
||||
#if defined(ARDUINO) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_SAM)
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/Delay.h"
|
||||
#include "../../shared/Marduino.h"
|
||||
#include "../../shared/Delay.h"
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
|
||||
@@ -208,8 +208,8 @@
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#0,#1") /* Store read bit as the bit 0 */
|
||||
|
||||
: [bin]"+r"(bin),
|
||||
[work]"+r"(work)
|
||||
: [bin]"+r"( bin ),
|
||||
[work]"+r"( work )
|
||||
: [bitband_miso_port]"r"( BITBAND_MISO_PORT ),
|
||||
[sck_mask]"r"( SCK_MASK ),
|
||||
[sck_port]"r"( SCK_PORT_PLUS30 )
|
||||
@@ -350,7 +350,7 @@
|
||||
static void spiRxBlock0(uint8_t *ptr, uint32_t todo) {
|
||||
uint32_t bin = 0;
|
||||
uint32_t work = 0;
|
||||
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */
|
||||
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS(((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */
|
||||
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */
|
||||
uint32_t SCK_MASK = PIN_MASK(SD_SCK_PIN);
|
||||
|
||||
@@ -412,10 +412,10 @@
|
||||
A("strb.w %[bin], [%[ptr]], #1") /* Store read value into buffer, increment buffer pointer */
|
||||
A("bne.n loop%=") /* Repeat until done */
|
||||
|
||||
: [ptr]"+r"(ptr),
|
||||
[todo]"+r"(todo),
|
||||
[bin]"+r"(bin),
|
||||
[work]"+r"(work)
|
||||
: [ptr]"+r"( ptr ),
|
||||
[todo]"+r"( todo ),
|
||||
[bin]"+r"( bin ),
|
||||
[work]"+r"( work )
|
||||
: [bitband_miso_port]"r"( BITBAND_MISO_PORT ),
|
||||
[sck_mask]"r"( SCK_MASK ),
|
||||
[sck_port]"r"( SCK_PORT_PLUS30 )
|
||||
|
||||
@@ -56,16 +56,12 @@
|
||||
#else
|
||||
#define G2_PWM_Y 0
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
#if HAS_MOTOR_CURRENT_PWM_Z
|
||||
#define G2_PWM_Z 1
|
||||
#else
|
||||
#define G2_PWM_Z 0
|
||||
#endif
|
||||
#if HAS_MOTOR_CURRENT_PWM_E
|
||||
#define G2_PWM_E 1
|
||||
#else
|
||||
#define G2_PWM_E 0
|
||||
#endif
|
||||
#define G2_PWM_E HAS_MOTOR_CURRENT_PWM_E
|
||||
#define G2_MASK_X(V) (G2_PWM_X * (V))
|
||||
#define G2_MASK_Y(V) (G2_PWM_Y * (V))
|
||||
#define G2_MASK_Z(V) (G2_PWM_Z * (V))
|
||||
@@ -80,17 +76,22 @@ PWM_map ISR_table[NUM_PWMS] = PWM_MAP_INIT;
|
||||
|
||||
void Stepper::digipot_init() {
|
||||
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_X_PIN, 0); // init pins
|
||||
#if G2_PWM_X
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_X_PIN, LOW); // init pins
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_Y_PIN, 0);
|
||||
#if G2_PWM_Y
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_Y_PIN, LOW);
|
||||
#endif
|
||||
#if G2_PWM_Z
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_Z_PIN, 0);
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_Z_PIN, LOW);
|
||||
#endif
|
||||
#if G2_PWM_E
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_E_PIN, 0);
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_E_PIN, LOW);
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0)
|
||||
OUT_WRITE(MOTOR_CURRENT_PWM_E0_PIN, LOW);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define WPKEY (0x50574D << 8) // “PWM” in ASCII
|
||||
|
||||
@@ -145,7 +145,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) {
|
||||
void stepperTask(void *parameter) {
|
||||
uint32_t nextMainISR = 0;
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
uint32_t nextAdvanceISR = Stepper::LA_ADV_NEVER;
|
||||
uint32_t nextAdvanceISR = stepper.LA_ADV_NEVER;
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
@@ -167,13 +167,13 @@ void stepperTask(void *parameter) {
|
||||
|
||||
if (!using_ftMotion) {
|
||||
if (!nextMainISR) {
|
||||
Stepper::pulse_phase_isr();
|
||||
nextMainISR = Stepper::block_phase_isr();
|
||||
stepper.pulse_phase_isr();
|
||||
nextMainISR = stepper.block_phase_isr();
|
||||
}
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
else if (!nextAdvanceISR) {
|
||||
Stepper::advance_isr();
|
||||
nextAdvanceISR = Stepper::la_interval;
|
||||
stepper.advance_isr();
|
||||
nextAdvanceISR = stepper.la_interval;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@@ -182,10 +182,10 @@ void stepperTask(void *parameter) {
|
||||
nextMainISR--;
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (nextAdvanceISR == Stepper::LA_ADV_NEVER)
|
||||
nextAdvanceISR = Stepper::la_interval;
|
||||
if (nextAdvanceISR == stepper.LA_ADV_NEVER)
|
||||
nextAdvanceISR = stepper.la_interval;
|
||||
|
||||
if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER)
|
||||
if (nextAdvanceISR && nextAdvanceISR != stepper.LA_ADV_NEVER)
|
||||
nextAdvanceISR--;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/Delay.h"
|
||||
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
extern void install_min_serial();
|
||||
#endif
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
// Dump the clock frequencies of the system, AHB, APB1, APB2, and F_CPU.
|
||||
static inline void HAL_clock_frequencies_dump() {
|
||||
auto& rcuInstance = rcu::RCU::get_instance();
|
||||
uint32_t freq = rcuInstance.get_clock_frequency(rcu::Clock_Frequency::CK_SYS);
|
||||
SERIAL_ECHOPGM("\nSYSTEM_CLOCK=", freq);
|
||||
freq = rcuInstance.get_clock_frequency(rcu::Clock_Frequency::CK_AHB);
|
||||
SERIAL_ECHOPGM("\nABH_CLOCK=", freq);
|
||||
freq = rcuInstance.get_clock_frequency(rcu::Clock_Frequency::CK_APB1);
|
||||
SERIAL_ECHOPGM("\nAPB1_CLOCK=", freq);
|
||||
freq = rcuInstance.get_clock_frequency(rcu::Clock_Frequency::CK_APB2);
|
||||
SERIAL_ECHOPGM("\nAPB2_CLOCK=", freq,
|
||||
"\nF_CPU=", F_CPU);
|
||||
// Done
|
||||
SERIAL_ECHOPGM("\n--\n");
|
||||
}
|
||||
#endif // MARLIN_DEV_MODE
|
||||
|
||||
// Initializes the Marlin HAL
|
||||
void MarlinHAL::init() {
|
||||
constexpr unsigned int cpuFreq = F_CPU;
|
||||
UNUSED(cpuFreq);
|
||||
|
||||
#if PIN_EXISTS(LED)
|
||||
OUT_WRITE(LED_PIN, LOW);
|
||||
#endif
|
||||
|
||||
SetTimerInterruptPriorities();
|
||||
|
||||
// Print clock frequencies to host serial
|
||||
TERN_(MARLIN_DEV_MODE, HAL_clock_frequencies_dump());
|
||||
|
||||
// Register min serial
|
||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial());
|
||||
}
|
||||
|
||||
// Returns the reset source based on the flags set in the RCU module
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
return
|
||||
(RCU_I.get_flag(rcu::Status_Flags::FLAG_FWDGTRST)) ? RST_WATCHDOG :
|
||||
(RCU_I.get_flag(rcu::Status_Flags::FLAG_SWRST)) ? RST_SOFTWARE :
|
||||
(RCU_I.get_flag(rcu::Status_Flags::FLAG_EPRST)) ? RST_EXTERNAL :
|
||||
(RCU_I.get_flag(rcu::Status_Flags::FLAG_PORRST)) ? RST_POWER_ON :
|
||||
(RCU_I.get_flag(rcu::Status_Flags::FLAG_LPRST)) ? RST_BROWN_OUT :
|
||||
0;
|
||||
}
|
||||
|
||||
// Returns the amount of free memory available in bytes
|
||||
int MarlinHAL::freeMemory() {
|
||||
volatile char top;
|
||||
return &top - reinterpret_cast<char*>(_sbrk(0));
|
||||
}
|
||||
|
||||
// Watchdog Timer
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout
|
||||
|
||||
#include <FWatchdogTimer.h>
|
||||
|
||||
FWatchdogTimer& watchdogTimer = FWatchdogTimer::get_instance();
|
||||
|
||||
// Initializes the watchdog timer
|
||||
void MarlinHAL::watchdog_init() {
|
||||
IF_DISABLED(DISABLE_WATCHDOG_INIT, watchdogTimer.begin(WDT_TIMEOUT_US));
|
||||
}
|
||||
|
||||
// Refreshes the watchdog timer to prevent system reset
|
||||
void MarlinHAL::watchdog_refresh() {
|
||||
watchdogTimer.reload();
|
||||
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
|
||||
TOGGLE(LED_PIN); // Heartbeat indicator
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // End of bss section
|
||||
}
|
||||
|
||||
// Resets the system to initiate a firmware flash.
|
||||
WEAK void flashFirmware(const int16_t) {
|
||||
hal.reboot();
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#include "../../core/macros.h"
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
|
||||
#include "temp_soc.h"
|
||||
#include "fastio.h"
|
||||
#include "Servo.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <GPIO.hpp>
|
||||
#include <AFIO.hpp>
|
||||
|
||||
// Default graphical display delays
|
||||
#define CPU_ST7920_DELAY_1 300
|
||||
#define CPU_ST7920_DELAY_2 40
|
||||
#define CPU_ST7920_DELAY_3 340
|
||||
|
||||
// Serial Ports
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
// Interrupts
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
#define cli() __disable_irq()
|
||||
#define sei() __enable_irq()
|
||||
|
||||
// Alias of __bss_end__
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
// Types
|
||||
typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs.
|
||||
typedef uint8_t pin_t; // Parity with mfl platform
|
||||
|
||||
// Servo
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
|
||||
#define RESUME_SERVO_OUTPUT() libServo::resume_all_servos()
|
||||
|
||||
// Debugging
|
||||
#define JTAG_DISABLE() AFIO_I.set_remap(gpio::Pin_Remap_Select::SWJ_DP_ONLY_REMAP)
|
||||
#define JTAGSWD_DISABLE() AFIO_I.set_remap(gpio::Pin_Remap_Select::SWJ_ALL_DISABLED_REMAP)
|
||||
#define JTAGSWD_RESET() AFIO_I.set_remap(gpio::Pin_Remap_Select::FULL_SWJ_REMAP)
|
||||
|
||||
// ADC
|
||||
#ifdef ADC_RESOLUTION
|
||||
#define HAL_ADC_RESOLUTION ADC_RESOLUTION
|
||||
#else
|
||||
#define HAL_ADC_RESOLUTION 12
|
||||
#endif
|
||||
|
||||
#define HAL_ADC_VREF_MV 3300
|
||||
|
||||
// Disable Marlin's software oversampling.
|
||||
// The MFL framework uses 16x hardware oversampling by default
|
||||
#ifdef GD32F303RE
|
||||
#define HAL_ADC_FILTERED
|
||||
#endif
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#ifndef PLATFORM_M997_SUPPORT
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
#endif
|
||||
|
||||
void flashFirmware(const int16_t);
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
extern "C" char* dtostrf(double val, signed char width, unsigned char prec, char* sout);
|
||||
|
||||
// MarlinHAL Class
|
||||
class MarlinHAL {
|
||||
public:
|
||||
// Before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
// Watchdog
|
||||
static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {});
|
||||
static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {});
|
||||
|
||||
static void init(); // called early in setup()
|
||||
static void init_board() {} // called less early in setup()
|
||||
static void reboot() { NVIC_SystemReset(); } // restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { sei(); }
|
||||
static void isr_off() { cli(); }
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() { RCU_I.clear_all_reset_flags(); }
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory();
|
||||
|
||||
// ADC methods
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); }
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); }
|
||||
|
||||
// Called from Temperature::isr to start ADC sampling on the given pin
|
||||
static void adc_start(const pin_t pin) { adc_result = static_cast<uint16_t>(analogRead(pin)); }
|
||||
|
||||
// Check if ADC is ready for reading
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// Current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
// Set the PWM duty cycle for the pin to the given value.
|
||||
// Optionally invert the duty cycle [default = false]
|
||||
// Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t value, const uint16_t scale = 255U, const bool invert = false);
|
||||
|
||||
// Set the frequency of the timer for the given pin.
|
||||
// All Timer PWM pins run at the same frequency.
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 <SPI.h>
|
||||
|
||||
using MarlinSPI = SPIClass;
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../feature/e_parser.h"
|
||||
#endif
|
||||
|
||||
using namespace arduino;
|
||||
|
||||
MarlinSerial& MarlinSerial::get_instance(usart::USART_Base Base, pin_size_t rxPin, pin_size_t txPin) {
|
||||
UsartSerial& serial = UsartSerial::get_instance(Base, rxPin, txPin);
|
||||
return *reinterpret_cast<MarlinSerial*>(&serial);
|
||||
}
|
||||
|
||||
#if USING_HW_SERIAL0
|
||||
MSerialT MSerial0(true, MarlinSerial::get_instance(usart::USART_Base::USART0_BASE, NO_PIN, NO_PIN));
|
||||
#endif
|
||||
#if USING_HW_SERIAL1
|
||||
MSerialT MSerial1(true, MarlinSerial::get_instance(usart::USART_Base::USART1_BASE, NO_PIN, NO_PIN));
|
||||
#endif
|
||||
#if USING_HW_SERIAL2
|
||||
MSerialT MSerial2(true, MarlinSerial::get_instance(usart::USART_Base::USART2_BASE, NO_PIN, NO_PIN));
|
||||
#endif
|
||||
#if USING_HW_SERIAL3
|
||||
MSerialT MSerial3(true, MarlinSerial::get_instance(usart::USART_Base::UART3_BASE, NO_PIN, NO_PIN));
|
||||
#endif
|
||||
#if USING_HW_SERIAL4
|
||||
MSerialT MSerial4(true, MarlinSerial::get_instance(usart::USART_Base::UART4_BASE, NO_PIN, NO_PIN));
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
// This callback needs to access the specific MarlinSerial instance
|
||||
// We'll use a static pointer to track the current instance
|
||||
static MarlinSerial* current_serial_instance = nullptr;
|
||||
|
||||
static void emergency_callback() {
|
||||
if (current_serial_instance) {
|
||||
uint8_t last_data = current_serial_instance->get_last_data();
|
||||
emergency_parser.update(current_serial_instance->emergency_state, last_data);
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinSerial::register_emergency_callback(void (*callback)()) {
|
||||
usart_.register_interrupt_callback(usart::Interrupt_Type::INTR_RBNEIE, callback);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MarlinSerial::begin(unsigned long baudrate, uint16_t config) {
|
||||
UsartSerial::begin(baudrate, config);
|
||||
#if DISABLED(SERIAL_DMA)
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
current_serial_instance = this;
|
||||
register_emergency_callback(emergency_callback);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void MarlinSerial::updateRxDmaBuffer() {
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
// Get the number of bytes available in the receive buffer
|
||||
size_t available_bytes = usart_.available_for_read(true);
|
||||
uint8_t data;
|
||||
|
||||
// Process only the available data
|
||||
for (size_t i = 0; i < available_bytes; ++i) {
|
||||
if (usart_.read_rx_buffer(data)) {
|
||||
emergency_parser.update(emergency_state, data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Call the base class implementation to handle any additional updates
|
||||
UsartSerial::updateRxDmaBuffer();
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../feature/e_parser.h"
|
||||
#endif
|
||||
|
||||
#include <UsartSerial.hpp>
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 4
|
||||
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
using namespace arduino;
|
||||
|
||||
struct MarlinSerial : public UsartSerial {
|
||||
static MarlinSerial& get_instance(usart::USART_Base Base, pin_size_t rxPin = NO_PIN, pin_size_t txPin = NO_PIN);
|
||||
|
||||
void begin(unsigned long baudrate, uint16_t config);
|
||||
inline void begin(unsigned long baudrate) { begin(baudrate, SERIAL_8N1); }
|
||||
void updateRxDmaBuffer();
|
||||
|
||||
#if DISABLED(SERIAL_DMA)
|
||||
FORCE_INLINE static uint8_t buffer_overruns() { return 0; }
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
EmergencyParser::State emergency_state;
|
||||
|
||||
// Accessor method to get the last received byte
|
||||
uint8_t get_last_data() { return usart_.get_last_data(); }
|
||||
|
||||
// Register the emergency callback
|
||||
void register_emergency_callback(void (*callback)());
|
||||
#endif
|
||||
|
||||
protected:
|
||||
using UsartSerial::UsartSerial;
|
||||
};
|
||||
|
||||
typedef Serial1Class<MarlinSerial> MSerialT;
|
||||
extern MSerialT MSerial0;
|
||||
extern MSerialT MSerial1;
|
||||
extern MSerialT MSerial2;
|
||||
extern MSerialT MSerial3;
|
||||
extern MSerialT MSerial4;
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#include "../shared/MinSerial.h"
|
||||
|
||||
// Base addresses for USART peripherals
|
||||
static constexpr uintptr_t USART_base[] = {
|
||||
0x40013800, // USART0
|
||||
0x40004400, // USART1
|
||||
0x40004800, // USART2
|
||||
0x40004C00, // UART3
|
||||
0x40005000 // UART4
|
||||
};
|
||||
|
||||
// Register offsets
|
||||
static constexpr uint32_t STAT0_OFFSET = 0x00U;
|
||||
static constexpr uint32_t DATA_OFFSET = 0x04U;
|
||||
static constexpr uint32_t BAUD_OFFSET = 0x08U;
|
||||
static constexpr uint32_t CTL0_OFFSET = 0x0CU;
|
||||
static constexpr uint32_t CTL1_OFFSET = 0x14U;
|
||||
|
||||
// Bit positions
|
||||
static constexpr uint32_t TBE_BIT = 7;
|
||||
static constexpr uint32_t TEN_BIT = 3;
|
||||
static constexpr uint32_t UEN_BIT = 13;
|
||||
|
||||
// NVIC interrupt numbers for USART
|
||||
static constexpr int nvicUART[] = { 37, 38, 39, 52, 53 };
|
||||
|
||||
// RCU PCLK values for USART
|
||||
static constexpr rcu::RCU_PCLK clockRegs[] = {
|
||||
rcu::RCU_PCLK::PCLK_USART0,
|
||||
rcu::RCU_PCLK::PCLK_USART1,
|
||||
rcu::RCU_PCLK::PCLK_USART2,
|
||||
rcu::RCU_PCLK::PCLK_UART3,
|
||||
rcu::RCU_PCLK::PCLK_UART4
|
||||
};
|
||||
|
||||
// Memory barrier instructions
|
||||
#define isb() __asm__ __volatile__ ("isb" : : : "memory")
|
||||
#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
|
||||
#define sw_barrier() __asm__ volatile("" : : : "memory")
|
||||
|
||||
// Direct register access macros
|
||||
#define USART_REG(offset) (*(volatile uint32_t*)(USART_base[SERIAL_PORT] + (offset)))
|
||||
#define USART_STAT0 USART_REG(STAT0_OFFSET)
|
||||
#define USART_DATA USART_REG(DATA_OFFSET)
|
||||
#define USART_BAUD USART_REG(BAUD_OFFSET)
|
||||
#define USART_CTL0 USART_REG(CTL0_OFFSET)
|
||||
#define USART_CTL1 USART_REG(CTL1_OFFSET)
|
||||
|
||||
// Bit manipulation macros
|
||||
#define READ_BIT(reg, bit) (((reg) >> (bit)) & 1U)
|
||||
#define SET_BIT(reg, bit) ((reg) |= (1U << (bit)))
|
||||
#define CLEAR_BIT(reg, bit) ((reg) &= ~(1U << (bit)))
|
||||
|
||||
// Initializes the MinSerial interface.
|
||||
// This function sets up the USART interface for serial communication.
|
||||
// If the selected serial port is not a hardware port, it disables the severe error reporting feature.
|
||||
static void MinSerialBegin() {
|
||||
#if !WITHIN(SERIAL_PORT, 0, 4)
|
||||
#warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error."
|
||||
#warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port."
|
||||
#else
|
||||
int nvicIndex = nvicUART[SERIAL_PORT];
|
||||
|
||||
// NVIC base address for interrupt disable
|
||||
struct NVICMin {
|
||||
volatile uint32_t ISER[32];
|
||||
volatile uint32_t ICER[32];
|
||||
};
|
||||
NVICMin *nvicBase = (NVICMin*)0xE000E100;
|
||||
|
||||
SBI32(nvicBase->ICER[nvicIndex >> 5], nvicIndex & 0x1F);
|
||||
|
||||
// We require memory barriers to properly disable interrupts
|
||||
// (https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the)
|
||||
dsb();
|
||||
isb();
|
||||
|
||||
// Get the RCU PCLK for this USART
|
||||
rcu::RCU_PCLK pclk = clockRegs[SERIAL_PORT];
|
||||
|
||||
// Disable then enable usart peripheral clocks
|
||||
rcu::RCU_DEVICE.set_pclk_enable(pclk, false);
|
||||
rcu::RCU_DEVICE.set_pclk_enable(pclk, true);
|
||||
|
||||
// Save current baudrate
|
||||
uint32_t baudrate = USART_BAUD;
|
||||
|
||||
// Reset USART control registers
|
||||
USART_CTL0 = 0;
|
||||
USART_CTL1 = 0; // 1 stop bit
|
||||
|
||||
// Restore baudrate
|
||||
USART_BAUD = baudrate;
|
||||
|
||||
// Enable transmitter and USART (8 bits, no parity, 1 stop bit)
|
||||
SET_BIT(USART_CTL0, TEN_BIT);
|
||||
SET_BIT(USART_CTL0, UEN_BIT);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Writes a single character to the serial port.
|
||||
static void MinSerialWrite(char c) {
|
||||
#if WITHIN(SERIAL_PORT, 0, 4)
|
||||
// Wait until transmit buffer is empty
|
||||
while (!READ_BIT(USART_STAT0, TBE_BIT)) {
|
||||
hal.watchdog_refresh();
|
||||
sw_barrier();
|
||||
}
|
||||
// Write character to data register
|
||||
USART_DATA = c;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Installs the minimum serial interface.
|
||||
// Sets the HAL_min_serial_init and HAL_min_serial_out function pointers to MinSerialBegin and MinSerialWrite respectively.
|
||||
void install_min_serial() {
|
||||
HAL_min_serial_init = &MinSerialBegin;
|
||||
HAL_min_serial_out = &MinSerialWrite;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
// A low-level assembly-based jump handler.
|
||||
// Unconditionally branches to the CommonHandler_ASM function.
|
||||
__attribute__((naked, aligned(4))) void JumpHandler_ASM() {
|
||||
__asm__ __volatile__ ("b CommonHandler_ASM\n");
|
||||
}
|
||||
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) HardFault_Handler();
|
||||
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) BusFault_Handler();
|
||||
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) UsageFault_Handler();
|
||||
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) MemManage_Handler();
|
||||
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) NMI_Handler();
|
||||
}
|
||||
|
||||
#endif // POSTMORTEM_DEBUGGING
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,8 @@
|
||||
# Generic GD32 HAL based on the MFL Arduino Core
|
||||
|
||||
This HAL is eventually intended to act as the generic HAL for all GD32 chips using the MFL library.
|
||||
|
||||
Currently it supports:
|
||||
* GD32F303RET6
|
||||
|
||||
Targeting the official [MFL Arduino Core](https://github.com/bnmguy/ArduinoCore_MFL).
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// MFL gd32f30x SDCARD using DMA through SDIO in C++
|
||||
//
|
||||
// Copyright (C) 2025 B. Mourit <bnmguy@gmail.com>
|
||||
//
|
||||
// This software 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 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This software 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 software.
|
||||
// If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "SDIO.hpp"
|
||||
|
||||
namespace sdio {
|
||||
|
||||
class DMA;
|
||||
|
||||
class CardDMA {
|
||||
public:
|
||||
static CardDMA& get_instance();
|
||||
|
||||
SDIO_Error_Type init();
|
||||
SDIO_Error_Type card_init();
|
||||
SDIO_Error_Type begin_startup_procedure();
|
||||
void begin_shutdown_procedure();
|
||||
// Configuration
|
||||
SDIO_Error_Type set_hardware_bus_width(Bus_Width width);
|
||||
// Main read/write functions for single and multiblock transfers
|
||||
SDIO_Error_Type read(uint8_t* buf, uint32_t address, uint32_t count);
|
||||
SDIO_Error_Type write(uint8_t* buf, uint32_t address, uint32_t count);
|
||||
// DMA transfers
|
||||
// Other card functions
|
||||
SDIO_Error_Type erase(uint32_t address_start, uint32_t address_end);
|
||||
// Interrupt handler
|
||||
void handle_interrupts();
|
||||
// Card select
|
||||
SDIO_Error_Type select_deselect();
|
||||
|
||||
SDIO_Error_Type get_card_interface_status(uint32_t* status);
|
||||
SDIO_Error_Type get_sdcard_status(uint32_t* status);
|
||||
|
||||
void check_dma_complete();
|
||||
SDIO_Error_Type stop_transfer();
|
||||
|
||||
Transfer_State get_transfer_state();
|
||||
uint32_t get_card_capacity() const;
|
||||
|
||||
SDIO_Error_Type send_bus_width_command(uint32_t width_value);
|
||||
|
||||
SDIO_Error_Type get_card_specific_data(Card_Info* info);
|
||||
constexpr Block_Size get_data_block_size_index(uint16_t size);
|
||||
|
||||
SDIO_Error_Type get_card_state(Card_State* card_state);
|
||||
SDIO_Error_Type check_sdio_status(Command_Index index = Command_Index::INVALID, bool check_index = false, bool ignore_crc = false);
|
||||
|
||||
// DMA configuration
|
||||
void set_dma_parameters(uint8_t* buf, uint32_t count, bool is_write);
|
||||
|
||||
// SDIO configuration
|
||||
void sdio_configure(const SDIO_Config config) { sdio_.init(config); }
|
||||
|
||||
// Varaible stored parameters
|
||||
SDIO_Error_Type get_scr(uint16_t rca, uint32_t* scr);
|
||||
SDIO_Error_Type store_cid();
|
||||
SDIO_Error_Type store_csd();
|
||||
|
||||
// Accessor methods
|
||||
SDIO_Config& get_config() { return config_; }
|
||||
dma::DMA& get_dma_instance() { return dma_; }
|
||||
void set_data_end_interrupt() { sdio_.set_interrupt_enable(Interrupt_Type::DTENDIE, true); }
|
||||
void set_sdio_dma_enable(bool enable) { sdio_.set_dma_enable(enable); }
|
||||
bool get_is_sdio_rx() { return is_rx_; }
|
||||
void clear_sdio_data_flags() { sdio_.clear_multiple_interrupt_flags(clear_data_flags); }
|
||||
void clear_sdio_cmd_flags() { sdio_.clear_multiple_interrupt_flags(clear_command_flags); }
|
||||
void clear_sdio_common_flags() { sdio_.clear_multiple_interrupt_flags(clear_common_flags); }
|
||||
Operational_State get_state() { return current_state_; }
|
||||
void set_state(Operational_State state) { current_state_ = state; }
|
||||
void set_transfer_end(bool value) { transfer_end_ = value; }
|
||||
void set_transfer_error(SDIO_Error_Type error) { transfer_error_ = error; }
|
||||
|
||||
inline SDIO_Error_Type set_desired_clock(uint32_t desired_clock, bool wide_bus, bool low_power) {
|
||||
sdio_.init({
|
||||
desired_clock,
|
||||
Clock_Edge::RISING_EDGE,
|
||||
wide_bus ? Bus_Width::WIDTH_4BIT : Bus_Width::WIDTH_1BIT,
|
||||
false,
|
||||
low_power,
|
||||
false
|
||||
});
|
||||
sync_domains();
|
||||
desired_clock_ = desired_clock;
|
||||
|
||||
return SDIO_Error_Type::OK;
|
||||
}
|
||||
|
||||
private:
|
||||
CardDMA();
|
||||
|
||||
// Prevent copying or assigning
|
||||
CardDMA(const CardDMA&) = delete;
|
||||
CardDMA& operator=(const CardDMA&) = delete;
|
||||
|
||||
// Helper function
|
||||
SDIO_Error_Type wait_for_card_ready();
|
||||
|
||||
// Member variables
|
||||
alignas(4) uint32_t sdcard_csd_[4];
|
||||
alignas(4) uint32_t sdcard_cid_[4];
|
||||
alignas(4) uint32_t sdcard_scr_[2];
|
||||
uint32_t desired_clock_;
|
||||
uint32_t stop_condition_;
|
||||
uint32_t total_bytes_;
|
||||
uint32_t count_;
|
||||
SDIO& sdio_;
|
||||
SDIO_Config& config_;
|
||||
const dma::DMA_Base dmaBase_;
|
||||
const dma::DMA_Channel dmaChannel_;
|
||||
dma::DMA& dma_;
|
||||
uint16_t sdcard_rca_;
|
||||
SDIO_Error_Type transfer_error_;
|
||||
Interface_Version interface_version_;
|
||||
Card_Type card_type_;
|
||||
volatile bool transfer_end_;
|
||||
volatile bool is_rx_;
|
||||
volatile bool multiblock_;
|
||||
volatile Operational_State current_state_;
|
||||
|
||||
// Private helper methods
|
||||
SDIO_Error_Type validate_voltage();
|
||||
SDIO_Error_Type get_r1_result(Command_Index index);
|
||||
//SDIO_Error_Type get_r2_r3_result();
|
||||
SDIO_Error_Type get_r6_result(Command_Index index, uint16_t* rca);
|
||||
SDIO_Error_Type get_r7_result();
|
||||
//SDIO_Error_Type get_r1_error_type(uint32_t response);
|
||||
SDIO_Error_Type get_command_sent_result();
|
||||
|
||||
inline void sync_domains() {
|
||||
delayMicroseconds(8);
|
||||
}
|
||||
|
||||
inline bool validate_transfer_params(uint32_t* buf, uint16_t size) {
|
||||
if (buf == nullptr) return false;
|
||||
// Size must be > 0, <= 2048 and power of 2
|
||||
if ((size == 0U) || (size > 2048U) || (size & (size - 1U))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void process_sdsc_specific_csd(Card_Info* info, const uint8_t* csd_bytes) {
|
||||
info->csd.device_size = (static_cast<uint32_t>(csd_bytes[6] & 0x03U) << 10U) |
|
||||
(static_cast<uint32_t>(csd_bytes[7]) << 2U) |
|
||||
(static_cast<uint32_t>((csd_bytes[8] & 0xC0U) >> 6U));
|
||||
info->csd.device_size_multiplier = static_cast<uint8_t>((csd_bytes[9] & 0x03U) << 1U |
|
||||
(csd_bytes[10] & 0x80U) >> 7U);
|
||||
|
||||
info->block_size = static_cast<uint32_t>(1 << info->csd.read_block_length);
|
||||
info->capacity = static_cast<uint32_t>((info->csd.device_size + 1U) *
|
||||
(1U << (info->csd.device_size_multiplier + 2U)) *
|
||||
info->block_size);
|
||||
}
|
||||
|
||||
void process_sdhc_specific_csd(Card_Info* info, const uint8_t* csd_bytes) {
|
||||
info->csd.device_size = static_cast<uint32_t>((csd_bytes[7] & 0x3FU) << 16U) |
|
||||
static_cast<uint32_t>((csd_bytes[8]) << 8U) |
|
||||
static_cast<uint32_t>(csd_bytes[9]);
|
||||
|
||||
info->block_size = BLOCK_SIZE;
|
||||
info->capacity = static_cast<uint32_t>((info->csd.device_size + 1U) *
|
||||
BLOCK_SIZE * KILOBYTE);
|
||||
}
|
||||
|
||||
void process_common_csd_tail(Card_Info* info, const uint8_t* csd_bytes) {
|
||||
info->csd.sector_size = static_cast<uint8_t>(((csd_bytes[9] & 0x3FU) << 1U) |
|
||||
(csd_bytes[10] & 0x80U) >> 7U);
|
||||
info->csd.speed_factor = static_cast<uint8_t>((csd_bytes[11] & 0x1CU) >> 2U);
|
||||
info->csd.write_block_length = static_cast<uint8_t>(((csd_bytes[11] & 0x03U) << 2U) |
|
||||
((csd_bytes[12] & 0xC0U) >> 6U));
|
||||
info->csd.checksum = static_cast<uint8_t>((csd_bytes[15] & 0xFEU) >> 1U);
|
||||
}
|
||||
|
||||
inline void disable_all_interrupts() {
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::DTCRCERRIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::DTTMOUTIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::DTENDIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::STBITEIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::TFHIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::RFHIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::TXUREIE, false);
|
||||
sdio_.set_interrupt_enable(Interrupt_Type::RXOREIE, false);
|
||||
}
|
||||
|
||||
template <typename CheckFunc>
|
||||
inline SDIO_Error_Type send_command_and_check(Command_Index command, uint32_t argument,
|
||||
Command_Response response, Wait_Type type, CheckFunc check_result) {
|
||||
sdio_.set_command_state_machine(command, argument, response, type);
|
||||
sync_domains();
|
||||
sdio_.set_command_state_machine_enable(true);
|
||||
return check_result();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sdio
|
||||
|
||||
extern sdio::CardDMA& CardDMA_I;
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SERVOS
|
||||
|
||||
#include "Servo.h"
|
||||
|
||||
static uint_fast8_t servoCount = 0;
|
||||
static libServo* servos[NUM_SERVOS] = {0};
|
||||
constexpr millis_t servoDelay[] = SERVO_DELAY;
|
||||
static_assert(COUNT(servoDelay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
||||
|
||||
// Initialize to the default timer priority. This will be overridden by a call from timers.cpp.
|
||||
// This allows all timer interrupt priorities to be managed from a single location in the HAL.
|
||||
static uint32_t servo_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 12, 0);
|
||||
|
||||
// This must be called after the MFL Servo class has initialized the timer.
|
||||
// To be safe this is currently called after every call to attach().
|
||||
static void fixServoTimerInterruptPriority() {
|
||||
auto& servoTimerIdx = GeneralTimer::get_instance(static_cast<timer::TIMER_Base>(TIMER_SERVO));
|
||||
NVIC_SetPriority(servoTimerIdx.getTimerUpIRQ(), servo_interrupt_priority);
|
||||
}
|
||||
|
||||
// Default constructor for libServo class.
|
||||
// Initializes the servo delay, pause state, and pause value.
|
||||
// Registers the servo instance in the servos array.
|
||||
libServo::libServo() :
|
||||
delay(servoDelay[servoCount]),
|
||||
was_attached_before_pause(false),
|
||||
value_before_pause(0)
|
||||
{
|
||||
servos[servoCount++] = this;
|
||||
}
|
||||
|
||||
// Attaches a servo to a specified pin.
|
||||
int8_t libServo::attach(const int pin) {
|
||||
if (servoCount >= MAX_SERVOS) return -1;
|
||||
if (pin > 0) servoPin = pin;
|
||||
auto result = mflServo.attach(servoPin);
|
||||
fixServoTimerInterruptPriority();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Attaches a servo to a specified pin with minimum and maximum pulse widths.
|
||||
int8_t libServo::attach(const int pin, const int min, const int max) {
|
||||
if (servoCount >= MAX_SERVOS) return -1;
|
||||
if (pin > 0) servoPin = pin;
|
||||
auto result = mflServo.attach(servoPin, min, max);
|
||||
fixServoTimerInterruptPriority();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Moves the servo to a specified position.
|
||||
void libServo::move(const int value) {
|
||||
if (attach(0) >= 0) {
|
||||
mflServo.write(value);
|
||||
safe_delay(delay);
|
||||
TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
|
||||
}
|
||||
}
|
||||
|
||||
// Pause the servo by detaching it and storing its current state.
|
||||
void libServo::pause() {
|
||||
was_attached_before_pause = mflServo.attached();
|
||||
if (was_attached_before_pause) {
|
||||
value_before_pause = mflServo.read();
|
||||
mflServo.detach();
|
||||
}
|
||||
}
|
||||
|
||||
// Resume a previously paused servo.
|
||||
// If the servo was attached before the pause, this function re-attaches
|
||||
// the servo and moves it to the position it was in before the pause.
|
||||
void libServo::resume() {
|
||||
if (was_attached_before_pause) {
|
||||
attach();
|
||||
move(value_before_pause);
|
||||
}
|
||||
}
|
||||
|
||||
// Pause all servos by stopping their timers.
|
||||
void libServo::pause_all_servos() {
|
||||
for (auto& servo : servos)
|
||||
if (servo) servo->pause();
|
||||
}
|
||||
|
||||
// Resume all paused servos by starting their timers.
|
||||
void libServo::resume_all_servos() {
|
||||
for (auto& servo : servos)
|
||||
if (servo) servo->resume();
|
||||
}
|
||||
|
||||
// Set the interrupt priority for the servo.
|
||||
// @param preemptPriority The preempt priority level.
|
||||
// @param subPriority The sub priority level.
|
||||
void libServo::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority) {
|
||||
servo_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority);
|
||||
}
|
||||
|
||||
#endif // HAS_SERVOS
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 <Servo.h>
|
||||
|
||||
#include "../../core/millis_t.h"
|
||||
|
||||
// Inherit and expand on the official library
|
||||
class libServo {
|
||||
public:
|
||||
libServo();
|
||||
|
||||
int8_t attach(const int pin = 0); // pin == 0 uses value from previous call
|
||||
int8_t attach(const int pin, const int min, const int max);
|
||||
void detach() { mflServo.detach(); }
|
||||
|
||||
int read() { return mflServo.read(); }
|
||||
void move(const int value);
|
||||
|
||||
void pause();
|
||||
void resume();
|
||||
|
||||
static void pause_all_servos();
|
||||
static void resume_all_servos();
|
||||
|
||||
static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
|
||||
|
||||
private:
|
||||
Servo mflServo;
|
||||
|
||||
int servoPin = 0;
|
||||
millis_t delay = 0;
|
||||
|
||||
bool was_attached_before_pause;
|
||||
int value_before_pause;
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm / Ryan Power
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ALL(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI)
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#define nop asm volatile ("\tnop\n")
|
||||
|
||||
static inline uint8_t swSpiTransfer_mode_0(uint8_t b) {
|
||||
for (uint8_t i = 0; i < 8; ++i) {
|
||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||
WRITE(DOGLCD_SCK, HIGH);
|
||||
WRITE(DOGLCD_MOSI, state);
|
||||
b <<= 1;
|
||||
WRITE(DOGLCD_SCK, LOW);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
static inline uint8_t swSpiTransfer_mode_3(uint8_t b) {
|
||||
for (uint8_t i = 0; i < 8; ++i) {
|
||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||
WRITE(DOGLCD_SCK, LOW);
|
||||
WRITE(DOGLCD_MOSI, state);
|
||||
b <<= 1;
|
||||
WRITE(DOGLCD_SCK, HIGH);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
static void u8g_sw_spi_shift_out(uint8_t val) {
|
||||
#if U8G_SPI_USE_MODE_3
|
||||
swSpiTransfer_mode_3(val);
|
||||
#else
|
||||
swSpiTransfer_mode_0(val);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void swSpiInit() {
|
||||
#if PIN_EXISTS(LCD_RESET)
|
||||
SET_OUTPUT(LCD_RESET_PIN);
|
||||
#endif
|
||||
SET_OUTPUT(DOGLCD_A0);
|
||||
OUT_WRITE(DOGLCD_SCK, LOW);
|
||||
OUT_WRITE(DOGLCD_MOSI, LOW);
|
||||
OUT_WRITE(DOGLCD_CS, HIGH);
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_MFL_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
swSpiInit();
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
#if PIN_EXISTS(LCD_RESET)
|
||||
WRITE(LCD_RESET_PIN, arg_val);
|
||||
#endif
|
||||
break;
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
#if U8G_SPI_USE_MODE_3 // This LCD SPI is running mode 3 while SD card is running mode 0
|
||||
if (arg_val) { // SCK idle state needs to be set to the proper idle state before
|
||||
// the next chip select goes active
|
||||
WRITE(DOGLCD_SCK, HIGH); // Set SCK to mode 3 idle state before CS goes active
|
||||
WRITE(DOGLCD_CS, LOW);
|
||||
nop; // Hold SCK high for a few ns
|
||||
nop;
|
||||
}
|
||||
else {
|
||||
WRITE(DOGLCD_CS, HIGH);
|
||||
WRITE(DOGLCD_SCK, LOW); // Set SCK to mode 0 idle state after CS goes inactive
|
||||
}
|
||||
#else
|
||||
WRITE(DOGLCD_CS, !arg_val);
|
||||
#endif
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_sw_spi_shift_out(arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ: {
|
||||
uint8_t* ptr = (uint8_t*)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
u8g_sw_spi_shift_out(*ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
} break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P: {
|
||||
uint8_t* ptr = (uint8_t*)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
u8g_sw_spi_shift_out(u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
} break;
|
||||
case U8G_COM_MSG_ADDRESS: // Define cmd (arg_val = 0) or data mode (arg_val = 1)
|
||||
WRITE(DOGLCD_A0, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB && FORCE_SOFT_SPI
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* PersistentStore for Arduino-style EEPROM interface
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#include "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
|
||||
#include "../shared/eeprom_if.h"
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#error "MARLIN_EEPROM_SIZE is required for IIC_BL24CXX_EEPROM."
|
||||
#endif
|
||||
|
||||
size_t PersistentStore::capacity() {
|
||||
return MARLIN_EEPROM_SIZE - eeprom_exclude_size;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
eeprom_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
uint16_t written = 0;
|
||||
while (size--) {
|
||||
uint8_t v = *value;
|
||||
uint8_t * const p = (uint8_t * const)REAL_EEPROM_ADDR(pos);
|
||||
// EPROM has only ~100,000 write cycles,
|
||||
// so only write bytes that have changed!
|
||||
if (v != eeprom_read_byte(p)) {
|
||||
eeprom_write_byte(p, v);
|
||||
if (++written & 0x7F) delay(4); else safe_delay(4);
|
||||
if (eeprom_read_byte(p) != v) {
|
||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
const uint8_t c = eeprom_read_byte((uint8_t*)REAL_EEPROM_ADDR(pos));
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
} while (--size);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Platform-independent Arduino functions for I2C EEPROM.
|
||||
* Enable USE_SHARED_EEPROM if not supplied by the framework.
|
||||
*/
|
||||
|
||||
#include "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
|
||||
#include "../../libs/BL24CXX.h"
|
||||
#include "../shared/eeprom_if.h"
|
||||
|
||||
void eeprom_init() {
|
||||
BL24CXX::init();
|
||||
}
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
return BL24CXX::writeOneByte(eeprom_address, value);
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
return BL24CXX::readOneByte(eeprom_address);
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if USE_WIRED_EEPROM
|
||||
|
||||
/**
|
||||
* PersistentStore for Arduino-style EEPROM interface
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#include "../shared/eeprom_if.h"
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
||||
#endif
|
||||
|
||||
size_t PersistentStore::capacity() {
|
||||
return MARLIN_EEPROM_SIZE - eeprom_exclude_size;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_start() {
|
||||
eeprom_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::access_finish() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
uint16_t written = 0;
|
||||
while (size--) {
|
||||
uint8_t v = *value;
|
||||
uint8_t * const p = (uint8_t * const)REAL_EEPROM_ADDR(pos);
|
||||
// EEPROM has only ~100,000 write cycles,
|
||||
// so only write bytes that have changed!
|
||||
if (v != eeprom_read_byte(p)) {
|
||||
eeprom_write_byte(p, v);
|
||||
// Avoid triggering watchdog during long EEPROM writes
|
||||
if (++written & 0x7F)
|
||||
delay(2);
|
||||
else
|
||||
safe_delay(2);
|
||||
if (eeprom_read_byte(p) != v) {
|
||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
const uint8_t c = eeprom_read_byte((uint8_t*)REAL_EEPROM_ADDR(pos));
|
||||
if (writing)
|
||||
*value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
} while (--size);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // USE_WIRED_EEPROM
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../../module/endstops.h"
|
||||
|
||||
// One ISR for all EXT-Interrupts
|
||||
void endstop_ISR() { endstops.update(); }
|
||||
|
||||
void setup_endstop_interrupts() {
|
||||
#define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
|
||||
TERN_(USE_X_MAX, _ATTACH(X_MAX_PIN));
|
||||
TERN_(USE_X_MIN, _ATTACH(X_MIN_PIN));
|
||||
TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN));
|
||||
TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN));
|
||||
TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN));
|
||||
TERN_(USE_Z_MIN, _ATTACH(Z_MIN_PIN));
|
||||
TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN));
|
||||
TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN));
|
||||
TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN));
|
||||
TERN_(USE_Y2_MIN, _ATTACH(Y2_MIN_PIN));
|
||||
TERN_(USE_Z2_MAX, _ATTACH(Z2_MAX_PIN));
|
||||
TERN_(USE_Z2_MIN, _ATTACH(Z2_MIN_PIN));
|
||||
TERN_(USE_Z3_MAX, _ATTACH(Z3_MAX_PIN));
|
||||
TERN_(USE_Z3_MIN, _ATTACH(Z3_MIN_PIN));
|
||||
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(USE_CALIBRATION, _ATTACH(CALIBRATION_PIN));
|
||||
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(USE_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(USE_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(USE_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(USE_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(USE_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(USE_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(USE_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(USE_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(USE_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <PinOpsMap.hpp>
|
||||
#include <PinOps.hpp>
|
||||
#include "timers.h"
|
||||
|
||||
static uint16_t timer_frequency[TIMER_COUNT];
|
||||
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t value, const uint16_t scale, const bool invert) {
|
||||
// Calculate duty cycle based on inversion flag
|
||||
const uint16_t duty = invert ? scale - value : value;
|
||||
|
||||
// Check if the pin supports PWM
|
||||
if (PWM_PIN(pin)) {
|
||||
// Get the timer peripheral base associated with the pin
|
||||
const auto timer_base = getPinOpsPeripheralBase<TIMERPinOps, timer::TIMER_Base>(TIMER_PinOps, static_cast<pin_size_t>(pin));
|
||||
|
||||
// Initialize the timer instance
|
||||
auto& TimerInstance = GeneralTimer::get_instance(timer_base);
|
||||
|
||||
// Get channel and previous channel mode
|
||||
const auto channel = getPackedPinChannel(getPackedPinOps(TIMER_PinOps, static_cast<pin_size_t>(pin)));
|
||||
const InputOutputMode previous = TimerInstance.getChannelMode(channel);
|
||||
|
||||
if (timer_frequency[static_cast<size_t>(timer_base)] == 0) {
|
||||
set_pwm_frequency(pin, PWM_FREQUENCY);
|
||||
}
|
||||
|
||||
// Set the PWM duty cycle
|
||||
TimerInstance.setCaptureCompare(channel, duty, CCFormat::B8);
|
||||
|
||||
// Configure pin as PWM output
|
||||
pinOpsPinout(TIMER_PinOps, static_cast<pin_size_t>(pin));
|
||||
|
||||
// Set channel mode if not already set and start timer
|
||||
if (previous != InputOutputMode::PWM0) {
|
||||
TimerInstance.setChannelMode(channel, InputOutputMode::PWM0, static_cast<pin_size_t>(pin));
|
||||
TimerInstance.start();
|
||||
}
|
||||
} else {
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, duty < scale / 2 ? LOW : HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
// Check if the pin supports PWM
|
||||
if (!PWM_PIN(pin)) return;
|
||||
|
||||
// Get the timer peripheral base associated with the pin
|
||||
const auto timer_base = getPinOpsPeripheralBase<TIMERPinOps, timer::TIMER_Base>(TIMER_PinOps, static_cast<pin_size_t>(pin));
|
||||
|
||||
// Guard against modifying protected timers
|
||||
#ifdef STEP_TIMER
|
||||
if (timer_base == static_cast<timer::TIMER_Base>(STEP_TIMER)) return;
|
||||
#endif
|
||||
#ifdef TEMP_TIMER
|
||||
if (timer_base == static_cast<timer::TIMER_Base>(TEMP_TIMER)) return;
|
||||
#endif
|
||||
#if defined(PULSE_TIMER) && MF_TIMER_PULSE != MF_TIMER_STEP
|
||||
if (timer_base == static_cast<timer::TIMER_Base>(PULSE_TIMER)) return;
|
||||
#endif
|
||||
|
||||
// Initialize the timer instance
|
||||
auto& TimerInstance = GeneralTimer::get_instance(timer_base);
|
||||
|
||||
TimerInstance.setRolloverValue(f_desired, TimerFormat::HERTZ);
|
||||
timer_frequency[timer_base_to_index(timer_base)] = f_desired;
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
// Fast I/O interfaces for GD32F303RE
|
||||
|
||||
#include <GPIO.hpp>
|
||||
#include <PinOps.hpp>
|
||||
#include <PinOpsMap.hpp>
|
||||
|
||||
static inline void fast_write_pin_wrapper(pin_size_t IO, bool V) {
|
||||
if (V) gpio::fast_set_pin(getPortFromPin(IO), getPinInPort(IO));
|
||||
else gpio::fast_clear_pin(getPortFromPin(IO), getPinInPort(IO));
|
||||
}
|
||||
|
||||
static inline bool fast_read_pin_wrapper(pin_size_t IO) {
|
||||
return gpio::fast_read_pin(getPortFromPin(IO), getPinInPort(IO));
|
||||
}
|
||||
|
||||
static inline void fast_toggle_pin_wrapper(pin_size_t IO) {
|
||||
gpio::fast_toggle_pin(getPortFromPin(IO), getPinInPort(IO));
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#ifndef PWM
|
||||
#define PWM OUTPUT
|
||||
#endif
|
||||
|
||||
#define _WRITE(IO, V) fast_write_pin_wrapper(IO, V)
|
||||
#define _READ(IO) fast_read_pin_wrapper(IO)
|
||||
#define _TOGGLE(IO) fast_toggle_pin_wrapper(IO)
|
||||
|
||||
#define _GET_MODE(IO)
|
||||
#define _SET_MODE(IO, M) pinMode((IO), (M))
|
||||
#define _SET_OUTPUT(IO) pinMode((IO), OUTPUT)
|
||||
#define _SET_OUTPUT_OD(IO) pinMode((IO), OUTPUT_OPEN_DRAIN)
|
||||
|
||||
#define WRITE(IO, V) _WRITE((IO), (V))
|
||||
#define READ(IO) _READ(IO)
|
||||
#define TOGGLE(IO) _TOGGLE(IO)
|
||||
|
||||
#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 SET_INPUT(IO) _SET_MODE((IO), INPUT)
|
||||
#define SET_INPUT_PULLUP(IO) _SET_MODE((IO), INPUT_PULLUP)
|
||||
#define SET_INPUT_PULLDOWN(IO) _SET_MODE((IO), INPUT_PULLDOWN)
|
||||
#define SET_OUTPUT(IO) OUT_WRITE((IO), LOW)
|
||||
#define SET_OUTPUT_OD(IO) OUT_WRITE_OD((IO), LOW)
|
||||
#define SET_PWM(IO) _SET_MODE((IO), PWM)
|
||||
|
||||
#define IS_INPUT(IO)
|
||||
#define IS_OUTPUT(IO)
|
||||
|
||||
#define PWM_PIN(P) isPinInPinOps(TIMER_PinOps, P)
|
||||
#define NO_COMPILE_TIME_PWM
|
||||
|
||||
// Wrappers for digitalRead and digitalWrite
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
#define extDigitalWrite(IO, V) digitalWrite((IO), (V))
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
#if ALL(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI)
|
||||
#define U8G_SW_SPI_MFL 1
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
#if ALL(HAS_MEDIA, USBD_USE_CDC_MSC)
|
||||
#define HAS_SD_HOST_DRIVE 1
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
// If no real or emulated EEPROM selected, fall back to SD emulation
|
||||
#if USE_FALLBACK_EEPROM
|
||||
#define SDCARD_EEPROM_EMULATION
|
||||
#elif ANY(I2C_EEPROM, SPI_EEPROM)
|
||||
#define USE_SHARED_EEPROM 1
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
// Test MFL GD32 specific configuration values for errors at compile-time.
|
||||
#if ENABLED(SDCARD_EEPROM_EMULATION) && !HAS_MEDIA
|
||||
#undef SDCARD_EEPROM_EMULATION // avoid additional error noise
|
||||
#if USE_FALLBACK_EEPROM
|
||||
#warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
|
||||
#endif
|
||||
#error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FLASH_EEPROM_LEVELING)
|
||||
#error "FLASH_EEPROM_LEVELING is not supported on GD32."
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on GD32."
|
||||
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
||||
#error "SERIAL_STATS_DROPPED_RX is not supported on GD32."
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_SOC && defined(ATEMP) && TEMP_SOC_PIN != ATEMP
|
||||
#error "TEMP_SENSOR_SOC requires 'TEMP_SOC_PIN ATEMP' on GD32"
|
||||
#endif
|
||||
|
||||
// Check for common serial pin conflicts
|
||||
#define _CHECK_SERIAL_PIN(N) (( \
|
||||
BTN_EN1 == N || BTN_EN2 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN0_PIN == N || \
|
||||
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N || \
|
||||
Y_STEP_PIN == N || Y_ENABLE_PIN == N || E0_ENABLE_PIN == N || POWER_LOSS_PIN == N \
|
||||
))
|
||||
|
||||
#define CHECK_SERIAL_PIN(T, N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN)
|
||||
|
||||
#if SERIAL_IN_USE(0)
|
||||
#if CHECK_SERIAL_PIN(TX, 0)
|
||||
#error "Serial Port 0 TX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#if CHECK_SERIAL_PIN(RX, 0)
|
||||
#error "Serial Port 0 RX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#endif
|
||||
#if SERIAL_IN_USE(1)
|
||||
#if CHECK_SERIAL_PIN(TX, 1)
|
||||
#error "Serial Port 1 TX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#if CHECK_SERIAL_PIN(RX, 1)
|
||||
#error "Serial Port 1 RX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#endif
|
||||
#if SERIAL_IN_USE(2)
|
||||
#if CHECK_SERIAL_PIN(TX, 2)
|
||||
#error "Serial Port 2 TX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#if CHECK_SERIAL_PIN(RX, 2)
|
||||
#error "Serial Port 2 RX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#endif
|
||||
#if SERIAL_IN_USE(3)
|
||||
#if CHECK_SERIAL_PIN(TX, 3)
|
||||
#error "Serial Port 3 TX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#if CHECK_SERIAL_PIN(RX, 3)
|
||||
#error "Serial Port 3 RX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#endif
|
||||
#if SERIAL_IN_USE(4)
|
||||
#if CHECK_SERIAL_PIN(TX, 4)
|
||||
#error "Serial Port 4 TX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#if CHECK_SERIAL_PIN(RX, 4)
|
||||
#error "Serial Port 4 RX IO pins conflict with another pin on the board."
|
||||
#endif
|
||||
#endif
|
||||
#undef CHECK_SERIAL_PIN
|
||||
#undef _CHECK_SERIAL_PIN
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
/**
|
||||
* Pins Debugging for GD32
|
||||
*
|
||||
* - NUMBER_PINS_TOTAL
|
||||
* - MULTI_NAME_PAD
|
||||
* - getPinByIndex(index)
|
||||
* - printPinNameByIndex(index)
|
||||
* - getPinIsDigitalByIndex(index)
|
||||
* - digitalPinToAnalogIndex(pin)
|
||||
* - getValidPinMode(pin)
|
||||
* - isValidPin(pin)
|
||||
* - isAnalogPin(pin)
|
||||
* - digitalRead_mod(pin)
|
||||
* - pwm_status(pin)
|
||||
* - printPinPWM(pin)
|
||||
* - printPinPort(pin)
|
||||
* - printPinNumber(pin)
|
||||
* - printPinAnalog(pin)
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include <Arduino.h>
|
||||
#include <PinOps.hpp>
|
||||
#include <Analog.h>
|
||||
|
||||
#ifndef TOTAL_PIN_COUNT
|
||||
#error "Expected TOTAL_PIN_COUNT not found."
|
||||
#endif
|
||||
|
||||
#define NUM_DIGITAL_PINS TOTAL_PIN_COUNT
|
||||
#define NUMBER_PINS_TOTAL TOTAL_PIN_COUNT
|
||||
|
||||
#define getPinByIndex(x) pin_t(pin_array[x].pin)
|
||||
#define isValidPin(P) WITHIN(P, 0, (NUM_DIGITAL_PINS - 1))
|
||||
#define digitalRead_mod(P) extDigitalRead(P)
|
||||
#define printPinNumber(P) do { sprintf_P(buffer, PSTR("%3hd "), pin_t(P)); SERIAL_ECHO(buffer); } while (0)
|
||||
#define printPinAnalog(P) do { sprintf_P(buffer, PSTR(" (A%2d) "), pin_t(getAdcChannelFromPin(P))); SERIAL_ECHO(buffer); } while (0)
|
||||
#define printPinNameByIndex(x) do { sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); } while (0)
|
||||
|
||||
#define MULTI_NAME_PAD 21 // Space needed to be pretty if not first name assigned to a pin
|
||||
|
||||
#ifndef M43_NEVER_TOUCH
|
||||
#define M43_NEVER_TOUCH(x) WITHIN(x, 9, 10) // SERIAL pins: PA9(TX) PA10(RX)
|
||||
#endif
|
||||
|
||||
bool isAnalogPin(const pin_t pin) {
|
||||
if (!isValidPin(pin)) return false;
|
||||
|
||||
if (getAdcChannel(pin) != adc::ADC_Channel::INVALID) {
|
||||
auto& instance = gpio::GPIO::get_instance(getPortFromPin(pin)).value();
|
||||
return instance.get_pin_mode(getPinInPort(pin)) == gpio::Pin_Mode::ANALOG && !M43_NEVER_TOUCH(pin);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getValidPinMode(const pin_t pin) {
|
||||
if (!isValidPin(pin)) return false;
|
||||
|
||||
auto& instance = gpio::GPIO::get_instance(getPortFromPin(pin)).value();
|
||||
gpio::Pin_Mode mode = instance.get_pin_mode(getPinInPort(pin));
|
||||
|
||||
return mode != gpio::Pin_Mode::ANALOG && mode != gpio::Pin_Mode::INPUT_FLOATING &&
|
||||
mode != gpio::Pin_Mode::INPUT_PULLUP && mode != gpio::Pin_Mode::INPUT_PULLDOWN;
|
||||
}
|
||||
|
||||
bool getPinIsDigitalByIndex(const int16_t index) {
|
||||
const pin_t pin = getPinByIndex(index);
|
||||
return (!isAnalogPin(pin));
|
||||
}
|
||||
|
||||
int8_t digitalPinToAnalogIndex(const pin_t pin) {
|
||||
if (!isValidPin(pin) || !isAnalogPin(pin)) return -1;
|
||||
return pin; // Analog and digital pin indexes are shared
|
||||
}
|
||||
|
||||
bool pwm_status(const pin_t pin) { return false; }
|
||||
void printPinPWM(const pin_t pin) { /* TODO */ }
|
||||
void printPinPort(const pin_t pin) { /* TODO */ }
|
||||
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(ONBOARD_SDIO)
|
||||
|
||||
#include <PinOpsMap.hpp>
|
||||
#include <PinOps.hpp>
|
||||
#include "SDCard.h"
|
||||
#include "sdio.h"
|
||||
|
||||
using namespace sdio;
|
||||
|
||||
#define TARGET_CLOCK 6000000U
|
||||
#define BLOCK_SIZE 512U
|
||||
#define CARD_TIMEOUT 500 // ms
|
||||
#define READ_RETRIES 3U
|
||||
|
||||
inline constexpr uint32_t TARGET_SDIO_CLOCK = TARGET_CLOCK;
|
||||
inline constexpr uint32_t SDIO_BLOCK_SIZE = BLOCK_SIZE;
|
||||
inline constexpr uint32_t SD_TIMEOUT = CARD_TIMEOUT;
|
||||
inline constexpr uint8_t SDIO_READ_RETRIES = READ_RETRIES;
|
||||
|
||||
Card_State cardState = Card_State::READY;
|
||||
|
||||
bool SDIO_SetBusWidth(Bus_Width width) {
|
||||
return (CardDMA_I.set_hardware_bus_width(width) == SDIO_Error_Type::OK);
|
||||
}
|
||||
|
||||
void mfl_sdio_init() {
|
||||
pinOpsPinout(SD_CMD_PinOps, static_cast<pin_size_t>(SDIO_CMD_PIN));
|
||||
pinOpsPinout(SD_CK_PinOps, static_cast<pin_size_t>(SDIO_CK_PIN));
|
||||
pinOpsPinout(SD_DATA0_PinOps, static_cast<pin_size_t>(SDIO_D0_PIN));
|
||||
pinOpsPinout(SD_DATA1_PinOps, static_cast<pin_size_t>(SDIO_D1_PIN));
|
||||
pinOpsPinout(SD_DATA2_PinOps, static_cast<pin_size_t>(SDIO_D2_PIN));
|
||||
pinOpsPinout(SD_DATA3_PinOps, static_cast<pin_size_t>(SDIO_D3_PIN));
|
||||
|
||||
NVIC_EnableIRQ(DMA1_Channel3_4_IRQn);
|
||||
NVIC_EnableIRQ(SDIO_IRQn);
|
||||
}
|
||||
|
||||
bool SDIO_Init() {
|
||||
SDIO_Error_Type result = SDIO_Error_Type::OK;
|
||||
uint8_t retryCount = SDIO_READ_RETRIES;
|
||||
|
||||
mfl_sdio_init();
|
||||
|
||||
uint8_t retries = retryCount;
|
||||
for (;;) {
|
||||
hal.watchdog_refresh();
|
||||
result = CardDMA_I.init();
|
||||
if (result == SDIO_Error_Type::OK) break;
|
||||
if (!--retries) return false;
|
||||
}
|
||||
|
||||
CardDMA_I.set_desired_clock(TARGET_SDIO_CLOCK, false, false);
|
||||
|
||||
retries = retryCount;
|
||||
for (;;) {
|
||||
hal.watchdog_refresh();
|
||||
if (SDIO_SetBusWidth(Bus_Width::WIDTH_4BIT)) break;
|
||||
if (!--retries) break;
|
||||
}
|
||||
|
||||
CardDMA_I.set_desired_clock(TARGET_SDIO_CLOCK, true, true);
|
||||
|
||||
// Fallback
|
||||
if (!retries) {
|
||||
mfl_sdio_init();
|
||||
retries = retryCount;
|
||||
for (;;) {
|
||||
hal.watchdog_refresh();
|
||||
result = CardDMA_I.init();
|
||||
if (result == SDIO_Error_Type::OK) break;
|
||||
if (!--retries) return false;
|
||||
}
|
||||
CardDMA_I.set_desired_clock(TARGET_SDIO_CLOCK, false, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t* src, uint8_t* dst) {
|
||||
hal.watchdog_refresh();
|
||||
SDIO_Error_Type result = SDIO_Error_Type::OK;
|
||||
|
||||
// Write
|
||||
if (src) {
|
||||
result = CardDMA_I.write(reinterpret_cast<uint8_t*>(const_cast<uint8_t*>(src)), block, 1);
|
||||
}
|
||||
// Read
|
||||
else {
|
||||
result = CardDMA_I.read(dst, block, 1);
|
||||
}
|
||||
|
||||
if (result != SDIO_Error_Type::OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
millis_t timeout = millis() + SD_TIMEOUT;
|
||||
while (CardDMA_I.get_state() != sdio::Operational_State::READY) {
|
||||
if (ELAPSED(millis(), timeout)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CardDMA_I.check_dma_complete();
|
||||
|
||||
timeout = millis() + SD_TIMEOUT;
|
||||
do {
|
||||
result = CardDMA_I.get_card_state(&cardState);
|
||||
if (ELAPSED(millis(), timeout)) {
|
||||
return false;
|
||||
}
|
||||
} while (result == SDIO_Error_Type::OK && cardState != sdio::Card_State::TRANSFER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDIO_ReadBlock(uint32_t block, uint8_t* dst) {
|
||||
// Check if the address is aligned to 4 bytes
|
||||
if (reinterpret_cast<uint32_t>(dst) & 0x03) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t retries = SDIO_READ_RETRIES;
|
||||
while (retries--) {
|
||||
if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDIO_WriteBlock(uint32_t block, const uint8_t* src) {
|
||||
// Check if the address is aligned to 4 bytes
|
||||
if (reinterpret_cast<uint32_t>(src) & 0x03) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t retries = SDIO_READ_RETRIES;
|
||||
while (retries--) {
|
||||
if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) {
|
||||
return true;
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDIO_IsReady() {
|
||||
return (CardDMA_I.get_state() == sdio::Operational_State::READY);
|
||||
}
|
||||
|
||||
uint32_t SDIO_GetCardSize() {
|
||||
return CardDMA_I.get_card_capacity();
|
||||
}
|
||||
|
||||
// DMA interrupt handler
|
||||
void DMA1_IRQHandler() {
|
||||
auto& dma_instance = CardDMA_I.get_dma_instance();
|
||||
bool is_receive = CardDMA_I.get_is_sdio_rx();
|
||||
|
||||
// Check for Transfer Complete Interrupt
|
||||
if (dma_instance.get_interrupt_flag(dma::Interrupt_Flags::INTR_FLAG_FTFIF)) {
|
||||
dma_instance.set_interrupt_enable(dma::Interrupt_Type::INTR_FTFIE, false);
|
||||
dma_instance.set_interrupt_enable(dma::Interrupt_Type::INTR_ERRIE, false);
|
||||
dma_instance.clear_interrupt_flag(dma::Interrupt_Flags::INTR_FLAG_FTFIF);
|
||||
if (is_receive) {
|
||||
CardDMA_I.set_sdio_dma_enable(false);
|
||||
CardDMA_I.clear_sdio_data_flags();
|
||||
CardDMA_I.set_state(sdio::Operational_State::READY);
|
||||
} else {
|
||||
CardDMA_I.set_data_end_interrupt();
|
||||
}
|
||||
// Signal that transfer is complete
|
||||
CardDMA_I.set_transfer_end(true);
|
||||
}
|
||||
|
||||
else if (dma_instance.get_interrupt_flag(dma::Interrupt_Flags::INTR_FLAG_ERRIF)) {
|
||||
dma_instance.set_interrupt_enable(dma::Interrupt_Type::INTR_HTFIE, false);
|
||||
dma_instance.set_interrupt_enable(dma::Interrupt_Type::INTR_ERRIE, false);
|
||||
dma_instance.set_interrupt_enable(dma::Interrupt_Type::INTR_FTFIE, false);
|
||||
// Clear all flags
|
||||
dma_instance.clear_interrupt_flag(dma::Interrupt_Flags::INTR_FLAG_GIF);
|
||||
// Signal that an error occurred
|
||||
CardDMA_I.set_transfer_error(SDIO_Error_Type::ERROR);
|
||||
CardDMA_I.set_state(sdio::Operational_State::READY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void SDIO_IRQHandler(void) {
|
||||
CardDMA_I.handle_interrupts();
|
||||
}
|
||||
|
||||
void DMA1_Channel3_4_IRQHandler(void) {
|
||||
DMA1_IRQHandler();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
#endif // ONBOARD_SDIO
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 <SDIO.hpp>
|
||||
#include <DMA.hpp>
|
||||
|
||||
#define SDIO_D0_PIN PC8
|
||||
#define SDIO_D1_PIN PC9
|
||||
#define SDIO_D2_PIN PC10
|
||||
#define SDIO_D3_PIN PC11
|
||||
#define SDIO_CK_PIN PC12
|
||||
#define SDIO_CMD_PIN PD2
|
||||
|
||||
void sdio_mfl_init();
|
||||
bool SDIO_SetBusWidth(sdio::Bus_Width width);
|
||||
void DMA1_IRQHandler(dma::DMA_Channel channel);
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
// Define SPI Pins: SCK, MISO, MOSI
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN PIN_SPI_SCK
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN PIN_SPI_MISO
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN PIN_SPI_MOSI
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
#define TS_TYPICAL_V 1.405
|
||||
#define TS_TYPICAL_TEMP 25
|
||||
#define TS_TYPICAL_SLOPE 4.5
|
||||
|
||||
// TODO: Implement voltage scaling (calibrated Vrefint) and ADC resolution scaling (when applicable)
|
||||
#define TEMP_SOC_SENSOR(RAW) ((TS_TYPICAL_V - (RAW) / float(OVERSAMPLENR) / float(HAL_ADC_RANGE) * (float(ADC_VREF_MV) / 1000)) / ((TS_TYPICAL_SLOPE) / 1000) + TS_TYPICAL_TEMP)
|
||||
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 "../platforms.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_MFL
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "timers.h"
|
||||
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// ------------------------
|
||||
|
||||
#define SWSERIAL_TIMER_IRQ_PRIORITY_DEFAULT 1 // Requires tight bit timing to communicate reliably with TMC drivers
|
||||
#define SERVO_TIMER_IRQ_PRIORITY_DEFAULT 1 // Requires tight PWM timing to control a BLTouch reliably
|
||||
#define STEP_TIMER_IRQ_PRIORITY_DEFAULT 2
|
||||
#define TEMP_TIMER_IRQ_PRIORITY_DEFAULT 14 // Low priority avoids interference with other hardware and timers
|
||||
|
||||
#ifndef TIMER_IRQ_PRIORITY
|
||||
#define TIMER_IRQ_PRIORITY 12
|
||||
#endif
|
||||
|
||||
#ifndef STEP_TIMER_IRQ_PRIORITY
|
||||
#define STEP_TIMER_IRQ_PRIORITY STEP_TIMER_IRQ_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef TEMP_TIMER_IRQ_PRIORITY
|
||||
#define TEMP_TIMER_IRQ_PRIORITY TEMP_TIMER_IRQ_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SW_SERIAL
|
||||
#include <SoftwareSerial.h>
|
||||
#ifndef SWSERIAL_TIMER_IRQ_PRIORITY
|
||||
#define SWSERIAL_TIMER_IRQ_PRIORITY SWSERIAL_TIMER_IRQ_PRIORITY_DEFAULT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_SERVOS
|
||||
#include "Servo.h"
|
||||
#ifndef SERVO_TIMER_IRQ_PRIORITY
|
||||
#define SERVO_TIMER_IRQ_PRIORITY SERVO_TIMER_IRQ_PRIORITY_DEFAULT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SPEAKER)
|
||||
// The MFL framework default timer priority is 12. The TEMP timer must have lower priority
|
||||
// than this due to the long running temperature ISR, and STEP timer should higher priority.
|
||||
#if !(TIMER_IRQ_PRIORITY > STEP_TIMER_IRQ_PRIORITY && TIMER_IRQ_PRIORITY < TEMP_TIMER_IRQ_PRIORITY)
|
||||
#error "Default timer interrupt priority is unspecified or set to a value which may degrade performance."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAL_TIMER_RATE
|
||||
#define HAL_TIMER_RATE GetStepperTimerClkFreq()
|
||||
#endif
|
||||
|
||||
#ifndef STEP_TIMER
|
||||
#define STEP_TIMER MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER
|
||||
#define TEMP_TIMER MF_TIMER_TEMP
|
||||
#endif
|
||||
|
||||
GeneralTimer& Step_Timer = GeneralTimer::get_instance(static_cast<timer::TIMER_Base>(STEP_TIMER));
|
||||
GeneralTimer& Temp_Timer = GeneralTimer::get_instance(static_cast<timer::TIMER_Base>(TEMP_TIMER));
|
||||
|
||||
bool is_step_timer_initialized = false;
|
||||
bool is_temp_timer_initialized = false;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
// Retrieves the clock frequency of the stepper timer
|
||||
uint32_t GetStepperTimerClkFreq() {
|
||||
return Step_Timer.getTimerClockFrequency();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts a hardware timer
|
||||
*
|
||||
* If the timer is not already initialized, this function will initialize it with the given frequency.
|
||||
* The timer is started immediately after initialization
|
||||
*
|
||||
* @param timer The timer base index to start
|
||||
* @param frequency The frequency at which the timer should run
|
||||
* @return None
|
||||
*/
|
||||
void HAL_timer_start(const uint8_t timer_number, const uint32_t frequency) {
|
||||
if (HAL_timer_initialized(timer_number) || (timer_number != MF_TIMER_STEP && timer_number != MF_TIMER_TEMP))
|
||||
return;
|
||||
|
||||
const bool is_step = (timer_number == MF_TIMER_STEP);
|
||||
const uint8_t priority = is_step ?
|
||||
static_cast<uint8_t>(STEP_TIMER_IRQ_PRIORITY) :
|
||||
static_cast<uint8_t>(TEMP_TIMER_IRQ_PRIORITY);
|
||||
|
||||
// Get the reference of the timer instance
|
||||
GeneralTimer& timer = is_step ? Step_Timer : Temp_Timer;
|
||||
|
||||
if (is_step) {
|
||||
timer.setPrescaler(STEPPER_TIMER_PRESCALE);
|
||||
timer.setRolloverValue(_MIN(static_cast<hal_timer_t>(HAL_TIMER_TYPE_MAX),
|
||||
(HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)),
|
||||
TimerFormat::TICK);
|
||||
is_step_timer_initialized = true;
|
||||
}
|
||||
else {
|
||||
timer.setRolloverValue(frequency, TimerFormat::HERTZ);
|
||||
is_temp_timer_initialized = true;
|
||||
}
|
||||
|
||||
timer.setAutoReloadEnable(false);
|
||||
timer.setInterruptPriority(priority, 0U);
|
||||
HAL_timer_enable_interrupt(timer_number);
|
||||
timer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enables the interrupt for the specified timer
|
||||
*
|
||||
* @param handle The timer handle for which to enable the interrupt
|
||||
* @return None
|
||||
*/
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_number) {
|
||||
if (!HAL_timer_initialized(timer_number)) return;
|
||||
|
||||
GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer;
|
||||
|
||||
if (timer_number == MF_TIMER_STEP && !timer.hasInterrupt())
|
||||
timer.attachInterrupt(Step_Handler);
|
||||
else if (timer_number == MF_TIMER_TEMP && !timer.hasInterrupt())
|
||||
timer.attachInterrupt(Temp_Handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables the interrupt for the specified timer
|
||||
*
|
||||
* @param handle The timer handle for which to disable the interrupt
|
||||
* @return None
|
||||
*/
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_number) {
|
||||
if (!HAL_timer_initialized(timer_number)) return;
|
||||
|
||||
GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer;
|
||||
if (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP)
|
||||
timer.detachInterrupt();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the interrupt is enabled for the specified timer
|
||||
*
|
||||
* @param handle The timer handle to check
|
||||
* @return True if the interrupt is enabled, false otherwise
|
||||
*/
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_number) {
|
||||
if (!HAL_timer_initialized(timer_number)) return false;
|
||||
|
||||
GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer;
|
||||
return (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP)
|
||||
? timer.hasInterrupt()
|
||||
: false;
|
||||
}
|
||||
|
||||
// Sets the interrupt priorities for timers used by TMC SW serial and servos.
|
||||
void SetTimerInterruptPriorities() {
|
||||
TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIORITY, 0));
|
||||
TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIORITY, 0));
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Detect timer conflicts
|
||||
// ------------------------
|
||||
|
||||
TERN_(SPEAKER, static constexpr timer::TIMER_Base timer_tone[] = {static_cast<timer::TIMER_Base>(TIMER_TONE)});
|
||||
TERN_(HAS_SERVOS, static constexpr timer::TIMER_Base timer_servo[] = {static_cast<timer::TIMER_Base>(TIMER_SERVO)});
|
||||
|
||||
enum TimerPurpose {
|
||||
PURPOSE_TONE,
|
||||
PURPOSE_SERVO,
|
||||
PURPOSE_STEP,
|
||||
PURPOSE_TEMP
|
||||
};
|
||||
|
||||
// List of timers to check for conflicts
|
||||
// Includes the timer purpose to ease debugging when evaluating at build-time
|
||||
// This cannot yet account for timers used for PWM output, such as for fans
|
||||
static constexpr struct { TimerPurpose p; int t; } timers_in_use[] = {
|
||||
#if ENABLED(SPEAKER)
|
||||
{ PURPOSE_TONE, timer_base_to_index(timer_tone[0]) }, // Set in variant.h
|
||||
#endif
|
||||
#if HAS_SERVOS
|
||||
{ PURPOSE_SERVO, timer_base_to_index(timer_servo[0]) }, // Set in variant.h
|
||||
#endif
|
||||
{ PURPOSE_STEP, MF_TIMER_STEP },
|
||||
{ PURPOSE_TEMP, MF_TIMER_TEMP },
|
||||
};
|
||||
|
||||
// Verifies if there are any timer conflicts in the timers_in_use array
|
||||
static constexpr bool verify_no_timer_conflicts() {
|
||||
for (uint8_t i = 0; i < COUNT(timers_in_use); i++)
|
||||
for (uint8_t j = i + 1; j < COUNT(timers_in_use); j++)
|
||||
if (timers_in_use[i].t == timers_in_use[j].t)
|
||||
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, VSCode can evaluate the array
|
||||
// when hovering over it, making it easy to identify the conflicting timers
|
||||
static_assert(verify_no_timer_conflicts(), "One or more timer conflict detected. Examine \"timers_in_use\" to help identify conflict.");
|
||||
|
||||
#endif // ARDUINO_ARCH_MFL
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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 <GeneralTimer.h>
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
// Timer configuration constants
|
||||
#define STEPPER_TIMER_RATE 2000000
|
||||
#define TEMP_TIMER_FREQUENCY 1000
|
||||
|
||||
// Timer instance definitions
|
||||
#define MF_TIMER_STEP 3
|
||||
#define MF_TIMER_TEMP 1
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
|
||||
#define hal_timer_t uint32_t
|
||||
#define HAL_TIMER_TYPE_MAX UINT16_MAX
|
||||
|
||||
extern uint32_t GetStepperTimerClkFreq();
|
||||
|
||||
// Timer prescaler calculations
|
||||
#define STEPPER_TIMER_PRESCALE (GetStepperTimerClkFreq() / STEPPER_TIMER_RATE) // Prescaler = 30
|
||||
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
||||
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Stepper timer ticks per µs
|
||||
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE
|
||||
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
|
||||
|
||||
// Timer interrupt priorities
|
||||
#define STEP_TIMER_IRQ_PRIORITY 2
|
||||
#define TEMP_TIMER_IRQ_PRIORITY 14
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
||||
|
||||
extern void Step_Handler();
|
||||
extern void Temp_Handler();
|
||||
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
#define HAL_STEP_TIMER_ISR() void Step_Handler()
|
||||
#endif
|
||||
#ifndef HAL_TEMP_TIMER_ISR
|
||||
#define HAL_TEMP_TIMER_ISR() void Temp_Handler()
|
||||
#endif
|
||||
|
||||
extern GeneralTimer& Step_Timer;
|
||||
extern GeneralTimer& Temp_Timer;
|
||||
|
||||
extern bool is_step_timer_initialized;
|
||||
extern bool is_temp_timer_initialized;
|
||||
|
||||
// Build-time mapping between timer base and index. Used in timers.cpp and fast_pwm.cpp
|
||||
static inline constexpr struct {timer::TIMER_Base base; uint8_t timer_number;} base_to_index[] = {
|
||||
{ timer::TIMER_Base::TIMER0_BASE, 0 },
|
||||
{ timer::TIMER_Base::TIMER1_BASE, 1 },
|
||||
{ timer::TIMER_Base::TIMER2_BASE, 2 },
|
||||
{ timer::TIMER_Base::TIMER3_BASE, 3 },
|
||||
{ timer::TIMER_Base::TIMER4_BASE, 4 },
|
||||
{ timer::TIMER_Base::TIMER5_BASE, 5 },
|
||||
{ timer::TIMER_Base::TIMER6_BASE, 6 },
|
||||
{ timer::TIMER_Base::TIMER7_BASE, 7 }
|
||||
};
|
||||
|
||||
// Converts a timer base to an integer timer index.
|
||||
constexpr int timer_base_to_index(timer::TIMER_Base base) {
|
||||
for (const auto& timer : base_to_index) {
|
||||
if (timer.base == base) {
|
||||
return static_cast<int>(timer.timer_number);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer, const uint32_t frequency);
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer);
|
||||
|
||||
// Configure timer priorities for peripherals such as Software Serial or Servos.
|
||||
// Exposed here to allow all timer priority information to reside in timers.cpp
|
||||
void SetTimerInterruptPriorities();
|
||||
|
||||
// FORCE_INLINE because these are used in performance-critical situations
|
||||
FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_number) {
|
||||
return (timer_number == MF_TIMER_STEP) ? is_step_timer_initialized :
|
||||
(timer_number == MF_TIMER_TEMP) ? is_temp_timer_initialized :
|
||||
false;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_number) {
|
||||
if (!HAL_timer_initialized(timer_number)) return 0U;
|
||||
|
||||
GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer;
|
||||
|
||||
return (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP)
|
||||
? timer.getCounter(TimerFormat::TICK)
|
||||
: 0U;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_number, const hal_timer_t value) {
|
||||
if (!HAL_timer_initialized(timer_number)) return;
|
||||
|
||||
const uint32_t new_value = static_cast<uint32_t>(value + 1U);
|
||||
GeneralTimer& timer = (timer_number == MF_TIMER_STEP) ? Step_Timer : Temp_Timer;
|
||||
|
||||
if (timer_number == MF_TIMER_STEP || timer_number == MF_TIMER_TEMP) {
|
||||
timer.setRolloverValue(new_value, TimerFormat::TICK);
|
||||
if (value < static_cast<hal_timer_t>(timer.getCounter(TimerFormat::TICK)))
|
||||
timer.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 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
|
||||
|
||||
// MFL LCD-specific defines
|
||||
uint8_t u8g_com_HAL_MFL_sw_spi_fn(u8g_t* u8g, uint8_t msg, uint8_t arg_val, void* arg_ptr); // u8g_com_mfl_swspi.cpp
|
||||
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_MFL_sw_spi_fn
|
||||
@@ -2,6 +2,9 @@
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2023 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
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2023 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
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2023 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
|
||||
|
||||
@@ -33,8 +33,8 @@ void sei() { } // Enable
|
||||
// Time functions
|
||||
void _delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
uint32_t millis() {
|
||||
return (uint32_t)Clock::millis();
|
||||
unsigned long millis() {
|
||||
return (unsigned long)Clock::millis();
|
||||
}
|
||||
|
||||
// This is required for some Arduino libraries we are using
|
||||
|
||||
@@ -76,9 +76,9 @@ extern "C" {
|
||||
extern "C" void delay(const int ms);
|
||||
void _delay_ms(const int ms);
|
||||
void delayMicroseconds(unsigned long);
|
||||
uint32_t millis();
|
||||
unsigned long millis();
|
||||
|
||||
//IO functions
|
||||
// IO functions
|
||||
void pinMode(const pin_t, const uint8_t);
|
||||
void digitalWrite(pin_t, uint8_t);
|
||||
bool digitalRead(pin_t);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "../include/i2c_util.h"
|
||||
#include "../../../core/millis_t.h"
|
||||
|
||||
extern int millis();
|
||||
uint32_t millis();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -107,7 +107,7 @@ uint8_t get_pin_mode(const pin_t Ard_num) {
|
||||
|
||||
uint dir = gpio_get_dir( Ard_num);
|
||||
|
||||
if(dir) return MODE_PIN_OUTPUT;
|
||||
if (dir) return MODE_PIN_OUTPUT;
|
||||
else return MODE_PIN_INPUT;
|
||||
|
||||
}
|
||||
|
||||
@@ -131,19 +131,19 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, hal_time
|
||||
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_0 ,compare , HAL_timer_alarm_pool_0_callback ,0 ,false );
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_0, compare, HAL_timer_alarm_pool_0_callback, 0, false);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_1 ,compare , HAL_timer_alarm_pool_1_callback ,0 ,false );
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_1, compare, HAL_timer_alarm_pool_1_callback, 0, false);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_2 ,compare , HAL_timer_alarm_pool_2_callback ,0 ,false );
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_2, compare, HAL_timer_alarm_pool_2_callback, 0, false);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_3 ,compare , HAL_timer_alarm_pool_3_callback ,0 ,false );
|
||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_3, compare, HAL_timer_alarm_pool_3_callback, 0, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,8 +239,8 @@ typedef struct {
|
||||
#define ADC_WORKMODE_SLOW_INTERL ((uint32_t)0x00080000)
|
||||
#define ADC_WORKMODE_ALTER_TRIG ((uint32_t)0x00090000)
|
||||
|
||||
#define ADC_EXT_TRIGCONV_T1_CC3 ((uint32_t)0x00040000) //!< For ADC1, ADC2 , ADC3 and ADC4
|
||||
#define ADC_EXT_TRIGCONV_NONE ((uint32_t)0x000E0000) //!< For ADC1, ADC2 , ADC3 and ADC4
|
||||
#define ADC_EXT_TRIGCONV_T1_CC3 ((uint32_t)0x00040000) //!< For ADC1, ADC2, ADC3, and ADC4
|
||||
#define ADC_EXT_TRIGCONV_NONE ((uint32_t)0x000E0000) //!< For ADC1, ADC2, ADC3, and ADC4
|
||||
|
||||
#define ADC_DAT_ALIGN_R ((uint32_t)0x00000000)
|
||||
#define ADC_DAT_ALIGN_L ((uint32_t)0x00000800)
|
||||
@@ -603,9 +603,9 @@ typedef struct {
|
||||
#define DMA_CHCFG7_PINC ((uint16_t)0x0040) //!< Peripheral increment mode
|
||||
#define DMA_CHCFG7_MINC ((uint16_t)0x0080) //!< Memory increment mode
|
||||
|
||||
#define DMA_CHCFG7_PSIZE , ((uint16_t)0x0300) //!< PSIZE[1:0] bits (Peripheral size)
|
||||
#define DMA_CHCFG7_PSIZE_0 ((uint16_t)0x0100) //!< Bit 0
|
||||
#define DMA_CHCFG7_PSIZE_1 ((uint16_t)0x0200) //!< Bit 1
|
||||
#define DMA_CHCFG7_PSIZE ((uint16_t)0x0300) //!< PSIZE[1:0] bits (Peripheral size)
|
||||
#define DMA_CHCFG7_PSIZE_0 ((uint16_t)0x0100) //!< Bit 0
|
||||
#define DMA_CHCFG7_PSIZE_1 ((uint16_t)0x0200) //!< Bit 1
|
||||
|
||||
#define DMA_CHCFG7_MSIZE ((uint16_t)0x0C00) //!< MSIZE[1:0] bits (Memory size)
|
||||
#define DMA_CHCFG7_MSIZE_0 ((uint16_t)0x0400) //!< Bit 0
|
||||
@@ -627,9 +627,9 @@ typedef struct {
|
||||
#define DMA_CHCFG8_PINC ((uint16_t)0x0040) //!< Peripheral increment mode
|
||||
#define DMA_CHCFG8_MINC ((uint16_t)0x0080) //!< Memory increment mode
|
||||
|
||||
#define DMA_CHCFG8_PSIZE , ((uint16_t)0x0300) //!< PSIZE[1:0] bits (Peripheral size)
|
||||
#define DMA_CHCFG8_PSIZE_0 ((uint16_t)0x0100) //!< Bit 0
|
||||
#define DMA_CHCFG8_PSIZE_1 ((uint16_t)0x0200) //!< Bit 1
|
||||
#define DMA_CHCFG8_PSIZE ((uint16_t)0x0300) //!< PSIZE[1:0] bits (Peripheral size)
|
||||
#define DMA_CHCFG8_PSIZE_0 ((uint16_t)0x0100) //!< Bit 0
|
||||
#define DMA_CHCFG8_PSIZE_1 ((uint16_t)0x0200) //!< Bit 1
|
||||
|
||||
#define DMA_CHCFG8_MSIZE ((uint16_t)0x0C00) //!< MSIZE[1:0] bits (Memory size)
|
||||
#define DMA_CHCFG8_MSIZE_0 ((uint16_t)0x0400) //!< Bit 0
|
||||
|
||||
@@ -145,7 +145,7 @@ bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t millis();
|
||||
unsigned long millis();
|
||||
|
||||
bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
|
||||
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
|
||||
@@ -219,7 +219,7 @@ bool SDIO_CmdAppSetBusWidth(uint32_t rsa, uint32_t argument) {
|
||||
|
||||
bool SDIO_CmdAppOperCommand(uint32_t sdType) {
|
||||
if (!SDIO_CmdAppCommand(0)) return false;
|
||||
SDIO_SendCommand(ACMD41_SD_APP_OP_COND , SDMMC_VOLTAGE_WINDOW_SD | sdType);
|
||||
SDIO_SendCommand(ACMD41_SD_APP_OP_COND, SDMMC_VOLTAGE_WINDOW_SD | sdType);
|
||||
return SDIO_GetCmdResp3();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,17 +53,17 @@
|
||||
|
||||
#define _SET_INPUT(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1); \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _SET_OUTPUT(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1)|PORT_PCR_SRE|PORT_PCR_DSE; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 1; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 1; \
|
||||
}while(0)
|
||||
|
||||
#define _SET_INPUT_PULLUP(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1) | PORT_PCR_PE | PORT_PCR_PS; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _IS_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
|
||||
@@ -53,17 +53,17 @@
|
||||
|
||||
#define _SET_INPUT(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1); \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _SET_OUTPUT(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1)|PORT_PCR_SRE|PORT_PCR_DSE; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 1; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 1; \
|
||||
}while(0)
|
||||
|
||||
#define _SET_INPUT_PULLUP(P) do{ \
|
||||
CORE_PIN ## P ## _CONFIG = PORT_PCR_MUX(1) | PORT_PCR_PE | PORT_PCR_PS; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
|
||||
GPIO_BITBAND(CORE_PIN ## P ## _DDRREG, CORE_PIN ## P ## _BIT) = 0; \
|
||||
}while(0)
|
||||
|
||||
#define _IS_INPUT(P) ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/LPC1768/NAME)
|
||||
#elif defined(ARDUINO_ARCH_HC32)
|
||||
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/HC32/NAME)
|
||||
#elif defined(ARDUINO_ARCH_MFL)
|
||||
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/GD32_MFL/NAME)
|
||||
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
|
||||
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/STM32F1/NAME)
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
#include "../LPC1768/Servo.h"
|
||||
#elif defined(ARDUINO_ARCH_HC32)
|
||||
#include "../HC32/Servo.h"
|
||||
#elif defined(ARDUINO_ARCH_MFL)
|
||||
#include "../GD32_MFL/Servo.h"
|
||||
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
|
||||
#include "../STM32F1/Servo.h"
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
|
||||
@@ -428,8 +428,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
|
||||
if (gcode.stepper_max_timed_out(ms)) {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOPGM(STR_KILL_PRE);
|
||||
SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
||||
SERIAL_ECHOLN(F(STR_KILL_PRE), F(STR_KILL_INACTIVE_TIME), parser.command_ptr);
|
||||
kill();
|
||||
}
|
||||
|
||||
@@ -497,8 +496,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
// ----------------------------------------------------------------
|
||||
if (killCount >= KILL_DELAY) {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOPGM(STR_KILL_PRE);
|
||||
SERIAL_ECHOLNPGM(STR_KILL_BUTTON);
|
||||
SERIAL_ECHOLN(F(STR_KILL_PRE), F(STR_KILL_BUTTON));
|
||||
kill();
|
||||
}
|
||||
#endif
|
||||
@@ -678,14 +676,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());
|
||||
|
||||
#if ANY(PSU_CONTROL, AUTO_POWER_CONTROL) && PIN_EXISTS(PS_ON_EDM)
|
||||
if ( ELAPSED(ms, powerManager.last_state_change_ms + PS_EDM_RESPONSE)
|
||||
if ( ELAPSED(ms, powerManager.last_state_change_ms, PS_EDM_RESPONSE)
|
||||
&& (READ(PS_ON_PIN) != READ(PS_ON_EDM_PIN) || TERN0(PSU_OFF_REDUNDANT, extDigitalRead(PS_ON1_PIN) != extDigitalRead(PS_ON1_EDM_PIN)))
|
||||
) kill(GET_TEXT_F(MSG_POWER_EDM_FAULT));
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
|
||||
if (thermalManager.degHotend(active_extruder) > (EXTRUDER_RUNOUT_MINTEMP)
|
||||
&& ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))
|
||||
&& ELAPSED(ms, gcode.previous_move_ms, SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))
|
||||
&& !planner.has_blocks_queued()
|
||||
) {
|
||||
const int8_t e_stepper = TERN(HAS_SWITCHING_EXTRUDER, active_extruder >> 1, active_extruder);
|
||||
@@ -736,7 +734,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // manage_inactivity()
|
||||
|
||||
#if ALL(EP_BABYSTEPPING, EMERGENCY_PARSER)
|
||||
#include "feature/babystep.h"
|
||||
@@ -890,7 +888,7 @@ void idle(const bool no_stepper_sleep/*=false*/) {
|
||||
TERN_(MARLIN_DEV_MODE, idle_depth--);
|
||||
|
||||
return;
|
||||
}
|
||||
} // idle()
|
||||
|
||||
/**
|
||||
* Kill all activity and lock the machine.
|
||||
@@ -983,7 +981,7 @@ void stop() {
|
||||
safe_delay(350); // allow enough time for messages to get out before stopping
|
||||
marlin_state = MarlinState::MF_STOPPED;
|
||||
}
|
||||
}
|
||||
} // stop()
|
||||
|
||||
inline void tmc_standby_setup() {
|
||||
#if PIN_EXISTS(X_STDBY)
|
||||
@@ -1052,7 +1050,7 @@ inline void tmc_standby_setup() {
|
||||
#if PIN_EXISTS(E7_STDBY)
|
||||
SET_INPUT_PULLDOWN(E7_STDBY_PIN);
|
||||
#endif
|
||||
}
|
||||
} // tmc_standby_setup()
|
||||
|
||||
/**
|
||||
* Marlin Firmware entry-point. Abandon Hope All Ye Who Enter Here.
|
||||
@@ -1702,7 +1700,7 @@ void setup() {
|
||||
SETUP_LOG("setup() completed.");
|
||||
|
||||
TERN_(MARLIN_TEST_BUILD, runStartupTests());
|
||||
}
|
||||
} // setup()
|
||||
|
||||
/**
|
||||
* The main Marlin program loop
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
#define BOARD_CHITU3D_V6 5036 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V9 5037 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE)
|
||||
#define BOARD_CREALITY_V4 5038 // Creality v4.x (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V422 5039 // Creality v4.2.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V422 5039 // Creality v4.2.2 (STM32F103RC / STM32F103RE) ... GD32 Variant Below!
|
||||
#define BOARD_CREALITY_V423 5040 // Creality v4.2.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V425 5041 // Creality v4.2.5 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 5042 // Creality v4.2.7 (STM32F103RC / STM32F103RE)
|
||||
@@ -549,15 +549,27 @@
|
||||
// HC32 ARM Cortex-M4
|
||||
//
|
||||
|
||||
#define BOARD_AQUILA_V101 7200 // Voxelab Aquila V1.0.0/V1.0.1/V1.0.2/V1.0.3 as found in the Voxelab Aquila X2 and C2
|
||||
#define BOARD_AQUILA_V101 7200 // Voxelab Aquila V1.0.0/1/2/3 (e.g., Aquila X2, C2). ... GD32 Variant Below!
|
||||
#define BOARD_CREALITY_ENDER2P_V24S4 7201 // Creality Ender 2 Pro v2.4.S4_170 (HC32f460kcta)
|
||||
|
||||
//
|
||||
// GD32 ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_AQUILA_V101_GD32_MFL 7300 // Voxelab Aquila V1.0.1 MFL (GD32F103RC) ... STM32/HC32 Variant Above!
|
||||
|
||||
//
|
||||
// GD32 ARM Cortex-M4
|
||||
//
|
||||
|
||||
#define BOARD_CREALITY_V422_GD32_MFL 7400 // Creality V4.2.2 MFL (GD32F303RE) ... STM32 Variant Above!
|
||||
|
||||
//
|
||||
// Raspberry Pi
|
||||
//
|
||||
|
||||
#define BOARD_RP2040 6200 // Generic RP2040 Test board
|
||||
#define BOARD_BTT_SKR_PICO 6201 // BigTreeTech SKR Pico 1.x
|
||||
#define BOARD_RP2040 6200 // Generic RP2040 Test board
|
||||
#define BOARD_BTT_SKR_PICO 6201 // BigTreeTech SKR Pico 1.x
|
||||
|
||||
//
|
||||
// Custom board
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
// Useful macro for stopping the CPU on an unexpected condition
|
||||
// This is used like SERIAL_ECHOPGM, that is: a key-value call of the local variables you want
|
||||
// to dump to the serial port before stopping the CPU.
|
||||
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
|
||||
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
|
||||
// \/ Don't use SERIAL_ECHOPGM with ONLY_FILENAME. It can't be a PGM string,
|
||||
#define BUG_ON(V...) do { SERIAL_ECHOLN(ONLY_FILENAME, __LINE__, F(": ")); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
|
||||
#elif ENABLED(MARLIN_DEV_MODE)
|
||||
// Don't stop the CPU here, but at least dump the bug on the serial port
|
||||
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
|
||||
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); } while(0)
|
||||
// \/ Don't use SERIAL_ECHOPGM with ONLY_FILENAME. It can't be a PGM string,
|
||||
#define BUG_ON(V...) do { SERIAL_ECHOLN(ONLY_FILENAME, __LINE__, F(": BUG!")); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); } while(0)
|
||||
#else
|
||||
// Release mode, let's ignore the bug
|
||||
#define BUG_ON(V...) NOOP
|
||||
|
||||
@@ -312,8 +312,9 @@
|
||||
#define STR_FILAMENT_RUNOUT_SENSOR "Filament runout sensor"
|
||||
#define STR_DRIVER_STEPPING_MODE "Driver stepping mode"
|
||||
#define STR_STEPPER_DRIVER_CURRENT "Stepper driver current"
|
||||
#define STR_HOMING_CURRENT "Homing Current (mA)"
|
||||
#define STR_HYBRID_THRESHOLD "Hybrid Threshold"
|
||||
#define STR_STALLGUARD_THRESHOLD "StallGuard threshold"
|
||||
#define STR_STALLGUARD_THRESHOLD "StallGuard Threshold"
|
||||
#define STR_HOME_OFFSET "Home offset"
|
||||
#define STR_SOFT_ENDSTOPS "Soft endstops"
|
||||
#define STR_MATERIAL_HEATUP "Material heatup parameters"
|
||||
|
||||
@@ -206,19 +206,23 @@
|
||||
#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION ? 'A' : 'B'
|
||||
#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION ? 'A' : '0'
|
||||
#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION ? 'A' : '1'
|
||||
#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION ? 'A' : '<nul>'
|
||||
#define _TERN(E,V...) __TERN(_CAT(T_,E),V) // Prepend 'T_' to get 'T_0' or 'T_1'
|
||||
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
|
||||
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
|
||||
#define IF_DISABLED(O,A) TERN(O,,A)
|
||||
|
||||
// "Ternary" that emits or omits the given content
|
||||
#define EMIT(V...) V
|
||||
#define OMIT(...)
|
||||
#define TERN_(O,A) _TERN(_ENA_1(O),OMIT,EMIT)(A) // OPTION ? 'A' : '<nul>'
|
||||
|
||||
// Macros to conditionally emit array items and function arguments
|
||||
#define _OPTITEM(A...) A,
|
||||
#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A))
|
||||
#define OPTITEM(O,A...) TERN_(O,DEFER(_OPTITEM)(A))
|
||||
#define _OPTARG(A...) , A
|
||||
#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A))
|
||||
#define OPTARG(O,A...) TERN_(O,DEFER(_OPTARG)(A))
|
||||
#define _OPTCODE(A) A;
|
||||
#define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A))
|
||||
#define OPTCODE(O,A) TERN_(O,DEFER(_OPTCODE)(A))
|
||||
|
||||
// Macros to avoid operations that aren't always optimized away (e.g., 'f + 0.0' and 'f * 1.0').
|
||||
// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
|
||||
@@ -654,11 +658,8 @@
|
||||
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
|
||||
#define _IF_ELSE(TF) _CAT(_IF_, TF)
|
||||
|
||||
#define _IF_1(V...) V _IF_1_ELSE
|
||||
#define _IF_0(...) _IF_0_ELSE
|
||||
|
||||
#define _IF_1_ELSE(...)
|
||||
#define _IF_0_ELSE(V...) V
|
||||
#define _IF_1(V...) V OMIT
|
||||
#define _IF_0(...) EMIT
|
||||
|
||||
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
|
||||
#define _END_OF_ARGUMENTS_() 0
|
||||
|
||||
@@ -30,5 +30,7 @@ typedef uint32_t millis_t;
|
||||
#define MS_TO_SEC(N) millis_t((N)/1000UL)
|
||||
#define MS_TO_SEC_PRECISE(N) (float(N)/1000.0f)
|
||||
|
||||
#define PENDING(NOW,SOON) ((int32_t)(NOW-(SOON))<0)
|
||||
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))
|
||||
constexpr bool _PENDING(const millis_t now, const millis_t when) { return int32_t(when - now) > 0; }
|
||||
constexpr bool _PENDING(const millis_t now, const millis_t start, const millis_t interval) { return (now - start) < interval; }
|
||||
#define PENDING(V...) _PENDING(V)
|
||||
#define ELAPSED(V...) !_PENDING(V)
|
||||
|
||||
@@ -220,7 +220,7 @@ struct SerialBase {
|
||||
// On non 2-complement CPU, there would be no possible representation for 2147483648.
|
||||
write('-');
|
||||
}
|
||||
printNumber_unsigned((uint_fixed_print_t)n , base);
|
||||
printNumber_unsigned((uint_fixed_print_t)n, base);
|
||||
}
|
||||
|
||||
// Print a decimal number
|
||||
|
||||
+46
-35
@@ -566,11 +566,11 @@ struct XYval {
|
||||
FI XYval<T>& operator= (const XYZEval<T> &rs) { set(XY_LIST(rs.x, rs.y)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
#define XY_OP(OP) { x TERN_(HAS_X_AXIS, OP rs.x), y TERN_(HAS_Y_AXIS, OP rs.y) }
|
||||
FI constexpr XYval<T> operator+ (const XYval<T> &rs) const { return { x + rs.x, y + rs.y }; }
|
||||
FI constexpr XYval<T> operator- (const XYval<T> &rs) const { return { x - rs.x, y - rs.y }; }
|
||||
FI constexpr XYval<T> operator* (const XYval<T> &rs) const { return { x * rs.x, y * rs.y }; }
|
||||
FI constexpr XYval<T> operator/ (const XYval<T> &rs) const { return { x / rs.x, y / rs.y }; }
|
||||
#define XY_OP(OP) { T(x TERN_(HAS_X_AXIS, OP rs.x)), T(y TERN_(HAS_Y_AXIS, OP rs.y)) }
|
||||
FI constexpr XYval<T> operator+ (const XYval<T> &rs) const { return { T(x + rs.x), T(y + rs.y) }; }
|
||||
FI constexpr XYval<T> operator- (const XYval<T> &rs) const { return { T(x - rs.x), T(y - rs.y) }; }
|
||||
FI constexpr XYval<T> operator* (const XYval<T> &rs) const { return { T(x * rs.x), T(y * rs.y) }; }
|
||||
FI constexpr XYval<T> operator/ (const XYval<T> &rs) const { return { T(x / rs.x), T(y / rs.y) }; }
|
||||
FI constexpr XYval<T> operator+ (const XYZval<T> &rs) const { return { XY_OP(+) }; }
|
||||
FI constexpr XYval<T> operator- (const XYZval<T> &rs) const { return { XY_OP(-) }; }
|
||||
FI constexpr XYval<T> operator* (const XYZval<T> &rs) const { return { XY_OP(*) }; }
|
||||
@@ -721,21 +721,21 @@ struct XYZval {
|
||||
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(NUM_AXIS_ELEM_LC(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI constexpr XYZval<T> operator+ (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(x + rs.x, y + rs.y, z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator- (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(x - rs.x, y - rs.y, z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator* (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(x * rs.x, y * rs.y, z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(x / rs.x, y / rs.y, z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator+ (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(x + rs.x, y + rs.y, z + rs.z, i + rs.i, j + rs.j, k + rs.k, u + rs.u, v + rs.v, w + rs.w ); }
|
||||
FI constexpr XYZval<T> operator- (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(x - rs.x, y - rs.y, z - rs.z, i - rs.i, j - rs.j, k - rs.k, u - rs.u, v - rs.v, w - rs.w ); }
|
||||
FI constexpr XYZval<T> operator* (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(x * rs.x, y * rs.y, z * rs.z, i * rs.i, j * rs.j, k * rs.k, u * rs.u, v * rs.v, w * rs.w ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(x / rs.x, y / rs.y, z / rs.z, i / rs.i, j / rs.j, k / rs.k, u / rs.u, v / rs.v, w / rs.w ); }
|
||||
FI constexpr XYZval<T> operator+ (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(x + rs.x, y + rs.y, z + rs.z, i + rs.i, j + rs.j, k + rs.k, u + rs.u, v + rs.v, w + rs.w ); }
|
||||
FI constexpr XYZval<T> operator- (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(x - rs.x, y - rs.y, z - rs.z, i - rs.i, j - rs.j, k - rs.k, u - rs.u, v - rs.v, w - rs.w ); }
|
||||
FI constexpr XYZval<T> operator* (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(x * rs.x, y * rs.y, z * rs.z, i * rs.i, j * rs.j, k * rs.k, u * rs.u, v * rs.v, w * rs.w ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(x / rs.x, y / rs.y, z / rs.z, i / rs.i, j / rs.j, k / rs.k, u / rs.u, v / rs.v, w / rs.w ); }
|
||||
FI constexpr XYZval<T> operator* (const float &p) const { return NUM_AXIS_ARRAY((T)(x * p), (T)(y * p), (T)(z * p), (T)(i * p), (T)(j * p), (T)(k * p), (T)(u * p), (T)(v * p), (T)(w * p)); }
|
||||
FI constexpr XYZval<T> operator+ (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(T(x + rs.x), T(y + rs.y), z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator- (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(T(x - rs.x), T(y - rs.y), z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator* (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(T(x * rs.x), T(y * rs.y), z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYval<T> &rs) const { return NUM_AXIS_ARRAY(T(x / rs.x), T(y / rs.y), z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZval<T> operator+ (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(T(x + rs.x), T(y + rs.y), T(z + rs.z), T(i + rs.i), T(j + rs.j), T(k + rs.k), T(u + rs.u), T(v + rs.v), T(w + rs.w) ); }
|
||||
FI constexpr XYZval<T> operator- (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(T(x - rs.x), T(y - rs.y), T(z - rs.z), T(i - rs.i), T(j - rs.j), T(k - rs.k), T(u - rs.u), T(v - rs.v), T(w - rs.w) ); }
|
||||
FI constexpr XYZval<T> operator* (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(T(x * rs.x), T(y * rs.y), T(z * rs.z), T(i * rs.i), T(j * rs.j), T(k * rs.k), T(u * rs.u), T(v * rs.v), T(w * rs.w) ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYZval<T> &rs) const { return NUM_AXIS_ARRAY(T(x / rs.x), T(y / rs.y), T(z / rs.z), T(i / rs.i), T(j / rs.j), T(k / rs.k), T(u / rs.u), T(v / rs.v), T(w / rs.w) ); }
|
||||
FI constexpr XYZval<T> operator+ (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(T(x + rs.x), T(y + rs.y), T(z + rs.z), T(i + rs.i), T(j + rs.j), T(k + rs.k), T(u + rs.u), T(v + rs.v), T(w + rs.w) ); }
|
||||
FI constexpr XYZval<T> operator- (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(T(x - rs.x), T(y - rs.y), T(z - rs.z), T(i - rs.i), T(j - rs.j), T(k - rs.k), T(u - rs.u), T(v - rs.v), T(w - rs.w) ); }
|
||||
FI constexpr XYZval<T> operator* (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(T(x * rs.x), T(y * rs.y), T(z * rs.z), T(i * rs.i), T(j * rs.j), T(k * rs.k), T(u * rs.u), T(v * rs.v), T(w * rs.w) ); }
|
||||
FI constexpr XYZval<T> operator/ (const XYZEval<T> &rs) const { return NUM_AXIS_ARRAY(T(x / rs.x), T(y / rs.y), T(z / rs.z), T(i / rs.i), T(j / rs.j), T(k / rs.k), T(u / rs.u), T(v / rs.v), T(w / rs.w) ); }
|
||||
FI constexpr XYZval<T> operator* (const float &p) const { return NUM_AXIS_ARRAY(T(x * p), T(y * p), T(z * p), T(i * p), T(j * p), T(k * p), T(u * p), T(v * p), T(w * p)); }
|
||||
FI constexpr XYZval<T> operator* (const int &p) const { return NUM_AXIS_ARRAY(x * p, y * p, z * p, i * p, j * p, k * p, u * p, v * p, w * p); }
|
||||
FI constexpr XYZval<T> operator/ (const float &p) const { return NUM_AXIS_ARRAY((T)(x / p), (T)(y / p), (T)(z / p), (T)(i / p), (T)(j / p), (T)(k / p), (T)(u / p), (T)(v / p), (T)(w / p)); }
|
||||
FI constexpr XYZval<T> operator/ (const float &p) const { return NUM_AXIS_ARRAY(T(x / p), T(y / p), T(z / p), T(i / p), T(j / p), T(k / p), T(u / p), T(v / p), T(w / p)); }
|
||||
FI constexpr XYZval<T> operator/ (const int &p) const { return NUM_AXIS_ARRAY(x / p, y / p, z / p, i / p, j / p, k / p, u / p, v / p, w / p); }
|
||||
FI constexpr XYZval<T> operator>>(const int &p) const { return NUM_AXIS_ARRAY(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); }
|
||||
FI constexpr XYZval<T> operator<<(const int &p) const { return NUM_AXIS_ARRAY(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); }
|
||||
@@ -870,21 +870,21 @@ struct XYZEval {
|
||||
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(NUM_AXIS_ELEM_LC(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI constexpr XYZEval<T> operator+ (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x + rs.x, y + rs.y, z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator- (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x - rs.x, y - rs.y, z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator* (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x * rs.x, y * rs.y, z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x / rs.x, y / rs.y, z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator+ (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x + rs.x, y + rs.y, z + rs.z, i + rs.i, j + rs.j, k + rs.k, u + rs.u, v + rs.v, w + rs.w); }
|
||||
FI constexpr XYZEval<T> operator- (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x - rs.x, y - rs.y, z - rs.z, i - rs.i, j - rs.j, k - rs.k, u - rs.u, v - rs.v, w - rs.w); }
|
||||
FI constexpr XYZEval<T> operator* (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x * rs.x, y * rs.y, z * rs.z, i * rs.i, j * rs.j, k * rs.k, u * rs.u, v * rs.v, w * rs.w); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, x / rs.x, y / rs.y, z / rs.z, i / rs.i, j / rs.j, k / rs.k, u / rs.u, v / rs.v, w / rs.w); }
|
||||
FI constexpr XYZEval<T> operator+ (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e + rs.e, x + rs.x, y + rs.y, z + rs.z, i + rs.i, j + rs.j, k + rs.k, u + rs.u, v + rs.v, w + rs.w); }
|
||||
FI constexpr XYZEval<T> operator- (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e - rs.e, x - rs.x, y - rs.y, z - rs.z, i - rs.i, j - rs.j, k - rs.k, u - rs.u, v - rs.v, w - rs.w); }
|
||||
FI constexpr XYZEval<T> operator* (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e * rs.e, x * rs.x, y * rs.y, z * rs.z, i * rs.i, j * rs.j, k * rs.k, u * rs.u, v * rs.v, w * rs.w); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e / rs.e, x / rs.x, y / rs.y, z / rs.z, i / rs.i, j / rs.j, k / rs.k, u / rs.u, v / rs.v, w / rs.w); }
|
||||
FI constexpr XYZEval<T> operator* (const float &p) const { return LOGICAL_AXIS_ARRAY((T)(e * p), (T)(x * p), (T)(y * p), (T)(z * p), (T)(i * p), (T)(j * p), (T)(k * p), (T)(u * p), (T)(v * p), (T)(w * p)); }
|
||||
FI constexpr XYZEval<T> operator+ (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x + rs.x), T(y + rs.y), z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator- (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x - rs.x), T(y - rs.y), z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator* (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x * rs.x), T(y * rs.y), z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x / rs.x), T(y / rs.y), z, i, j, k, u, v, w); }
|
||||
FI constexpr XYZEval<T> operator+ (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x + rs.x), T(y + rs.y), T(z + rs.z), T(i + rs.i), T(j + rs.j), T(k + rs.k), T(u + rs.u), T(v + rs.v), T(w + rs.w)); }
|
||||
FI constexpr XYZEval<T> operator- (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x - rs.x), T(y - rs.y), T(z - rs.z), T(i - rs.i), T(j - rs.j), T(k - rs.k), T(u - rs.u), T(v - rs.v), T(w - rs.w)); }
|
||||
FI constexpr XYZEval<T> operator* (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x * rs.x), T(y * rs.y), T(z * rs.z), T(i * rs.i), T(j * rs.j), T(k * rs.k), T(u * rs.u), T(v * rs.v), T(w * rs.w)); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(e, T(x / rs.x), T(y / rs.y), T(z / rs.z), T(i / rs.i), T(j / rs.j), T(k / rs.k), T(u / rs.u), T(v / rs.v), T(w / rs.w)); }
|
||||
FI constexpr XYZEval<T> operator+ (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(T(e + rs.e), T(x + rs.x), T(y + rs.y), T(z + rs.z), T(i + rs.i), T(j + rs.j), T(k + rs.k), T(u + rs.u), T(v + rs.v), T(w + rs.w)); }
|
||||
FI constexpr XYZEval<T> operator- (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(T(e - rs.e), T(x - rs.x), T(y - rs.y), T(z - rs.z), T(i - rs.i), T(j - rs.j), T(k - rs.k), T(u - rs.u), T(v - rs.v), T(w - rs.w)); }
|
||||
FI constexpr XYZEval<T> operator* (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(T(e * rs.e), T(x * rs.x), T(y * rs.y), T(z * rs.z), T(i * rs.i), T(j * rs.j), T(k * rs.k), T(u * rs.u), T(v * rs.v), T(w * rs.w)); }
|
||||
FI constexpr XYZEval<T> operator/ (const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(T(e / rs.e), T(x / rs.x), T(y / rs.y), T(z / rs.z), T(i / rs.i), T(j / rs.j), T(k / rs.k), T(u / rs.u), T(v / rs.v), T(w / rs.w)); }
|
||||
FI constexpr XYZEval<T> operator* (const float &p) const { return LOGICAL_AXIS_ARRAY(T(e * p), T(x * p), T(y * p), T(z * p), T(i * p), T(j * p), T(k * p), T(u * p), T(v * p), T(w * p)); }
|
||||
FI constexpr XYZEval<T> operator* (const int &p) const { return LOGICAL_AXIS_ARRAY(e * p, x * p, y * p, z * p, i * p, j * p, k * p, u * p, v * p, w * p); }
|
||||
FI constexpr XYZEval<T> operator/ (const float &p) const { return LOGICAL_AXIS_ARRAY((T)(e / p), (T)(x / p), (T)(y / p), (T)(z / p), (T)(i / p), (T)(j / p), (T)(k / p), (T)(u / p), (T)(v / p), (T)(w / p)); }
|
||||
FI constexpr XYZEval<T> operator/ (const float &p) const { return LOGICAL_AXIS_ARRAY(T(e / p), T(x / p), T(y / p), T(z / p), T(i / p), T(j / p), T(k / p), T(u / p), T(v / p), T(w / p)); }
|
||||
FI constexpr XYZEval<T> operator/ (const int &p) const { return LOGICAL_AXIS_ARRAY(e / p, x / p, y / p, z / p, i / p, j / p, k / p, u / p, v / p, w / p); }
|
||||
FI constexpr XYZEval<T> operator>>(const int &p) const { return LOGICAL_AXIS_ARRAY(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); }
|
||||
FI constexpr XYZEval<T> operator<<(const int &p) const { return LOGICAL_AXIS_ARRAY(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); }
|
||||
@@ -892,8 +892,8 @@ struct XYZEval {
|
||||
|
||||
// Absolute difference between two objects
|
||||
FI constexpr XYZEval<T> diff(const XYZEval<T> &rs) const { return LOGICAL_AXIS_ARRAY(T(_ABS(e - rs.e)), T(_ABS(x - rs.x)), T(_ABS(y - rs.y)), T(_ABS(z - rs.z)), T(_ABS(i - rs.i)), T(_ABS(j - rs.j)), T(_ABS(k - rs.k)), T(_ABS(u - rs.u)), T(_ABS(v - rs.v)), T(_ABS(w - rs.w)) ); }
|
||||
FI constexpr XYZEval<T> diff(const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(0 , T(_ABS(x - rs.x)), T(_ABS(y - rs.y)), T(_ABS(z - rs.z)), T(_ABS(i - rs.i)), T(_ABS(j - rs.j)), T(_ABS(k - rs.k)), T(_ABS(u - rs.u)), T(_ABS(v - rs.v)), T(_ABS(w - rs.w)) ); }
|
||||
FI constexpr XYZEval<T> diff(const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(0 , T(_ABS(x - rs.x)), T(_ABS(y - rs.y)), z, i, j, k, u, v, w ); }
|
||||
FI constexpr XYZEval<T> diff(const XYZval<T> &rs) const { return LOGICAL_AXIS_ARRAY(0, T(_ABS(x - rs.x)), T(_ABS(y - rs.y)), T(_ABS(z - rs.z)), T(_ABS(i - rs.i)), T(_ABS(j - rs.j)), T(_ABS(k - rs.k)), T(_ABS(u - rs.u)), T(_ABS(v - rs.v)), T(_ABS(w - rs.w)) ); }
|
||||
FI constexpr XYZEval<T> diff(const XYval<T> &rs) const { return LOGICAL_AXIS_ARRAY(0, T(_ABS(x - rs.x)), T(_ABS(y - rs.y)), z, i, j, k, u, v, w ); }
|
||||
|
||||
// Modifier operators
|
||||
FI XYZEval<T>& operator+=(const XYval<T> &rs) { XY_CODE(x += rs.x, y += rs.y); return *this; }
|
||||
@@ -1231,3 +1231,14 @@ public:
|
||||
#undef _LSE
|
||||
#undef _RSE
|
||||
#undef FI
|
||||
|
||||
// Axis names for G-code parsing, reports, etc.
|
||||
constexpr xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
|
||||
#if NUM_AXES <= XYZ && !HAS_EXTRUDERS
|
||||
#define AXIS_CHAR(A) ((char)('X' + A))
|
||||
#define IAXIS_CHAR AXIS_CHAR
|
||||
#else
|
||||
constexpr xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K', 'U', 'V', 'W');
|
||||
#define AXIS_CHAR(A) axis_codes[A]
|
||||
#define IAXIS_CHAR(A) iaxis_codes[A]
|
||||
#endif
|
||||
|
||||
@@ -154,10 +154,8 @@ void safe_delay(millis_t ms) {
|
||||
const float rz = bedlevel.get_z_correction(current_position);
|
||||
SERIAL_ECHO(ftostr43sign(rz, '+'));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (planner.z_fade_height) {
|
||||
SERIAL_ECHOPGM(" (", ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position.z), '+'));
|
||||
SERIAL_CHAR(')');
|
||||
}
|
||||
if (planner.z_fade_height)
|
||||
SERIAL_ECHO(F(" ("), ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position.z), '+'), C(')'));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -176,10 +174,7 @@ void safe_delay(millis_t ms) {
|
||||
SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(z_offset + z_correction, '+'));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (planner.z_fade_height) {
|
||||
SERIAL_ECHOPGM(" (", ftostr43sign(
|
||||
z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+'
|
||||
));
|
||||
SERIAL_CHAR(')');
|
||||
SERIAL_ECHO(F(" ("), ftostr43sign(z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+'), C(')'));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -82,17 +82,6 @@ public:
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
|
||||
// Axis names for G-code parsing, reports, etc.
|
||||
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
|
||||
#if NUM_AXES <= XYZ && !HAS_EXTRUDERS
|
||||
#define AXIS_CHAR(A) ((char)('X' + A))
|
||||
#define IAXIS_CHAR AXIS_CHAR
|
||||
#else
|
||||
const xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K', 'U', 'V', 'W');
|
||||
#define AXIS_CHAR(A) axis_codes[A]
|
||||
#define IAXIS_CHAR(A) iaxis_codes[A]
|
||||
#endif
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
enum MarlinError : uint8_t {
|
||||
ERR_NONE,
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
static void move_z_with_encoder(const_float_t multiplier);
|
||||
static float measure_point_with_encoder();
|
||||
static float measure_business_card_thickness();
|
||||
static void manually_probe_remaining_mesh(const xy_pos_t&, const_float_t , const_float_t , const bool) __O0;
|
||||
static void manually_probe_remaining_mesh(const xy_pos_t&, const_float_t, const_float_t, const bool) __O0;
|
||||
static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) __O0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// BLTouch commands are sent as servo angles
|
||||
typedef unsigned char BLTCommand;
|
||||
|
||||
#define DEPLOY_ALARM true
|
||||
#define STOW_ALARM true
|
||||
#define BLTOUCH_DEPLOY 10
|
||||
#define BLTOUCH_STOW 90
|
||||
@@ -104,7 +105,7 @@ public:
|
||||
static bool triggered();
|
||||
|
||||
private:
|
||||
static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); }
|
||||
static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY) == DEPLOY_ALARM; }
|
||||
static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY) == STOW_ALARM; }
|
||||
|
||||
static void clear();
|
||||
|
||||
@@ -72,7 +72,7 @@ void CancelObject::report() {
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM("Canceled:");
|
||||
for (int i = 0; i < state.object_count; i++)
|
||||
if (TEST(state.canceled, i)) { SERIAL_CHAR(' '); SERIAL_ECHO(i); }
|
||||
if (TEST(state.canceled, i)) SERIAL_ECHO(C(' '), i);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ void ControllerFan::update() {
|
||||
* - If System is on idle and idle fan speed settings is activated.
|
||||
*/
|
||||
set_fan_speed(
|
||||
settings.auto_mode && lastComponentOn && PENDING(ms, lastComponentOn + SEC_TO_MS(settings.duration))
|
||||
settings.auto_mode && lastComponentOn && PENDING(ms, lastComponentOn, SEC_TO_MS(settings.duration))
|
||||
? settings.active_speed : settings.idle_speed
|
||||
);
|
||||
|
||||
|
||||
@@ -87,13 +87,7 @@ void DigipotI2C::init() {
|
||||
Wire.begin();
|
||||
#endif
|
||||
// Set up initial currents as defined in Configuration_adv.h
|
||||
static const float digipot_motor_current[] PROGMEM =
|
||||
#if ENABLED(DIGIPOT_USE_RAW_VALUES)
|
||||
DIGIPOT_MOTOR_CURRENT
|
||||
#else
|
||||
DIGIPOT_I2C_MOTOR_CURRENTS
|
||||
#endif
|
||||
;
|
||||
static const float digipot_motor_current[] PROGMEM = TERN(DIGIPOT_USE_RAW_VALUES, DIGIPOT_MOTOR_CURRENT, DIGIPOT_I2C_MOTOR_CURRENTS);
|
||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); ++i)
|
||||
set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ void EasythreedUI::blinkLED() {
|
||||
prev_blink_interval_ms = blink_interval_ms;
|
||||
blink_start_ms = ms;
|
||||
}
|
||||
if (PENDING(ms, blink_start_ms + blink_interval_ms))
|
||||
if (PENDING(ms, blink_start_ms, blink_interval_ms))
|
||||
WRITE(EASYTHREED_LED_PIN, LOW);
|
||||
else if (PENDING(ms, blink_start_ms + 2 * blink_interval_ms))
|
||||
else if (PENDING(ms, blink_start_ms, 2 * blink_interval_ms))
|
||||
WRITE(EASYTHREED_LED_PIN, HIGH);
|
||||
else
|
||||
blink_start_ms = ms;
|
||||
@@ -107,7 +107,7 @@ void EasythreedUI::loadButton() {
|
||||
break;
|
||||
|
||||
case FS_PRESS:
|
||||
if (ELAPSED(millis(), filament_time + BTN_DEBOUNCE_MS)) { // After a short debounce delay...
|
||||
if (ELAPSED(millis(), filament_time, BTN_DEBOUNCE_MS)) { // After a short debounce delay...
|
||||
if (!READ(BTN_RETRACT) || !READ(BTN_FEED)) { // ...if switch still toggled...
|
||||
thermalManager.setTargetHotend(EXTRUDE_MINTEMP + 10, 0); // Start heating up
|
||||
blink_interval_ms = LED_BLINK_7; // Set the LED to blink fast
|
||||
@@ -175,14 +175,14 @@ void EasythreedUI::printButton() {
|
||||
break;
|
||||
|
||||
case KS_PRESS:
|
||||
if (ELAPSED(ms, key_time + BTN_DEBOUNCE_MS)) // Wait for debounce interval to expire
|
||||
if (ELAPSED(ms, key_time, BTN_DEBOUNCE_MS)) // Wait for debounce interval to expire
|
||||
key_status = READ(BTN_PRINT) ? KS_IDLE : KS_PROCEED; // Proceed if still pressed
|
||||
break;
|
||||
|
||||
case KS_PROCEED:
|
||||
if (!READ(BTN_PRINT)) break; // Wait for the button to be released
|
||||
key_status = KS_IDLE; // Ready for the next press
|
||||
if (PENDING(ms, key_time + 1200 - BTN_DEBOUNCE_MS)) { // Register a press < 1.2 seconds
|
||||
if (PENDING(ms, key_time, 1200 - BTN_DEBOUNCE_MS)) { // Register a press < 1.2 seconds
|
||||
switch (print_key_flag) {
|
||||
case PF_START: { // The "Print" button starts an SD card print
|
||||
if (printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?')
|
||||
|
||||
@@ -168,8 +168,7 @@ void I2CPositionEncoder::update() {
|
||||
float sumP = 0;
|
||||
for (uint8_t i = 0; i < I2CPE_ERR_PRST_ARRAY_SIZE; ++i) sumP += errPrst[i];
|
||||
const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
|
||||
SERIAL_ECHOLN(C(AXIS_CHAR(encoderAxis)), F(" : CORRECT ERR "), errorP * planner.mm_per_step[encoderAxis], F("mm"));
|
||||
babystep.add_steps(encoderAxis, -LROUND(errorP));
|
||||
errPrstIdx = 0;
|
||||
}
|
||||
@@ -188,8 +187,7 @@ void I2CPositionEncoder::update() {
|
||||
if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, nextErrorCountTime)) {
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" : LARGE ERR ", error, "; diffSum=", diffSum);
|
||||
SERIAL_ECHOLN(C(AXIS_CHAR(encoderAxis)), F(" : LARGE ERR "), error, F("; diffSum="), diffSum);
|
||||
errorCount++;
|
||||
nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS;
|
||||
}
|
||||
@@ -208,8 +206,7 @@ void I2CPositionEncoder::set_homed() {
|
||||
homed = trusted = true;
|
||||
|
||||
#ifdef I2CPE_DEBUG
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" axis encoder homed, offset of ", zeroOffset, " ticks.");
|
||||
SERIAL_ECHO(C(AXIS_CHAR(encoderAxis)), F(" axis encoder homed, offset of "), zeroOffset, F(" ticks.\n"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -219,8 +216,7 @@ void I2CPositionEncoder::set_unhomed() {
|
||||
homed = trusted = false;
|
||||
|
||||
#ifdef I2CPE_DEBUG
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" axis encoder unhomed.");
|
||||
SERIAL_ECHO(C(AXIS_CHAR(encoderAxis)), F(" axis encoder unhomed.\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -247,10 +243,8 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
|
||||
diff = actual - target,
|
||||
error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading
|
||||
|
||||
if (report) {
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm");
|
||||
}
|
||||
if (report)
|
||||
SERIAL_ECHO(C(AXIS_CHAR(encoderAxis)), F(" axis target="), target, F("mm; actual="), actual, F("mm; err="), error, F("mm\n"));
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -282,10 +276,8 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
|
||||
|
||||
errorPrev = error;
|
||||
|
||||
if (report) {
|
||||
SERIAL_CHAR(AXIS_CHAR(encoderAxis));
|
||||
SERIAL_ECHOLNPGM(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error);
|
||||
}
|
||||
if (report)
|
||||
SERIAL_ECHOLN(C(AXIS_CHAR(encoderAxis)), F(" axis target="), target, F("; actual="), encoderCountInStepperTicksScaled, F("; err="), error);
|
||||
|
||||
if (suppressOutput) {
|
||||
if (report) SERIAL_ECHOLNPGM("!Discontinuity. Suppressing error.");
|
||||
@@ -647,23 +639,22 @@ void I2CPositionEncodersMgr::init() {
|
||||
void I2CPositionEncodersMgr::report_position(const int8_t idx, const bool units, const bool noOffset) {
|
||||
CHECK_IDX();
|
||||
|
||||
if (units)
|
||||
if (units) {
|
||||
SERIAL_ECHOLN(noOffset ? encoders[idx].mm_from_count(encoders[idx].get_raw_count()) : encoders[idx].get_position_mm());
|
||||
else {
|
||||
if (noOffset) {
|
||||
const int32_t raw_count = encoders[idx].get_raw_count();
|
||||
SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()], ' ');
|
||||
|
||||
for (uint8_t j = 31; j > 0; j--)
|
||||
SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j)));
|
||||
|
||||
SERIAL_ECHO((bool)(0x00000001 & raw_count));
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOLN(raw_count);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLN(encoders[idx].get_position());
|
||||
return;
|
||||
}
|
||||
|
||||
if (noOffset) {
|
||||
const int32_t raw_count = encoders[idx].get_raw_count();
|
||||
SERIAL_CHAR(AXIS_CHAR(encoders[idx].get_axis()), ' ');
|
||||
|
||||
for (uint8_t j = 31; j >= 0; j--)
|
||||
SERIAL_ECHO(TEST32(raw_count, j));
|
||||
|
||||
SERIAL_ECHOLN(C(' '), raw_count);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLN(encoders[idx].get_position());
|
||||
}
|
||||
|
||||
void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const uint8_t newaddr) {
|
||||
@@ -707,7 +698,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
|
||||
// and enable it (it will likely have failed initialization on power-up, before the address change).
|
||||
const int8_t idx = idx_from_addr(newaddr);
|
||||
if (idx >= 0 && !encoders[idx].get_active()) {
|
||||
SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()]);
|
||||
SERIAL_CHAR(AXIS_CHAR(encoders[idx].get_axis()));
|
||||
SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again.");
|
||||
encoders[idx].set_active(encoders[idx].passes_test(true));
|
||||
}
|
||||
|
||||
@@ -172,4 +172,46 @@ void MarlinEthernet::check() {
|
||||
}
|
||||
}
|
||||
|
||||
void say_ethernet() { SERIAL_ECHOPGM(" Ethernet "); }
|
||||
|
||||
void MarlinEthernet::ETH0_report(const bool forReplay/*=true*/) {
|
||||
say_ethernet();
|
||||
SERIAL_ECHO_TERNARY(ethernet.hardware_enabled, "port ", "en", "dis", "abled.\n");
|
||||
if (ethernet.hardware_enabled) {
|
||||
say_ethernet();
|
||||
SERIAL_ECHO_TERNARY(ethernet.have_telnet_client, "client ", "en", "dis", "abled.\n");
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM("Send 'M552 S1' to enable.");
|
||||
}
|
||||
|
||||
void MarlinEthernet::MAC_report(const bool forReplay/*=true*/) {
|
||||
if (!forReplay) SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM("MAC: ");
|
||||
if (ethernet.hardware_enabled) {
|
||||
uint8_t mac[6];
|
||||
Ethernet.MACAddress(mac);
|
||||
for (uint8_t i = 0; i < 6; ++i) {
|
||||
if (mac[i] < 0x10) SERIAL_CHAR('0');
|
||||
SERIAL_PRINT(mac[i], PrintBase::Hex);
|
||||
if (i < 5) SERIAL_CHAR(':');
|
||||
}
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOPGM("Disabled");
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
// Display current values when the link is active,
|
||||
// otherwise show the stored values
|
||||
void MarlinEthernet::ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo, const bool forReplay/*=true*/) {
|
||||
if (!forReplay) SERIAL_ECHO_START();
|
||||
SERIAL_ECHO(F(" M"), cmd, C(' '));
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
SERIAL_ECHO(ipo[i]);
|
||||
if (i < 3) SERIAL_CHAR('.');
|
||||
}
|
||||
SERIAL_ECHOLN(F(" ; "), post);
|
||||
}
|
||||
|
||||
#endif // HAS_ETHERNET
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <NativeEthernet.h>
|
||||
#endif
|
||||
|
||||
#include "../HAL/shared/Marduino.h"
|
||||
|
||||
// Teensy 4.1 uses internal MAC Address
|
||||
|
||||
class MarlinEthernet {
|
||||
@@ -34,6 +36,10 @@ class MarlinEthernet {
|
||||
static EthernetClient telnetClient;
|
||||
static void init();
|
||||
static void check();
|
||||
|
||||
static void ETH0_report(const bool forReplay=true);
|
||||
static void MAC_report(const bool forReplay=true);
|
||||
static void ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo, const bool forReplay=true);
|
||||
};
|
||||
|
||||
extern MarlinEthernet ethernet;
|
||||
|
||||
@@ -480,32 +480,30 @@ void Max7219::register_setup() {
|
||||
#if MAX7219_INIT_TEST
|
||||
|
||||
uint8_t test_mode = 0;
|
||||
millis_t next_patt_ms;
|
||||
bool patt_on;
|
||||
|
||||
#if MAX7219_INIT_TEST == 2
|
||||
|
||||
#define MAX7219_LEDS (MAX7219_X_LEDS * MAX7219_Y_LEDS)
|
||||
|
||||
constexpr millis_t pattern_delay = 4;
|
||||
|
||||
int8_t spiralx, spiraly, spiral_dir;
|
||||
xy_int8_t spiral;
|
||||
int8_t spiral_dir;
|
||||
uvalue_t(MAX7219_LEDS) spiral_count;
|
||||
|
||||
void Max7219::test_pattern() {
|
||||
constexpr int8_t way[][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
|
||||
led_set(spiralx, spiraly, patt_on);
|
||||
const int8_t x = spiralx + way[spiral_dir][0], y = spiraly + way[spiral_dir][1];
|
||||
if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == patt_on)
|
||||
void Max7219::run_test_pattern() {
|
||||
constexpr xy_int8_t way[] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
|
||||
led_set(spiral.x, spiral.y, patt_on);
|
||||
const xy_int8_t xy = spiral + way[spiral_dir];
|
||||
if (!WITHIN(xy.x, 0, MAX7219_X_LEDS - 1) || !WITHIN(xy.y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(xy.x, xy.y) == patt_on)
|
||||
spiral_dir = (spiral_dir + 1) & 0x3;
|
||||
spiralx += way[spiral_dir][0];
|
||||
spiraly += way[spiral_dir][1];
|
||||
spiral += way[spiral_dir];
|
||||
if (!spiral_count--) {
|
||||
if (!patt_on)
|
||||
test_mode = 0;
|
||||
else {
|
||||
spiral_count = MAX7219_LEDS;
|
||||
spiralx = spiraly = spiral_dir = 0;
|
||||
spiral.reset();
|
||||
spiral_dir = 0;
|
||||
patt_on = false;
|
||||
}
|
||||
}
|
||||
@@ -516,7 +514,11 @@ void Max7219::register_setup() {
|
||||
constexpr millis_t pattern_delay = 20;
|
||||
int8_t sweep_count, sweepx, sweep_dir;
|
||||
|
||||
void Max7219::test_pattern() {
|
||||
void Max7219::run_test_pattern() {
|
||||
static millis_t next_pattern_ms = 0;
|
||||
const millis_t ms = millis();
|
||||
if (PENDING(ms, next_pattern_ms)) return;
|
||||
next_pattern_ms = ms + pattern_delay;
|
||||
set_column(sweepx, patt_on ? 0xFFFFFFFF : 0x00000000);
|
||||
sweepx += sweep_dir;
|
||||
if (!WITHIN(sweepx, 0, MAX7219_X_LEDS - 1)) {
|
||||
@@ -527,26 +529,20 @@ void Max7219::register_setup() {
|
||||
else
|
||||
sweepx -= MAX7219_X_LEDS * sweep_dir;
|
||||
FLIP(patt_on);
|
||||
next_patt_ms += 100;
|
||||
next_pattern_ms += 100;
|
||||
if (++test_mode > 4) test_mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Max7219::run_test_pattern() {
|
||||
const millis_t ms = millis();
|
||||
if (PENDING(ms, next_patt_ms)) return;
|
||||
next_patt_ms = ms + pattern_delay;
|
||||
test_pattern();
|
||||
}
|
||||
|
||||
void Max7219::start_test_pattern() {
|
||||
clear();
|
||||
test_mode = 1;
|
||||
patt_on = true;
|
||||
#if MAX7219_INIT_TEST == 2
|
||||
spiralx = spiraly = spiral_dir = 0;
|
||||
spiral.reset();
|
||||
spiral_dir = 0;
|
||||
spiral_count = MAX7219_LEDS;
|
||||
#else
|
||||
sweep_dir = 1;
|
||||
@@ -761,7 +757,7 @@ void Max7219::idle_tasks() {
|
||||
|
||||
#ifdef MAX7219_DEBUG_MULTISTEPPING
|
||||
static uint8_t last_multistepping = 0;
|
||||
const uint8_t multistepping = Stepper::steps_per_isr;
|
||||
const uint8_t multistepping = stepper.steps_per_isr;
|
||||
if (multistepping != last_multistepping) {
|
||||
static uint8_t log2_old = 0;
|
||||
uint8_t log2_new = 0;
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
if (mode == ACCUMULATE_TOTAL) return;
|
||||
|
||||
// update time_fraction every hundred milliseconds
|
||||
if (instance_count == 0 && ELAPSED(now, last_calc_time + 100000)) {
|
||||
if (instance_count == 0 && now - last_calc_time > 100000) {
|
||||
time_fraction = total_time * 128 / (now - last_calc_time);
|
||||
last_calc_time = now;
|
||||
total_time = 0;
|
||||
|
||||
@@ -164,7 +164,7 @@ void MMU2::mmu_loop() {
|
||||
MMU2_SEND("S1"); // Read Version
|
||||
state = -2;
|
||||
}
|
||||
else if (ELAPSED(millis(), prev_request + 30000)) { // 30sec after reset disable MMU
|
||||
else if (ELAPSED(millis(), prev_request, 30000)) { // 30sec after reset disable MMU
|
||||
SERIAL_ECHOLNPGM("MMU not responding - DISABLED");
|
||||
state = 0;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ void MMU2::mmu_loop() {
|
||||
last_cmd = cmd;
|
||||
cmd = MMU_CMD_NONE;
|
||||
}
|
||||
else if (ELAPSED(millis(), prev_P0_request + 300)) {
|
||||
else if (ELAPSED(millis(), prev_P0_request, 300)) {
|
||||
MMU2_SEND("P0"); // Read FINDA
|
||||
state = 2; // wait for response
|
||||
}
|
||||
@@ -296,7 +296,7 @@ void MMU2::mmu_loop() {
|
||||
if (cmd == MMU_CMD_NONE) ready = true;
|
||||
state = 1;
|
||||
}
|
||||
else if (ELAPSED(millis(), prev_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s)
|
||||
else if (ELAPSED(millis(), prev_request, MMU_P0_TIMEOUT)) // Resend request after timeout (3s)
|
||||
state = 1;
|
||||
|
||||
TERN_(HAS_PRUSA_MMU2S, check_filament());
|
||||
@@ -335,7 +335,7 @@ void MMU2::mmu_loop() {
|
||||
last_cmd = MMU_CMD_NONE;
|
||||
}
|
||||
}
|
||||
else if (ELAPSED(millis(), prev_request + MMU_CMD_TIMEOUT)) {
|
||||
else if (ELAPSED(millis(), prev_request, MMU_CMD_TIMEOUT)) {
|
||||
// resend request after timeout
|
||||
if (last_cmd) {
|
||||
DEBUG_ECHOLNPGM("MMU retry");
|
||||
|
||||
@@ -196,16 +196,16 @@ namespace MMU3 {
|
||||
return FindErrorIndex(ERR_OTHER_UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
uint16_t PrusaErrorCode(const uint8_t i) { return (uint16_t)pgm_read_word(&errorCodes[i]); }
|
||||
uint16_t PrusaErrorCode(const uint8_t i) { return pgm_read_word(errorCodes + i); }
|
||||
|
||||
FSTR_P const PrusaErrorTitle(const uint8_t i) { return (FSTR_P const)pgm_read_ptr(&errorTitles[i]); }
|
||||
FSTR_P const PrusaErrorDesc(const uint8_t i) { return (FSTR_P const)pgm_read_ptr(&errorDescs[i]); }
|
||||
FSTR_P const PrusaErrorTitle(const uint8_t i) { return (FSTR_P const)pgm_read_ptr(errorTitles + i); }
|
||||
FSTR_P const PrusaErrorDesc(const uint8_t i) { return (FSTR_P const)pgm_read_ptr(errorDescs + i); }
|
||||
|
||||
uint8_t PrusaErrorButtons(const uint8_t i) { return pgm_read_byte(errorButtons + i); }
|
||||
|
||||
FSTR_P const PrusaErrorButtonTitle(const uint8_t bi) {
|
||||
// -1 represents the hidden NoOperation button which is not drawn in any way
|
||||
return (FSTR_P const)pgm_read_ptr(&btnOperation[bi - 1]);
|
||||
return (FSTR_P const)pgm_read_ptr(btnOperation + bi - 1);
|
||||
}
|
||||
|
||||
Buttons ButtonPressed(const ErrorCode ec) {
|
||||
|
||||
@@ -261,7 +261,7 @@ void Power::power_off() {
|
||||
nextPowerCheck = now + 2500UL;
|
||||
if (is_power_needed())
|
||||
power_on();
|
||||
else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(now, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))))
|
||||
else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(now, lastPowerOn, SEC_TO_MS(POWER_TIMEOUT))))
|
||||
power_off();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ bool SpindleLaser::enable_state; // Virtual
|
||||
uint8_t SpindleLaser::power, // Actual power output 0-255 ocr or "0 = off" > 0 = "on"
|
||||
SpindleLaser::last_power_applied; // = 0 // Basic power state tracking
|
||||
|
||||
#if HAS_SPINDLE_ACCELERATION
|
||||
uint32_t SpindleLaser::acceleration_spindle_deg_per_s2; // (°/s/s) Spindle acceleration. Initialized by settings.load
|
||||
#endif
|
||||
|
||||
#if ENABLED(LASER_FEATURE)
|
||||
cutter_test_pulse_t SpindleLaser::testPulse = 50; // (ms) Test fire pulse default duration
|
||||
uint8_t SpindleLaser::last_block_power; // = 0 // Track power changes for dynamic inline power
|
||||
@@ -100,7 +104,22 @@ void SpindleLaser::init() {
|
||||
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
|
||||
hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency);
|
||||
#endif
|
||||
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
|
||||
#if HAS_SPINDLE_ACCELERATION
|
||||
const int16_t diff = ocr - last_power_applied;
|
||||
const uint8_t abs_diff = ABS(diff);
|
||||
uint8_t current_ocr = last_power_applied;
|
||||
// Duration between ocr increments. SPEED_POWER_MAX is in RPM.
|
||||
const millis_t duration = (float(SPEED_POWER_MAX) * (60000.f / 2550.f) / float(acceleration_spindle_deg_per_s2)) * abs_diff;
|
||||
millis_t next_ocr_change = millis() + duration;
|
||||
while (current_ocr != ocr) {
|
||||
while (PENDING(millis(), next_ocr_change)) idle();
|
||||
current_ocr += diff > 0 ? 1 : -1;
|
||||
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), current_ocr ^ SPINDLE_LASER_PWM_OFF);
|
||||
next_ocr_change += duration;
|
||||
}
|
||||
#else
|
||||
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpindleLaser::set_ocr(const uint8_t ocr) {
|
||||
@@ -111,10 +130,10 @@ void SpindleLaser::init() {
|
||||
}
|
||||
|
||||
void SpindleLaser::ocr_off() {
|
||||
_set_ocr(0);
|
||||
#if PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF
|
||||
#endif
|
||||
_set_ocr(0);
|
||||
}
|
||||
#endif // SPINDLE_LASER_USE_PWM
|
||||
|
||||
@@ -127,9 +146,8 @@ void SpindleLaser::init() {
|
||||
*/
|
||||
void SpindleLaser::apply_power(const uint8_t opwr) {
|
||||
if (enabled() || opwr == 0) { // 0 check allows us to disable where no ENA pin exists
|
||||
// Test and set the last power used to improve performance
|
||||
// Test the last power used to improve performance
|
||||
if (opwr == last_power_applied) return;
|
||||
last_power_applied = opwr;
|
||||
// Handle PWM driven or just simple on/off
|
||||
#if ENABLED(SPINDLE_LASER_USE_PWM)
|
||||
if (CUTTER_UNIT_IS(RPM) && unitPower == 0)
|
||||
@@ -146,6 +164,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) {
|
||||
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
|
||||
isReadyForUI = true;
|
||||
#endif
|
||||
last_power_applied = opwr;
|
||||
}
|
||||
else {
|
||||
#if PIN_EXISTS(SPINDLE_LASER_ENA)
|
||||
|
||||
@@ -109,11 +109,14 @@ public:
|
||||
static uint8_t power,
|
||||
last_power_applied; // Basic power state tracking
|
||||
|
||||
static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K
|
||||
static cutter_frequency_t frequency; // (Hz) Laser/Spindle PWM frequency (2000..50000)
|
||||
|
||||
static cutter_power_t menuPower, // Power as set via LCD menu in PWM, Percentage or RPM
|
||||
unitPower; // Power as displayed status in PWM, Percentage or RPM
|
||||
static cutter_power_t menuPower, // Power as set via LCD menu in PWM, Percentage, or RPM
|
||||
unitPower; // Power as displayed status in PWM, Percentage, or RPM
|
||||
|
||||
#if HAS_SPINDLE_ACCELERATION
|
||||
static uint32_t acceleration_spindle_deg_per_s2; // (°/s/s) Spindle acceleration
|
||||
#endif
|
||||
static void init();
|
||||
|
||||
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY
|
||||
|
||||
+128
-357
@@ -43,6 +43,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(EDITABLE_HOMING_CURRENT)
|
||||
homing_current_t homing_current_mA;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check for over temperature or short to ground error flags.
|
||||
* Report and log warning of overtemperature condition.
|
||||
@@ -344,127 +348,70 @@
|
||||
|
||||
if (need_update_error_counters || need_debug_reporting) {
|
||||
|
||||
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
|
||||
{
|
||||
bool result = false;
|
||||
#if AXIS_IS_TMC(X)
|
||||
if (monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
if (monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
if (result) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
step_current_down(stepperX);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
step_current_down(stepperX2);
|
||||
#endif
|
||||
#if X_IS_TRINAMIC || X2_IS_TRINAMIC
|
||||
if ( TERN0(X_IS_TRINAMIC, monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting))
|
||||
|| TERN0(X2_IS_TRINAMIC, monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting))
|
||||
) {
|
||||
TERN_(X_IS_TRINAMIC, step_current_down(stepperX));
|
||||
TERN_(X2_IS_TRINAMIC, step_current_down(stepperX2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2)
|
||||
{
|
||||
bool result = false;
|
||||
#if AXIS_IS_TMC(Y)
|
||||
if (monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
if (monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
if (result) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
step_current_down(stepperY);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
step_current_down(stepperY2);
|
||||
#endif
|
||||
#if Y_IS_TRINAMIC || Y2_IS_TRINAMIC
|
||||
if ( TERN0(Y_IS_TRINAMIC, monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting))
|
||||
|| TERN0(Y2_IS_TRINAMIC, monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting))
|
||||
) {
|
||||
TERN_(Y_IS_TRINAMIC, step_current_down(stepperY));
|
||||
TERN_(Y2_IS_TRINAMIC, step_current_down(stepperY2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
|
||||
{
|
||||
bool result = false;
|
||||
#if AXIS_IS_TMC(Z)
|
||||
if (monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
if (monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
if (monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
if (monitor_tmc_driver(stepperZ4, need_update_error_counters, need_debug_reporting)) result = true;
|
||||
#endif
|
||||
if (result) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
step_current_down(stepperZ);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
step_current_down(stepperZ2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
step_current_down(stepperZ3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
step_current_down(stepperZ4);
|
||||
#endif
|
||||
#if ANY(Z_IS_TRINAMIC, Z2_IS_TRINAMIC, Z3_IS_TRINAMIC, Z4_IS_TRINAMIC)
|
||||
if ( TERN0(Z_IS_TRINAMIC, monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting))
|
||||
|| TERN0(Z2_IS_TRINAMIC, monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting))
|
||||
|| TERN0(Z3_IS_TRINAMIC, monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting))
|
||||
|| TERN0(Z4_IS_TRINAMIC, monitor_tmc_driver(stepperZ4, need_update_error_counters, need_debug_reporting))
|
||||
) {
|
||||
TERN_(Z_IS_TRINAMIC, step_current_down(stepperZ));
|
||||
TERN_(Z2_IS_TRINAMIC, step_current_down(stepperZ2));
|
||||
TERN_(Z3_IS_TRINAMIC, step_current_down(stepperZ3));
|
||||
TERN_(Z4_IS_TRINAMIC, step_current_down(stepperZ4));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
#if I_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperI);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(J)
|
||||
#if J_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperJ);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(K)
|
||||
#if K_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperK);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(U)
|
||||
#if U_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperU, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperU);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(V)
|
||||
#if V_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperV, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperV);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(W)
|
||||
#if W_IS_TRINAMIC
|
||||
if (monitor_tmc_driver(stepperW, need_update_error_counters, need_debug_reporting))
|
||||
step_current_down(stepperW);
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
(void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
(void)monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
(void)monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
(void)monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
(void)monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
(void)monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
(void)monitor_tmc_driver(stepperE6, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
(void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
TERN_(E0_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E1_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E2_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E3_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E4_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E5_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E6_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE6, need_update_error_counters, need_debug_reporting));
|
||||
TERN_(E7_IS_TRINAMIC, (void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting));
|
||||
|
||||
if (TERN0(TMC_DEBUG, need_debug_reporting)) SERIAL_EOL();
|
||||
}
|
||||
@@ -781,82 +728,38 @@
|
||||
|
||||
static void tmc_debug_loop(const TMC_debug_enum n OPTARGS_LOGICAL(const bool)) {
|
||||
if (TERN0(HAS_X_AXIS, x)) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
tmc_status(stepperX, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
tmc_status(stepperX2, n);
|
||||
#endif
|
||||
TERN_(X_IS_TRINAMIC, tmc_status(stepperX, n));
|
||||
TERN_(X2_IS_TRINAMIC, tmc_status(stepperX2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Y_AXIS, y)) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
tmc_status(stepperY, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
tmc_status(stepperY2, n);
|
||||
#endif
|
||||
TERN_(Y_IS_TRINAMIC, tmc_status(stepperY, n));
|
||||
TERN_(Y2_IS_TRINAMIC, tmc_status(stepperY2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Z_AXIS, z)) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
tmc_status(stepperZ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
tmc_status(stepperZ2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
tmc_status(stepperZ3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
tmc_status(stepperZ4, n);
|
||||
#endif
|
||||
TERN_(Z_IS_TRINAMIC, tmc_status(stepperZ, n));
|
||||
TERN_(Z2_IS_TRINAMIC, tmc_status(stepperZ2, n));
|
||||
TERN_(Z3_IS_TRINAMIC, tmc_status(stepperZ3, n));
|
||||
TERN_(Z4_IS_TRINAMIC, tmc_status(stepperZ4, n));
|
||||
}
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
if (i) tmc_status(stepperI, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(J)
|
||||
if (j) tmc_status(stepperJ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(K)
|
||||
if (k) tmc_status(stepperK, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(U)
|
||||
if (u) tmc_status(stepperU, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(V)
|
||||
if (v) tmc_status(stepperV, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(W)
|
||||
if (w) tmc_status(stepperW, n);
|
||||
#endif
|
||||
TERN_(I_IS_TRINAMIC, if (i) tmc_status(stepperI, n));
|
||||
TERN_(J_IS_TRINAMIC, if (j) tmc_status(stepperJ, n));
|
||||
TERN_(K_IS_TRINAMIC, if (k) tmc_status(stepperK, n));
|
||||
TERN_(U_IS_TRINAMIC, if (u) tmc_status(stepperU, n));
|
||||
TERN_(V_IS_TRINAMIC, if (v) tmc_status(stepperV, n));
|
||||
TERN_(W_IS_TRINAMIC, if (w) tmc_status(stepperW, n));
|
||||
|
||||
if (TERN0(HAS_EXTRUDERS, e)) {
|
||||
#if AXIS_IS_TMC(E0)
|
||||
tmc_status(stepperE0, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
tmc_status(stepperE1, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
tmc_status(stepperE2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
tmc_status(stepperE3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
tmc_status(stepperE4, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
tmc_status(stepperE5, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
tmc_status(stepperE6, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
tmc_status(stepperE7, n);
|
||||
#endif
|
||||
TERN_(E0_IS_TRINAMIC, tmc_status(stepperE0, n));
|
||||
TERN_(E1_IS_TRINAMIC, tmc_status(stepperE1, n));
|
||||
TERN_(E2_IS_TRINAMIC, tmc_status(stepperE2, n));
|
||||
TERN_(E3_IS_TRINAMIC, tmc_status(stepperE3, n));
|
||||
TERN_(E4_IS_TRINAMIC, tmc_status(stepperE4, n));
|
||||
TERN_(E5_IS_TRINAMIC, tmc_status(stepperE5, n));
|
||||
TERN_(E6_IS_TRINAMIC, tmc_status(stepperE6, n));
|
||||
TERN_(E7_IS_TRINAMIC, tmc_status(stepperE7, n));
|
||||
}
|
||||
|
||||
SERIAL_EOL();
|
||||
@@ -864,82 +767,38 @@
|
||||
|
||||
static void drv_status_loop(const TMC_drv_status_enum n OPTARGS_LOGICAL(const bool)) {
|
||||
if (TERN0(HAS_X_AXIS, x)) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
tmc_parse_drv_status(stepperX, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
tmc_parse_drv_status(stepperX2, n);
|
||||
#endif
|
||||
TERN_(X_IS_TRINAMIC, tmc_parse_drv_status(stepperX, n));
|
||||
TERN_(X2_IS_TRINAMIC, tmc_parse_drv_status(stepperX2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Y_AXIS, y)) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
tmc_parse_drv_status(stepperY, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
tmc_parse_drv_status(stepperY2, n);
|
||||
#endif
|
||||
TERN_(Y_IS_TRINAMIC, tmc_parse_drv_status(stepperY, n));
|
||||
TERN_(Y2_IS_TRINAMIC, tmc_parse_drv_status(stepperY2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Z_AXIS, z)) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
tmc_parse_drv_status(stepperZ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
tmc_parse_drv_status(stepperZ2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
tmc_parse_drv_status(stepperZ3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
tmc_parse_drv_status(stepperZ4, n);
|
||||
#endif
|
||||
TERN_(Z_IS_TRINAMIC, tmc_parse_drv_status(stepperZ, n));
|
||||
TERN_(Z2_IS_TRINAMIC, tmc_parse_drv_status(stepperZ2, n));
|
||||
TERN_(Z3_IS_TRINAMIC, tmc_parse_drv_status(stepperZ3, n));
|
||||
TERN_(Z4_IS_TRINAMIC, tmc_parse_drv_status(stepperZ4, n));
|
||||
}
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
if (i) tmc_parse_drv_status(stepperI, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(J)
|
||||
if (j) tmc_parse_drv_status(stepperJ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(K)
|
||||
if (k) tmc_parse_drv_status(stepperK, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(U)
|
||||
if (u) tmc_parse_drv_status(stepperU, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(V)
|
||||
if (v) tmc_parse_drv_status(stepperV, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(W)
|
||||
if (w) tmc_parse_drv_status(stepperW, n);
|
||||
#endif
|
||||
TERN_(I_IS_TRINAMIC, if (i) tmc_parse_drv_status(stepperI, n));
|
||||
TERN_(J_IS_TRINAMIC, if (j) tmc_parse_drv_status(stepperJ, n));
|
||||
TERN_(K_IS_TRINAMIC, if (k) tmc_parse_drv_status(stepperK, n));
|
||||
TERN_(U_IS_TRINAMIC, if (u) tmc_parse_drv_status(stepperU, n));
|
||||
TERN_(V_IS_TRINAMIC, if (v) tmc_parse_drv_status(stepperV, n));
|
||||
TERN_(W_IS_TRINAMIC, if (w) tmc_parse_drv_status(stepperW, n));
|
||||
|
||||
if (TERN0(HAS_EXTRUDERS, e)) {
|
||||
#if AXIS_IS_TMC(E0)
|
||||
tmc_parse_drv_status(stepperE0, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
tmc_parse_drv_status(stepperE1, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
tmc_parse_drv_status(stepperE2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
tmc_parse_drv_status(stepperE3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
tmc_parse_drv_status(stepperE4, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
tmc_parse_drv_status(stepperE5, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
tmc_parse_drv_status(stepperE6, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
tmc_parse_drv_status(stepperE7, n);
|
||||
#endif
|
||||
TERN_(E0_IS_TRINAMIC, tmc_parse_drv_status(stepperE0, n));
|
||||
TERN_(E1_IS_TRINAMIC, tmc_parse_drv_status(stepperE1, n));
|
||||
TERN_(E2_IS_TRINAMIC, tmc_parse_drv_status(stepperE2, n));
|
||||
TERN_(E3_IS_TRINAMIC, tmc_parse_drv_status(stepperE3, n));
|
||||
TERN_(E4_IS_TRINAMIC, tmc_parse_drv_status(stepperE4, n));
|
||||
TERN_(E5_IS_TRINAMIC, tmc_parse_drv_status(stepperE5, n));
|
||||
TERN_(E6_IS_TRINAMIC, tmc_parse_drv_status(stepperE6, n));
|
||||
TERN_(E7_IS_TRINAMIC, tmc_parse_drv_status(stepperE7, n));
|
||||
}
|
||||
|
||||
SERIAL_EOL();
|
||||
@@ -1078,82 +937,38 @@
|
||||
|
||||
static void tmc_get_registers(TMC_get_registers_enum n OPTARGS_LOGICAL(const bool)) {
|
||||
if (TERN0(HAS_X_AXIS, x)) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
tmc_get_registers(stepperX, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
tmc_get_registers(stepperX2, n);
|
||||
#endif
|
||||
TERN_(X_IS_TRINAMIC, tmc_get_registers(stepperX, n));
|
||||
TERN_(X2_IS_TRINAMIC, tmc_get_registers(stepperX2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Y_AXIS, y)) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
tmc_get_registers(stepperY, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
tmc_get_registers(stepperY2, n);
|
||||
#endif
|
||||
TERN_(Y_IS_TRINAMIC, tmc_get_registers(stepperY, n));
|
||||
TERN_(Y2_IS_TRINAMIC, tmc_get_registers(stepperY2, n));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Z_AXIS, z)) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
tmc_get_registers(stepperZ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
tmc_get_registers(stepperZ2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
tmc_get_registers(stepperZ3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
tmc_get_registers(stepperZ4, n);
|
||||
#endif
|
||||
TERN_(Z_IS_TRINAMIC, tmc_get_registers(stepperZ, n));
|
||||
TERN_(Z2_IS_TRINAMIC, tmc_get_registers(stepperZ2, n));
|
||||
TERN_(Z3_IS_TRINAMIC, tmc_get_registers(stepperZ3, n));
|
||||
TERN_(Z4_IS_TRINAMIC, tmc_get_registers(stepperZ4, n));
|
||||
}
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
if (i) tmc_get_registers(stepperI, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(J)
|
||||
if (j) tmc_get_registers(stepperJ, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(K)
|
||||
if (k) tmc_get_registers(stepperK, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(U)
|
||||
if (u) tmc_get_registers(stepperU, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(V)
|
||||
if (v) tmc_get_registers(stepperV, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(W)
|
||||
if (w) tmc_get_registers(stepperW, n);
|
||||
#endif
|
||||
TERN_(I_IS_TRINAMIC, if (i) tmc_get_registers(stepperI, n));
|
||||
TERN_(J_IS_TRINAMIC, if (j) tmc_get_registers(stepperJ, n));
|
||||
TERN_(K_IS_TRINAMIC, if (k) tmc_get_registers(stepperK, n));
|
||||
TERN_(U_IS_TRINAMIC, if (u) tmc_get_registers(stepperU, n));
|
||||
TERN_(V_IS_TRINAMIC, if (v) tmc_get_registers(stepperV, n));
|
||||
TERN_(W_IS_TRINAMIC, if (w) tmc_get_registers(stepperW, n));
|
||||
|
||||
if (TERN0(HAS_EXTRUDERS, e)) {
|
||||
#if AXIS_IS_TMC(E0)
|
||||
tmc_get_registers(stepperE0, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
tmc_get_registers(stepperE1, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
tmc_get_registers(stepperE2, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
tmc_get_registers(stepperE3, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
tmc_get_registers(stepperE4, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
tmc_get_registers(stepperE5, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
tmc_get_registers(stepperE6, n);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
tmc_get_registers(stepperE7, n);
|
||||
#endif
|
||||
TERN_(E0_IS_TRINAMIC, tmc_get_registers(stepperE0, n));
|
||||
TERN_(E1_IS_TRINAMIC, tmc_get_registers(stepperE1, n));
|
||||
TERN_(E2_IS_TRINAMIC, tmc_get_registers(stepperE2, n));
|
||||
TERN_(E3_IS_TRINAMIC, tmc_get_registers(stepperE3, n));
|
||||
TERN_(E4_IS_TRINAMIC, tmc_get_registers(stepperE4, n));
|
||||
TERN_(E5_IS_TRINAMIC, tmc_get_registers(stepperE5, n));
|
||||
TERN_(E6_IS_TRINAMIC, tmc_get_registers(stepperE6, n));
|
||||
TERN_(E7_IS_TRINAMIC, tmc_get_registers(stepperE7, n));
|
||||
}
|
||||
|
||||
SERIAL_EOL();
|
||||
@@ -1243,82 +1058,38 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS_LC(const bool)) {
|
||||
uint8_t axis_connection = 0;
|
||||
|
||||
if (TERN0(HAS_X_AXIS, x)) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
axis_connection += test_connection(stepperX);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
axis_connection += test_connection(stepperX2);
|
||||
#endif
|
||||
TERN_(X_IS_TRINAMIC, axis_connection += test_connection(stepperX));
|
||||
TERN_(X2_IS_TRINAMIC, axis_connection += test_connection(stepperX2));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Y_AXIS, y)) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
axis_connection += test_connection(stepperY);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
axis_connection += test_connection(stepperY2);
|
||||
#endif
|
||||
TERN_(Y_IS_TRINAMIC, axis_connection += test_connection(stepperY));
|
||||
TERN_(Y2_IS_TRINAMIC, axis_connection += test_connection(stepperY2));
|
||||
}
|
||||
|
||||
if (TERN0(HAS_Z_AXIS, z)) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
axis_connection += test_connection(stepperZ);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
axis_connection += test_connection(stepperZ2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
axis_connection += test_connection(stepperZ3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
axis_connection += test_connection(stepperZ4);
|
||||
#endif
|
||||
TERN_(Z_IS_TRINAMIC, axis_connection += test_connection(stepperZ));
|
||||
TERN_(Z2_IS_TRINAMIC, axis_connection += test_connection(stepperZ2));
|
||||
TERN_(Z3_IS_TRINAMIC, axis_connection += test_connection(stepperZ3));
|
||||
TERN_(Z4_IS_TRINAMIC, axis_connection += test_connection(stepperZ4));
|
||||
}
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
if (i) axis_connection += test_connection(stepperI);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(J)
|
||||
if (j) axis_connection += test_connection(stepperJ);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(K)
|
||||
if (k) axis_connection += test_connection(stepperK);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(U)
|
||||
if (u) axis_connection += test_connection(stepperU);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(V)
|
||||
if (v) axis_connection += test_connection(stepperV);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(W)
|
||||
if (w) axis_connection += test_connection(stepperW);
|
||||
#endif
|
||||
TERN_(I_IS_TRINAMIC, if (i) axis_connection += test_connection(stepperI));
|
||||
TERN_(J_IS_TRINAMIC, if (j) axis_connection += test_connection(stepperJ));
|
||||
TERN_(K_IS_TRINAMIC, if (k) axis_connection += test_connection(stepperK));
|
||||
TERN_(U_IS_TRINAMIC, if (u) axis_connection += test_connection(stepperU));
|
||||
TERN_(V_IS_TRINAMIC, if (v) axis_connection += test_connection(stepperV));
|
||||
TERN_(W_IS_TRINAMIC, if (w) axis_connection += test_connection(stepperW));
|
||||
|
||||
if (TERN0(HAS_EXTRUDERS, e)) {
|
||||
#if AXIS_IS_TMC(E0)
|
||||
axis_connection += test_connection(stepperE0);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
axis_connection += test_connection(stepperE1);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
axis_connection += test_connection(stepperE2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
axis_connection += test_connection(stepperE3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
axis_connection += test_connection(stepperE4);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
axis_connection += test_connection(stepperE5);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
axis_connection += test_connection(stepperE6);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
axis_connection += test_connection(stepperE7);
|
||||
#endif
|
||||
TERN_(E0_IS_TRINAMIC, axis_connection += test_connection(stepperE0));
|
||||
TERN_(E1_IS_TRINAMIC, axis_connection += test_connection(stepperE1));
|
||||
TERN_(E2_IS_TRINAMIC, axis_connection += test_connection(stepperE2));
|
||||
TERN_(E3_IS_TRINAMIC, axis_connection += test_connection(stepperE3));
|
||||
TERN_(E4_IS_TRINAMIC, axis_connection += test_connection(stepperE4));
|
||||
TERN_(E5_IS_TRINAMIC, axis_connection += test_connection(stepperE5));
|
||||
TERN_(E6_IS_TRINAMIC, axis_connection += test_connection(stepperE6));
|
||||
TERN_(E7_IS_TRINAMIC, axis_connection += test_connection(stepperE7));
|
||||
}
|
||||
|
||||
if (axis_connection) LCD_MESSAGE(MSG_ERROR_TMC);
|
||||
|
||||
@@ -375,6 +375,32 @@ void test_tmc_connection(LOGICAL_AXIS_DECL_LC(const bool, true));
|
||||
|
||||
#endif // USE_SENSORLESS
|
||||
|
||||
#if HAS_HOMING_CURRENT
|
||||
|
||||
// Axes that have a distinct homing current
|
||||
struct homing_current_t {
|
||||
OPTCODE(X_HAS_HOME_CURRENT, uint16_t X)
|
||||
OPTCODE(Y_HAS_HOME_CURRENT, uint16_t Y)
|
||||
OPTCODE(Z_HAS_HOME_CURRENT, uint16_t Z)
|
||||
OPTCODE(X2_HAS_HOME_CURRENT, uint16_t X2)
|
||||
OPTCODE(Y2_HAS_HOME_CURRENT, uint16_t Y2)
|
||||
OPTCODE(Z2_HAS_HOME_CURRENT, uint16_t Z2)
|
||||
OPTCODE(Z3_HAS_HOME_CURRENT, uint16_t Z3)
|
||||
OPTCODE(Z4_HAS_HOME_CURRENT, uint16_t Z4)
|
||||
OPTCODE(I_HAS_HOME_CURRENT, uint16_t I)
|
||||
OPTCODE(J_HAS_HOME_CURRENT, uint16_t J)
|
||||
OPTCODE(K_HAS_HOME_CURRENT, uint16_t K)
|
||||
OPTCODE(U_HAS_HOME_CURRENT, uint16_t U)
|
||||
OPTCODE(V_HAS_HOME_CURRENT, uint16_t V)
|
||||
OPTCODE(W_HAS_HOME_CURRENT, uint16_t W)
|
||||
};
|
||||
|
||||
#if ENABLED(EDITABLE_HOMING_CURRENT)
|
||||
extern homing_current_t homing_current_mA;
|
||||
#endif
|
||||
|
||||
#endif // HAS_HOMING_CURRENT
|
||||
|
||||
#endif // HAS_TRINAMIC_CONFIG
|
||||
|
||||
#if HAS_TMC_SPI
|
||||
|
||||
@@ -88,10 +88,8 @@
|
||||
fr_mm_s = HYPOT(minfr, minfr);
|
||||
|
||||
// Set homing current to X and Y axis if defined
|
||||
#if HAS_CURRENT_HOME(X)
|
||||
set_homing_current(X_AXIS);
|
||||
#endif
|
||||
#if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
|
||||
TERN_(X_HAS_HOME_CURRENT, set_homing_current(X_AXIS));
|
||||
#if Y_HAS_HOME_CURRENT && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
|
||||
set_homing_current(Y_AXIS);
|
||||
#endif
|
||||
|
||||
@@ -113,10 +111,8 @@
|
||||
|
||||
current_position.set(0.0, 0.0);
|
||||
|
||||
#if HAS_CURRENT_HOME(X)
|
||||
restore_homing_current(X_AXIS);
|
||||
#endif
|
||||
#if HAS_CURRENT_HOME(Y) && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
|
||||
TERN_(X_HAS_HOME_CURRENT, restore_homing_current(X_AXIS));
|
||||
#if Y_HAS_HOME_CURRENT && NONE(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
|
||||
restore_homing_current(Y_AXIS);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -95,37 +95,36 @@ void GcodeSuite::G34() {
|
||||
|
||||
#if HAS_MOTOR_CURRENT_SPI
|
||||
const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
|
||||
const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS];
|
||||
const uint32_t previous_current_Z = stepper.motor_current_setting[Z_AXIS];
|
||||
stepper.set_digipot_current(Z_AXIS, target_current);
|
||||
#elif HAS_MOTOR_CURRENT_PWM
|
||||
const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
|
||||
const uint32_t previous_current = stepper.motor_current_setting[1]; // Z
|
||||
const uint32_t previous_current_Z = stepper.motor_current_setting[1]; // Z
|
||||
stepper.set_digipot_current(1, target_current);
|
||||
#elif HAS_MOTOR_CURRENT_DAC
|
||||
const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT);
|
||||
const float previous_current = dac_amps(Z_AXIS, target_current);
|
||||
const float previous_current_Z = dac_amps(Z_AXIS, target_current);
|
||||
stepper_dac.set_current_value(Z_AXIS, target_current);
|
||||
#elif HAS_MOTOR_CURRENT_I2C
|
||||
const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
|
||||
previous_current = dac_amps(Z_AXIS);
|
||||
const float previous_current_Z = dac_amps(Z_AXIS);
|
||||
digipot_i2c.set_current(Z_AXIS, target_current)
|
||||
#elif HAS_TRINAMIC_CONFIG
|
||||
const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
|
||||
static uint16_t previous_current_arr[NUM_Z_STEPPERS];
|
||||
#if AXIS_IS_TMC(Z)
|
||||
previous_current_arr[0] = stepperZ.getMilliamps();
|
||||
#if Z_IS_TRINAMIC
|
||||
static uint16_t previous_current_Z = stepperZ.getMilliamps();
|
||||
stepperZ.rms_current(target_current);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
previous_current_arr[1] = stepperZ2.getMilliamps();
|
||||
#if Z2_IS_TRINAMIC
|
||||
static uint16_t previous_current_Z2 = stepperZ2.getMilliamps();
|
||||
stepperZ2.rms_current(target_current);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
previous_current_arr[2] = stepperZ3.getMilliamps();
|
||||
#if Z3_IS_TRINAMIC
|
||||
static uint16_t previous_current_Z3 = stepperZ3.getMilliamps();
|
||||
stepperZ3.rms_current(target_current);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
previous_current_arr[3] = stepperZ4.getMilliamps();
|
||||
#if Z4_IS_TRINAMIC
|
||||
static uint16_t previous_current_Z4 = stepperZ4.getMilliamps();
|
||||
stepperZ4.rms_current(target_current);
|
||||
#endif
|
||||
#endif
|
||||
@@ -140,26 +139,18 @@ void GcodeSuite::G34() {
|
||||
#endif
|
||||
|
||||
#if HAS_MOTOR_CURRENT_SPI
|
||||
stepper.set_digipot_current(Z_AXIS, previous_current);
|
||||
stepper.set_digipot_current(Z_AXIS, previous_current_Z);
|
||||
#elif HAS_MOTOR_CURRENT_PWM
|
||||
stepper.set_digipot_current(1, previous_current);
|
||||
stepper.set_digipot_current(1, previous_current_Z);
|
||||
#elif HAS_MOTOR_CURRENT_DAC
|
||||
stepper_dac.set_current_value(Z_AXIS, previous_current);
|
||||
stepper_dac.set_current_value(Z_AXIS, previous_current_Z);
|
||||
#elif HAS_MOTOR_CURRENT_I2C
|
||||
digipot_i2c.set_current(Z_AXIS, previous_current)
|
||||
digipot_i2c.set_current(Z_AXIS, previous_current_Z)
|
||||
#elif HAS_TRINAMIC_CONFIG
|
||||
#if AXIS_IS_TMC(Z)
|
||||
stepperZ.rms_current(previous_current_arr[0]);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
stepperZ2.rms_current(previous_current_arr[1]);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
stepperZ3.rms_current(previous_current_arr[2]);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
stepperZ4.rms_current(previous_current_arr[3]);
|
||||
#endif
|
||||
TERN_(Z_IS_TRINAMIC, stepperZ.rms_current(previous_current_Z));
|
||||
TERN_(Z2_IS_TRINAMIC, stepperZ2.rms_current(previous_current_Z2));
|
||||
TERN_(Z3_IS_TRINAMIC, stepperZ3.rms_current(previous_current_Z3));
|
||||
TERN_(Z4_IS_TRINAMIC, stepperZ4.rms_current(previous_current_Z4));
|
||||
#endif
|
||||
|
||||
// Back off end plate, back to normal motion range
|
||||
|
||||
@@ -261,7 +261,19 @@ void GcodeSuite::M48() {
|
||||
|
||||
#if HAS_STATUS_MESSAGE
|
||||
// Display M48 results in the status bar
|
||||
ui.set_status_and_level(MString<30>(GET_TEXT_F(MSG_M48_DEVIATION), F(": "), w_float_t(sigma, 2, 6)));
|
||||
if (MAX_MESSAGE_SIZE <= 20) {
|
||||
// 12345678901234567890
|
||||
// Deviation: 0.123456
|
||||
ui.set_status_and_level(TS(GET_TEXT_F(MSG_M48_DEVIATION), F(": "), w_float_t(sigma, 2, 6)));
|
||||
} else if (MAX_MESSAGE_SIZE <= 30) {
|
||||
// 123456789012345678901234567890
|
||||
// Dev:0.12345, Max delta:0.12345
|
||||
ui.set_status_and_level(TS(GET_TEXT_F(MSG_M48_DEV), ':', w_float_t(sigma, 2, 5), F(", "), GET_TEXT(MSG_M48_MAX_DELTA), ':', w_float_t(_MAX(mean - min, max - mean), 2, 5)));
|
||||
} else {
|
||||
// 1234567890123456789012345678901234567890
|
||||
// Deviation: 1.23456, Max delta: 1.23456
|
||||
ui.set_status_and_level(TS(GET_TEXT_F(MSG_M48_DEVIATION), F(": "), w_float_t(sigma, 2, 6), F(", "), GET_TEXT(MSG_M48_MAX_DELTA), F(": "), w_float_t(_MAX(mean - min, max - mean), 2, 6)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
|
||||
if (!forReplay) {
|
||||
report_heading(forReplay, F(STR_FILAMENT_SETTINGS), false);
|
||||
report_heading(false, F(STR_FILAMENT_SETTINGS), false);
|
||||
if (!parser.volumetric_enabled) SERIAL_ECHOPGM(" (Disabled):");
|
||||
SERIAL_EOL();
|
||||
report_echo_start(forReplay);
|
||||
report_echo_start(false);
|
||||
}
|
||||
|
||||
#if EXTRUDERS == 1
|
||||
@@ -231,7 +231,7 @@ void GcodeSuite::M203_report(const bool forReplay/*=true*/) {
|
||||
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
for (uint8_t i = 0; i < E_STEPPERS; ++i) {
|
||||
if (!forReplay) SERIAL_ECHO_START();
|
||||
report_echo_start(forReplay);
|
||||
SERIAL_ECHOLNPGM_P(
|
||||
PSTR(" M203 T"), i
|
||||
, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)])
|
||||
|
||||
@@ -42,7 +42,7 @@ void GcodeSuite::M550() {
|
||||
machine_name = parser.value_string();
|
||||
else if (TERN(GCODE_QUOTED_STRINGS, false, parser.seen('P')))
|
||||
machine_name = parser.string_arg[0] == 'P' ? &parser.string_arg[1] : parser.string_arg;
|
||||
else if (parser.string_arg && parser.string_arg[0])
|
||||
else if (parser.has_string())
|
||||
machine_name = parser.string_arg;
|
||||
else
|
||||
did_set = false;
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
|
||||
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
|
||||
|
||||
#ifdef DEBUG_DXC_MODE
|
||||
#if ENABLED(DEBUG_DXC_MODE)
|
||||
|
||||
if (parser.seen('W')) {
|
||||
DEBUG_ECHO_START();
|
||||
|
||||
@@ -69,7 +69,7 @@ void GcodeSuite::T(const int8_t tool_index) {
|
||||
reset_stepper_timeout();
|
||||
|
||||
#if HAS_PRUSA_MMU3
|
||||
if (parser.string_arg) {
|
||||
if (parser.has_string()) {
|
||||
mmu3.tool_change(parser.string_arg[0], uint8_t(tool_index)); // Special commands T?/Tx/Tc
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,15 +46,32 @@
|
||||
* Set percentage of max current for all axes (Requires HAS_DIGIPOT_DAC)
|
||||
*/
|
||||
void GcodeSuite::M907() {
|
||||
|
||||
#if HAS_MOTOR_CURRENT_SPI
|
||||
|
||||
if (!parser.seen("BS" STR_AXES_LOGICAL))
|
||||
return M907_report();
|
||||
|
||||
if (parser.seenval('S')) for (uint8_t i = 0; i < MOTOR_CURRENT_COUNT; ++i) stepper.set_digipot_current(i, parser.value_int());
|
||||
LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) stepper.set_digipot_current(i, parser.value_int()); // X Y Z (I J K U V W) E (map to drivers according to DIGIPOT_CHANNELS. Default with NUM_AXES 3: map X Y Z E to X Y Z E0)
|
||||
// Additional extruders use B,C.
|
||||
// TODO: Change these parameters because 'E' is used and D should be reserved for debugging. B<index>?
|
||||
// S<current> - Set current in mA for all axes
|
||||
if (parser.seenval('S'))
|
||||
for (uint8_t i = 0; i < MOTOR_CURRENT_COUNT; ++i)
|
||||
stepper.set_digipot_current(i, parser.value_int());
|
||||
|
||||
// X Y Z I J K U V W E
|
||||
// Map to drivers according to pots addresses.
|
||||
// Default with NUM_AXES 3: map X Y Z E to X Y Z E0.
|
||||
LOOP_LOGICAL_AXES(i)
|
||||
if (parser.seenval(IAXIS_CHAR(i)))
|
||||
stepper.set_digipot_current(i, parser.value_int());
|
||||
|
||||
/**
|
||||
* Additional extruders use B,C in this legacy protocol
|
||||
* TODO: Update to allow for an index with X, Y, Z, E axis to isolate a single stepper
|
||||
* and use configured axis names instead of IJKUVW. i.e., Match the behavior of
|
||||
* other G-codes that set stepper-specific parameters. If necessary deprecate G-codes.
|
||||
* Bonus Points: Standardize a method that all G-codes can use to refer to one or
|
||||
* more steppers/drivers and apply to various G-codes.
|
||||
*/
|
||||
#if E_STEPPERS >= 2
|
||||
if (parser.seenval('B')) stepper.set_digipot_current(E_AXIS + 1, parser.value_int());
|
||||
#if E_STEPPERS >= 3
|
||||
@@ -68,58 +85,88 @@ void GcodeSuite::M907() {
|
||||
#define HAS_X_Y_XY_I_J_K_U_V_W 1
|
||||
#endif
|
||||
|
||||
#if HAS_X_Y_XY_I_J_K_U_V_W || HAS_MOTOR_CURRENT_PWM_E || PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
#if ANY(HAS_X_Y_XY_I_J_K_U_V_W, HAS_MOTOR_CURRENT_PWM_E, HAS_MOTOR_CURRENT_PWM_Z)
|
||||
|
||||
if (!parser.seen("S"
|
||||
#if HAS_X_Y_XY_I_J_K_U_V_W
|
||||
"XY" SECONDARY_AXIS_GANG("I", "J", "K", "U", "V", "W")
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
"Z"
|
||||
#endif
|
||||
#if HAS_MOTOR_CURRENT_PWM_E
|
||||
"E"
|
||||
NUM_AXIS_GANG("X", "Y",, "I", "J", "K", "U", "V", "W")
|
||||
#endif
|
||||
TERN_(HAS_MOTOR_CURRENT_PWM_Z, "Z")
|
||||
TERN_(HAS_MOTOR_CURRENT_PWM_E, "E")
|
||||
)) return M907_report();
|
||||
|
||||
if (parser.seenval('S')) for (uint8_t a = 0; a < MOTOR_CURRENT_COUNT; ++a) stepper.set_digipot_current(a, parser.value_int());
|
||||
// S<current> - Set all stepper current to the same value
|
||||
if (parser.seenval('S')) {
|
||||
const int16_t v = parser.value_int();
|
||||
for (uint8_t a = 0; a < MOTOR_CURRENT_COUNT; ++a)
|
||||
stepper.set_digipot_current(a, v);
|
||||
}
|
||||
|
||||
#if HAS_X_Y_XY_I_J_K_U_V_W
|
||||
if (NUM_AXIS_GANG(
|
||||
parser.seenval('X'), || parser.seenval('Y'), || false,
|
||||
|| parser.seenval('I'), || parser.seenval('J'), || parser.seenval('K'),
|
||||
|| parser.seenval('U'), || parser.seenval('V'), || parser.seenval('W')
|
||||
)) stepper.set_digipot_current(0, parser.value_int());
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
if (parser.seenval('Z')) stepper.set_digipot_current(1, parser.value_int());
|
||||
#endif
|
||||
#if HAS_MOTOR_CURRENT_PWM_E
|
||||
if (parser.seenval('E')) stepper.set_digipot_current(2, parser.value_int());
|
||||
#endif
|
||||
// X Y I J K U V W - All aliases to set the current for "most axes."
|
||||
// Only the value of the last given parameter is used.
|
||||
if (ENABLED(HAS_X_Y_XY_I_J_K_U_V_W) && (NUM_AXIS_GANG(
|
||||
parser.seenval('X'), || parser.seenval('Y'), || false,
|
||||
|| parser.seenval('I'), || parser.seenval('J'), || parser.seenval('K'),
|
||||
|| parser.seenval('U'), || parser.seenval('V'), || parser.seenval('W')
|
||||
)))
|
||||
stepper.set_digipot_current(0, parser.value_int());
|
||||
|
||||
// Z<current> - Set the current just for the Z axis
|
||||
if (TERN0(HAS_MOTOR_CURRENT_PWM_Z, parser.seenval('Z')))
|
||||
stepper.set_digipot_current(1, parser.value_int());
|
||||
|
||||
// Z<current> - Set the current just for the Extruder
|
||||
if (TERN0(HAS_MOTOR_CURRENT_PWM_E, parser.seenval('E')))
|
||||
stepper.set_digipot_current(2, parser.value_int());
|
||||
|
||||
#endif
|
||||
|
||||
#endif // HAS_MOTOR_CURRENT_PWM
|
||||
|
||||
#if HAS_MOTOR_CURRENT_I2C
|
||||
// this one uses actual amps in floating point
|
||||
if (parser.seenval('S')) for (uint8_t q = 0; q < DIGIPOT_I2C_NUM_CHANNELS; ++q) digipot_i2c.set_current(q, parser.value_float());
|
||||
LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) digipot_i2c.set_current(i, parser.value_float()); // X Y Z (I J K U V W) E (map to drivers according to pots adresses. Default with NUM_AXES 3 X Y Z E: map to X Y Z E0)
|
||||
// This current driver takes actual Amps in floating point
|
||||
// rather than milli-amps or some scalar unit.
|
||||
|
||||
// S<current> - Set the same current in Amps on all channels
|
||||
if (parser.seenval('S')) {
|
||||
const float v = parser.value_float();
|
||||
for (uint8_t q = 0; q < DIGIPOT_I2C_NUM_CHANNELS; ++q)
|
||||
digipot_i2c.set_current(q, v);
|
||||
}
|
||||
|
||||
// X Y Z I J K U V W E
|
||||
// Map to drivers according to pots addresses.
|
||||
// Default with NUM_AXES 3: map X Y Z E to X Y Z E0.
|
||||
LOOP_LOGICAL_AXES(i)
|
||||
if (parser.seenval(IAXIS_CHAR(i)))
|
||||
digipot_i2c.set_current(i, parser.value_float());
|
||||
|
||||
// Additional extruders use B,C,D.
|
||||
// TODO: Change these parameters because 'E' is used and because 'D' should be reserved for debugging. B<index>?
|
||||
// TODO: Make parameters work like other axis-specific / stepper-specific. See above.
|
||||
#if E_STEPPERS >= 2
|
||||
for (uint8_t i = E_AXIS + 1; i < _MAX(DIGIPOT_I2C_NUM_CHANNELS, (NUM_AXES + 3)); i++)
|
||||
if (parser.seenval('B' + i - (E_AXIS + 1))) digipot_i2c.set_current(i, parser.value_float());
|
||||
if (parser.seenval('B' + i - (E_AXIS + 1)))
|
||||
digipot_i2c.set_current(i, parser.value_float());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // HAS_MOTOR_CURRENT_I2C
|
||||
|
||||
#if HAS_MOTOR_CURRENT_DAC
|
||||
|
||||
// S<current> - Set the same current percentage on all axes
|
||||
if (parser.seenval('S')) {
|
||||
const float dac_percent = parser.value_float();
|
||||
LOOP_LOGICAL_AXES(i) stepper_dac.set_current_percent(i, dac_percent);
|
||||
LOOP_LOGICAL_AXES(i)
|
||||
stepper_dac.set_current_percent(i, dac_percent);
|
||||
}
|
||||
LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) stepper_dac.set_current_percent(i, parser.value_float()); // X Y Z (I J K U V W) E (map to drivers according to DAC_STEPPER_ORDER. Default with NUM_AXES 3: X Y Z E map to X Y Z E0)
|
||||
|
||||
// X Y Z I J K U V W E
|
||||
// Map to drivers according to pots addresses.
|
||||
// Default with NUM_AXES 3: map X Y Z E to X Y Z E0.
|
||||
LOOP_LOGICAL_AXES(i)
|
||||
if (parser.seenval(IAXIS_CHAR(i)))
|
||||
stepper_dac.set_current_percent(i, parser.value_float());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -131,8 +178,10 @@ void GcodeSuite::M907() {
|
||||
report_heading_etc(forReplay, F(STR_STEPPER_MOTOR_CURRENTS));
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
SERIAL_ECHOLNPGM_P( // PWM-based has 3 values:
|
||||
PSTR(" M907 X"), stepper.motor_current_setting[0] // X, Y, (I, J, K, U, V, W)
|
||||
, SP_Z_STR, stepper.motor_current_setting[1] // Z
|
||||
PSTR(" M907 X"), stepper.motor_current_setting[0] // X, Y, (I, J, K, U, V, W)
|
||||
#if HAS_MOTOR_CURRENT_PWM_Z
|
||||
, SP_Z_STR, stepper.motor_current_setting[1] // Z
|
||||
#endif
|
||||
#if HAS_MOTOR_CURRENT_PWM_E
|
||||
, SP_E_STR, stepper.motor_current_setting[2] // E
|
||||
#endif
|
||||
|
||||
@@ -28,44 +28,6 @@
|
||||
#include "../../../core/serial.h"
|
||||
#include "../../gcode.h"
|
||||
|
||||
void say_ethernet() { SERIAL_ECHOPGM(" Ethernet "); }
|
||||
|
||||
void ETH0_report() {
|
||||
say_ethernet();
|
||||
SERIAL_ECHO_TERNARY(ethernet.hardware_enabled, "port ", "en", "dis", "abled.\n");
|
||||
if (ethernet.hardware_enabled) {
|
||||
say_ethernet();
|
||||
SERIAL_ECHO_TERNARY(ethernet.have_telnet_client, "client ", "en", "dis", "abled.\n");
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM("Send 'M552 S1' to enable.");
|
||||
}
|
||||
|
||||
void MAC_report() {
|
||||
uint8_t mac[6];
|
||||
if (ethernet.hardware_enabled) {
|
||||
Ethernet.MACAddress(mac);
|
||||
SERIAL_ECHOPGM(" MAC: ");
|
||||
for (uint8_t i = 0; i < 6; ++i) {
|
||||
if (mac[i] < 16) SERIAL_CHAR('0');
|
||||
SERIAL_PRINT(mac[i], PrintBase::Hex);
|
||||
if (i < 5) SERIAL_CHAR(':');
|
||||
}
|
||||
}
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
// Display current values when the link is active,
|
||||
// otherwise show the stored values
|
||||
void ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo) {
|
||||
SERIAL_CHAR('M'); SERIAL_ECHO(cmd); SERIAL_CHAR(' ');
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
SERIAL_ECHO(ipo[i]);
|
||||
if (i < 3) SERIAL_CHAR('.');
|
||||
}
|
||||
SERIAL_ECHOLN(F(" ; "), post);
|
||||
}
|
||||
|
||||
/**
|
||||
* M552: Set IP address, enable/disable network interface
|
||||
*
|
||||
@@ -92,13 +54,13 @@ void GcodeSuite::M552() {
|
||||
}
|
||||
}
|
||||
const bool nopar = !seenS && !seenP;
|
||||
if (nopar || seenS) ETH0_report();
|
||||
if (nopar || seenS) ethernet.ETH0_report();
|
||||
if (nopar || seenP) M552_report();
|
||||
}
|
||||
|
||||
void GcodeSuite::M552_report() {
|
||||
void GcodeSuite::M552_report(const bool forReplay/*=true*/) {
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
ip_report(552, F("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip);
|
||||
ethernet.ip_report(552, F("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip, forReplay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,9 +73,9 @@ void GcodeSuite::M553() {
|
||||
M553_report();
|
||||
}
|
||||
|
||||
void GcodeSuite::M553_report() {
|
||||
void GcodeSuite::M553_report(const bool forReplay/*=true*/) {
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
ip_report(553, F("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet);
|
||||
ethernet.ip_report(553, F("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet, forReplay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,9 +88,9 @@ void GcodeSuite::M554() {
|
||||
M554_report();
|
||||
}
|
||||
|
||||
void GcodeSuite::M554_report() {
|
||||
void GcodeSuite::M554_report(const bool forReplay/*=true*/) {
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
ip_report(554, F("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway);
|
||||
ethernet.ip_report(554, F("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway, forReplay);
|
||||
}
|
||||
|
||||
#endif // HAS_ETHERNET
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
void GcodeSuite::M592_report(const bool forReplay/*=true*/) {
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
report_heading(forReplay, F(STR_NONLINEAR_EXTRUSION));
|
||||
report_heading_etc(forReplay, F(STR_NONLINEAR_EXTRUSION));
|
||||
SERIAL_ECHOLNPGM(" M592 A", stepper.ne.A, " B", stepper.ne.B, " C", stepper.ne.C);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ void GcodeSuite::M603_report(const bool forReplay/*=true*/) {
|
||||
TERN_(MARLIN_SMALL_BUILD, return);
|
||||
|
||||
report_heading(forReplay, F(STR_FILAMENT_LOAD_UNLOAD));
|
||||
|
||||
#if EXTRUDERS == 1
|
||||
report_echo_start(forReplay);
|
||||
SERIAL_ECHOPGM(" M603 L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length), " ;");
|
||||
|
||||
@@ -160,7 +160,7 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) {
|
||||
report_heading(forReplay, F(STR_DRIVER_STEPPING_MODE));
|
||||
|
||||
auto say_M569 = [](const bool forReplay, FSTR_P const etc=nullptr, const bool eol=false) {
|
||||
if (!forReplay) SERIAL_ECHO_START();
|
||||
report_echo_start(forReplay);
|
||||
SERIAL_ECHOPGM(" M569 S1");
|
||||
if (etc) SERIAL_ECHO(C(' '), etc);
|
||||
if (eol) SERIAL_EOL();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user