Compare commits

..

2 Commits

Author SHA1 Message Date
InsanityAutomation 3e15472e05 Update MarlinCore.cpp 2024-04-10 15:12:02 -04:00
InsanityAutomation 55360141fd Update MarlinCore.cpp 2024-04-07 19:33:27 -04:00
929 changed files with 17606 additions and 37305 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ contact_links:
url: https://www.facebook.com/groups/1049718498464482 url: https://www.facebook.com/groups/1049718498464482
about: Please ask and answer questions here. about: Please ask and answer questions here.
- name: 🕹 Marlin on Discord - name: 🕹 Marlin on Discord
url: https://discord.com/servers/marlin-firmware-461605380783472640 url: https://discord.gg/n5NJ59y
about: Join the Discord server for support and discussion. about: Join the Discord server for support and discussion.
- name: 🔗 Marlin Discussion Forum - name: 🔗 Marlin Discussion Forum
url: https://reprap.org/forum/list.php?415 url: https://reprap.org/forum/list.php?415
+1 -1
View File
@@ -43,7 +43,7 @@ We have a Message Board and a Facebook group where our knowledgable user communi
If chat is more your speed, you can join the MarlinFirmware Discord server: If chat is more your speed, you can join the MarlinFirmware Discord server:
* Use the link https://discord.com/servers/marlin-firmware-461605380783472640 to join up as a General User. * Use the link https://discord.gg/n5NJ59y to join up as a General User.
* Even though our Discord is pretty active, it may take a while for community members to respond — please be patient! * Even though our Discord is pretty active, it may take a while for community members to respond — please be patient!
* Use the `#general` channel for general questions or discussion about Marlin. * Use the `#general` channel for general questions or discussion about Marlin.
* Other channels exist for certain topics or are limited to Patrons. Check the channel list. * Other channels exist for certain topics or are limited to Patrons. Check the channel list.
-73
View File
@@ -1,73 +0,0 @@
#
# ci-unit-tests.yml
# Build and execute unit tests to catch functional issues in code
#
name: CI - Unit Tests
on:
pull_request:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths-ignore:
- config/**
- data/**
- docs/**
- '**/*.md'
push:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths-ignore:
- config/**
- data/**
- docs/**
- '**/*.md'
jobs:
# This runs all unit tests as a single job. While it should be possible to break this up into
# multiple jobs, they currently run quickly and finish long before the compilation tests.
run_unit_tests:
name: Unit Test
# These tests will only be able to run on the bugfix-2.1.x branch, until the next release
# pulls them into additional branches.
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- name: Check out the PR
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Select Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Install PlatformIO
run: |
pip install -U platformio
pio upgrade --dev
pio pkg update --global
- name: Run All Unit Tests
run: |
make unit-test-all-local
-48
View File
@@ -1,48 +0,0 @@
#
# ci-validate-boards.yml
# Validate boards.h to make sure it's all set up correctly
#
name: CI - Validate boards.h
# We can do the on: section as two items, one for pull requests and one for pushes...
on:
pull_request:
branches:
- bugfix-2.1.x
paths:
- 'Marlin/src/core/boards.h'
push:
branches:
- bugfix-2.1.x
paths:
- 'Marlin/src/core/boards.h'
jobs:
validate_pins_files:
name: Validate boards.h
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- name: Check out the PR
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Select Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Validate core/boards.h
run: |
make validate-boards -j
-51
View File
@@ -1,51 +0,0 @@
#
# ci-validate-pins.yml
# Validate that all of the pins files are unchanged by pinsformat.py
#
name: CI - Validate Pins Files
on:
pull_request:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths:
- 'Marlin/src/pins/*/**'
push:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths:
- 'Marlin/src/pins/*/**'
jobs:
validate_pins_files:
name: Validate Pins Files
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- name: Check out the PR
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Select Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Validate all pins files
run: |
make validate-pins -j
@@ -1,9 +1,9 @@
# #
# ci-build-tests.yml # test-builds.yml
# Do test builds to catch compile errors # Do test builds to catch compile errors
# #
name: CI - Build Tests name: CI
on: on:
pull_request: pull_request:
@@ -14,8 +14,6 @@ on:
- config/** - config/**
- data/** - data/**
- docs/** - docs/**
- test/**
- Marlin/tests/**
- '**/*.md' - '**/*.md'
push: push:
branches: branches:
@@ -25,25 +23,21 @@ on:
- config/** - config/**
- data/** - data/**
- docs/** - docs/**
- test/**
- Marlin/tests/**
- '**/*.md' - '**/*.md'
jobs: jobs:
test_builds: test_builds:
name: Build Test name: Run All Tests
if: github.repository == 'MarlinFirmware/Marlin' if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: true
matrix: matrix:
test-platform: test-platform:
# Native # Native
- linux_native - linux_native
- simulator_linux_release
# AVR # AVR
- mega2560 - mega2560
@@ -106,9 +100,9 @@ jobs:
# STM32F4 # STM32F4
- ARMED - ARMED
- BTT_BTT002 - BIGTREE_BTT002
- BTT_GTR_V1_0 - BIGTREE_GTR_V1_0
- BTT_SKR_PRO - BIGTREE_SKR_PRO
- FLYF407ZG - FLYF407ZG
- FYSETC_S6 - FYSETC_S6
- LERDGEK - LERDGEK
@@ -183,13 +177,6 @@ jobs:
pio upgrade --dev pio upgrade --dev
pio pkg update --global pio pkg update --global
- name: Install Simulator dependencies
run: |
sudo apt-get install build-essential
sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-net-dev
sudo apt-get install libglm-dev
- name: Run ${{ matrix.test-platform }} Tests - name: Run ${{ matrix.test-platform }} Tests
run: | run: |
make tests-single-ci TEST_TARGET=${{ matrix.test-platform }} make tests-single-ci TEST_TARGET=${{ matrix.test-platform }}
-1
View File
@@ -125,7 +125,6 @@ vc-fileutils.settings
# Visual Studio Code # Visual Studio Code
.vscode/* .vscode/*
!.vscode/extensions.json !.vscode/extensions.json
*.code-workspace
# Simulation files # Simulation files
imgui.ini imgui.ini
-16
View File
@@ -1,16 +0,0 @@
/**
* Marlin-specific settings for Zed
*
* For a full list of overridable settings, and general information on folder-specific settings,
* see the documentation: https://zed.dev/docs/configuring-zed#settings-files
*/
{
"languages": {
"C": {
"enable_language_server": false
},
"C++": {
"enable_language_server": false
}
}
}
+8 -56
View File
@@ -2,24 +2,17 @@ SCRIPTS_DIR := buildroot/share/scripts
CONTAINER_RT_BIN := docker CONTAINER_RT_BIN := docker
CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
CONTAINER_IMAGE := marlin-dev CONTAINER_IMAGE := marlin-dev
UNIT_TEST_CONFIG ?= default
help: help:
@echo "Tasks for local development:" @echo "Tasks for local development:"
@echo "make marlin : Build Marlin for the configured board" @echo "make marlin : Build marlin for the configured board"
@echo "make format-pins -j : Reformat all pins files (-j for parallel execution)" @echo "make format-pins : Reformat all pins files"
@echo "make validate-pins -j : Validate all pins files, fails if any require reformatting"
@echo "make validate-boards -j : Validate boards.h and pins.h for standards compliance"
@echo "make tests-single-ci : Run a single test from inside the CI" @echo "make tests-single-ci : Run a single test from inside the CI"
@echo "make tests-single-local : Run a single test locally" @echo "make tests-single-local : Run a single test locally"
@echo "make tests-single-local-docker : Run a single test locally, using docker" @echo "make tests-single-local-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally" @echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker" @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 setup-local-docker : Build the local docker image"
@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-docker : Run all code tests locally, using docker"
@echo "make setup-local-docker : Setup local docker using buildx"
@echo "" @echo ""
@echo "Options for testing:" @echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the" @echo " TEST_TARGET Set when running tests-single-*, to select the"
@@ -29,9 +22,6 @@ help:
@echo " run on GitHub CI" @echo " run on GitHub CI"
@echo " ONLY_TEST Limit tests to only those that contain this, or" @echo " ONLY_TEST Limit tests to only those that contain this, or"
@echo " the index of the test (1-based)" @echo " the index of the test (1-based)"
@echo " UNIT_TEST_CONFIG Set the name of the config from the test folder, without"
@echo " the leading number. Default is 'default'". Used with the
@echo " unit-test-single-* tasks"
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value" @echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:" @echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!" @echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
@@ -53,61 +43,23 @@ tests-single-local:
tests-single-local-docker: tests-single-local-docker:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)" $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
tests-all-local: tests-all-local:
@python -c "import yaml" 2>/dev/null || (echo 'pyyaml module is not installed. Install it with "python -m pip install pyyaml"' && exit 1)
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \ export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \ && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& for TEST_TARGET in $$(python $(SCRIPTS_DIR)/get_test_targets.py) ; do \ && for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
if [ "$$TEST_TARGET" = "linux_native" ] && [ "$$(uname)" = "Darwin" ]; then \
echo "Skipping tests for $$TEST_TARGET on macOS" ; \
continue ; \
fi ; \
echo "Running tests for $$TEST_TARGET" ; \
run_tests . $$TEST_TARGET || exit 1 ; \
sleep 5; \
done
tests-all-local-docker: tests-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
unit-test-single-local:
platformio run -t marlin_$(UNIT_TEST_CONFIG) -e linux_native_test
unit-test-single-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local UNIT_TEST_CONFIG=$(UNIT_TEST_CONFIG)
unit-test-all-local:
platformio run -t test-marlin -e linux_native_test
unit-test-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-all-local
setup-local-docker: setup-local-docker:
$(CONTAINER_RT_BIN) buildx build -t $(CONTAINER_IMAGE) -f docker/Dockerfile . $(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h') PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
.PHONY: $(PINS) format-pins validate-pins
$(PINS): %: $(PINS): %:
@echo "Formatting $@" @echo "Formatting $@" && node $(SCRIPTS_DIR)/pinsformat.js $@
@python $(SCRIPTS_DIR)/pinsformat.py $< $@
format-pins: $(PINS) format-pins: $(PINS)
validate-pins: format-pins
@echo "Validating pins files"
@git diff --exit-code || (git status && echo "\nError: Pins files are not formatted correctly. Run \"make format-pins\" to fix.\n" && exit 1)
BOARDS_FILE := Marlin/src/core/boards.h
.PHONY: validate-boards
validate-boards:
@echo "Validating boards.h file"
@python $(SCRIPTS_DIR)/validate_boards.py $(BOARDS_FILE) || (echo "\nError: boards.h file is not valid. Please check and correct it.\n" && exit 1)
+41 -110
View File
@@ -50,7 +50,7 @@
* *
* Calibration Guides: https://reprap.org/wiki/Calibration * Calibration Guides: https://reprap.org/wiki/Calibration
* https://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide * https://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide
* https://web.archive.org/web/20220907014303/sites.google.com/site/repraplogphase/calibration-of-your-reprap * https://web.archive.org/web/20220907014303/https://sites.google.com/site/repraplogphase/calibration-of-your-reprap
* https://youtu.be/wAL9d7FgInk * https://youtu.be/wAL9d7FgInk
* https://teachingtechyt.github.io/calibration.html * https://teachingtechyt.github.io/calibration.html
* *
@@ -61,7 +61,7 @@
// @section info // @section info
// Author info of this build printed to the host during boot and M115 // Author info of this build printed to the host during boot and M115
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Original author or contributor. #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes) //#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
// @section machine // @section machine
@@ -77,7 +77,7 @@
* Serial port -1 is the USB emulated serial port, if available. * Serial port -1 is the USB emulated serial port, if available.
* Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader. * Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader.
* *
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] * :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/ */
#define SERIAL_PORT 0 #define SERIAL_PORT 0
@@ -99,29 +99,19 @@
/** /**
* Select a secondary serial port on the board to use for communication with the host. * Select a secondary serial port on the board to use for communication with the host.
* Currently Ethernet (-2) is only supported on Teensy 4.1 boards. * Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
*/ */
//#define SERIAL_PORT_2 -1 //#define SERIAL_PORT_2 -1
//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE //#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE
/** /**
* Select a third serial port on the board to use for communication with the host. * Select a third serial port on the board to use for communication with the host.
* Currently supported for AVR, DUE, SAMD51, LPC1768/9, STM32/STM32F1/HC32, and Teensy 4.x * Currently only supported for AVR, DUE, LPC1768/9 and STM32/STM32F1
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] * :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/ */
//#define SERIAL_PORT_3 1 //#define SERIAL_PORT_3 1
//#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE //#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE
/**
* Select a serial port to communicate with RS485 protocol
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
*/
//#define RS485_SERIAL_PORT 1
#ifdef RS485_SERIAL_PORT
//#define M485_PROTOCOL 1 // Check your host for protocol compatibility
//#define RS485_BUS_BUFFER_SIZE 128
#endif
// Enable the Bluetooth serial interface on AT90USB devices // Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH //#define BLUETOOTH
@@ -385,15 +375,14 @@
* PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version)
* PRUSA_MMU2 : Průša MMU2 * PRUSA_MMU2 : Průša MMU2
* PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5)
* PRUSA_MMU3 : Průša MMU3 (Requires MK3S extruder with motion sensor and MMU firmware version 3.x.x, EXTRUDERS = 5)
* EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) * EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware)
* EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) * EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware)
* *
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* See additional options in Configuration_adv.h. * See additional options in Configuration_adv.h.
* :["PRUSA_MMU1", "PRUSA_MMU2", "PRUSA_MMU2S", "PRUSA_MMU3", "EXTENDABLE_EMU_MMU2", "EXTENDABLE_EMU_MMU2S"] * :["PRUSA_MMU1", "PRUSA_MMU2", "PRUSA_MMU2S", "EXTENDABLE_EMU_MMU2", "EXTENDABLE_EMU_MMU2S"]
*/ */
//#define MMU_MODEL PRUSA_MMU3 //#define MMU_MODEL PRUSA_MMU2
// @section psu control // @section psu control
@@ -683,7 +672,7 @@
* MPCTEMP : Predictive Model temperature control. (~1.8K without auto-tune) * MPCTEMP : Predictive Model temperature control. (~1.8K without auto-tune)
*/ */
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning #define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
//#define MPCTEMP // See https://marlinfw.org/docs/features/model_predictive_control.html //#define MPCTEMP // ** EXPERIMENTAL ** See https://marlinfw.org/docs/features/model_predictive_control.html
#define PID_MAX 255 // Limit hotend current while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_MAX 255 // Limit hotend current while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#define PID_K1 0.95 // Smoothing factor within any PID loop #define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -714,13 +703,10 @@
* Use a physical model of the hotend to control temperature. When configured correctly this gives * Use a physical model of the hotend to control temperature. When configured correctly this gives
* better responsiveness and stability than PID and removes the need for PID_EXTRUSION_SCALING * better responsiveness and stability than PID and removes the need for PID_EXTRUSION_SCALING
* and PID_FAN_SCALING. Enable MPC_AUTOTUNE and use M306 T to autotune the model. * and PID_FAN_SCALING. Enable MPC_AUTOTUNE and use M306 T to autotune the model.
* @section mpc temp * @section mpctemp
*/ */
#if ENABLED(MPCTEMP) #if ENABLED(MPCTEMP)
#define MPC_AUTOTUNE // Include a method to do MPC auto-tuning (~6.3K bytes of flash) #define MPC_AUTOTUNE // Include a method to do MPC auto-tuning (~6.3K bytes of flash)
#if ENABLED(MPC_AUTOTUNE)
//#define MPC_AUTOTUNE_DEBUG // Enable MPC debug logging (~870 bytes of flash)
#endif
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1.3K bytes of flash) //#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1.3K bytes of flash)
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash) //#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
@@ -802,40 +788,6 @@
//#define BED_LIMIT_SWITCHING // Keep the bed temperature within BED_HYSTERESIS of the target //#define BED_LIMIT_SWITCHING // Keep the bed temperature within BED_HYSTERESIS of the target
#endif #endif
/**
* Peltier Bed - Heating and Cooling
*
* A Peltier device transfers heat from one side to the other in proportion to the amount of
* current flowing through the device and the direction of current flow. So the same device
* can both heat and cool.
*
* When "cooling" in addition to rejecting the heat transferred from the hot side to the cold
* side, the dissipated power (voltage * current) must also be rejected. Be sure to set up a
* fan that can be powered in sync with the Peltier unit.
*
* This feature is only set up to run in bang-bang mode because Peltiers don't handle PWM
* well without filter circuitry.
*
* Since existing 3D printers are made to handle relatively high current for the heated bed,
* we can use the heated bed power pins to control the Peltier power using the same G-codes
* as the heated bed (M140, M190, etc.).
*
* A second GPIO pin is required to control current direction.
* Two configurations are possible: Relay and H-Bridge
*
* (At this time only relay is supported. H-bridge requires 4 MOS switches configured in H-Bridge.)
*
* Power is handled by the bang-bang control loop: 0 or 255.
* Cooling applications are more common than heating, so the pin states are commonly:
* LOW = Heating = Relay Energized
* HIGH = Cooling = Relay in "Normal" state
*/
//#define PELTIER_BED
#if ENABLED(PELTIER_BED)
#define PELTIER_DIR_PIN -1 // Relay control pin for Peltier
#define PELTIER_DIR_HEAT_STATE LOW // The relay pin state that causes the Peltier to heat
#endif
// Add 'M190 R T' for more gradual M190 R bed cooling. // Add 'M190 R T' for more gradual M190 R bed cooling.
//#define BED_ANNEALING_GCODE //#define BED_ANNEALING_GCODE
@@ -876,16 +828,14 @@
// Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element // 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. // and placed inside the small Creality printer enclosure tent.
// //
#define DEFAULT_chamberKp 37.04 #define DEFAULT_chamberKp 37.04
#define DEFAULT_chamberKi 1.40 #define DEFAULT_chamberKi 1.40
#define DEFAULT_chamberKd 655.17 #define DEFAULT_chamberKd 655.17
// M309 P37.04 I1.04 D655.17 // M309 P37.04 I1.04 D655.17
// FIND YOUR OWN: "M303 E-2 C8 S50" to run autotune on the chamber at 50 degreesC for 8 cycles. // FIND YOUR OWN: "M303 E-2 C8 S50" to run autotune on the chamber at 50 degreesC for 8 cycles.
#endif // PIDTEMPCHAMBER #endif // PIDTEMPCHAMBER
// @section pid temp
#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) #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 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 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
@@ -1504,8 +1454,7 @@
* A lightweight, solenoid-driven probe. * A lightweight, solenoid-driven probe.
* For information about this sensor https://github.com/bigtreetech/MicroProbe * For information about this sensor https://github.com/bigtreetech/MicroProbe
* *
* Also requires PROBE_ENABLE_DISABLE * Also requires: PROBE_ENABLE_DISABLE
* With FT_MOTION requires ENDSTOP_INTERRUPTS_FEATURE
*/ */
//#define BIQU_MICROPROBE_V1 // Triggers HIGH //#define BIQU_MICROPROBE_V1 // Triggers HIGH
//#define BIQU_MICROPROBE_V2 // Triggers LOW //#define BIQU_MICROPROBE_V2 // Triggers LOW
@@ -1644,8 +1593,7 @@
// with NOZZLE_AS_PROBE this can be negative for a wider probing area. // with NOZZLE_AS_PROBE this can be negative for a wider probing area.
#define PROBING_MARGIN 10 #define PROBING_MARGIN 10
// X and Y axis travel speed (mm/min) between probes. // X and Y axis travel speed (mm/min) between probes
// Leave undefined to use the average of the current XY homing feedrate.
#define XY_PROBE_FEEDRATE (133*60) #define XY_PROBE_FEEDRATE (133*60)
// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2)
@@ -1676,7 +1624,6 @@
#define PROBE_TARE_DELAY 200 // (ms) Delay after tare before #define PROBE_TARE_DELAY 200 // (ms) Delay after tare before
#define PROBE_TARE_STATE HIGH // State to write pin for tare #define PROBE_TARE_STATE HIGH // State to write pin for tare
//#define PROBE_TARE_PIN PA5 // Override default pin //#define PROBE_TARE_PIN PA5 // Override default pin
//#define PROBE_TARE_MENU // Display a menu item to tare the probe
#if ENABLED(PROBE_ACTIVATION_SWITCH) #if ENABLED(PROBE_ACTIVATION_SWITCH)
//#define PROBE_TARE_ONLY_WHILE_INACTIVE // Fail to tare/probe if PROBE_ACTIVATION_SWITCH is active //#define PROBE_TARE_ONLY_WHILE_INACTIVE // Fail to tare/probe if PROBE_ACTIVATION_SWITCH is active
#endif #endif
@@ -1714,8 +1661,8 @@
* probe Z Offset set with NOZZLE_TO_PROBE_OFFSET, M851, or the LCD. * probe Z Offset set with NOZZLE_TO_PROBE_OFFSET, M851, or the LCD.
* Only integer values >= 1 are valid here. * Only integer values >= 1 are valid here.
* *
* Example: 'M851 Z-5' with a CLEARANCE of 4 => 9mm from bed to nozzle. * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle.
* But: 'M851 Z+1' with a CLEARANCE of 2 => 2mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle.
*/ */
#define Z_CLEARANCE_DEPLOY_PROBE 10 // (mm) Z Clearance for Deploy/Stow #define Z_CLEARANCE_DEPLOY_PROBE 10 // (mm) Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 5 // (mm) Z Clearance between probe points #define Z_CLEARANCE_BETWEEN_PROBES 5 // (mm) Z Clearance between probe points
@@ -1766,8 +1713,6 @@
#define PROBING_BED_TEMP 50 #define PROBING_BED_TEMP 50
#endif #endif
// @section stepper drivers
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
// :{ 0:'Low', 1:'High' } // :{ 0:'Low', 1:'High' }
#define X_ENABLE_ON 0 #define X_ENABLE_ON 0
@@ -1941,8 +1886,6 @@
#endif #endif
/** /**
* @section filament runout sensors
*
* Filament Runout Sensors * Filament Runout Sensors
* Mechanical or opto endstops are used to check for the presence of filament. * Mechanical or opto endstops are used to check for the presence of filament.
* *
@@ -2275,7 +2218,7 @@
#if ENABLED(LCD_BED_TRAMMING) #if ENABLED(LCD_BED_TRAMMING)
#define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
#define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at tramming points #define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at tramming points
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z raise between tramming points #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between tramming points
//#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner //#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner
//#define BED_TRAMMING_USE_PROBE //#define BED_TRAMMING_USE_PROBE
#if ENABLED(BED_TRAMMING_USE_PROBE) #if ENABLED(BED_TRAMMING_USE_PROBE)
@@ -2339,9 +2282,6 @@
// Homing speeds (linear=mm/min, rotational=°/min) // Homing speeds (linear=mm/min, rotational=°/min)
#define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (4*60) } #define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (4*60) }
// Edit homing feedrates with M210 and MarlinUI menu items
//#define EDITABLE_HOMING_FEEDRATE
// Validate that endstops are triggered on homing moves // Validate that endstops are triggered on homing moves
#define VALIDATE_HOMING_ENDSTOPS #define VALIDATE_HOMING_ENDSTOPS
@@ -2468,9 +2408,9 @@
#define PREHEAT_2_TEMP_CHAMBER 35 #define PREHEAT_2_TEMP_CHAMBER 35
#define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255 #define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255
// @section motion
/** /**
* @section nozzle park
*
* Nozzle Park * Nozzle Park
* *
* Park the nozzle at the given XYZ position on idle or G27. * Park the nozzle at the given XYZ position on idle or G27.
@@ -2493,8 +2433,6 @@
#endif #endif
/** /**
* @section nozzle clean
*
* Clean Nozzle Feature * Clean Nozzle Feature
* *
* Adds the G12 command to perform a nozzle cleaning process. * Adds the G12 command to perform a nozzle cleaning process.
@@ -2655,24 +2593,9 @@
//#include "Configuration_Secure.h" // External file with PASSWORD_DEFAULT_VALUE //#include "Configuration_Secure.h" // External file with PASSWORD_DEFAULT_VALUE
#endif #endif
// @section media //=============================================================================
//============================= LCD and SD support ============================
/** //=============================================================================
* SD CARD
*
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
*/
//#define SDSUPPORT
/**
* SD CARD: ENABLE CRC
*
* Use CRC checks and retries on the SD communication.
*/
#if ENABLED(SDSUPPORT)
//#define SD_CHECK_AND_RETRY
#endif
// @section interface // @section interface
@@ -2719,6 +2642,21 @@
*/ */
#define LCD_INFO_SCREEN_STYLE 0 #define LCD_INFO_SCREEN_STYLE 0
/**
* SD CARD
*
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
*/
//#define SDSUPPORT
/**
* SD CARD: ENABLE CRC
*
* Use CRC checks and retries on the SD communication.
*/
//#define SD_CHECK_AND_RETRY
/** /**
* LCD Menu Items * LCD Menu Items
* *
@@ -2847,7 +2785,7 @@
// //
// Original RADDS LCD Display+Encoder+SDCardReader // Original RADDS LCD Display+Encoder+SDCardReader
// https://web.archive.org/web/20200719145306/doku.radds.org/dokumentation/lcd-display/ // https://web.archive.org/web/20200719145306/http://doku.radds.org/dokumentation/lcd-display/
// //
//#define RADDS_DISPLAY //#define RADDS_DISPLAY
@@ -2913,7 +2851,7 @@
// //
// Elefu RA Board Control Panel // Elefu RA Board Control Panel
// https://web.archive.org/web/20140823033947/www.elefu.com/index.php?route=product/product&product_id=53 // https://web.archive.org/web/20140823033947/http://www.elefu.com/index.php?route=product/product&product_id=53
// //
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
@@ -3045,7 +2983,7 @@
// //
// Cartesio UI // Cartesio UI
// https://web.archive.org/web/20180605050442/mauk.cc/webshop/cartesio-shop/electronics/user-interface // https://web.archive.org/web/20180605050442/http://mauk.cc/webshop/cartesio-shop/electronics/user-interface
// //
//#define CARTESIO_UI //#define CARTESIO_UI
@@ -3282,11 +3220,6 @@
// //
//#define ANYCUBIC_LCD_VYPER //#define ANYCUBIC_LCD_VYPER
//
// Sovol SV-06 Resistive Touch Screen
//
//#define SOVOL_SV06_RTS
// //
// 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028 // 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028
// //
@@ -3482,9 +3415,7 @@
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
#if ANY(TFT_CLASSIC_UI, TFT_COLOR_UI) //#define DISABLE_ENCODER // Disable the click encoder, if any
//#define NO_BACK_MENU_ITEM // Don't display a top menu item to go back to the parent menu
#endif
#define TOUCH_SCREEN_CALIBRATION #define TOUCH_SCREEN_CALIBRATION
+109 -239
View File
@@ -47,9 +47,8 @@
* 2 = config.ini - File format for PlatformIO preprocessing. * 2 = config.ini - File format for PlatformIO preprocessing.
* 3 = schema.json - The entire configuration schema. (13 = pattern groups) * 3 = schema.json - The entire configuration schema. (13 = pattern groups)
* 4 = schema.yml - The entire configuration schema. * 4 = schema.yml - The entire configuration schema.
* 5 = Config.h - Minimal configuration by popular demand.
*/ */
//#define CONFIG_EXPORT 105 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml', 5:'Config.h'] //#define CONFIG_EXPORT 2 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml']
//=========================================================================== //===========================================================================
//============================= Thermal Settings ============================ //============================= Thermal Settings ============================
@@ -203,7 +202,7 @@
// //
#if DISABLED(PIDTEMPBED) #if DISABLED(PIDTEMPBED)
#define BED_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control #define BED_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control
#if ANY(BED_LIMIT_SWITCHING, PELTIER_BED) #if ENABLED(BED_LIMIT_SWITCHING)
#define BED_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > BED_HYSTERESIS #define BED_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > BED_HYSTERESIS
#endif #endif
#endif #endif
@@ -304,9 +303,9 @@
* If you get false positives for "Thermal Runaway", increase * If you get false positives for "Thermal Runaway", increase
* THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD * THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
*/ */
#if ALL(HAS_HOTEND, THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 40 // (seconds) #define THERMAL_PROTECTION_PERIOD 40 // (seconds)
#define THERMAL_PROTECTION_HYSTERESIS 4 // (°C) #define THERMAL_PROTECTION_HYSTERESIS 4 // (°C)
//#define ADAPTIVE_FAN_SLOWING // Slow down the part-cooling fan if the temperature drops //#define ADAPTIVE_FAN_SLOWING // Slow down the part-cooling fan if the temperature drops
#if ENABLED(ADAPTIVE_FAN_SLOWING) #if ENABLED(ADAPTIVE_FAN_SLOWING)
@@ -335,7 +334,7 @@
/** /**
* Thermal Protection parameters for the bed are just as above for hotends. * Thermal Protection parameters for the bed are just as above for hotends.
*/ */
#if TEMP_SENSOR_BED && ENABLED(THERMAL_PROTECTION_BED) #if ENABLED(THERMAL_PROTECTION_BED)
#define THERMAL_PROTECTION_BED_PERIOD 20 // (seconds) #define THERMAL_PROTECTION_BED_PERIOD 20 // (seconds)
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // (°C) #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // (°C)
@@ -349,7 +348,7 @@
/** /**
* Thermal Protection parameters for the heated chamber. * Thermal Protection parameters for the heated chamber.
*/ */
#if TEMP_SENSOR_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER) #if ENABLED(THERMAL_PROTECTION_CHAMBER)
#define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // (seconds) #define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // (seconds)
#define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // (°C) #define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // (°C)
@@ -363,7 +362,7 @@
/** /**
* Thermal Protection parameters for the laser cooler. * Thermal Protection parameters for the laser cooler.
*/ */
#if TEMP_SENSOR_COOLER && ENABLED(THERMAL_PROTECTION_COOLER) #if ENABLED(THERMAL_PROTECTION_COOLER)
#define THERMAL_PROTECTION_COOLER_PERIOD 10 // (seconds) #define THERMAL_PROTECTION_COOLER_PERIOD 10 // (seconds)
#define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // (°C) #define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // (°C)
@@ -591,8 +590,6 @@
// Use TEMP_SENSOR_SOC as a trigger for enabling the controller fan // Use TEMP_SENSOR_SOC as a trigger for enabling the controller fan
//#define CONTROLLER_FAN_MIN_SOC_TEMP 40 // (°C) Turn on the fan if the SoC reaches this temperature //#define CONTROLLER_FAN_MIN_SOC_TEMP 40 // (°C) Turn on the fan if the SoC reaches this temperature
#define CONTROLLER_FAN_BED_HEATING // Turn on the fan when heating the bed
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings //#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#if ENABLED(CONTROLLER_FAN_EDITABLE) #if ENABLED(CONTROLLER_FAN_EDITABLE)
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu #define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
@@ -607,8 +604,6 @@
*/ */
//#define FAN_KICKSTART_TIME 100 // (ms) //#define FAN_KICKSTART_TIME 100 // (ms)
//#define FAN_KICKSTART_POWER 180 // 64-255 //#define FAN_KICKSTART_POWER 180 // 64-255
//#define FAN_KICKSTART_LINEAR // Set kickstart time linearly based on the speed, e.g., for 20% (51) it will be FAN_KICKSTART_TIME * 0.2.
// Useful for quick speed up to low speed. Kickstart power must be set to 255.
// Some coolers may require a non-zero "off" state. // Some coolers may require a non-zero "off" state.
//#define FAN_OFF_PWM 1 //#define FAN_OFF_PWM 1
@@ -1084,11 +1079,9 @@
#define HOME_AFTER_G34 #define HOME_AFTER_G34
#endif #endif
/** //
* Assisted Tramming // Add the G35 command to read bed corners to help adjust screws. Requires a bed probe.
* //
* Add the G35 command to measure bed corners and help adjust screws. Requires a bed probe.
*/
//#define ASSISTED_TRAMMING //#define ASSISTED_TRAMMING
#if ENABLED(ASSISTED_TRAMMING) #if ENABLED(ASSISTED_TRAMMING)
@@ -1109,35 +1102,29 @@
//#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment //#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment
/** /**
* Screw Thread. Use one of the following defines: * Screw thread:
* * M3: 30 = Clockwise, 31 = Counter-Clockwise
* M3_CW = M3 Clockwise, M3_CCW = M3 Counter-Clockwise * M4: 40 = Clockwise, 41 = Counter-Clockwise
* M4_CW = M4 Clockwise, M4_CCW = M4 Counter-Clockwise * M5: 50 = Clockwise, 51 = Counter-Clockwise
* M5_CW = M5 Clockwise, M5_CCW = M5 Counter-Clockwise
*
* :{'M3_CW':'M3 Clockwise','M3_CCW':'M3 Counter-Clockwise','M4_CW':'M4 Clockwise','M4_CCW':'M4 Counter-Clockwise','M5_CW':'M5 Clockwise','M5_CCW':'M5 Counter-Clockwise'}
*/ */
#define TRAMMING_SCREW_THREAD M3_CW #define TRAMMING_SCREW_THREAD 30
#endif #endif
// @section motion control // @section motion control
/** /**
* Fixed-time-based Motion Control -- BETA FEATURE * Fixed-time-based Motion Control -- EXPERIMENTAL
* Enable/disable and set parameters with G-code M493. * Enable/disable and set parameters with G-code M493.
* See ft_types.h for named values used by FTM options.
*/ */
//#define FT_MOTION //#define FT_MOTION
#if ENABLED(FT_MOTION) #if ENABLED(FT_MOTION)
//#define FTM_IS_DEFAULT_MOTION // Use FT Motion as the factory default? #define FTM_DEFAULT_MODE ftMotionMode_DISABLED // Default mode of fixed time control. (Enums in ft_types.h)
#define FTM_DEFAULT_DYNFREQ_MODE dynFreqMode_DISABLED // Default mode of dynamic frequency calculation. (DISABLED, Z_BASED, MASS_BASED) #define FTM_DEFAULT_DYNFREQ_MODE dynFreqMode_DISABLED // Default mode of dynamic frequency calculation. (Enums in ft_types.h)
#define FTM_DEFAULT_SHAPER_X ftMotionShaper_NONE // Default shaper mode on X axis (NONE, ZV, ZVD, ZVDD, ZVDDD, EI, 2HEI, 3HEI, MZV) #define FTM_SHAPING_DEFAULT_X_FREQ 37.0f // (Hz) Default peak frequency used by input shapers
#define FTM_DEFAULT_SHAPER_Y ftMotionShaper_NONE // Default shaper mode on Y axis #define FTM_SHAPING_DEFAULT_Y_FREQ 37.0f // (Hz) Default peak frequency used by input shapers
#define FTM_SHAPING_DEFAULT_FREQ_X 37.0f // (Hz) Default peak frequency used by input shapers
#define FTM_SHAPING_DEFAULT_FREQ_Y 37.0f // (Hz) Default peak frequency used by input shapers
#define FTM_LINEAR_ADV_DEFAULT_ENA false // Default linear advance enable (true) or disable (false) #define FTM_LINEAR_ADV_DEFAULT_ENA false // Default linear advance enable (true) or disable (false)
#define FTM_LINEAR_ADV_DEFAULT_K 0.0f // Default linear advance gain. (Acceleration-based scaling factor.) #define FTM_LINEAR_ADV_DEFAULT_K 0.0f // Default linear advance gain
#define FTM_SHAPING_ZETA_X 0.1f // Zeta used by input shapers for X axis #define FTM_SHAPING_ZETA_X 0.1f // Zeta used by input shapers for X axis
#define FTM_SHAPING_ZETA_Y 0.1f // Zeta used by input shapers for Y axis #define FTM_SHAPING_ZETA_Y 0.1f // Zeta used by input shapers for Y axis
@@ -1160,13 +1147,18 @@
#define FTM_FS 1000 // (Hz) Frequency for trajectory generation. (Reciprocal of FTM_TS) #define FTM_FS 1000 // (Hz) Frequency for trajectory generation. (Reciprocal of FTM_TS)
#define FTM_TS 0.001f // (s) Time step for trajectory generation. (Reciprocal of FTM_FS) #define FTM_TS 0.001f // (s) Time step for trajectory generation. (Reciprocal of FTM_FS)
// These values may be configured to adjust the duration of loop().
#define FTM_STEPS_PER_LOOP 60 // Number of stepper commands to generate each loop()
#define FTM_POINTS_PER_LOOP 100 // Number of trajectory points to generate each loop()
#if DISABLED(COREXY) #if DISABLED(COREXY)
#define FTM_STEPPER_FS 20000 // (Hz) Frequency for stepper I/O update #define FTM_STEPPER_FS 20000 // (Hz) Frequency for stepper I/O update
// Use this to adjust the time required to consume the command buffer. // Use this to adjust the time required to consume the command buffer.
// Try increasing this value if stepper motion is choppy. // Try increasing this value if stepper motion is choppy.
#define FTM_STEPPERCMD_BUFF_SIZE 3000 // Size of the stepper command buffers #define FTM_STEPPERCMD_BUFF_SIZE 3000 // Size of the stepper command buffers
// (FTM_STEPS_PER_LOOP * FTM_POINTS_PER_LOOP) is a good start
// If you run out of memory, fall back to 3000 and increase progressively
#else #else
// CoreXY motion needs a larger buffer size. These values are based on our testing. // CoreXY motion needs a larger buffer size. These values are based on our testing.
#define FTM_STEPPER_FS 30000 #define FTM_STEPPER_FS 30000
@@ -1188,24 +1180,29 @@
#endif #endif
/** /**
* Input Shaping * Input Shaping -- EXPERIMENTAL
* *
* Zero Vibration (ZV) Input Shaping for X and/or Y movements. * Zero Vibration (ZV) Input Shaping for X and/or Y movements.
* *
* This option uses a lot of SRAM for the step buffer. The buffer size is * This option uses a lot of SRAM for the step buffer. The buffer size is
* calculated automatically from SHAPING_FREQ_[XYZ], DEFAULT_AXIS_STEPS_PER_UNIT, * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT,
* DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can
* be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE. * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE.
* The higher the frequency and the lower the feedrate, the smaller the buffer. * The higher the frequency and the lower the feedrate, the smaller the buffer.
* If the buffer is too small at runtime, input shaping will have reduced * If the buffer is too small at runtime, input shaping will have reduced
* effectiveness during high speed movements. * effectiveness during high speed movements.
* *
* Tune with M593 D<factor> F<frequency> * Tune with M593 D<factor> F<frequency>:
*
* D<factor> Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes.
* F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes.
* T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet)
* X<1> Set the given parameters only for the X axis.
* Y<1> Set the given parameters only for the Y axis.
*/ */
//#define INPUT_SHAPING_X //#define INPUT_SHAPING_X
//#define INPUT_SHAPING_Y //#define INPUT_SHAPING_Y
//#define INPUT_SHAPING_Z #if ANY(INPUT_SHAPING_X, INPUT_SHAPING_Y)
#if ANY(INPUT_SHAPING_X, INPUT_SHAPING_Y, INPUT_SHAPING_Z)
#if ENABLED(INPUT_SHAPING_X) #if ENABLED(INPUT_SHAPING_X)
#define SHAPING_FREQ_X 40.0 // (Hz) The default dominant resonant frequency on the X axis. #define SHAPING_FREQ_X 40.0 // (Hz) The default dominant resonant frequency on the X axis.
#define SHAPING_ZETA_X 0.15 // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). #define SHAPING_ZETA_X 0.15 // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping).
@@ -1214,10 +1211,6 @@
#define SHAPING_FREQ_Y 40.0 // (Hz) The default dominant resonant frequency on the Y axis. #define SHAPING_FREQ_Y 40.0 // (Hz) The default dominant resonant frequency on the Y axis.
#define SHAPING_ZETA_Y 0.15 // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). #define SHAPING_ZETA_Y 0.15 // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping).
#endif #endif
#if ENABLED(INPUT_SHAPING_Z)
#define SHAPING_FREQ_Z 40.0 // (Hz) The default dominant resonant frequency on the Z axis.
#define SHAPING_ZETA_Z 0.15 // Damping ratio of the Z axis (range: 0.0 = no damping to 1.0 = critical damping).
#endif
//#define SHAPING_MIN_FREQ 20.0 // (Hz) By default the minimum of the shaping frequencies. Override to affect SRAM usage. //#define SHAPING_MIN_FREQ 20.0 // (Hz) By default the minimum of the shaping frequencies. Override to affect SRAM usage.
//#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage. //#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage.
//#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters.
@@ -1339,6 +1332,8 @@
//#define CALIBRATION_SCRIPT_PRE "M117 Starting Auto-Calibration\nT0\nG28\nG12\nM117 Calibrating..." //#define CALIBRATION_SCRIPT_PRE "M117 Starting Auto-Calibration\nT0\nG28\nG12\nM117 Calibrating..."
//#define CALIBRATION_SCRIPT_POST "M500\nM117 Calibration data saved" //#define CALIBRATION_SCRIPT_POST "M500\nM117 Calibration data saved"
#define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm
#define CALIBRATION_FEEDRATE_SLOW 60 // mm/min #define CALIBRATION_FEEDRATE_SLOW 60 // mm/min
#define CALIBRATION_FEEDRATE_FAST 1200 // mm/min #define CALIBRATION_FEEDRATE_FAST 1200 // mm/min
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min
@@ -1497,17 +1492,8 @@
#define FEEDRATE_CHANGE_BEEP_FREQUENCY 440 #define FEEDRATE_CHANGE_BEEP_FREQUENCY 440
#endif #endif
/**
* Probe Offset Wizard
* Add a Probe Z Offset calibration option to the LCD menu.
* Use this helper to get a perfect 'M851 Z' probe offset.
* When launched this powerful wizard:
* - Measures the bed height at the configured position with the probe.
* - Moves the nozzle to the same position for a "paper" measurement.
* - The difference is used to set the probe Z offset.
*/
#if HAS_BED_PROBE && ANY(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI) #if HAS_BED_PROBE && ANY(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
//#define PROBE_OFFSET_WIZARD //#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu
#if ENABLED(PROBE_OFFSET_WIZARD) #if ENABLED(PROBE_OFFSET_WIZARD)
/** /**
* Enable to init the Probe Z-Offset when starting the Wizard. * Enable to init the Probe Z-Offset when starting the Wizard.
@@ -1524,10 +1510,6 @@
#if HAS_MARLINUI_MENU #if HAS_MARLINUI_MENU
#if HAS_BED_PROBE #if HAS_BED_PROBE
// Show Deploy / Stow Probe options in the Motion menu.
#define PROBE_DEPLOY_STOW_MENU
// Add calibration in the Probe Offsets menu to compensate for X-axis twist. // Add calibration in the Probe Offsets menu to compensate for X-axis twist.
//#define X_AXIS_TWIST_COMPENSATION //#define X_AXIS_TWIST_COMPENSATION
#if ENABLED(X_AXIS_TWIST_COMPENSATION) #if ENABLED(X_AXIS_TWIST_COMPENSATION)
@@ -1542,6 +1524,8 @@
#define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points
#endif #endif
// Show Deploy / Stow Probe options in the Motion menu.
#define PROBE_DEPLOY_STOW_MENU
#endif #endif
// Include a page of printer information in the LCD Main Menu // Include a page of printer information in the LCD Main Menu
@@ -1572,9 +1556,6 @@
// BACK menu items keep the highlight at the top // BACK menu items keep the highlight at the top
//#define TURBO_BACK_MENU_ITEM //#define TURBO_BACK_MENU_ITEM
// BACK menu items show "Back" instead of the previous menu name
//#define GENERIC_BACK_MENU_ITEM
// Insert a menu for preheating at the top level to allow for quick access // Insert a menu for preheating at the top level to allow for quick access
//#define PREHEAT_SHORTCUT_MENU_ITEM //#define PREHEAT_SHORTCUT_MENU_ITEM
@@ -1603,7 +1584,7 @@
#if HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of flash. //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of flash.
#endif #endif
#if ANY(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, HAS_MARLINUI_HD44780) #if ANY(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE)
//#define SHOW_CUSTOM_BOOTSCREEN // Show the bitmap in Marlin/_Bootscreen.h on startup. //#define SHOW_CUSTOM_BOOTSCREEN // Show the bitmap in Marlin/_Bootscreen.h on startup.
#endif #endif
#endif #endif
@@ -2349,7 +2330,6 @@
* *
* Control extrusion rate based on instantaneous extruder velocity. Can be used to correct for * Control extrusion rate based on instantaneous extruder velocity. Can be used to correct for
* underextrusion at high extruder speeds that are otherwise well-behaved (i.e., not skipping). * underextrusion at high extruder speeds that are otherwise well-behaved (i.e., not skipping).
* For better results also enable ADAPTIVE_STEP_SMOOTHING.
*/ */
//#define NONLINEAR_EXTRUSION //#define NONLINEAR_EXTRUSION
@@ -2577,28 +2557,27 @@
//#define MINIMUM_STEPPER_PRE_DIR_DELAY 650 //#define MINIMUM_STEPPER_PRE_DIR_DELAY 650
/** /**
* Minimum stepper driver pulse width (in ns) * Minimum stepper driver pulse width (in µs)
* If undefined, these defaults (from Conditionals-4-adv.h) apply: * 0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers
* 100 : Minimum for TMC2xxx stepper drivers * 0 : Minimum 500ns for LV8729, adjusted in stepper.h
* 500 : Minimum for LV8729 * 1 : Minimum for A4988 and A5984 stepper drivers
* 1000 : Minimum for A4988 and A5984 stepper drivers * 2 : Minimum for DRV8825 stepper drivers
* 2000 : Minimum for DRV8825 stepper drivers * 3 : Minimum for TB6600 stepper drivers
* 3000 : Minimum for TB6600 stepper drivers * 30 : Minimum for TB6560 stepper drivers
* 30000 : Minimum for TB6560 stepper drivers
* *
* Override the default value based on the driver type set in Configuration.h. * Override the default value based on the driver type set in Configuration.h.
*/ */
//#define MINIMUM_STEPPER_PULSE_NS 2000 //#define MINIMUM_STEPPER_PULSE 2
/** /**
* Maximum stepping rate (in Hz) the stepper driver allows * Maximum stepping rate (in Hz) the stepper driver allows
* If undefined, these defaults (from Conditionals-4-adv.h) apply: * If undefined, defaults to 1MHz / (2 * MINIMUM_STEPPER_PULSE)
* 5000000 : Maximum for TMC2xxx stepper drivers * 5000000 : Maximum for TMC2xxx stepper drivers
* 1000000 : Maximum for LV8729 stepper driver * 1000000 : Maximum for LV8729 stepper driver
* 500000 : Maximum for A4988 stepper driver * 500000 : Maximum for A4988 stepper driver
* 250000 : Maximum for DRV8825 stepper driver * 250000 : Maximum for DRV8825 stepper driver
* 150000 : Maximum for TB6600 stepper driver * 150000 : Maximum for TB6600 stepper driver
* 15000 : Maximum for TB6560 stepper driver * 15000 : Maximum for TB6560 stepper driver
* *
* Override the default value based on the driver type set in Configuration.h. * Override the default value based on the driver type set in Configuration.h.
*/ */
@@ -2719,14 +2698,14 @@
* This feature is EXPERIMENTAL so use with caution and test thoroughly. * This feature is EXPERIMENTAL so use with caution and test thoroughly.
* Enable this option to receive data on the serial ports via the onboard DMA * Enable this option to receive data on the serial ports via the onboard DMA
* controller for more stable and reliable high-speed serial communication. * controller for more stable and reliable high-speed serial communication.
* Support is currently limited to some STM32 MCUs and all HC32 MCUs. * Only some STM32 MCUs are currently supported.
* Note: This has no effect on emulated USB serial ports. * Note: This has no effect on emulated USB serial ports.
*/ */
//#define SERIAL_DMA //#define SERIAL_DMA
/** /**
* Set the number of proportional font spaces required to fill up a typical character space. * Set the number of proportional font spaces required to fill up a typical character space.
* This can help to better align the output of commands like 'G29 O' Mesh Output. * This can help to better align the output of commands like `G29 O` Mesh Output.
* *
* For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0.
* Otherwise, adjust according to your client and font. * Otherwise, adjust according to your client and font.
@@ -2991,7 +2970,7 @@
#if AXIS_IS_TMC_CONFIG(X) #if AXIS_IS_TMC_CONFIG(X)
#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
#define X_CURRENT_HOME X_CURRENT // (mA) RMS current for homing. (Typically lower than *_CURRENT.) #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing
#define X_MICROSTEPS 16 // 0..256 #define X_MICROSTEPS 16 // 0..256
#define X_RSENSE 0.11 #define X_RSENSE 0.11
#define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
@@ -3201,13 +3180,6 @@
//#define E7_HOLD_MULTIPLIER 0.5 //#define E7_HOLD_MULTIPLIER 0.5
#endif #endif
/**
* Use the homing current for all probing. (e.g., Current may be reduced to the
* point where a collision makes the motor skip instead of damaging the bed,
* though this is unlikely to save delicate probes from being damaged.
*/
//#define PROBING_USE_CURRENT_HOME
// @section tmc/spi // @section tmc/spi
/** /**
@@ -3472,7 +3444,7 @@
/** /**
* Step on both rising and falling edge signals (as with a square wave). * Step on both rising and falling edge signals (as with a square wave).
*/ */
#define EDGE_STEPPING //#define EDGE_STEPPING
/** /**
* Enable M122 debugging command for TMC stepper drivers. * Enable M122 debugging command for TMC stepper drivers.
@@ -3554,7 +3526,7 @@
//#define PHOTOGRAPH_PIN 23 //#define PHOTOGRAPH_PIN 23
// Canon Hack Development Kit // Canon Hack Development Kit
// https://web.archive.org/web/20200920094805/captain-slow.dk/2014/03/09/3d-printing-timelapses/ // https://web.archive.org/web/20200920094805/https://captain-slow.dk/2014/03/09/3d-printing-timelapses/
//#define CHDK_PIN 4 //#define CHDK_PIN 4
// Optional second move with delay to trigger the camera shutter // Optional second move with delay to trigger the camera shutter
@@ -4289,8 +4261,7 @@
/** /**
* Instant freeze / unfreeze functionality * Instant freeze / unfreeze functionality
* Potentially useful for rapid stop that allows being resumed. Halts stepper movement. * Potentially useful for emergency stop that allows being resumed.
* Note this does NOT pause spindles, lasers, fans, heaters or any other auxiliary device.
* @section interface * @section interface
*/ */
//#define FREEZE_FEATURE //#define FREEZE_FEATURE
@@ -4371,7 +4342,7 @@
* Extras for an ESP32-based motherboard with WIFISUPPORT * Extras for an ESP32-based motherboard with WIFISUPPORT
* These options don't apply to add-on WiFi modules based on ESP32 WiFi101. * These options don't apply to add-on WiFi modules based on ESP32 WiFi101.
*/ */
#if ANY(WIFISUPPORT, ESP3D_WIFISUPPORT) #if ENABLED(WIFISUPPORT)
//#define WEBSUPPORT // Start a webserver (which may include auto-discovery) using SPIFFS //#define WEBSUPPORT // Start a webserver (which may include auto-discovery) using SPIFFS
//#define OTASUPPORT // Support over-the-air firmware updates //#define OTASUPPORT // Support over-the-air firmware updates
//#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
@@ -4407,81 +4378,58 @@
//#define E_MUX0_PIN 40 // Always Required //#define E_MUX0_PIN 40 // Always Required
//#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs //#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs
//#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs //#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs
#elif HAS_PRUSA_MMU2
// Serial port used for communication with MMU2.
#define MMU2_SERIAL_PORT 2
#elif HAS_PRUSA_MMU2 || HAS_PRUSA_MMU3 // Use hardware reset for MMU if a pin is defined for it
// Common settings for MMU2/MMU2S/MMU3 //#define MMU2_RST_PIN 23
// Serial port used for communication with MMU2/MMU2S/MMU3.
#define MMU_SERIAL_PORT 2
#define MMU_BAUD 115200
//#define MMU_RST_PIN 23 // Define this pin to use Hardware Reset for MMU2/MMU2S/MMU3 // Enable if the MMU2 has 12V stepper motors (MMU2 Firmware 1.0.2 and up)
//#define MMU2_MODE_12V
//#define MMU_MENUS // Add an LCD menu for MMU2/MMU2S/MMU3 // G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600"
//#define MMU_DEBUG // Write debug info to serial output // Add an LCD menu for MMU2
//#define MMU2_MENUS
// Options pertaining to MMU2 and MMU2S // Settings for filament load / unload from the LCD menu.
#if HAS_PRUSA_MMU2 // This is for Průša MK3-style extruders. Customize for your hardware.
// Enable if the MMU2 has 12V stepper motors (MMU2 Firmware 1.0.2 and up) #define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0
//#define MMU2_MODE_12V #define MMU2_LOAD_TO_NOZZLE_SEQUENCE \
{ 7.2, 1145 }, \
{ 14.4, 871 }, \
{ 36.0, 1393 }, \
{ 14.4, 871 }, \
{ 50.0, 198 }
// Settings for filament load / unload from the LCD menu. #define MMU2_RAMMING_SEQUENCE \
// This is for Průša MK3-style extruders. Customize for your hardware. { 1.0, 1000 }, \
#define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0 { 1.0, 1500 }, \
{ 2.0, 2000 }, \
// G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout { 1.5, 3000 }, \
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600" { 2.5, 4000 }, \
{ -15.0, 5000 }, \
// MMU2 sequences use mm/min. Not compatible with MMU3, which use mm/sec. { -14.0, 1200 }, \
#define MMU2_LOAD_TO_NOZZLE_SEQUENCE \ { -6.0, 600 }, \
{ 4.4, 871 }, \ { 10.0, 700 }, \
{ 10.0, 1393 }, \ { -10.0, 400 }, \
{ 4.4, 871 }, \ { -50.0, 2000 }
{ 10.0, 198 }
#define MMU2_RAMMING_SEQUENCE \
{ 1.0, 1000 }, \
{ 1.0, 1500 }, \
{ 2.0, 2000 }, \
{ 1.5, 3000 }, \
{ 2.5, 4000 }, \
{ -15.0, 5000 }, \
{ -14.0, 1200 }, \
{ -6.0, 600 }, \
{ 10.0, 700 }, \
{ -10.0, 400 }, \
{ -50.0, 2000 }
#endif // HAS_PRUSA_MMU2
/** /**
* Options pertaining to MMU2S devices * Using a sensor like the MMU2S
* Requires the MK3S extruder with a sensor at the extruder idler, like the MMU2S. * This mode requires a MK3S extruder with a sensor at the extruder idler, like the MMU2S.
* See https://help.prusa3d.com/guide/3b-mk3s-mk2-5s-extruder-upgrade_41560#42048, step 11 * See https://help.prusa3d.com/guide/3b-mk3s-mk2-5s-extruder-upgrade_41560#42048, step 11
*/ */
#if HAS_PRUSA_MMU2S #if HAS_PRUSA_MMU2S
#define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries) #define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries)
/**
* This is called after the filament runout sensor is triggered to check if
* the filament has been loaded properly by moving the filament back and
* forth to see if the filament runout sensor is going to get triggered
* again, which should not occur if the filament is properly loaded.
*
* Thus, the MMU2_CAN_LOAD_SEQUENCE should contain some forward and
* backward moves. The forward moves should be greater than the backward
* moves.
*
* This is useless if your filament runout sensor is way behind the gears.
* In that case use {0, MMU2_CAN_LOAD_FEEDRATE}
*
* Adjust MMU2_CAN_LOAD_SEQUENCE according to your setup.
*/
#define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min) #define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min)
#define MMU2_CAN_LOAD_SEQUENCE \ #define MMU2_CAN_LOAD_SEQUENCE \
{ 5.0, MMU2_CAN_LOAD_FEEDRATE }, \ { 0.1, MMU2_CAN_LOAD_FEEDRATE }, \
{ 15.0, MMU2_CAN_LOAD_FEEDRATE }, \ { 60.0, MMU2_CAN_LOAD_FEEDRATE }, \
{ -10.0, MMU2_CAN_LOAD_FEEDRATE } { -52.0, MMU2_CAN_LOAD_FEEDRATE }
#define MMU2_CAN_LOAD_RETRACT 6.0 // (mm) Keep under the distance between Load Sequence values #define MMU2_CAN_LOAD_RETRACT 6.0 // (mm) Keep under the distance between Load Sequence values
#define MMU2_CAN_LOAD_DEVIATION 0.8 // (mm) Acceptable deviation #define MMU2_CAN_LOAD_DEVIATION 0.8 // (mm) Acceptable deviation
@@ -4492,90 +4440,10 @@
// Continue unloading if sensor detects filament after the initial unload move // Continue unloading if sensor detects filament after the initial unload move
//#define MMU_IR_UNLOAD_MOVE //#define MMU_IR_UNLOAD_MOVE
#else
#elif HAS_PRUSA_MMU3
// MMU3 settings
#define MMU3_HAS_CUTTER // Enable cutter related functionality
#define MMU3_MAX_RETRIES 3 // Number of retries (total time = timeout*retries)
// As discussed with our PrusaSlicer profile specialist
// - ToolChange shall not try to push filament into the very tip of the nozzle
// to have some space for additional G-code to tune the extruded filament length
// in the profile
// Beware - this value is used to initialize the MMU logic layer - it will be sent to the MMU upon line up (written into its 8bit register 0x0b)
// However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething).
// The printer intercepts such a call and sets its extra load distance to match the new value as well.
#define MMU3_FILAMENT_SENSOR_E_POSITION 0 // (mm)
#define _MMU3_LOAD_DISTANCE_PAST_GEARS 5 // (mm)
#define MMU3_TOOL_CHANGE_LOAD_LENGTH (MMU3_FILAMENT_SENSOR_E_POSITION + _MMU3_LOAD_DISTANCE_PAST_GEARS) // (mm)
#define MMU3_LOAD_TO_NOZZLE_FEED_RATE 20.0 // (mm/s)
#define MMU3_VERIFY_LOAD_TO_NOZZLE_FEED_RATE 50.0 // (mm/s)
#define _MMU3_VERIFY_LOAD_TO_NOZZLE_TWEAK -5.0 // (mm) Amount to adjust the length for verifying load-to-nozzle
// The first thing the MMU does is initialize its axis.
// Meanwhile the E-motor will unload 20mm of filament in about 1 second.
#define MMU3_RETRY_UNLOAD_TO_FINDA_LENGTH 80.0 // (mm)
#define MMU3_RETRY_UNLOAD_TO_FINDA_FEED_RATE 80.0 // (mm/s)
// After loading a new filament, the printer will extrude this length of filament
// then retract to the original position. This is used to check if the filament sensor
// reading flickers or filament is jammed.
#define _MMU_EXTRUDER_PTFE_LENGTH 42.3 // (mm)
#define _MMU_EXTRUDER_HEATBREAK_LENGTH 17.7 // (mm)
#define MMU3_CHECK_FILAMENT_PRESENCE_EXTRUSION_LENGTH (MMU3_FILAMENT_SENSOR_E_POSITION + _MMU_EXTRUDER_PTFE_LENGTH + _MMU_EXTRUDER_HEATBREAK_LENGTH + _MMU3_VERIFY_LOAD_TO_NOZZLE_TWEAK) // (mm)
/** /**
* SpoolJoin Consumes All Filament -- EXPERIMENTAL * MMU1 Extruder Sensor
*
* SpoolJoin normally triggers when FINDA sensor untriggers while printing.
* This is the default behaviour and it doesn't consume all the filament
* before triggering a filament change. This leaves some filament in the
* current slot and before switching to the next slot it is unloaded.
*
* Enabling this option will trigger the filament change when both FINDA
* and Filament Runout Sensor triggers during the print and it allows the
* filament in the current slot to be completely consumed before doing the
* filament change. But this can cause problems as a little bit of filament
* will be left between the extruder gears (thinking that the filament
* sensor is triggered through the gears) and the end of the PTFE tube and
* can cause filament load issues.
*/
//#define MMU3_SPOOL_JOIN_CONSUMES_ALL_FILAMENT
// MMU3 sequences use mm/sec. Not compatible with MMU2 which use mm/min.
#define MMU3_LOAD_TO_NOZZLE_SEQUENCE \
{ _MMU_EXTRUDER_PTFE_LENGTH, MMM_TO_MMS(810) }, /* (13.5 mm/s) Fast load ahead of heatbreak */ \
{ _MMU_EXTRUDER_HEATBREAK_LENGTH, MMM_TO_MMS(198) } /* ( 3.3 mm/s) Slow load after heatbreak */
#define MMU3_RAMMING_SEQUENCE \
{ 0.2816, MMM_TO_MMS(1339.0) }, \
{ 0.3051, MMM_TO_MMS(1451.0) }, \
{ 0.3453, MMM_TO_MMS(1642.0) }, \
{ 0.3990, MMM_TO_MMS(1897.0) }, \
{ 0.4761, MMM_TO_MMS(2264.0) }, \
{ 0.5767, MMM_TO_MMS(2742.0) }, \
{ 0.5691, MMM_TO_MMS(3220.0) }, \
{ 0.1081, MMM_TO_MMS(3220.0) }, \
{ 0.7644, MMM_TO_MMS(3635.0) }, \
{ 0.8248, MMM_TO_MMS(3921.0) }, \
{ 0.8483, MMM_TO_MMS(4033.0) }, \
{ -15.0, MMM_TO_MMS(6000.0) }, \
{ -24.5, MMM_TO_MMS(1200.0) }, \
{ -7.0, MMM_TO_MMS( 600.0) }, \
{ -3.5, MMM_TO_MMS( 360.0) }, \
{ 20.0, MMM_TO_MMS( 454.0) }, \
{ -20.0, MMM_TO_MMS( 303.0) }, \
{ -35.0, MMM_TO_MMS(2000.0) }
#else // MMU2 (not MMU2S)
/**
* MMU2 Extruder Sensor
* *
* Support for a Průša (or other) IR Sensor to detect filament near the extruder * Support for a Průša (or other) IR Sensor to detect filament near the extruder
* and make loading more reliable. Suitable for an extruder equipped with a filament * and make loading more reliable. Suitable for an extruder equipped with a filament
@@ -4585,14 +4453,16 @@
* move up to the gears. If no filament is detected, the MMU2 can make some more attempts. * move up to the gears. If no filament is detected, the MMU2 can make some more attempts.
* If all attempts fail, a filament runout will be triggered. * If all attempts fail, a filament runout will be triggered.
*/ */
//#define MMU2_EXTRUDER_SENSOR //#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU2_EXTRUDER_SENSOR) #if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU2_LOADING_ATTEMPTS_NR 5 // Number of times to try loading filament before failure #define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail
#endif #endif
#endif #endif
#endif // HAS_PRUSA_MMU2 || HAS_PRUSA_MMU3 //#define MMU2_DEBUG // Write debug info to serial output
#endif // HAS_PRUSA_MMU2
/** /**
* Advanced Print Counter settings * Advanced Print Counter settings
+73 -104
View File
@@ -187,17 +187,6 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1033)
# RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan) # RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
else ifeq ($(HARDWARE_MOTHERBOARD),1034) else ifeq ($(HARDWARE_MOTHERBOARD),1034)
# RAMPS 1.6+ (Power outputs: Hotend, Fan, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1035)
# RAMPS 1.6+ (Power outputs: Hotend0, Hotend1, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1036)
# RAMPS 1.6+ (Power outputs: Hotend, Fan0, Fan1)
else ifeq ($(HARDWARE_MOTHERBOARD),1037)
# RAMPS 1.6+ (Power outputs: Hotend0, Hotend1, Fan)
else ifeq ($(HARDWARE_MOTHERBOARD),1038)
# RAMPS 1.6+ (Power outputs: Spindle, Controller Fan)
else ifeq ($(HARDWARE_MOTHERBOARD),1039)
# #
# RAMPS Derivatives - ATmega1280, ATmega2560 # RAMPS Derivatives - ATmega1280, ATmega2560
# #
@@ -232,113 +221,108 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1112)
else ifeq ($(HARDWARE_MOTHERBOARD),1113) else ifeq ($(HARDWARE_MOTHERBOARD),1113)
# BigTreeTech or BIQU KFB2.0 # BigTreeTech or BIQU KFB2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1114) else ifeq ($(HARDWARE_MOTHERBOARD),1114)
# Zonestar zrib V2.0 (Chinese RAMPS replica) # zrib V2.0 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1115) else ifeq ($(HARDWARE_MOTHERBOARD),1115)
# Zonestar zrib V5.2 (Chinese RAMPS replica) # zrib V5.2 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1116) else ifeq ($(HARDWARE_MOTHERBOARD),1116)
# Zonestar zrib V5.3 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Felix 2.0+ Electronics Board (RAMPS like) # Felix 2.0+ Electronics Board (RAMPS like)
else ifeq ($(HARDWARE_MOTHERBOARD),1118) else ifeq ($(HARDWARE_MOTHERBOARD),1117)
# Invent-A-Part RigidBoard # Invent-A-Part RigidBoard
else ifeq ($(HARDWARE_MOTHERBOARD),1119) else ifeq ($(HARDWARE_MOTHERBOARD),1118)
# Invent-A-Part RigidBoard V2 # Invent-A-Part RigidBoard V2
else ifeq ($(HARDWARE_MOTHERBOARD),1120) else ifeq ($(HARDWARE_MOTHERBOARD),1119)
# Sainsmart 2-in-1 board # Sainsmart 2-in-1 board
else ifeq ($(HARDWARE_MOTHERBOARD),1121) else ifeq ($(HARDWARE_MOTHERBOARD),1120)
# Ultimaker # Ultimaker
else ifeq ($(HARDWARE_MOTHERBOARD),1122) else ifeq ($(HARDWARE_MOTHERBOARD),1121)
# Ultimaker (Older electronics. Pre 1.5.4. This is rare) # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
else ifeq ($(HARDWARE_MOTHERBOARD),1123) else ifeq ($(HARDWARE_MOTHERBOARD),1122)
MCU ?= atmega1280 MCU ?= atmega1280
PROG_MCU ?= m1280 PROG_MCU ?= m1280
# Azteeg X3 # Azteeg X3
else ifeq ($(HARDWARE_MOTHERBOARD),1124) else ifeq ($(HARDWARE_MOTHERBOARD),1123)
# Azteeg X3 Pro # Azteeg X3 Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1125) else ifeq ($(HARDWARE_MOTHERBOARD),1124)
# Ultimainboard 2.x (Uses TEMP_SENSOR 20) # Ultimainboard 2.x (Uses TEMP_SENSOR 20)
else ifeq ($(HARDWARE_MOTHERBOARD),1126) else ifeq ($(HARDWARE_MOTHERBOARD),1125)
# Rumba # Rumba
else ifeq ($(HARDWARE_MOTHERBOARD),1127) else ifeq ($(HARDWARE_MOTHERBOARD),1126)
# Raise3D N series Rumba derivative # Raise3D N series Rumba derivative
else ifeq ($(HARDWARE_MOTHERBOARD),1128) else ifeq ($(HARDWARE_MOTHERBOARD),1127)
# Rapide Lite 200 (v1, low-cost RUMBA clone with drv) # Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
else ifeq ($(HARDWARE_MOTHERBOARD),1129) else ifeq ($(HARDWARE_MOTHERBOARD),1128)
# Formbot T-Rex 2 Plus # Formbot T-Rex 2 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1130) else ifeq ($(HARDWARE_MOTHERBOARD),1129)
# Formbot T-Rex 3 # Formbot T-Rex 3
else ifeq ($(HARDWARE_MOTHERBOARD),1131) else ifeq ($(HARDWARE_MOTHERBOARD),1130)
# Formbot Raptor # Formbot Raptor
else ifeq ($(HARDWARE_MOTHERBOARD),1132) else ifeq ($(HARDWARE_MOTHERBOARD),1131)
# Formbot Raptor 2 # Formbot Raptor 2
else ifeq ($(HARDWARE_MOTHERBOARD),1133) else ifeq ($(HARDWARE_MOTHERBOARD),1132)
# bq ZUM Mega 3D # bq ZUM Mega 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1134) else ifeq ($(HARDWARE_MOTHERBOARD),1133)
# MakeBoard Mini v2.1.2 by MicroMake # MakeBoard Mini v2.1.2 by MicroMake
else ifeq ($(HARDWARE_MOTHERBOARD),1135) else ifeq ($(HARDWARE_MOTHERBOARD),1134)
# TriGorilla Anycubic version 1.3-based on RAMPS EFB # TriGorilla Anycubic version 1.3-based on RAMPS EFB
else ifeq ($(HARDWARE_MOTHERBOARD),1136) else ifeq ($(HARDWARE_MOTHERBOARD),1135)
# ... Ver 1.4 # ... Ver 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1137) else ifeq ($(HARDWARE_MOTHERBOARD),1136)
# ... Rev 1.1 (new servo pin order) # ... Rev 1.1 (new servo pin order)
else ifeq ($(HARDWARE_MOTHERBOARD),1138) else ifeq ($(HARDWARE_MOTHERBOARD),1137)
# Creality: Ender-4, CR-8 # Creality: Ender-4, CR-8
else ifeq ($(HARDWARE_MOTHERBOARD),1139) else ifeq ($(HARDWARE_MOTHERBOARD),1138)
# Creality: CR10S, CR20, CR-X # Creality: CR10S, CR20, CR-X
else ifeq ($(HARDWARE_MOTHERBOARD),1140) else ifeq ($(HARDWARE_MOTHERBOARD),1139)
# Dagoma F5 # Dagoma F5
else ifeq ($(HARDWARE_MOTHERBOARD),1141) else ifeq ($(HARDWARE_MOTHERBOARD),1140)
# Dagoma D6 (as found in the Dagoma DiscoUltimate V2 TMC)
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# FYSETC F6 1.3 # FYSETC F6 1.3
else ifeq ($(HARDWARE_MOTHERBOARD),1143) else ifeq ($(HARDWARE_MOTHERBOARD),1141)
# FYSETC F6 1.4 # FYSETC F6 1.4
else ifeq ($(HARDWARE_MOTHERBOARD),1144) else ifeq ($(HARDWARE_MOTHERBOARD),1142)
# Wanhao Duplicator i3 Plus # Wanhao Duplicator i3 Plus
else ifeq ($(HARDWARE_MOTHERBOARD),1145) else ifeq ($(HARDWARE_MOTHERBOARD),1143)
# VORON Design # VORON Design
else ifeq ($(HARDWARE_MOTHERBOARD),1146) else ifeq ($(HARDWARE_MOTHERBOARD),1144)
# Tronxy TRONXY-V3-1.0 # Tronxy TRONXY-V3-1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1147) else ifeq ($(HARDWARE_MOTHERBOARD),1145)
# Z-Bolt X Series # Z-Bolt X Series
else ifeq ($(HARDWARE_MOTHERBOARD),1148) else ifeq ($(HARDWARE_MOTHERBOARD),1146)
# TT OSCAR # TT OSCAR
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
# Overlord/Overlord Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
# ADIMLab Gantry v1
else ifeq ($(HARDWARE_MOTHERBOARD),1149) else ifeq ($(HARDWARE_MOTHERBOARD),1149)
# BIQU Tango V1 # ADIMLab Gantry v2
else ifeq ($(HARDWARE_MOTHERBOARD),1150) else ifeq ($(HARDWARE_MOTHERBOARD),1150)
# MKS GEN L V2 # BIQU Tango V1
else ifeq ($(HARDWARE_MOTHERBOARD),1151) else ifeq ($(HARDWARE_MOTHERBOARD),1151)
# MKS GEN L V2.1 # MKS GEN L V2
else ifeq ($(HARDWARE_MOTHERBOARD),1152) else ifeq ($(HARDWARE_MOTHERBOARD),1152)
# Copymaster 3D # MKS GEN L V2.1
else ifeq ($(HARDWARE_MOTHERBOARD),1153) else ifeq ($(HARDWARE_MOTHERBOARD),1153)
# Ortur 4 # Copymaster 3D
else ifeq ($(HARDWARE_MOTHERBOARD),1154) else ifeq ($(HARDWARE_MOTHERBOARD),1154)
# Tenlog D3 Hero IDEX printer # Ortur 4
else ifeq ($(HARDWARE_MOTHERBOARD),1155) else ifeq ($(HARDWARE_MOTHERBOARD),1155)
# Tenlog D3, D5, D6 IDEX Printer # Tenlog D3 Hero IDEX printer
else ifeq ($(HARDWARE_MOTHERBOARD),1156) else ifeq ($(HARDWARE_MOTHERBOARD),1156)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) # Tenlog D3,5,6 Pro IDEX printers
else ifeq ($(HARDWARE_MOTHERBOARD),1157) else ifeq ($(HARDWARE_MOTHERBOARD),1157)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1158) else ifeq ($(HARDWARE_MOTHERBOARD),1158)
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1159) else ifeq ($(HARDWARE_MOTHERBOARD),1159)
# Longer LK1 PRO / Alfawise U20 Pro (PRO version) # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
else ifeq ($(HARDWARE_MOTHERBOARD),1160) else ifeq ($(HARDWARE_MOTHERBOARD),1160)
# Longer LKx PRO / Alfawise Uxx Pro (PRO version) # Longer LK1 PRO / Alfawise U20 Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1161) else ifeq ($(HARDWARE_MOTHERBOARD),1161)
# Pxmalion Core I3 # Longer LKx PRO / Alfawise Uxx Pro (PRO version)
else ifeq ($(HARDWARE_MOTHERBOARD),1162) else ifeq ($(HARDWARE_MOTHERBOARD),1162)
# Panowin Cutlass (as found in the Panowin F1) # Zonestar zrib V5.3 (Chinese RAMPS replica)
else ifeq ($(HARDWARE_MOTHERBOARD),1163) else ifeq ($(HARDWARE_MOTHERBOARD),1163)
# Kodama Bardo V1.x (as found in the Kodama Trinus) # Pxmalion Core I3
else ifeq ($(HARDWARE_MOTHERBOARD),1164) else ifeq ($(HARDWARE_MOTHERBOARD),1164)
# XTLW MFF V1.0
else ifeq ($(HARDWARE_MOTHERBOARD),1165)
# XTLW MFF V2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1166)
# #
# RAMBo and derivatives # RAMBo and derivatives
@@ -356,7 +340,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1203)
else ifeq ($(HARDWARE_MOTHERBOARD),1204) else ifeq ($(HARDWARE_MOTHERBOARD),1204)
# abee Scoovo X9H # abee Scoovo X9H
else ifeq ($(HARDWARE_MOTHERBOARD),1205) else ifeq ($(HARDWARE_MOTHERBOARD),1205)
# ThinkerV2 # Rambo ThinkerV2
else ifeq ($(HARDWARE_MOTHERBOARD),1206) else ifeq ($(HARDWARE_MOTHERBOARD),1206)
# #
@@ -399,40 +383,30 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1315)
else ifeq ($(HARDWARE_MOTHERBOARD),1316) else ifeq ($(HARDWARE_MOTHERBOARD),1316)
# Geeetech GT2560 Rev B for A10(M/T/D) # Geeetech GT2560 Rev B for A10(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1317) else ifeq ($(HARDWARE_MOTHERBOARD),1317)
# Geeetech GT2560 Rev B for Mecreator2
else ifeq ($(HARDWARE_MOTHERBOARD),1318)
# Geeetech GT2560 Rev B for A20(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1319)
# Geeetech GT2560 Rev B for A10(M/T/D) # Geeetech GT2560 Rev B for A10(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1320) else ifeq ($(HARDWARE_MOTHERBOARD),1318)
# Geeetech GT2560 Rev B for Mecreator2
else ifeq ($(HARDWARE_MOTHERBOARD),1319)
# Geeetech GT2560 Rev B for A20(M/T/D) # Geeetech GT2560 Rev B for A20(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1321) else ifeq ($(HARDWARE_MOTHERBOARD),1320)
# Einstart retrofit # Einstart retrofit
else ifeq ($(HARDWARE_MOTHERBOARD),1322) else ifeq ($(HARDWARE_MOTHERBOARD),1321)
# Wanhao 0ne+ i3 Mini # Wanhao 0ne+ i3 Mini
else ifeq ($(HARDWARE_MOTHERBOARD),1323) else ifeq ($(HARDWARE_MOTHERBOARD),1322)
# Overlord/Overlord Pro
else ifeq ($(HARDWARE_MOTHERBOARD),1324)
# ADIMLab Gantry v1
else ifeq ($(HARDWARE_MOTHERBOARD),1325)
# ADIMLab Gantry v2
else ifeq ($(HARDWARE_MOTHERBOARD),1326)
# Leapfrog Xeed 2015 # Leapfrog Xeed 2015
else ifeq ($(HARDWARE_MOTHERBOARD),1327) else ifeq ($(HARDWARE_MOTHERBOARD),1323)
# PICA Shield (original version) # PICA Shield (original version)
else ifeq ($(HARDWARE_MOTHERBOARD),1328) else ifeq ($(HARDWARE_MOTHERBOARD),1324)
# PICA Shield (rev C or later) # PICA Shield (rev C or later)
else ifeq ($(HARDWARE_MOTHERBOARD),1329) else ifeq ($(HARDWARE_MOTHERBOARD),1325)
# Intamsys 4.0 (Funmat HT) # Intamsys 4.0 (Funmat HT)
else ifeq ($(HARDWARE_MOTHERBOARD),1330) else ifeq ($(HARDWARE_MOTHERBOARD),1326)
# Malyan M180 Mainboard Version 2 (no display function, direct G-code only) # Malyan M180 Mainboard Version 2 (no display function, direct G-code only)
else ifeq ($(HARDWARE_MOTHERBOARD),1331) else ifeq ($(HARDWARE_MOTHERBOARD),1327)
# Geeetech GT2560 Rev B for A20(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1328)
# Mega controller & Protoneer CNC Shield V3.00 # Mega controller & Protoneer CNC Shield V3.00
else ifeq ($(HARDWARE_MOTHERBOARD),1332) else ifeq ($(HARDWARE_MOTHERBOARD),1329)
# WEEDO 62A board (TINA2, Monoprice Cadet, etc.)
else ifeq ($(HARDWARE_MOTHERBOARD),1333)
# Geeetech GT2560 V4.1B for A10(M/T/D)
else ifeq ($(HARDWARE_MOTHERBOARD),1334)
# #
# ATmega1281, ATmega2561 # ATmega1281, ATmega2561
@@ -466,7 +440,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1502)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega644p MCU ?= atmega644p
PROG_MCU ?= m644p PROG_MCU ?= m644p
# Melzi V2 # Melzi V2.0
else ifeq ($(HARDWARE_MOTHERBOARD),1503) else ifeq ($(HARDWARE_MOTHERBOARD),1503)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
@@ -476,38 +450,33 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1504)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# Melzi Creality3D (for CR-10 etc) # Melzi Creality3D board (for CR-10 etc)
else ifeq ($(HARDWARE_MOTHERBOARD),1505) else ifeq ($(HARDWARE_MOTHERBOARD),1505)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# Melzi Creality3D (for Ender-2) # Melzi Malyan M150 board
else ifeq ($(HARDWARE_MOTHERBOARD),1506) else ifeq ($(HARDWARE_MOTHERBOARD),1506)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# Melzi Malyan M150 # Tronxy X5S
else ifeq ($(HARDWARE_MOTHERBOARD),1507) else ifeq ($(HARDWARE_MOTHERBOARD),1507)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# Tronxy X5S # STB V1.1
else ifeq ($(HARDWARE_MOTHERBOARD),1508) else ifeq ($(HARDWARE_MOTHERBOARD),1508)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# STB V1.1 # Azteeg X1
else ifeq ($(HARDWARE_MOTHERBOARD),1509) else ifeq ($(HARDWARE_MOTHERBOARD),1509)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
# Azteeg X1
else ifeq ($(HARDWARE_MOTHERBOARD),1510)
HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p
PROG_MCU ?= m1284p
# Anet 1.0 (Melzi clone) # Anet 1.0 (Melzi clone)
else ifeq ($(HARDWARE_MOTHERBOARD),1511) else ifeq ($(HARDWARE_MOTHERBOARD),1510)
HARDWARE_VARIANT ?= Sanguino HARDWARE_VARIANT ?= Sanguino
MCU ?= atmega1284p MCU ?= atmega1284p
PROG_MCU ?= m1284p PROG_MCU ?= m1284p
+1 -1
View File
@@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release * here we define this default string as the date where the latest release
* version was tagged. * version was tagged.
*/ */
//#define STRING_DISTRIBUTION_DATE "2024-10-17" //#define STRING_DISTRIBUTION_DATE "2024-04-07"
/** /**
* Defines a generic printer name to be output to the LCD after booting Marlin. * Defines a generic printer name to be output to the LCD after booting Marlin.
+6 -6
View File
@@ -129,11 +129,11 @@ typedef Servo hal_servo_t;
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if !WITHIN(MMU_SERIAL_PORT, 0, 3) #if !WITHIN(MMU2_SERIAL_PORT, 0, 3)
#error "MMU_SERIAL_PORT must be from 0 to 3" #error "MMU2_SERIAL_PORT must be from 0 to 3"
#endif #endif
#define MMU_SERIAL mmuSerial #define MMU2_SERIAL mmuSerial
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
@@ -141,7 +141,7 @@ typedef Servo hal_servo_t;
#error "LCD_SERIAL_PORT must be from 0 to 3." #error "LCD_SERIAL_PORT must be from 0 to 3."
#endif #endif
#define LCD_SERIAL lcdSerial #define LCD_SERIAL lcdSerial
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
#endif #endif
#endif #endif
@@ -159,7 +159,7 @@ typedef Servo hal_servo_t;
#define GET_PIN_MAP_INDEX(pin) pin #define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
#define HAL_SENSITIVE_PINS 0, 1 #define HAL_SENSITIVE_PINS 0, 1,
#ifdef __AVR_AT90USB1286__ #ifdef __AVR_AT90USB1286__
#define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
+8 -8
View File
@@ -601,20 +601,20 @@ MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
#endif // SERIAL_PORT_3 #endif // SERIAL_PORT_3
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
ISR(SERIAL_REGNAME(USART, MMU_SERIAL_PORT, _RX_vect)) { ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _RX_vect)) {
MarlinSerial<MMU2SerialCfg<MMU_SERIAL_PORT>>::store_rxd_char(); MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::store_rxd_char();
} }
ISR(SERIAL_REGNAME(USART, MMU_SERIAL_PORT, _UDRE_vect)) { ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _UDRE_vect)) {
MarlinSerial<MMU2SerialCfg<MMU_SERIAL_PORT>>::_tx_udr_empty_irq(); MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::_tx_udr_empty_irq();
} }
template class MarlinSerial< MMU2SerialCfg<MMU_SERIAL_PORT> >; template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >;
MSerialMMU2 mmuSerial(MSerialMMU2::HasEmergencyParser); MSerialMMU2 mmuSerial(MSerialMMU2::HasEmergencyParser);
#endif // MMU_SERIAL_PORT #endif // MMU2_SERIAL_PORT
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
@@ -629,7 +629,7 @@ MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >; template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser); MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser);
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
template<typename Cfg> template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() { typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send. const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
+3 -3
View File
@@ -205,7 +205,7 @@
static ring_buffer_pos_t available(); static ring_buffer_pos_t available();
static void write(const uint8_t c); static void write(const uint8_t c);
static void flushTX(); static void flushTX();
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
static ring_buffer_pos_t get_tx_buffer_free(); static ring_buffer_pos_t get_tx_buffer_free();
#endif #endif
@@ -246,7 +246,7 @@
#endif // !USBCON #endif // !USBCON
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
template <uint8_t serial> template <uint8_t serial>
struct MMU2SerialCfg { struct MMU2SerialCfg {
static constexpr int PORT = serial; static constexpr int PORT = serial;
@@ -260,7 +260,7 @@
static constexpr bool RX_OVERRUNS = false; static constexpr bool RX_OVERRUNS = false;
}; };
typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU_SERIAL_PORT> > > MSerialMMU2; typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialMMU2;
extern MSerialMMU2 mmuSerial; extern MSerialMMU2 mmuSerial;
#endif #endif
-8
View File
@@ -345,14 +345,6 @@ void setup_endstop_interrupts() {
pciSetup(Z_MIN_PROBE_PIN); pciSetup(Z_MIN_PROBE_PIN);
#endif #endif
#endif #endif
#if USE_CALIBRATION
#if (digitalPinToInterrupt(CALIBRATION_PIN) != NOT_AN_INTERRUPT)
_ATTACH(CALIBRATION_PIN);
#else
static_assert(digitalPinHasPCICR(CALIBRATION_PIN), "CALIBRATION_PIN is not interrupt-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue.");
pciSetup(CALIBRATION_PIN);
#endif
#endif
// If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI. // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
} }
+1 -1
View File
@@ -150,7 +150,7 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
else { else {
if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2 if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2
const uint16_t rft = (F_CPU) / (p * f_desired); const uint16_t rft = (F_CPU) / (p * f_desired);
DEBUG_ECHOLNPGM("(Not Timer 2) F_CPU=", STRINGIFY(F_CPU), " prescaler=", p, " f_desired=", f_desired); DEBUG_ECHOLNPGM("(Not Timer 2) F_CPU=" STRINGIFY(F_CPU), " prescaler=", p, " f_desired=", f_desired);
res_fast_temp = rft - 1; res_fast_temp = rft - 1;
res_pc_temp = rft / 2; res_pc_temp = rft / 2;
} }
+3
View File
@@ -28,6 +28,9 @@
* Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 | E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx * Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 | E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx
* Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 78 79 80 xx xx 84 85 71 70 xx xx xx xx xx 81 82 83 xx xx 72 73 75 76 77 74 xx xx xx xx xx * Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 78 79 80 xx xx 84 85 71 70 xx xx xx xx xx 81 82 83 xx xx 72 73 75 76 77 74 xx xx xx xx xx
* Analog Input : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 * Analog Input : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/ */
#include "../fastio.h" #include "../fastio.h"
+3
View File
@@ -26,6 +26,9 @@
* *
* Logical Pin: 38 39 40 41 42 43 44 45 16 10 11 12 06 07 08 09 30 31 32 33 34 35 36 37 17 18 19 20 21 22 23 24 00 01 13 05 02 03 14 15 46 47 48 49 50 51 52 53 25 26 27 28 29 04 * Logical Pin: 38 39 40 41 42 43 44 45 16 10 11 12 06 07 08 09 30 31 32 33 34 35 36 37 17 18 19 20 21 22 23 24 00 01 13 05 02 03 14 15 46 47 48 49 50 51 52 53 25 26 27 28 29 04
* Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5 * Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/ */
#include "../fastio.h" #include "../fastio.h"
+3
View File
@@ -26,6 +26,9 @@
* *
* Logical Pin: 08 09 10 11 12 13 14 15 16 17 18 19 20 21 00 01 02 03 04 05 06 07 * Logical Pin: 08 09 10 11 12 13 14 15 16 17 18 19 20 21 00 01 02 03 04 05 06 07
* Port: B0 B1 B2 B3 B4 B5 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 * Port: B0 B1 B2 B3 B4 B5 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/ */
#include "../fastio.h" #include "../fastio.h"
+3
View File
@@ -26,6 +26,9 @@
* *
* Logical Pin: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 * Logical Pin: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
* Port: B0 B1 B2 B3 B4 B5 B6 B7 D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 C2 C3 C4 C5 C6 C7 A7 A6 A5 A4 A3 A2 A1 A0 * Port: B0 B1 B2 B3 B4 B5 B6 B7 D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 C2 C3 C4 C5 C6 C7 A7 A6 A5 A4 A3 A2 A1 A0
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/ */
/** ATMega644 /** ATMega644
+4 -1
View File
@@ -26,7 +26,10 @@
* *
* Logical Pin: 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 * Logical Pin: 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45
* Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 * Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7
* Logical pins 46-47 aren't supported by Teensyduino, but are supported below as E2 and E3 * The logical pins 46 and 47 are not supported by Teensyduino, but are supported below as E2 and E3
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/ */
#include "../fastio.h" #include "../fastio.h"
+17 -17
View File
@@ -42,7 +42,7 @@
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p) #define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p) #define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p) #define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
#define getValidPinMode(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin)) #define GET_PINMODE(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin))
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70 #elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
@@ -50,32 +50,32 @@
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer_plus_70(p) #define digitalPinToTimer_DEBUG(p) digitalPinToTimer_plus_70(p)
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask_plus_70(p) #define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask_plus_70(p)
#define digitalPinToPort_DEBUG(p) digitalPinToPort_plus_70(p) #define digitalPinToPort_DEBUG(p) digitalPinToPort_plus_70(p)
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); } bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
#else #else
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p) #define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p) #define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p) #define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); } bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
#define getPinByIndex(p) pgm_read_byte(&pin_array[p].pin) #define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin)
#endif #endif
#define isValidPin(pin) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0) #define VALID_PIN(pin) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0)
#if AVR_ATmega1284_FAMILY #if AVR_ATmega1284_FAMILY
#define isAnalogPin(P) WITHIN(P, analogInputToDigitalPin(7), analogInputToDigitalPin(0)) #define IS_ANALOG(P) WITHIN(P, analogInputToDigitalPin(7), analogInputToDigitalPin(0))
#define digitalPinToAnalogIndex(P) int(isAnalogPin(P) ? (P) - analogInputToDigitalPin(7) : -1) #define DIGITAL_PIN_TO_ANALOG_PIN(P) int(IS_ANALOG(P) ? (P) - analogInputToDigitalPin(7) : -1)
#else #else
#define _ANALOG1(P) WITHIN(P, analogInputToDigitalPin(0), analogInputToDigitalPin(7)) #define _ANALOG1(P) WITHIN(P, analogInputToDigitalPin(0), analogInputToDigitalPin(7))
#define _ANALOG2(P) WITHIN(P, analogInputToDigitalPin(8), analogInputToDigitalPin(15)) #define _ANALOG2(P) WITHIN(P, analogInputToDigitalPin(8), analogInputToDigitalPin(15))
#define isAnalogPin(P) (_ANALOG1(P) || _ANALOG2(P)) #define IS_ANALOG(P) (_ANALOG1(P) || _ANALOG2(P))
#define digitalPinToAnalogIndex(P) int(_ANALOG1(P) ? (P) - analogInputToDigitalPin(0) : _ANALOG2(P) ? (P) - analogInputToDigitalPin(8) + 8 : -1) #define DIGITAL_PIN_TO_ANALOG_PIN(P) int(_ANALOG1(P) ? (P) - analogInputToDigitalPin(0) : _ANALOG2(P) ? (P) - analogInputToDigitalPin(8) + 8 : -1)
#endif #endif
#define getPinByIndex(p) pgm_read_byte(&pin_array[p].pin) #define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin)
#define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin
void printPinNameByIndex(uint8_t x) { void PRINT_ARRAY_NAME(uint8_t x) {
PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name); PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name);
for (uint8_t y = 0; y < MAX_NAME_LENGTH; ++y) { for (uint8_t y = 0; y < MAX_NAME_LENGTH; ++y) {
char temp_char = pgm_read_byte(name_mem_pointer + y); char temp_char = pgm_read_byte(name_mem_pointer + y);
@@ -88,7 +88,7 @@ void printPinNameByIndex(uint8_t x) {
} }
} }
#define getPinIsDigitalByIndex(x) pgm_read_byte(&pin_array[x].is_digital) #define GET_ARRAY_IS_DIGITAL(x) pgm_read_byte(&pin_array[x].is_digital)
#if defined(__AVR_ATmega1284P__) // 1284 IDE extensions set this to the number of #if defined(__AVR_ATmega1284P__) // 1284 IDE extensions set this to the number of
#undef NUM_DIGITAL_PINS // digital only pins while all other CPUs have it #undef NUM_DIGITAL_PINS // digital only pins while all other CPUs have it
@@ -276,7 +276,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
if (TEST(*TMSK, TOIE)) err_prob_interrupt(); if (TEST(*TMSK, TOIE)) err_prob_interrupt();
} }
void printPinPWM(uint8_t pin) { void pwm_details(uint8_t pin) {
switch (digitalPinToTimer_DEBUG(pin)) { switch (digitalPinToTimer_DEBUG(pin)) {
#if ABTEST(0) #if ABTEST(0)
@@ -347,7 +347,7 @@ void printPinPWM(uint8_t pin) {
#else #else
UNUSED(print_is_also_tied); UNUSED(print_is_also_tied);
#endif #endif
} // printPinPWM } // pwm_details
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs #ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
int digitalRead_mod(const pin_t pin) { // same as digitalRead except the PWM stop section has been removed int digitalRead_mod(const pin_t pin) { // same as digitalRead except the PWM stop section has been removed
@@ -356,7 +356,7 @@ void printPinPWM(uint8_t pin) {
} }
#endif #endif
void printPinPort(const pin_t pin) { // print port number void print_port(const pin_t pin) { // print port number
#ifdef digitalPinToPort_DEBUG #ifdef digitalPinToPort_DEBUG
uint8_t x; uint8_t x;
SERIAL_ECHOPGM(" Port: "); SERIAL_ECHOPGM(" Port: ");
@@ -386,7 +386,7 @@ void printPinPort(const pin_t pin) { // print port number
#endif #endif
} }
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#undef ABTEST #undef ABTEST
@@ -120,7 +120,7 @@ void u8g_spiSend_sw_AVR_mode_3(uint8_t val) {
U8G_ATOMIC_END(); U8G_ATOMIC_END();
} }
#if U8G_SPI_USE_MODE_3 #if ENABLED(FYSETC_MINI_12864)
#define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_3 #define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_3
#else #else
#define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_0 #define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_0
@@ -143,9 +143,9 @@ uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
break; break;
case U8G_COM_MSG_CHIP_SELECT: case U8G_COM_MSG_CHIP_SELECT:
#if U8G_SPI_USE_MODE_3 // LCD SPI is running mode 3 while SD card is running mode 0 #if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW); u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
} }
+5 -5
View File
@@ -81,11 +81,11 @@ extern DefaultSerial4 MSerial3;
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 0, 3) #if WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#error "MMU_SERIAL_PORT must be from 0 to 3." #error "MMU2_SERIAL_PORT must be from 0 to 3."
#endif #endif
#endif #endif
@@ -127,7 +127,7 @@ typedef Servo hal_servo_t;
#define HAL_ADC_RESOLUTION 10 #define HAL_ADC_RESOLUTION 10
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) pin_t((p < 12U) ? (p) + 54U : -1) #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
#endif #endif
// //
+1 -1
View File
@@ -50,7 +50,7 @@
static Flags<_Nbr_16timers> DisablePending; // ISR should disable the timer at the next timer reset static Flags<_Nbr_16timers> DisablePending; // ISR should disable the timer at the next timer reset
// ------------------------ // ------------------------
// Interrupt handler for the TC0 channel 1. /// Interrupt handler for the TC0 channel 1.
// ------------------------ // ------------------------
void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t); void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t);
-1
View File
@@ -64,7 +64,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN)); TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN)); TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_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_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN)); TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN)); TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
+1 -1
View File
@@ -61,7 +61,7 @@
#else #else
#define G2_PWM_Z 0 #define G2_PWM_Z 0
#endif #endif
#if HAS_MOTOR_CURRENT_PWM_E #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
#define G2_PWM_E 1 #define G2_PWM_E 1
#else #else
#define G2_PWM_E 0 #define G2_PWM_E 0
+7 -6
View File
@@ -68,15 +68,16 @@
* Usually the hardware SPI pins are only available to the LCD. This makes the DUE hard SPI used at the same time * Usually the hardware SPI pins are only available to the LCD. This makes the DUE hard SPI used at the same time
* as the TMC2130 soft SPI the most common setup. * as the TMC2130 soft SPI the most common setup.
*/ */
#define _IS_HW_SPI(P) (defined(TMC_SPI_##P) && (TMC_SPI_##P == SD_MOSI_PIN || TMC_SPI_##P == SD_MISO_PIN || TMC_SPI_##P == SD_SCK_PIN))
#if HAS_MEDIA && HAS_DRIVER(TMC2130) #if HAS_MEDIA && HAS_DRIVER(TMC2130)
#define _IS_HW_SPI(P) (defined(TMC_SPI_##P) && (TMC_SPI_##P == SD_MOSI_PIN || TMC_SPI_##P == SD_MISO_PIN || TMC_SPI_##P == SD_SCK_PIN)) #if ENABLED(TMC_USE_SW_SPI)
#if DISABLED(SOFTWARE_SPI) && ENABLED(TMC_USE_SW_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK)) #if DISABLED(SOFTWARE_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK))
#error "DUE hardware SPI is required but is incompatible with TMC2130 software SPI. Either disable TMC_USE_SW_SPI or use separate pins for the two SPIs." #error "DUE hardware SPI is required but is incompatible with TMC2130 software SPI. Either disable TMC_USE_SW_SPI or use separate pins for the two SPIs."
#endif #endif
#if ENABLED(SOFTWARE_SPI) && DISABLED(TMC_USE_SW_SPI) #elif ENABLED(SOFTWARE_SPI)
#error "DUE software SPI is required but is incompatible with TMC2130 hardware SPI. Enable TMC_USE_SW_SPI to fix." #error "DUE software SPI is required but is incompatible with TMC2130 hardware SPI. Enable TMC_USE_SW_SPI to fix."
#endif #endif
#undef _IS_HW_SPI
#endif #endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
+11 -11
View File
@@ -64,19 +64,19 @@
#define NUMBER_PINS_TOTAL PINS_COUNT #define NUMBER_PINS_TOTAL PINS_COUNT
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin #define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define isValidPin(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
#define digitalPinToAnalogIndex(p) int(p - analogInputToDigitalPin(0)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
#define isAnalogPin(P) WITHIN(P, pin_t(analogInputToDigitalPin(0)), pin_t(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1))) #define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
#define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \ #define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \
((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM)) ((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM))
#define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
bool getValidPinMode(int8_t pin) { // 1: output, 0: input bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
volatile Pio* port = g_APinDescription[pin].pPort; volatile Pio* port = g_APinDescription[pin].pPort;
uint32_t mask = g_APinDescription[pin].ulPin; uint32_t mask = g_APinDescription[pin].ulPin;
uint8_t pin_status = g_pinStatus[pin] & 0xF; uint8_t pin_status = g_pinStatus[pin] & 0xF;
@@ -85,14 +85,14 @@ bool getValidPinMode(int8_t pin) { // 1: output, 0: input
|| pwm_status(pin)); || pwm_status(pin));
} }
void printPinPWM(int32_t pin) { void pwm_details(int32_t pin) {
if (pwm_status(pin)) { if (pwm_status(pin)) {
uint32_t chan = g_APinDescription[pin].ulPWMChannel; uint32_t chan = g_APinDescription[pin].ulPWMChannel;
SERIAL_ECHOPGM("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY); SERIAL_ECHOPGM("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
} }
} }
void printPinPort(const pin_t) {} void print_port(const pin_t) {}
/** /**
* DUE Board pin | PORT | Label * DUE Board pin | PORT | Label
+1 -1
View File
@@ -24,7 +24,7 @@
/** /**
* Define SPI Pins: SCK, MISO, MOSI, SS * Define SPI Pins: SCK, MISO, MOSI, SS
* *
* Available chip select pins for HW SPI are 4 10 52 77 87 * Available chip select pins for HW SPI are 4 10 52 77
*/ */
#if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87 #if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87
#if SDSS == 4 #if SDSS == 4
@@ -66,7 +66,7 @@
#include <U8glib-HAL.h> #include <U8glib-HAL.h>
#if U8G_SPI_USE_MODE_3 #if ENABLED(FYSETC_MINI_12864)
#define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_3 #define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_3
#else #else
#define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_0 #define SPISEND_SW_DUE u8g_spiSend_sw_DUE_mode_0
@@ -96,15 +96,15 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
break; break;
case U8G_COM_MSG_CHIP_SELECT: case U8G_COM_MSG_CHIP_SELECT:
#if U8G_SPI_USE_MODE_3 // LCD SPI is running mode 3 while SD card is running mode 0 #if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1); //set SCK to mode 3 idle state before CS goes active
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, LOW); u8g_SetPILevel_DUE(u8g, U8G_PI_CS, LOW);
} }
else { else {
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, HIGH); u8g_SetPILevel_DUE(u8g, U8G_PI_CS, HIGH);
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); //set SCK to mode 0 idle state after CS goes inactive
} }
#else #else
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, !arg_val); u8g_SetPILevel_DUE(u8g, U8G_PI_CS, !arg_val);
+1 -1
View File
@@ -11,7 +11,7 @@ if pioutil.is_pio_build():
if current_OS == 'Windows': if current_OS == 'Windows':
env = pioutil.env Import("env")
# Use bossac.exe on Windows # Use bossac.exe on Windows
env.Replace( env.Replace(
+16 -14
View File
@@ -18,32 +18,32 @@ extern "C" {
void sd_mmc_spi_mem_init() { void sd_mmc_spi_mem_init() {
} }
inline bool media_ready() {
return IS_SD_MOUNTED() && IS_SD_INSERTED() && !IS_SD_FILE_OPEN() && !IS_SD_PRINTING();
}
bool sd_mmc_spi_unload(bool) { return true; }
bool sd_mmc_spi_wr_protect() { return false; }
bool sd_mmc_spi_removal() { return !media_ready(); }
Ctrl_status sd_mmc_spi_test_unit_ready() { Ctrl_status sd_mmc_spi_test_unit_ready() {
#ifdef DISABLE_DUE_SD_MMC #ifdef DISABLE_DUE_SD_MMC
return CTRL_NO_PRESENT; return CTRL_NO_PRESENT;
#endif #endif
if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
return CTRL_GOOD; return CTRL_GOOD;
} }
// NOTE: This function is defined as returning the address of the last block // NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1 // in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) { Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
*nb_sector = card.diskIODriver()->cardSize() - 1; *nb_sector = card.diskIODriver()->cardSize() - 1;
return CTRL_GOOD; return CTRL_GOOD;
} }
bool sd_mmc_spi_unload(bool) { return true; }
bool sd_mmc_spi_wr_protect() { return false; }
bool sd_mmc_spi_removal() {
return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted());
}
#if ACCESS_USB == true #if ACCESS_USB == true
/** /**
* \name MEM <-> USB Interface * \name MEM <-> USB Interface
@@ -61,7 +61,8 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
#ifdef DISABLE_DUE_SD_MMC #ifdef DISABLE_DUE_SD_MMC
return CTRL_NO_PRESENT; return CTRL_NO_PRESENT;
#endif #endif
if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC #ifdef DEBUG_MMC
{ {
@@ -100,7 +101,8 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
#ifdef DISABLE_DUE_SD_MMC #ifdef DISABLE_DUE_SD_MMC
return CTRL_NO_PRESENT; return CTRL_NO_PRESENT;
#endif #endif
if (sd_mmc_spi_removal()) return CTRL_NO_PRESENT; if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#ifdef DEBUG_MMC #ifdef DEBUG_MMC
{ {
+8 -8
View File
@@ -74,7 +74,7 @@
//! //!
//! @brief This function initializes the hw/sw resources required to drive the SD_MMC_SPI. //! @brief This function initializes the hw/sw resources required to drive the SD_MMC_SPI.
//!/ //!/
void sd_mmc_spi_mem_init(); extern void sd_mmc_spi_mem_init(void);
//! //!
//! @brief This function tests the state of the SD_MMC memory and sends it to the Host. //! @brief This function tests the state of the SD_MMC memory and sends it to the Host.
@@ -87,7 +87,7 @@ void sd_mmc_spi_mem_init();
//! Media not present -> CTRL_NO_PRESENT //! Media not present -> CTRL_NO_PRESENT
//! Media has changed -> CTRL_BUSY //! Media has changed -> CTRL_BUSY
//!/ //!/
Ctrl_status sd_mmc_spi_test_unit_ready(); extern Ctrl_status sd_mmc_spi_test_unit_ready(void);
//! //!
//! @brief This function gives the address of the last valid sector. //! @brief This function gives the address of the last valid sector.
@@ -98,7 +98,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready();
//! Media ready -> CTRL_GOOD //! Media ready -> CTRL_GOOD
//! Media not present -> CTRL_NO_PRESENT //! Media not present -> CTRL_NO_PRESENT
//!/ //!/
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector); extern Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
/*! \brief Unload/Load the SD/MMC card selected /*! \brief Unload/Load the SD/MMC card selected
* *
@@ -109,7 +109,7 @@ Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
* *
* \return \c true if unload/load done success. * \return \c true if unload/load done success.
*/ */
bool sd_mmc_spi_unload(bool unload); extern bool sd_mmc_spi_unload(bool unload);
//! //!
//! @brief This function returns the write protected status of the memory. //! @brief This function returns the write protected status of the memory.
@@ -120,14 +120,14 @@ bool sd_mmc_spi_unload(bool unload);
//! //!
//! @return false -> the memory is not write-protected (always) //! @return false -> the memory is not write-protected (always)
//!/ //!/
bool sd_mmc_spi_wr_protect(); extern bool sd_mmc_spi_wr_protect(void);
//! //!
//! @brief This function tells if the memory has been removed or not. //! @brief This function tells if the memory has been removed or not.
//! //!
//! @return false -> The memory isn't removed //! @return false -> The memory isn't removed
//! //!
bool sd_mmc_spi_removal(); extern bool sd_mmc_spi_removal(void);
//---- ACCESS DATA FUNCTIONS ---- //---- ACCESS DATA FUNCTIONS ----
@@ -147,7 +147,7 @@ bool sd_mmc_spi_removal();
//! It is ready -> CTRL_GOOD //! It is ready -> CTRL_GOOD
//! A error occur -> CTRL_FAIL //! A error occur -> CTRL_FAIL
//! //!
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector); extern Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
//! This function initializes the SD/MMC memory for a write operation //! This function initializes the SD/MMC memory for a write operation
//! //!
@@ -161,7 +161,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
//! It is ready -> CTRL_GOOD //! It is ready -> CTRL_GOOD
//! An error occurs -> CTRL_FAIL //! An error occurs -> CTRL_FAIL
//! //!
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector); extern Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector);
#endif // #if ACCESS_USB == true #endif // #if ACCESS_USB == true
+8 -9
View File
@@ -209,17 +209,16 @@ int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); }
// ADC // ADC
// ------------------------ // ------------------------
// https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32/api-reference/peripherals/adc.html #define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL
adc1_channel_t get_channel(int pin) { adc1_channel_t get_channel(int pin) {
switch (pin) { switch (pin) {
case 39: return ADC1_CHANNEL_3; case 39: return ADC1_CHANNEL(39);
case 36: return ADC1_CHANNEL_0; case 36: return ADC1_CHANNEL(36);
case 35: return ADC1_CHANNEL_7; case 35: return ADC1_CHANNEL(35);
case 34: return ADC1_CHANNEL_6; case 34: return ADC1_CHANNEL(34);
case 33: return ADC1_CHANNEL_5; case 33: return ADC1_CHANNEL(33);
case 32: return ADC1_CHANNEL_4; case 32: return ADC1_CHANNEL(32);
case 37: return ADC1_CHANNEL_1;
case 38: return ADC1_CHANNEL_2;
} }
return ADC1_CHANNEL_MAX; return ADC1_CHANNEL_MAX;
} }
@@ -59,7 +59,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN)); TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN)); TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_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_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN)); TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN)); TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
+1 -1
View File
@@ -152,7 +152,7 @@ void stepperTask(void *parameter) {
xQueueReceive(dma.queue, &dma.current, portMAX_DELAY); xQueueReceive(dma.queue, &dma.current, portMAX_DELAY);
dma.rw_pos = 0; dma.rw_pos = 0;
const bool using_ftMotion = TERN0(FT_MOTION, ftMotion.cfg.active); const bool using_ftMotion = TERN0(FT_MOTION, ftMotion.cfg.mode);
while (dma.rw_pos < DMA_SAMPLE_COUNT) { while (dma.rw_pos < DMA_SAMPLE_COUNT) {
+1 -1
View File
@@ -90,7 +90,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
config.counter_en = TIMER_PAUSE; config.counter_en = TIMER_PAUSE;
config.alarm_en = TIMER_ALARM_EN; config.alarm_en = TIMER_ALARM_EN;
config.intr_type = TIMER_INTR_LEVEL; config.intr_type = TIMER_INTR_LEVEL;
config.auto_reload = TIMER_AUTORELOAD_EN; config.auto_reload = true;
// Select and initialize the timer // Select and initialize the timer
timer_init(timer.group, timer.idx, &config); timer_init(timer.group, timer.idx, &config);
+2 -1
View File
@@ -53,11 +53,12 @@ typedef uint64_t hal_timer_t;
#if ENABLED(I2S_STEPPER_STREAM) #if ENABLED(I2S_STEPPER_STREAM)
#define STEPPER_TIMER_PRESCALE 1 #define STEPPER_TIMER_PRESCALE 1
#define STEPPER_TIMER_RATE 250000 // 250khz, 4µs pulses of i2s word clock #define STEPPER_TIMER_RATE 250000 // 250khz, 4µs pulses of i2s word clock
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
#else #else
#define STEPPER_TIMER_PRESCALE 40 #define STEPPER_TIMER_PRESCALE 40
#define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz #define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#endif #endif
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts #define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
+14 -30
View File
@@ -114,19 +114,22 @@
// Misc. Functions // Misc. Functions
// //
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) pin_t(p) #define analogInputToDigitalPin(p) (p)
#endif #endif
#define CRITICAL_SECTION_START() \ #define CRITICAL_SECTION_START \
const bool irqon = !__get_PRIMASK(); \ uint32_t primask = __get_PRIMASK(); \
__disable_irq(); \ (void)__iCliRetVal()
__DSB();
#define CRITICAL_SECTION_END() \
__DSB(); \
if (irqon) __enable_irq();
#define cli() __disable_irq() #define CRITICAL_SECTION_END \
#define sei() __enable_irq() if (!primask) \
(void)__iSeiRetVal()
// Disable interrupts
#define cli() noInterrupts()
// Enable interrupts
#define sei() interrupts()
// bss_end alias // bss_end alias
#define __bss_end __bss_end__ #define __bss_end __bss_end__
@@ -139,31 +142,12 @@
// ADC // ADC
// //
#define HAL_ADC_VREF_MV 3300 #define HAL_ADC_VREF_MV 3300
#define HAL_ADC_RESOLUTION 12 #define HAL_ADC_RESOLUTION 10
#define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin #define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
//
// Debug port disable
// JTMS / SWDIO = PA13
// JTCK / SWCLK = PA14
// JTDI = PA15
// JTDO = PB3
// NJTRST = PB4
//
#define DBG_SWCLK _BV(0)
#define DBG_SWDIO _BV(1)
#define DBG_TDO _BV(2)
#define DBG_TDI _BV(3)
#define DBG_TRST _BV(4)
#define DBG_ALL (DBG_SWCLK | DBG_SWDIO | DBG_TDO | DBG_TDI | DBG_TRST)
#define JTAGSWD_RESET() PORT_DebugPortSetting(DBG_ALL, Enable);
#define JTAG_DISABLE() PORT_DebugPortSetting(DBG_TDO | DBG_TDI | DBG_TRST, Disable);
#define JTAGSWD_DISABLE() PORT_DebugPortSetting(DBG_ALL, Disable);
// //
// MarlinHAL implementation // MarlinHAL implementation
// //
+2 -33
View File
@@ -123,11 +123,6 @@ void MarlinHAL::init() {
// Register min serial // Register min serial
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); TERN_(POSTMORTEM_DEBUGGING, install_min_serial());
// warn if low memory after init
if (freeMemory() < 1024) {
SERIAL_WARN_MSG("HAL: low memory after init!\n");
}
} }
void MarlinHAL::init_board() {} void MarlinHAL::init_board() {}
@@ -152,31 +147,7 @@ void MarlinHAL::delay_ms(const int ms) {
delay(ms); delay(ms);
} }
void MarlinHAL::idletask() { void MarlinHAL::idletask() {}
#if ENABLED(MARLIN_DEV_MODE)
// check & print serial RX errors
MSerialT *serials[] = { &MSerial1, &MSerial2 };
for (int serial = 0; serial < 2; serial++) {
usart_receive_error_t err = serials[serial]->getReceiveError();
if (err != usart_receive_error_t::None) {
// "Warning: MSerial[n] RX [Framing|Parity|Overrun] Error"
SERIAL_WARN_START();
SERIAL_ECHOPGM(" MSerial");
SERIAL_ECHO(serial + 1);
SERIAL_ECHOPGM(" RX ");
switch(err) {
case usart_receive_error_t::FramingError: SERIAL_ECHOPGM("Framing"); break;
case usart_receive_error_t::ParityError: SERIAL_ECHOPGM("Parity"); break;
case usart_receive_error_t::OverrunError: SERIAL_ECHOPGM("Overrun"); break;
case usart_receive_error_t::RxDataDropped: SERIAL_ECHOPGM("DataDropped"); break;
default: break;
}
SERIAL_ECHOPGM(" Error");
SERIAL_EOL();
}
}
#endif
}
uint8_t MarlinHAL::get_reset_source() { uint8_t MarlinHAL::get_reset_source() {
// Query reset cause from RMU // Query reset cause from RMU
@@ -232,9 +203,7 @@ int MarlinHAL::freeMemory() {
return &top - _sbrk(0); return &top - _sbrk(0);
} }
void MarlinHAL::adc_init() { void MarlinHAL::adc_init() {}
analogReadResolution(HAL_ADC_RESOLUTION);
}
void MarlinHAL::adc_enable(const pin_t pin) { void MarlinHAL::adc_enable(const pin_t pin) {
#if TEMP_SENSOR_SOC #if TEMP_SENSOR_SOC
+3 -23
View File
@@ -46,34 +46,14 @@ constexpr bool serial_handles_emergency(int port) {
// //
// Define serial ports // Define serial ports
// //
#define DEFINE_HWSERIAL_MARLIN(name, n) \
// serial port where RX and TX use IRQs
#define DEFINE_IRQ_SERIAL_MARLIN(name, n) \
MSerialT name(serial_handles_emergency(n), \ MSerialT name(serial_handles_emergency(n), \
&USART##n##_config, \ &USART##n##_config, \
BOARD_USART##n##_TX_PIN, \ BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN); BOARD_USART##n##_RX_PIN);
// serial port where RX uses DMA and TX uses IRQs DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
// all serial ports use DMA1 DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
// since there are 4 USARTs and 4 DMA channels, we can use the USART number as the DMA channel
#define DEFINE_DMA_SERIAL_MARLIN(name, n) \
MSerialT name(serial_handles_emergency(n), \
&USART##n##_config, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN, \
M4_DMA1, \
((en_dma_channel_t)(n - 1))); // map USART1 to DMA channel 0, USART2 to DMA channel 1, etc.
#define DEFINE_SERIAL_MARLIN(name, n) TERN(SERIAL_DMA, DEFINE_DMA_SERIAL_MARLIN(name, n), DEFINE_IRQ_SERIAL_MARLIN(name, n))
DEFINE_SERIAL_MARLIN(MSerial1, 1);
DEFINE_SERIAL_MARLIN(MSerial2, 2);
// TODO: remove this warning when SERIAL_DMA has been tested some more
#if ENABLED(SERIAL_DMA)
#warning "SERIAL_DMA may be unstable on HC32F460."
#endif
// //
// Serial port assertions // Serial port assertions
+8 -38
View File
@@ -25,42 +25,17 @@
#include <drivers/usart/Usart.h> #include <drivers/usart/Usart.h>
// Optionally set uart IRQ priority to reduce overflow errors // Optionally set uart IRQ priority to reduce overflow errors
//#define UART_RX_IRQ_PRIO 1 // #define UART_IRQ_PRIO 1
//#define UART_TX_IRQ_PRIO 1
//#define UART_RX_DMA_IRQ_PRIO 1
struct MarlinSerial : public Usart { struct MarlinSerial : public Usart {
MarlinSerial( MarlinSerial(struct usart_config_t *usart_device, gpio_pin_t tx_pin, gpio_pin_t rx_pin) : Usart(usart_device, tx_pin, rx_pin) {}
struct usart_config_t *usart_device,
gpio_pin_t tx_pin,
gpio_pin_t rx_pin
#if ENABLED(SERIAL_DMA)
, M4_DMA_TypeDef *dma_unit = nullptr,
en_dma_channel_t rx_dma_channel = DmaCh0
#endif
) : Usart(usart_device, tx_pin, rx_pin) {
#if ENABLED(SERIAL_DMA)
if (dma_unit != nullptr) {
enableRxDma(dma_unit, rx_dma_channel);
}
#endif
}
#if defined(UART_RX_IRQ_PRIO) || defined(UART_TX_IRQ_PRIO) || defined(UART_RX_DMA_IRQ_PRIO) #ifdef UART_IRQ_PRIO
void setPriority() { void setPriority() {
#if defined(UART_RX_IRQ_PRIO) NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_RX_IRQ_PRIO); NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_RX_IRQ_PRIO); NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_IRQ_PRIO);
#endif NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_IRQ_PRIO);
#if defined(UART_TX_IRQ_PRIO)
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_TX_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_TX_IRQ_PRIO);
#endif
#if defined(UART_RX_DMA_IRQ_PRIO) && ENABLED(SERIAL_DMA)
NVIC_SetPriority(c_dev()->dma.rx.rx_data_available_dma_btc.interrupt_number, UART_RX_DMA_IRQ_PRIO);
#endif
} }
void begin(uint32_t baud) { void begin(uint32_t baud) {
@@ -72,12 +47,7 @@ struct MarlinSerial : public Usart {
Usart::begin(baud, config); Usart::begin(baud, config);
setPriority(); setPriority();
} }
#endif
void begin(uint32_t baud, const stc_usart_uart_init_t *config, const bool rxNoiseFilter = true) {
Usart::begin(baud, config, rxNoiseFilter);
setPriority();
}
#endif // UART_RX_IRQ_PRIO || UART_TX_IRQ_PRIO || UART_RX_DMA_IRQ_PRIO
}; };
typedef Serial1Class<MarlinSerial> MSerialT; typedef Serial1Class<MarlinSerial> MSerialT;
-75
View File
@@ -1,75 +0,0 @@
/**
* app_config.h is included by the hc32f460 arduino build script for every source file.
* it is used to configure the arduino core (and ddl) automatically according
* to the settings in Configuration.h and Configuration_adv.h.
*/
#pragma once
#ifndef _HC32_APP_CONFIG_H_
#define _HC32_APP_CONFIG_H_
#include "../../inc/MarlinConfigPre.h"
//
// dev mode
//
#if ENABLED(MARLIN_DEV_MODE)
#define __DEBUG 1
#define __CORE_DEBUG 1
#endif
//
// Fault Handlers and Panic
//
#if ENABLED(POSTMORTEM_DEBUGGING)
// disable arduino core fault handler, as we define our own
#define CORE_DISABLE_FAULT_HANDLER 1
#endif
// force-enable panic handler so that we can use our custom one (in MinSerial)
#define PANIC_ENABLE 1
// use short filenames in ddl debug and core panic output
#define __DEBUG_SHORT_FILENAMES 1
#define __PANIC_SHORT_FILENAMES 1
// omit panic messages in core panic output
#define __OMIT_PANIC_MESSAGE 1
//
// Usart
//
// disable serial globals (Serial1, Serial2, ...), as we define our own
#define DISABLE_SERIAL_GLOBALS 1
// increase the size of the Usart buffers (both RX and TX)
// NOTE:
// the heap usage will increase by (SERIAL_BUFFER_SIZE - 64) * "number of serial ports used"
// if running out of heap, the system may become unstable
//#define SERIAL_BUFFER_SIZE 256
// enable support for Usart Clock Divider / Oversampling auto config
#define USART_AUTO_CLKDIV_OS_CONFIG 1
// enable USART_RX_DMA_SUPPORT core option when SERIAL_DMA is enabled
#if ENABLED(SERIAL_DMA)
#define USART_RX_DMA_SUPPORT 1
#endif
//
// Misc.
//
// redirect printf to host serial
#define REDIRECT_PRINTF_TO_SERIAL 1
// F_CPU must be known at compile time, but on HC32F460 it's not.
// Thus we assume HCLK to be 200MHz, as that's what is configured in
// 'core_hook_sysclock_init' in 'sysclock.cpp'.
// If you face issues with this assumption, please double-check with the values
// printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
// see also: HAL_TIMER_RATE in timers.h
#define F_CPU 200000000 // 200MHz HCLK
#endif // _HC32_APP_CONFIG_H_
+1 -3
View File
@@ -101,14 +101,12 @@ void setup_endstop_interrupts() {
SETUP(Z_MIN_PROBE); SETUP(Z_MIN_PROBE);
SETUP(CALIBRATION);
#undef SETUP #undef SETUP
} }
// Ensure 1 - 10 IRQs are registered // Ensure 1 - 10 IRQs are registered
// Disable some endstops if you encounter this error // Disable some endstops if you encounter this error
#define ENDSTOPS_INTERRUPTS_COUNT COUNT_ENABLED(USE_X_MAX, USE_X_MIN, USE_X2_MAX, USE_X2_MIN, USE_Y_MAX, USE_Y_MIN, USE_Y2_MAX, USE_Y2_MIN, USE_Z_MAX, USE_Z_MIN, USE_Z2_MAX, USE_Z2_MIN, USE_Z3_MAX, USE_Z3_MIN, USE_Z4_MAX, USE_Z4_MIN, USE_Z_MIN_PROBE, USE_CALIBRATION) #define ENDSTOPS_INTERRUPTS_COUNT COUNT_ENABLED(USE_X_MAX, USE_X_MIN, USE_X2_MAX, USE_X2_MIN, USE_Y_MAX, USE_Y_MIN, USE_Y2_MAX, USE_Y2_MIN, USE_Z_MAX, USE_Z_MIN, USE_Z2_MAX, USE_Z2_MIN, USE_Z3_MAX, USE_Z3_MIN, USE_Z4_MAX, USE_Z4_MIN, USE_Z_MIN_PROBE)
#if ENDSTOPS_INTERRUPTS_COUNT > 10 #if ENDSTOPS_INTERRUPTS_COUNT > 10
#error "Too many endstop interrupts! HC32F460 only supports 10 endstop interrupts." #error "Too many endstop interrupts! HC32F460 only supports 10 endstop interrupts."
#elif ENDSTOPS_INTERRUPTS_COUNT == 0 #elif ENDSTOPS_INTERRUPTS_COUNT == 0
-31
View File
@@ -20,20 +20,6 @@
* *
*/ */
#pragma once #pragma once
#include <core_util.h>
#if !defined(ARDUINO_CORE_VERSION_INT) || !defined(GET_VERSION_INT)
// version macros were introduced in arduino core version 1.1.0
// below that version, we polyfill them
#define GET_VERSION_INT(major, minor, patch) ((major * 100000) + (minor * 1000) + patch)
#define ARDUINO_CORE_VERSION_INT GET_VERSION_INT(1, 0, 0)
#endif
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
// because we use app_config.h introduced in arduino core version 1.1.0, the
// HAL is not compatible with older versions
#error "The HC32 HAL is not compatible with Arduino Core versions < 1.1.0. Consider updating the Arduino Core."
#endif
#ifndef BOARD_XTAL_FREQUENCY #ifndef BOARD_XTAL_FREQUENCY
#error "BOARD_XTAL_FREQUENCY is required for HC32F460." #error "BOARD_XTAL_FREQUENCY is required for HC32F460."
@@ -88,20 +74,3 @@
#error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN." #error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN."
#endif #endif
#endif #endif
#if ENABLED(SERIAL_DMA)
#if !defined(USART_RX_DMA_SUPPORT)
#error "SERIAL_DMA requires USART_RX_DMA_SUPPORT to be enabled in the arduino core."
#endif
// Before arduino core version 1.2.0, USART_RX_DMA_SUPPORT did not implement
// core_hook_usart_rx_irq, which is required for the emergency parser.
// With 1.2.0, this was fixed (see https://github.com/shadow578/framework-arduino-hc32f46x/pull/25).
#if ENABLED(EMERGENCY_PARSER) && ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 2, 0)
#error "EMERGENCY_PARSER is not supported with SERIAL_DMA. Please disable either SERIAL_DMA or EMERGENCY_PARSER."
#endif
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
#error "SERIAL_DMA is not supported with arduino core version < 1.1.0."
#endif
#endif
+18 -18
View File
@@ -31,24 +31,24 @@
#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS #define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS #define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
#define isValidPin(pin) IS_GPIO_PIN(pin) #define VALID_PIN(pin) IS_GPIO_PIN(pin)
// Note: pin_array is defined in `Marlin/src/pins/pinsDebug.h`, and since this file is included // Note: pin_array is defined in `Marlin/src/pins/pinsDebug.h`, and since this file is included
// after it, it is available in this file as well. // after it, it is available in this file as well.
#define getPinByIndex(p) pin_t(pin_array[p].pin) #define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
#define digitalRead_mod(p) extDigitalRead(p) #define digitalRead_mod(p) extDigitalRead(p)
#define printPinNumber(p) \ #define PRINT_PIN(p) \
do { \ do { \
sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); \ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); \
SERIAL_ECHO(buffer); \ SERIAL_ECHO(buffer); \
} while (0) } while (0)
#define printPinAnalog(p) \ #define PRINT_PIN_ANALOG(p) \
do { \ do { \
sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); \ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); \
SERIAL_ECHO(buffer); \ SERIAL_ECHO(buffer); \
} while (0) } while (0)
#define PRINT_PORT(p) printPinPort(p) #define PRINT_PORT(p) print_port(p)
#define printPinNameByIndex(x) \ #define PRINT_ARRAY_NAME(x) \
do { \ do { \
sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); \ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); \
SERIAL_ECHO(buffer); \ SERIAL_ECHO(buffer); \
@@ -71,14 +71,14 @@
#define M43_NEVER_TOUCH(Q) (IS_HOST_USART_PIN(Q) || IS_OSC_PIN(Q)) #define M43_NEVER_TOUCH(Q) (IS_HOST_USART_PIN(Q) || IS_OSC_PIN(Q))
#endif #endif
static int8_t digitalPinToAnalogIndex(pin_t pin) { static pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
if (!isValidPin(pin)) return -1; if (!VALID_PIN(pin)) return -1;
const int8_t adc_channel = int8_t(PIN_MAP[pin].adc_info.channel); const int8_t adc_channel = int8_t(PIN_MAP[pin].adc_info.channel);
return pin_t(adc_channel); return pin_t(adc_channel);
} }
static bool isAnalogPin(pin_t pin) { static bool IS_ANALOG(pin_t pin) {
if (!isValidPin(pin)) return false; if (!VALID_PIN(pin)) return false;
if (PIN_MAP[pin].adc_info.channel != ADC_PIN_INVALID) if (PIN_MAP[pin].adc_info.channel != ADC_PIN_INVALID)
return _GET_MODE(pin) == INPUT_ANALOG && !M43_NEVER_TOUCH(pin); return _GET_MODE(pin) == INPUT_ANALOG && !M43_NEVER_TOUCH(pin);
@@ -86,13 +86,13 @@ static bool isAnalogPin(pin_t pin) {
return false; return false;
} }
static bool getValidPinMode(const pin_t pin) { static bool GET_PINMODE(const pin_t pin) {
return isValidPin(pin) && !IS_INPUT(pin); return VALID_PIN(pin) && !IS_INPUT(pin);
} }
static bool getPinIsDigitalByIndex(const int16_t array_pin) { static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
const pin_t pin = getPinByIndex(array_pin); const pin_t pin = GET_ARRAY_PIN(array_pin);
return (!isAnalogPin(pin)); return (!IS_ANALOG(pin));
} }
/** /**
@@ -117,7 +117,7 @@ bool pwm_status(const pin_t pin) {
return timera_is_unit_initialized(unit) && timera_is_channel_active(unit, channel) && getPinMode(pin) == OUTPUT_PWM; return timera_is_unit_initialized(unit) && timera_is_channel_active(unit, channel) && getPinMode(pin) == OUTPUT_PWM;
} }
void printPinPWM(const pin_t pin) { void pwm_details(const pin_t pin) {
// Get timer assignment for pin // Get timer assignment for pin
timera_config_t *unit; timera_config_t *unit;
en_timera_channel_t channel; en_timera_channel_t channel;
@@ -161,7 +161,7 @@ void printPinPWM(const pin_t pin) {
} }
} }
void printPinPort(pin_t pin) { void print_port(pin_t pin) {
const char port = 'A' + char(pin >> 4); // Pin div 16 const char port = 'A' + char(pin >> 4); // Pin div 16
const int16_t gbit = PIN_MAP[pin].bit_pos; const int16_t gbit = PIN_MAP[pin].bit_pos;
char buffer[8]; char buffer[8];
+17 -26
View File
@@ -54,7 +54,7 @@
fn \ fn \
} }
stc_sd_handle_t *handle = nullptr; stc_sd_handle_t *handle;
bool SDIO_Init() { bool SDIO_Init() {
// Configure SDIO pins // Configure SDIO pins
@@ -66,45 +66,36 @@ bool SDIO_Init() {
GPIO_SetFunc(BOARD_SDIO_CMD, Func_Sdio); GPIO_SetFunc(BOARD_SDIO_CMD, Func_Sdio);
GPIO_SetFunc(BOARD_SDIO_DET, Func_Sdio); GPIO_SetFunc(BOARD_SDIO_DET, Func_Sdio);
// If a handle is already initialized, free it before creating a new one
// otherwise, we will leak memory, which will eventually crash the system
if (handle != nullptr) {
delete handle->pstcDmaInitCfg;
delete handle->pstcCardInitCfg;
delete handle;
handle = nullptr;
}
// Create DMA configuration // Create DMA configuration
stc_sdcard_dma_init_t *dmaConf = new stc_sdcard_dma_init_t; stc_sdcard_dma_init_t *dmaConf = new stc_sdcard_dma_init_t;
dmaConf->DMAx = SDIO_DMA_PERIPHERAL; dmaConf->DMAx = SDIO_DMA_PERIPHERAL;
dmaConf->enDmaCh = SDIO_DMA_CHANNEL; dmaConf->enDmaCh = SDIO_DMA_CHANNEL;
// Create card configuration
// This should be a fairly safe configuration for most cards
stc_sdcard_init_t *cardConf = new stc_sdcard_init_t;
cardConf->enBusWidth = SdiocBusWidth4Bit;
cardConf->enClkFreq = SdiocClk400K;
cardConf->enSpeedMode = SdiocNormalSpeedMode;
cardConf->pstcInitCfg = nullptr;
// Create handle in DMA mode // Create handle in DMA mode
handle = new stc_sd_handle_t; handle = new stc_sd_handle_t;
handle->SDIOCx = SDIO_PERIPHERAL; handle->SDIOCx = SDIO_PERIPHERAL;
handle->enDevMode = SdCardDmaMode; handle->enDevMode = SdCardDmaMode;
handle->pstcDmaInitCfg = dmaConf; handle->pstcDmaInitCfg = dmaConf;
//handle->pstcCardInitCfg = cardConf; // assigned in SDCARD_Init
// Create card configuration
// This should be a fairly safe configuration for most cards
stc_sdcard_init_t cardConf = {
.enBusWidth = SdiocBusWidth4Bit,
.enClkFreq = SdiocClk400K,
.enSpeedMode = SdiocNormalSpeedMode,
//.pstcInitCfg = NULL,
};
// Initialize sd card // Initialize sd card
en_result_t rc = SDCARD_Init(handle, cardConf); en_result_t rc = SDCARD_Init(handle, &cardConf);
if (rc != Ok) printf("SDIO_Init() error (rc=%u)\n", rc); if (rc != Ok) printf("SDIO_Init() error (rc=%u)\n", rc);
return rc == Ok; return rc == Ok;
} }
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false); CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(dst != nullptr, "SDIO_ReadBlock dst is NULL", return false); CORE_ASSERT(dst != NULL, "SDIO_ReadBlock dst is NULL");
WITH_RETRY(SDIO_READ_RETRIES, { WITH_RETRY(SDIO_READ_RETRIES, {
en_result_t rc = SDCARD_ReadBlocks(handle, block, 1, dst, SDIO_READ_TIMEOUT); en_result_t rc = SDCARD_ReadBlocks(handle, block, 1, dst, SDIO_READ_TIMEOUT);
@@ -116,8 +107,8 @@ bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
} }
bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false); CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(src != nullptr, "SDIO_WriteBlock src is NULL", return false); CORE_ASSERT(src != NULL, "SDIO_WriteBlock src is NULL");
WITH_RETRY(SDIO_WRITE_RETRIES, { WITH_RETRY(SDIO_WRITE_RETRIES, {
en_result_t rc = SDCARD_WriteBlocks(handle, block, 1, (uint8_t *)src, SDIO_WRITE_TIMEOUT); en_result_t rc = SDCARD_WriteBlocks(handle, block, 1, (uint8_t *)src, SDIO_WRITE_TIMEOUT);
@@ -129,12 +120,12 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
} }
bool SDIO_IsReady() { bool SDIO_IsReady() {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false); CORE_ASSERT(handle != NULL, "SDIO not initialized");
return bool(handle->stcCardStatus.READY_FOR_DATA); return bool(handle->stcCardStatus.READY_FOR_DATA);
} }
uint32_t SDIO_GetCardSize() { uint32_t SDIO_GetCardSize() {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return 0); CORE_ASSERT(handle != NULL, "SDIO not initialized");
// Multiply number of blocks with block size to get size in bytes // Multiply number of blocks with block size to get size in bytes
const uint64_t cardSizeBytes = uint64_t(handle->stcSdCardInfo.u32LogBlockNbr) * uint64_t(handle->stcSdCardInfo.u32LogBlockSize); const uint64_t cardSizeBytes = uint64_t(handle->stcSdCardInfo.u32LogBlockNbr) * uint64_t(handle->stcSdCardInfo.u32LogBlockSize);
+9 -24
View File
@@ -96,44 +96,29 @@ void core_hook_sysclock_init() {
#endif #endif
#endif #endif
// sysclk is now configured according to F_CPU (i.e., 200MHz PLL output) // Setup clock divisors for sysclk = 200 MHz:
const uint32_t sysclock = F_CPU;
// Setup clock divisors for sysclk = 200 MHz
// Note: PCLK1 is used for step+temp timers, and need to be kept at 50 MHz (until there is a better solution) // Note: PCLK1 is used for step+temp timers, and need to be kept at 50 MHz (until there is a better solution)
constexpr stc_clk_sysclk_cfg_t sysClkConf = { stc_clk_sysclk_cfg_t sysClkConf = {
.enHclkDiv = ClkSysclkDiv1, // HCLK = 200 MHz (CPU) .enHclkDiv = ClkSysclkDiv1, // HCLK = 200 MHz (CPU)
.enExclkDiv = ClkSysclkDiv2, // EXCLK = 100 MHz (SDIO) .enExclkDiv = ClkSysclkDiv2, // EXCLK = 100 MHz (SDIO)
.enPclk0Div = ClkSysclkDiv2, // PCLK0 = 100 MHz (Timer6 (not used)) .enPclk0Div = ClkSysclkDiv1, // PCLK0 = 200 MHz (Timer6 (not used))
.enPclk1Div = ClkSysclkDiv4, // PCLK1 = 50 MHz (USART, SPI, I2S, Timer0 (step+temp), TimerA (Servo)) .enPclk1Div = ClkSysclkDiv4, // PCLK1 = 50 MHz (USART, SPI, I2S, Timer0 (step+temp), TimerA (Servo))
.enPclk2Div = ClkSysclkDiv8, // PCLK2 = 25 MHz (ADC) .enPclk2Div = ClkSysclkDiv4, // PCLK2 = 50 MHz (ADC)
.enPclk3Div = ClkSysclkDiv8, // PCLK3 = 25 MHz (I2C, WDT) .enPclk3Div = ClkSysclkDiv4, // PCLK3 = 50 MHz (I2C, WDT)
.enPclk4Div = ClkSysclkDiv2, // PCLK4 = 100 MHz (ADC ctl) .enPclk4Div = ClkSysclkDiv2, // PCLK4 = 100 MHz (ADC ctl)
}; };
#if ARDUINO_CORE_VERSION_INT >= GET_VERSION_INT(1, 2, 0)
assert_system_clocks_valid<
sysclock,
sysClkConf.enHclkDiv,
sysClkConf.enPclk0Div,
sysClkConf.enPclk1Div,
sysClkConf.enPclk2Div,
sysClkConf.enPclk3Div,
sysClkConf.enPclk4Div,
sysClkConf.enExclkDiv
>();
#endif
sysclock_set_clock_dividers(&sysClkConf); sysclock_set_clock_dividers(&sysClkConf);
// Set power mode // Set power mode
power_mode_update_pre(sysclock); #define POWER_MODE_SYSTEM_CLOCK 200000000 // 200 MHz
power_mode_update_pre(POWER_MODE_SYSTEM_CLOCK);
// Switch to MPLL as sysclk source // Switch to MPLL as sysclk source
CLK_SetSysClkSource(CLKSysSrcMPLL); CLK_SetSysClkSource(CLKSysSrcMPLL);
// Set power mode // Set power mode
power_mode_update_post(sysclock); power_mode_update_post(POWER_MODE_SYSTEM_CLOCK);
#undef POWER_MODE_SYSTEM_CLOCK
} }
#endif // ARDUINO_ARCH_HC32 #endif // ARDUINO_ARCH_HC32
+27 -31
View File
@@ -38,48 +38,44 @@ extern Timer0 step_timer;
// Timer Configurations // Timer Configurations
// //
/** // TODO: some calculations (step irq min_step_rate) require the timer rate to be known at compile time
* HAL_TIMER_RATE must be known at compile time since it's used to calculate // this is not possible with the HC32F460, as the timer rate depends on PCLK1
* STEPPER_TIMER_RATE, which is used in 'constexpr' calculations. // as a workaround, PCLK1 = 50MHz is assumed (check with clock dump in MarlinHAL::init())
* On the HC32F460 the timer rate depends on PCLK1, which is derived from the #define HAL_TIMER_RATE 50000000 // 50MHz
* system clock configured at runtime. As a workaround, we use the existing // #define HAL_TIMER_RATE TIMER0_BASE_FREQUENCY
* assumption of a 200MHz clock, defining F_CPU as 200000000, then configure PCLK1
* as F_CPU with a divider of 4 in 'sysclock.cpp::core_hook_sysclock_init'. // TODO: CYCLES_PER_MICROSECOND seems to be used by Marlin to calculate the number of cycles per microsecond in the timer ISRs
* // by default, it uses F_CPU, but since that is not known at compile time for HC32, we overwrite it here
* If you face issues with this assumption, please double-check with the values #undef CYCLES_PER_MICROSECOND
* printed by 'MarlinHAL::HAL_clock_frequencies_dump'. #define CYCLES_PER_MICROSECOND (HAL_TIMER_RATE / 1000000UL)
*
* TODO: If the 'constexpr' requirement is ever lifted, use TIMER0_BASE_FREQUENCY instead
*/
#define HAL_TIMER_RATE (F_CPU / 4) // i.e., 50MHz
//#define HAL_TIMER_RATE TIMER0_BASE_FREQUENCY
// Temperature timer // Temperature timer
#define TEMP_TIMER_NUM (&temp_timer) #define TEMP_TIMER_NUM (&temp_timer)
#define TEMP_TIMER_PRIORITY DDL_IRQ_PRIORITY_02 #define TEMP_TIMER_PRIORITY DDL_IRQ_PRIORITY_02
#define TEMP_TIMER_PRESCALE 16UL // 12.5MHz #define TEMP_TIMER_PRESCALE 16ul
#define TEMP_TIMER_RATE 1000 // 1kHz #define TEMP_TIMER_RATE 1000 // 1kHz
#define TEMP_TIMER_FREQUENCY TEMP_TIMER_RATE // 1kHz also #define TEMP_TIMER_FREQUENCY TEMP_TIMER_RATE // Alias for Marlin
// Stepper timer // Stepper timer
#define STEP_TIMER_NUM (&step_timer) #define STEP_TIMER_NUM (&step_timer)
#define STEP_TIMER_PRIORITY DDL_IRQ_PRIORITY_00 // Top priority, nothing else uses it #define STEP_TIMER_PRIORITY DDL_IRQ_PRIORITY_01
#define STEPPER_TIMER_PRESCALE 16UL // 12.5MHz #define STEPPER_TIMER_PRESCALE 16ul
#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // 50MHz / 16 = 3.125MHz // TODO: STEPPER_TIMER_RATE seems to work fine like this, but requires further testing...
#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000UL) // Integer 3 #define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // 50MHz / 16 = 3.125MHz
#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000)
// Pulse timer (== stepper timer) // Pulse timer (== stepper timer)
#define PULSE_TIMER_NUM STEP_TIMER_NUM #define PULSE_TIMER_NUM STEP_TIMER_NUM
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
// //
// Channel aliases // Channel aliases
// //
#define MF_TIMER_TEMP TEMP_TIMER_NUM #define MF_TIMER_TEMP TEMP_TIMER_NUM
#define MF_TIMER_STEP STEP_TIMER_NUM #define MF_TIMER_STEP STEP_TIMER_NUM
#define MF_TIMER_PULSE PULSE_TIMER_NUM #define MF_TIMER_PULSE PULSE_TIMER_NUM
// //
// HAL functions // HAL functions
@@ -82,7 +82,7 @@ static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, c
} }
static void u8g_sw_spi_shift_out(uint8_t val) { static void u8g_sw_spi_shift_out(uint8_t val) {
#if U8G_SPI_USE_MODE_3 #if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed); swSpiTransfer_mode_3(val, SPI_speed);
#else #else
swSpiTransfer_mode_0(val, SPI_speed); swSpiTransfer_mode_0(val, SPI_speed);
@@ -116,15 +116,15 @@ uint8_t u8g_com_HAL_HC32_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
break; break;
case U8G_COM_MSG_CHIP_SELECT: 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 ANY(FYSETC_MINI_12864, MKS_MINI_12864) // 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 if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
WRITE(DOGLCD_SCK, HIGH); // Set SCK to mode 3 idle state before CS goes active WRITE(DOGLCD_SCK, HIGH); // Set SCK to mode 3 idle state before CS goes active
WRITE(DOGLCD_CS, LOW); WRITE(DOGLCD_CS, LOW);
} }
else { else {
WRITE(DOGLCD_CS, HIGH); WRITE(DOGLCD_CS, HIGH);
WRITE(DOGLCD_SCK, LOW); // Set SCK to mode 0 idle state after CS goes inactive WRITE(DOGLCD_SCK, LOW); // Set SCK to mode 0 idle state after CS goes inactive
} }
#else #else
WRITE(DOGLCD_CS, !arg_val); WRITE(DOGLCD_CS, !arg_val);
+1 -1
View File
@@ -52,7 +52,7 @@ uint8_t MarlinHAL::active_ch = 0;
uint16_t MarlinHAL::adc_value() { uint16_t MarlinHAL::adc_value() {
const pin_t pin = analogInputToDigitalPin(active_ch); const pin_t pin = analogInputToDigitalPin(active_ch);
if (!isValidPin(pin)) return 0; if (!VALID_PIN(pin)) return 0;
return uint16_t((Gpio::get(pin) >> 2) & 0x3FF); // return 10bit value as Marlin expects return uint16_t((Gpio::get(pin) >> 2) & 0x3FF); // return 10bit value as Marlin expects
} }
+6 -6
View File
@@ -49,28 +49,28 @@ extern "C" void delay(const int msec) {
// IO functions // IO functions
// As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2) // As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
void pinMode(const pin_t pin, const uint8_t mode) { void pinMode(const pin_t pin, const uint8_t mode) {
if (!isValidPin(pin)) return; if (!VALID_PIN(pin)) return;
Gpio::setMode(pin, mode); Gpio::setMode(pin, mode);
} }
void digitalWrite(pin_t pin, uint8_t pin_status) { void digitalWrite(pin_t pin, uint8_t pin_status) {
if (!isValidPin(pin)) return; if (!VALID_PIN(pin)) return;
Gpio::set(pin, pin_status); Gpio::set(pin, pin_status);
} }
bool digitalRead(pin_t pin) { bool digitalRead(pin_t pin) {
if (!isValidPin(pin)) return false; if (!VALID_PIN(pin)) return false;
return Gpio::get(pin); return Gpio::get(pin);
} }
void analogWrite(pin_t pin, int pwm_value) { // 1 - 254: pwm_value, 0: LOW, 255: HIGH void analogWrite(pin_t pin, int pwm_value) { // 1 - 254: pwm_value, 0: LOW, 255: HIGH
if (!isValidPin(pin)) return; if (!VALID_PIN(pin)) return;
Gpio::set(pin, pwm_value); Gpio::set(pin, pwm_value);
} }
uint16_t analogRead(pin_t adc_pin) { uint16_t analogRead(pin_t adc_pin) {
if (!isValidPin(digitalPinToAnalogIndex(adc_pin))) return 0; if (!VALID_PIN(DIGITAL_PIN_TO_ANALOG_PIN(adc_pin))) return 0;
return Gpio::get(digitalPinToAnalogIndex(adc_pin)); return Gpio::get(DIGITAL_PIN_TO_ANALOG_PIN(adc_pin));
} }
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) { char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) {
+1 -4
View File
@@ -37,10 +37,7 @@ Timer::Timer() {
} }
Timer::~Timer() { Timer::~Timer() {
if (timerid != 0) { timer_delete(timerid);
timer_delete(timerid);
timerid = 0;
}
} }
void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) { void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
+2 -2
View File
@@ -42,7 +42,7 @@ constexpr pin_t analogInputToDigitalPin(const int8_t p) {
} }
// Get the analog index for a digital pin // Get the analog index for a digital pin
constexpr int8_t digitalPinToAnalogIndex(const pin_t p) { constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC); return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC);
} }
@@ -50,7 +50,7 @@ constexpr int8_t digitalPinToAnalogIndex(const pin_t p) {
constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; } constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; }
// Test whether the pin is valid // Test whether the pin is valid
constexpr bool isValidPin(const pin_t p) { return WITHIN(p, 0, NUM_DIGITAL_PINS); } constexpr bool VALID_PIN(const pin_t p) { return WITHIN(p, 0, NUM_DIGITAL_PINS); }
// Test whether the pin is PWM // Test whether the pin is PWM
constexpr bool PWM_PIN(const pin_t p) { return false; } constexpr bool PWM_PIN(const pin_t p) { return false; }
-2
View File
@@ -21,7 +21,6 @@
*/ */
#ifdef __PLAT_LINUX__ #ifdef __PLAT_LINUX__
#ifndef UNIT_TEST
//#define GPIO_LOGGING // Full GPIO and Positional Logging //#define GPIO_LOGGING // Full GPIO and Positional Logging
@@ -136,5 +135,4 @@ int main() {
read_serial.join(); read_serial.join();
} }
#endif // UNIT_TEST
#endif // __PLAT_LINUX__ #endif // __PLAT_LINUX__
+11 -11
View File
@@ -29,20 +29,20 @@
*/ */
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0) #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
#define digitalRead_mod(p) digitalRead(p) #define digitalRead_mod(p) digitalRead(p)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
// active ADC function/mode/code values for PINSEL registers // active ADC function/mode/code values for PINSEL registers
constexpr int8_t ADC_pin_mode(pin_t pin) { return -1; } constexpr int8_t ADC_pin_mode(pin_t pin) { return -1; }
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; } int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) ? 0 : -1; }
bool getValidPinMode(const pin_t pin) { bool GET_PINMODE(const pin_t pin) {
const int8_t pin_mode = get_pin_mode(pin); const int8_t pin_mode = get_pin_mode(pin);
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin
return false; return false;
@@ -50,11 +50,11 @@ bool getValidPinMode(const pin_t pin) {
return (Gpio::getMode(pin) != 0); // Input/output state return (Gpio::getMode(pin) != 0); // Input/output state
} }
bool getPinIsDigitalByIndex(const pin_t pin) { bool GET_ARRAY_IS_DIGITAL(const pin_t pin) {
return (!isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin)); return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
} }
void printPinPWM(const pin_t pin) {} void pwm_details(const pin_t pin) {}
bool pwm_status(const pin_t) { return false; } bool pwm_status(const pin_t) { return false; }
void printPinPort(const pin_t) {} void print_port(const pin_t) {}
+6
View File
@@ -28,6 +28,12 @@
// spiBeginTransaction. // spiBeginTransaction.
#endif #endif
// Onboard SD
//#define SD_SCK_PIN P0_07
//#define SD_MISO_PIN P0_08
//#define SD_MOSI_PIN P0_09
//#define SD_SS_PIN P0_06
// External SD // External SD
#ifndef SD_SCK_PIN #ifndef SD_SCK_PIN
#define SD_SCK_PIN 50 #define SD_SCK_PIN 50
+10 -10
View File
@@ -82,13 +82,13 @@ extern DefaultSerial1 USBSerial;
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if MMU_SERIAL_PORT == -1 #if MMU2_SERIAL_PORT == -1
#define MMU_SERIAL USBSerial #define MMU2_SERIAL USBSerial
#elif WITHIN(MMU_SERIAL_PORT, 0, 3) #elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#error "MMU_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif #endif
#endif #endif
@@ -100,7 +100,7 @@ extern DefaultSerial1 USBSerial;
#else #else
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif #endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
#endif #endif
#endif #endif
@@ -137,12 +137,12 @@ extern DefaultSerial1 USBSerial;
// //
// Test whether the pin is valid // Test whether the pin is valid
constexpr bool isValidPin(const pin_t pin) { constexpr bool VALID_PIN(const pin_t pin) {
return LPC176x::pin_is_valid(pin); return LPC176x::pin_is_valid(pin);
} }
// Get the analog index for a digital pin // Get the analog index for a digital pin
constexpr int8_t digitalPinToAnalogIndex(const pin_t pin) { constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t pin) {
return (LPC176x::pin_is_valid(pin) && LPC176x::pin_has_adc(pin)) ? pin : -1; return (LPC176x::pin_is_valid(pin) && LPC176x::pin_has_adc(pin)) ? pin : -1;
} }
@@ -159,7 +159,7 @@ constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) {
// Parse a G-code word into a pin index // Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
// P0.6 thru P0.9 are for the onboard SD card // P0.6 thru P0.9 are for the onboard SD card
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09 #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09,
// ------------------------ // ------------------------
// Defines // Defines
@@ -146,12 +146,6 @@ void setup_endstop_interrupts() {
#endif #endif
_ATTACH(Z_MIN_PROBE_PIN); _ATTACH(Z_MIN_PROBE_PIN);
#endif #endif
#if USE_CALIBRATION
#if !LPC1768_PIN_INTERRUPT_M(CALIBRATION_PIN)
#error "CALIBRATION_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(CALIBRATION_PIN);
#endif
#if USE_I_MAX #if USE_I_MAX
#if !LPC1768_PIN_INTERRUPT_M(I_MAX_PIN) #if !LPC1768_PIN_INTERRUPT_M(I_MAX_PIN)
#error "I_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #error "I_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+2 -4
View File
@@ -26,10 +26,8 @@
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
if (!LPC176x::pin_is_valid(pin)) return; if (!LPC176x::pin_is_valid(pin)) return;
if (LPC176x::pwm_attach_pin(pin)) { if (LPC176x::pwm_attach_pin(pin))
const uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, LPC176x::pwm_get_period(pin)); LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
LPC176x::pwm_write(pin, duty);
}
} }
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
+1 -1
View File
@@ -66,7 +66,7 @@
#define _WRITE(IO,V) WRITE_PIN(IO,V) #define _WRITE(IO,V) WRITE_PIN(IO,V)
/// toggle a pin /// toggle a pin
#define _TOGGLE(IO) LPC176x::gpio_toggle(IO) #define _TOGGLE(IO) _WRITE(IO, !READ(IO))
/// set pin as input /// set pin as input
#define _SET_INPUT(IO) SET_DIR_INPUT(IO) #define _SET_INPUT(IO) SET_DIR_INPUT(IO)
+9 -9
View File
@@ -29,12 +29,12 @@
*/ */
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0) #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
#define digitalRead_mod(p) extDigitalRead(p) #define digitalRead_mod(p) extDigitalRead(p)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(p), LPC176x::pin_bit(p)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(p), LPC176x::pin_bit(p)); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR("_A%d "), LPC176x::pin_get_adc_channel(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR("_A%d "), LPC176x::pin_get_adc_channel(pin)); SERIAL_ECHO(buffer); }while(0)
#define MULTI_NAME_PAD 17 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 17 // space needed to be pretty if not first name assigned to a pin
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities // pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
@@ -42,15 +42,15 @@
#define M43_NEVER_TOUCH(Q) ((Q) == P0_29 || (Q) == P0_30 || (Q) == P2_09) // USB pins #define M43_NEVER_TOUCH(Q) ((Q) == P0_29 || (Q) == P0_30 || (Q) == P2_09) // USB pins
#endif #endif
bool getValidPinMode(const pin_t pin) { bool GET_PINMODE(const pin_t pin) {
if (!LPC176x::pin_is_valid(pin) || LPC176x::pin_adc_enabled(pin)) // Invalid pin or active analog pin if (!LPC176x::pin_is_valid(pin) || LPC176x::pin_adc_enabled(pin)) // Invalid pin or active analog pin
return false; return false;
return LPC176x::gpio_direction(pin); return LPC176x::gpio_direction(pin);
} }
#define getPinIsDigitalByIndex(x) ((bool) pin_array[x].is_digital) #define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
void printPinPort(const pin_t) {} void print_port(const pin_t) {}
void printPinPWM(const pin_t) {} void pwm_details(const pin_t) {}
bool pwm_status(const pin_t) { return false; } bool pwm_status(const pin_t) { return false; }
+6 -7
View File
@@ -28,13 +28,12 @@
// spiBeginTransaction. // spiBeginTransaction.
#endif #endif
// Onboard SD /** onboard SD card */
//#define SD_SCK_PIN P0_07 //#define SD_SCK_PIN P0_07
//#define SD_MISO_PIN P0_08 //#define SD_MISO_PIN P0_08
//#define SD_MOSI_PIN P0_09 //#define SD_MOSI_PIN P0_09
//#define SD_SS_PIN P0_06 //#define SD_SS_PIN P0_06
/** external */
// External SD
#ifndef SD_SCK_PIN #ifndef SD_SCK_PIN
#define SD_SCK_PIN P0_15 #define SD_SCK_PIN P0_15
#endif #endif
@@ -132,7 +132,7 @@ uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck
static uint8_t SPI_speed = 0; static uint8_t SPI_speed = 0;
static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) { static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
#if U8G_SPI_USE_MODE_3 #if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin); swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
#else #else
swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin); swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin);
@@ -160,15 +160,15 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
break; break;
case U8G_COM_MSG_CHIP_SELECT: case U8G_COM_MSG_CHIP_SELECT:
#if U8G_SPI_USE_MODE_3 // LCD SPI is running mode 3 while SD card is running mode 0 #if ANY(FYSETC_MINI_12864, MKS_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
u8g_SetPILevel(u8g, U8G_PI_CS, LOW); u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
} }
else { else {
u8g_SetPILevel(u8g, U8G_PI_CS, HIGH); u8g_SetPILevel(u8g, U8G_PI_CS, HIGH);
u8g_SetPILevel(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive u8g_SetPILevel(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive
} }
#else #else
u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val); u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
@@ -13,9 +13,9 @@ if pioutil.is_pio_build():
target_drive = "REARM" target_drive = "REARM"
import platform import platform
current_OS = platform.system()
env = pioutil.env current_OS = platform.system()
Import("env")
def print_error(e): def print_error(e):
print('\nUnable to find destination disk (%s)\n' \ print('\nUnable to find destination disk (%s)\n' \
+4 -4
View File
@@ -87,11 +87,11 @@ extern MSerialT serial_stream_3;
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 0, 3) #if WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#error "MMU_SERIAL_PORT must be from 0 to 3. Please update your configuration." #error "MMU2_SERIAL_PORT must be from 0 to 3. Please update your configuration."
#endif #endif
#endif #endif
+6 -6
View File
@@ -27,9 +27,9 @@
int8_t ADC_pin_mode(pin_t pin) { return -1; } int8_t ADC_pin_mode(pin_t pin) { return -1; }
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; } int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) ? 0 : -1; }
bool getValidPinMode(const pin_t pin) { bool GET_PINMODE(const pin_t pin) {
const int8_t pin_mode = get_pin_mode(pin); const int8_t pin_mode = get_pin_mode(pin);
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin
return false; return false;
@@ -37,12 +37,12 @@ bool getValidPinMode(const pin_t pin) {
return (Gpio::getMode(pin) != 0); // Input/output state return (Gpio::getMode(pin) != 0); // Input/output state
} }
bool getPinIsDigitalByIndex(const pin_t pin) { bool GET_ARRAY_IS_DIGITAL(const pin_t pin) {
return !isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin); return !IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin);
} }
void printPinPort(const pin_t) {} void print_port(const pin_t) {}
void printPinPWM(const pin_t) {} void pwm_details(const pin_t) {}
bool pwm_status(const pin_t) { return false; } bool pwm_status(const pin_t) { return false; }
#endif #endif
+9 -9
View File
@@ -30,19 +30,19 @@
*/ */
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0) #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
#define digitalRead_mod(p) digitalRead(p) #define digitalRead_mod(p) digitalRead(p)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
// Active ADC function/mode/code values for PINSEL registers // Active ADC function/mode/code values for PINSEL registers
int8_t ADC_pin_mode(pin_t pin); int8_t ADC_pin_mode(pin_t pin);
int8_t get_pin_mode(const pin_t pin); int8_t get_pin_mode(const pin_t pin);
bool getValidPinMode(const pin_t pin); bool GET_PINMODE(const pin_t pin);
bool getPinIsDigitalByIndex(const pin_t pin); bool GET_ARRAY_IS_DIGITAL(const pin_t pin);
void printPinPort(const pin_t); void print_port(const pin_t);
void printPinPWM(const pin_t); void pwm_details(const pin_t);
bool pwm_status(const pin_t); bool pwm_status(const pin_t);
@@ -131,7 +131,7 @@ static uint8_t swSpiInit(const uint8_t spi_speed, const uint8_t clk_pin, const u
} }
static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) { static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
#if U8G_SPI_USE_MODE_3 #if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin); swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
#else #else
swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin); swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin);
@@ -159,15 +159,15 @@ uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt
break; break;
case U8G_COM_MSG_CHIP_SELECT: case U8G_COM_MSG_CHIP_SELECT:
#if U8G_SPI_USE_MODE_3 // LCD SPI is running mode 3 while SD card is running mode 0 #if ANY(FYSETC_MINI_12864, MKS_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
u8g_SetPILevel(u8g, U8G_PI_CS, LOW); u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
} }
else { else {
u8g_SetPILevel(u8g, U8G_PI_CS, HIGH); u8g_SetPILevel(u8g, U8G_PI_CS, HIGH);
u8g_SetPILevel(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive u8g_SetPILevel(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive
} }
#else #else
u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val); u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
+6 -6
View File
@@ -69,13 +69,13 @@ extern DefaultSerial3 MSerial1;
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 0, 1) #if WITHIN(MMU2_SERIAL_PORT, 0, 1)
#define MMU_SERIAL MSERIAL(SERIAL_PORT) #define MMU2_SERIAL MSERIAL(SERIAL_PORT)
#elif MMU_SERIAL_PORT == -1 #elif MMU2_SERIAL_PORT == -1
#define MMU_SERIAL MSerialUSB #define MMU2_SERIAL MSerialUSB
#else #else
#error "MMU_SERIAL_PORT must be -1 (Native USB only)." #error "MMU2_SERIAL_PORT must be -1 (Native USB only)."
#endif #endif
#endif #endif
+1 -9
View File
@@ -83,7 +83,6 @@
#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) #define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN))
#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) #define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN))
#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) #define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN))
#define MATCH_CALIBRATION_EILINE(P) TERN0(USE_CALIBRATION, DEFER4(MATCH_EILINE)(P, CALIBRATION_PIN))
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ #define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \ && !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
@@ -100,8 +99,7 @@
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \ && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \ && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \ && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P) \ && !MATCH_Z_MIN_PROBE_EILINE(P) )
&& !MATCH_CALIBRATION_EILINE(P) )
// One ISR for all EXT-Interrupts // One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
@@ -210,12 +208,6 @@ void setup_endstop_interrupts() {
#endif #endif
_ATTACH(Z_MIN_PROBE_PIN); _ATTACH(Z_MIN_PROBE_PIN);
#endif #endif
#if USE_CALIBRATION
#if !AVAILABLE_EILINE(CALIBRATION_PIN)
#error "CALIBRATION_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(CALIBRATION_PIN);
#endif
#if USE_I_MAX #if USE_I_MAX
#if !AVAILABLE_EILINE(I_MAX_PIN) #if !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+1 -1
View File
@@ -152,7 +152,7 @@
: ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \ : ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \
: ADC_INPUTCTRL_MUXPOS_PIN15) : ADC_INPUTCTRL_MUXPOS_PIN15)
#define digitalPinToAnalogIndex(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1) #define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1)
/** /**
* pins * pins
+10 -9
View File
@@ -30,13 +30,14 @@
#define digitalRead_mod(p) extDigitalRead(p) #define digitalRead_mod(p) extDigitalRead(p)
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0) #define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); 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 PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define isValidPin(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL) #define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL)
#define isAnalogPin(P) (digitalPinToAnalogIndex(P)!=-1) #define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p)
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1)
#define pwm_status(pin) digitalPinHasPWM(pin) #define pwm_status(pin) digitalPinHasPWM(pin)
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
@@ -44,13 +45,13 @@
// uses pin index // uses pin index
#define M43_NEVER_TOUCH(Q) ((Q) >= 75) #define M43_NEVER_TOUCH(Q) ((Q) >= 75)
bool getValidPinMode(int8_t pin) { // 1: output, 0: input bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
const EPortType samdport = g_APinDescription[pin].ulPort; const EPortType samdport = g_APinDescription[pin].ulPort;
const uint32_t samdpin = g_APinDescription[pin].ulPin; const uint32_t samdpin = g_APinDescription[pin].ulPin;
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN; return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
} }
void printPinPWM(int32_t pin) { void pwm_details(int32_t pin) {
if (pwm_status(pin)) { if (pwm_status(pin)) {
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative; //uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
//SERIAL_ECHOPGM("PWM = ", duty); //SERIAL_ECHOPGM("PWM = ", duty);
+6 -16
View File
@@ -69,23 +69,13 @@
#endif #endif
#endif #endif
#ifdef SERIAL_PORT_3 #ifdef MMU2_SERIAL_PORT
#if SERIAL_PORT_3 == -1 #if MMU2_SERIAL_PORT == -1
#define MYSERIAL3 MSerial0 #define MMU2_SERIAL MSerial0
#elif WITHIN(SERIAL_PORT_3, 0, 3) #elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#error "SERIAL_PORT_3 must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif
#ifdef MMU_SERIAL_PORT
#if MMU_SERIAL_PORT == -1
#define MMU_SERIAL MSerial0
#elif WITHIN(MMU_SERIAL_PORT, 0, 3)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
#else
#error "MMU_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif #endif
#endif #endif
+1 -9
View File
@@ -82,7 +82,6 @@
#define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) #define MATCH_Z4_MAX_EILINE(P) TERN0(USE_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN))
#define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) #define MATCH_Z4_MIN_EILINE(P) TERN0(USE_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN))
#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) #define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(USE_Z_MIN_PROBE, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN))
#define MATCH_CALIBRATION_EILINE(P) TERN0(USE_CALIBRATION, DEFER4(MATCH_EILINE)(P, CALIBRATION_PIN))
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ #define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \ && !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
@@ -99,8 +98,7 @@
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \ && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \ && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \ && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P) \ && !MATCH_Z_MIN_PROBE_EILINE(P) )
&& !MATCH_CALIBRATION_EILINE(P) )
// One ISR for all EXT-Interrupts // One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
@@ -185,12 +183,6 @@ void setup_endstop_interrupts() {
#endif #endif
_ATTACH(Z_MIN_PROBE_PIN); _ATTACH(Z_MIN_PROBE_PIN);
#endif #endif
#if USE_CALIBRATION
#if !AVAILABLE_EILINE(CALIBRATION_PIN)
#error "CALIBRATION_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(CALIBRATION_PIN);
#endif
#if USE_I_MAX #if USE_I_MAX
#if !AVAILABLE_EILINE(I_MAX_PIN) #if !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+1 -1
View File
@@ -174,7 +174,7 @@
: (P == 17) ? PIN_TO_SAMD_PIN(13) \ : (P == 17) ? PIN_TO_SAMD_PIN(13) \
: PIN_TO_SAMD_PIN(9)) : PIN_TO_SAMD_PIN(9))
#define digitalPinToAnalogIndex(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1) #define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1)
/** /**
* pins * pins
+10 -9
View File
@@ -29,13 +29,14 @@
#define digitalRead_mod(p) extDigitalRead(p) #define digitalRead_mod(p) extDigitalRead(p)
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0) #define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); 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 PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define getPinByIndex(p) pin_array[p].pin #define GET_ARRAY_PIN(p) pin_array[p].pin
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define isValidPin(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
#define isAnalogPin(P) (digitalPinToAnalogIndex(P)!=-1) #define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p)
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1)
#define pwm_status(pin) digitalPinHasPWM(pin) #define pwm_status(pin) digitalPinHasPWM(pin)
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
@@ -43,13 +44,13 @@
// uses pin index // uses pin index
#define M43_NEVER_TOUCH(Q) ((Q) >= 75) #define M43_NEVER_TOUCH(Q) ((Q) >= 75)
bool getValidPinMode(int8_t pin) { // 1: output, 0: input bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
const EPortType samdport = g_APinDescription[pin].ulPort; const EPortType samdport = g_APinDescription[pin].ulPort;
const uint32_t samdpin = g_APinDescription[pin].ulPin; const uint32_t samdpin = g_APinDescription[pin].ulPin;
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN; return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
} }
void printPinPWM(int32_t pin) { void pwm_details(int32_t pin) {
if (pwm_status(pin)) { if (pwm_status(pin)) {
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative; //uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
//SERIAL_ECHOPGM("PWM = ", duty); //SERIAL_ECHOPGM("PWM = ", duty);
+9 -17
View File
@@ -90,15 +90,15 @@
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU_SERIAL_PORT, 1, 9) #if WITHIN(MMU2_SERIAL_PORT, 1, 9)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#elif !defined(USBCON) #elif !defined(USBCON)
#error "MMU_SERIAL_PORT must be from 1 to 9." #error "MMU2_SERIAL_PORT must be from 1 to 9."
#elif MMU_SERIAL_PORT == -1 #elif MMU2_SERIAL_PORT == -1
#define MMU_SERIAL MSerialUSB #define MMU2_SERIAL MSerialUSB
#else #else
#error "MMU_SERIAL_PORT must be from 1 to 9, or -1 for Native USB." #error "MMU2_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
#endif #endif
#endif #endif
@@ -112,24 +112,16 @@
#else #else
#error "LCD_SERIAL_PORT must be from 1 to 9, or -1 for Native USB." #error "LCD_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
#endif #endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif #endif
#endif #endif
#ifdef RS485_SERIAL_PORT
#if WITHIN(RS485_SERIAL_PORT, 1, 9)
#define RS485_SERIAL MSERIAL(RS485_SERIAL_PORT)
#else
#error "RS485_SERIAL_PORT must be from 1 to 9."
#endif
#endif
/** /**
* TODO: review this to return 1 for pins that are not analog input * TODO: review this to return 1 for pins that are not analog input
*/ */
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) pin_t(p) #define analogInputToDigitalPin(p) (p)
#endif #endif
// //
+1 -1
View File
@@ -37,7 +37,7 @@ static SPISettings spiConfig;
// Public functions // Public functions
// ------------------------ // ------------------------
#if ANY(SOFTWARE_SPI, FORCE_SOFT_SPI) #if ENABLED(SOFTWARE_SPI)
// ------------------------ // ------------------------
// Software SPI // Software SPI
-3
View File
@@ -37,9 +37,6 @@
#ifndef USART5 #ifndef USART5
#define USART5 UART5 #define USART5 UART5
#endif #endif
#ifndef USART6
#define USART6 UART6
#endif
#ifndef USART7 #ifndef USART7
#define USART7 UART7 #define USART7 UART7
#endif #endif
-1
View File
@@ -53,7 +53,6 @@
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
void _rx_complete_irq(serial_t *obj); void _rx_complete_irq(serial_t *obj);
FORCE_INLINE static uint8_t buffer_overruns() { return 0; } // Not implemented. Void to avoid platform-dependent code.
protected: protected:
usart_rx_callback_t _rx_callback; usart_rx_callback_t _rx_callback;
@@ -1,136 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2024 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 HAL_STM32
#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_STM32_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 // HAL_STM32
@@ -45,7 +45,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN)); TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN)); TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_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_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN)); TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN)); TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
@@ -30,3 +30,6 @@
#undef F_CPU #undef F_CPU
#define F_CPU BOARD_F_CPU #define F_CPU BOARD_F_CPU
#endif #endif
// The Sensitive Pins array is not optimizable
#define RUNTIME_ONLY_ANALOG_TO_DIGITAL
+13 -13
View File
@@ -115,16 +115,16 @@ const XrefInfo pin_xref[] PROGMEM = {
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1) #define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
#endif #endif
#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)) #define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS))
#define isValidPin(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))) #define VALID_PIN(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)))
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads #define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
#define printPinNumber(Q) #define PRINT_PIN(Q)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define digitalPinToAnalogIndex(ANUM) -1 // will report analog pin number in the print port routine #define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine
// x is a variable used to search pin_array // x is a variable used to search pin_array
#define getPinIsDigitalByIndex(x) ((bool) pin_array[x].is_digital) #define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
#define getPinByIndex(x) ((pin_t) pin_array[x].pin) #define GET_ARRAY_PIN(x) ((pin_t) pin_array[x].pin)
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin #define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin
// //
@@ -164,7 +164,7 @@ uint8_t get_pin_mode(const pin_t Ard_num) {
} }
} }
bool getValidPinMode(const pin_t Ard_num) { bool GET_PINMODE(const pin_t Ard_num) {
const uint8_t pin_mode = get_pin_mode(Ard_num); const uint8_t pin_mode = get_pin_mode(Ard_num);
return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT; // assume all alt definitions are PWM return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT; // assume all alt definitions are PWM
} }
@@ -173,11 +173,11 @@ int8_t digital_pin_to_analog_pin(const pin_t Ard_num) {
if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)) if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
return Ard_num - NUM_ANALOG_FIRST; return Ard_num - NUM_ANALOG_FIRST;
const int8_t ind = digitalPinToAnalogIndex(Ard_num); const uint32_t ind = digitalPinToAnalogInput(Ard_num);
return (ind < NUM_ANALOG_INPUTS) ? ind : -1; return (ind < NUM_ANALOG_INPUTS) ? ind : -1;
} }
bool isAnalogPin(const pin_t Ard_num) { bool IS_ANALOG(const pin_t Ard_num) {
return get_pin_mode(Ard_num) == MODE_PIN_ANALOG; return get_pin_mode(Ard_num) == MODE_PIN_ANALOG;
} }
@@ -186,7 +186,7 @@ bool is_digital(const pin_t Ard_num) {
return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT; return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
} }
void printPinPort(const pin_t Ard_num) { void print_port(const pin_t Ard_num) {
char buffer[16]; char buffer[16];
pin_t Index; pin_t Index;
for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++) for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++)
@@ -226,7 +226,7 @@ bool pwm_status(const pin_t Ard_num) {
return get_pin_mode(Ard_num) == MODE_PIN_ALT; return get_pin_mode(Ard_num) == MODE_PIN_ALT;
} }
void printPinPWM(const pin_t Ard_num) { void pwm_details(const pin_t Ard_num) {
#ifndef STM32F1xx #ifndef STM32F1xx
if (pwm_status(Ard_num)) { if (pwm_status(Ard_num)) {
uint32_t alt_all = 0; uint32_t alt_all = 0;
@@ -285,4 +285,4 @@ void printPinPWM(const pin_t Ard_num) {
#else #else
// TODO: F1 doesn't support changing pins function, so we need to check the function of the PIN and if it's enabled // TODO: F1 doesn't support changing pins function, so we need to check the function of the PIN and if it's enabled
#endif #endif
} // printPinPWM } // pwm_details
+1 -1
View File
@@ -238,7 +238,7 @@ void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; hdma_sdio.Init.MemInc = DMA_MINC_ENABLE;
hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_sdio.Init.Priority = DMA_PRIORITY_MEDIUM; hdma_sdio.Init.Priority = DMA_PRIORITY_LOW;
__HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio);
__HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio);
-1
View File
@@ -182,7 +182,6 @@ void TFT_FSMC::transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t cou
DMAtx.Init.PeriphInc = memoryIncrease; DMAtx.Init.PeriphInc = memoryIncrease;
HAL_DMA_Init(&DMAtx); HAL_DMA_Init(&DMAtx);
HAL_DMA_Start(&DMAtx, (uint32_t)data, (uint32_t)&(LCD->RAM), count); HAL_DMA_Start(&DMAtx, (uint32_t)data, (uint32_t)&(LCD->RAM), count);
TERN_(TFT_SHARED_IO, while (isBusy()));
} }
void TFT_FSMC::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) { void TFT_FSMC::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) {
+1 -1
View File
@@ -337,7 +337,7 @@ void TFT_SPI::transmitDMA(uint32_t memoryIncrease, uint16_t *data, uint16_t coun
SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request
#endif #endif
TERN_(TFT_SHARED_IO, while (isBusy())); TERN_(TFT_SHARED_IO, while (isBusy()) { /* nada */ });
} }
void TFT_SPI::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) { void TFT_SPI::transmit(uint32_t memoryIncrease, uint16_t *data, uint16_t count) {
+3 -3
View File
@@ -25,8 +25,8 @@
* STM32 LCD-specific defines * STM32 LCD-specific defines
*/ */
uint8_t u8g_com_HAL_STM32_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // u8g_com_stm32duino_swspi.cpp uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32_sw_spi_fn
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL
#define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
+9 -20
View File
@@ -118,14 +118,14 @@
#endif #endif
#endif #endif
#ifdef MMU_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if MMU_SERIAL_PORT == -1 #if MMU2_SERIAL_PORT == -1
#define MMU_SERIAL UsbSerial #define MMU2_SERIAL UsbSerial
#elif WITHIN(MMU_SERIAL_PORT, 1, NUM_UARTS) #elif WITHIN(MMU2_SERIAL_PORT, 1, NUM_UARTS)
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#define MMU_SERIAL MSERIAL(1) // dummy port #define MMU2_SERIAL MSERIAL(1) // dummy port
static_assert(false, "MMU_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.") static_assert(false, "MMU2_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#endif #endif
#endif #endif
@@ -138,27 +138,16 @@
#define LCD_SERIAL MSERIAL(1) // dummy port #define LCD_SERIAL MSERIAL(1) // dummy port
static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.") static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#endif #endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI) #if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif #endif
#endif #endif
#ifdef RS485_SERIAL_PORT
#if RS485_SERIAL_PORT == -1
#define RS485_SERIAL UsbSerial
#elif WITHIN(RS485_SERIAL_PORT, 1, NUM_UARTS)
#define RS485_SERIAL MSERIAL(RS485_SERIAL_PORT)
#else
#define RS485_SERIAL MSERIAL(1) // dummy port
static_assert(false, "RS485_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ".")
#endif
#endif
/** /**
* TODO: review this to return 1 for pins that are not analog input * TODO: review this to return 1 for pins that are not analog input
*/ */
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) pin_t(p) #define analogInputToDigitalPin(p) (p)
#endif #endif
#ifndef digitalPinHasPWM #ifndef digitalPinHasPWM
+56
View File
@@ -0,0 +1,56 @@
from __future__ import print_function
import sys
#dynamic build flags for generic compile options
if __name__ == "__main__":
args = " ".join([ "-std=gnu++14",
"-Os",
"-mcpu=cortex-m3",
"-mthumb",
"-fsigned-char",
"-fno-move-loop-invariants",
"-fno-strict-aliasing",
"-fsingle-precision-constant",
"--specs=nano.specs",
"--specs=nosys.specs",
"-IMarlin/src/HAL/STM32F1",
"-MMD",
"-MP",
"-DTARGET_STM32F1"
])
for i in range(1, len(sys.argv)):
args += " " + sys.argv[i]
print(args)
# extra script for linker options
else:
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
ARFLAGS=["rcs"],
ASFLAGS=["-x", "assembler-with-cpp"],
CXXFLAGS=[
"-fabi-version=0",
"-fno-use-cxa-atexit",
"-fno-threadsafe-statics"
],
LINKFLAGS=[
"-Os",
"-mcpu=cortex-m3",
"-ffreestanding",
"-mthumb",
"--specs=nano.specs",
"--specs=nosys.specs",
"-u_printf_float",
],
)
@@ -89,7 +89,7 @@ static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, c
} }
static void u8g_sw_spi_shift_out(uint8_t val) { static void u8g_sw_spi_shift_out(uint8_t val) {
#if U8G_SPI_USE_MODE_3 #if ENABLED(FYSETC_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed); swSpiTransfer_mode_3(val, SPI_speed);
#else #else
swSpiTransfer_mode_0(val, SPI_speed); swSpiTransfer_mode_0(val, SPI_speed);
@@ -123,15 +123,15 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
break; break;
case U8G_COM_MSG_CHIP_SELECT: 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 ENABLED(FYSETC_MINI_12864) // 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 if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active // the next chip select goes active
WRITE(DOGLCD_SCK, HIGH); // Set SCK to mode 3 idle state before CS goes active WRITE(DOGLCD_SCK, HIGH); // Set SCK to mode 3 idle state before CS goes active
WRITE(DOGLCD_CS, LOW); WRITE(DOGLCD_CS, LOW);
} }
else { else {
WRITE(DOGLCD_CS, HIGH); WRITE(DOGLCD_CS, HIGH);
WRITE(DOGLCD_SCK, LOW); // Set SCK to mode 0 idle state after CS goes inactive WRITE(DOGLCD_SCK, LOW); // Set SCK to mode 0 idle state after CS goes inactive
} }
#else #else
WRITE(DOGLCD_CS, !arg_val); WRITE(DOGLCD_CS, !arg_val);
@@ -70,7 +70,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN)); TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN)); TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_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_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN)); TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN)); TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
+17 -17
View File
@@ -39,12 +39,12 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS #define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS #define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
#define isValidPin(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS) #define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
#define getPinByIndex(p) pin_t(pin_array[p].pin) #define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
#define digitalRead_mod(p) extDigitalRead(p) #define digitalRead_mod(p) extDigitalRead(p)
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); 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 PRINT_ARRAY_NAME(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 #define MULTI_NAME_PAD 21 // space needed to be pretty if not first name assigned to a pin
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities // pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
@@ -52,10 +52,10 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
#define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX) #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
#endif #endif
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? _GET_MODE(pin) : -1; } int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) ? _GET_MODE(pin) : -1; }
int8_t digitalPinToAnalogIndex(const pin_t pin) { pin_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t pin) {
if (!isValidPin(pin)) return -1; if (!VALID_PIN(pin)) return -1;
pin_t adc_channel = pin_t(PIN_MAP[pin].adc_channel); pin_t adc_channel = pin_t(PIN_MAP[pin].adc_channel);
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = (pin_t)ADCx; if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = (pin_t)ADCx;
@@ -63,8 +63,8 @@ int8_t digitalPinToAnalogIndex(const pin_t pin) {
return adc_channel; return adc_channel;
} }
bool isAnalogPin(const pin_t pin) { bool IS_ANALOG(const pin_t pin) {
if (!isValidPin(pin)) return false; if (!VALID_PIN(pin)) return false;
if (PIN_MAP[pin].adc_channel != ADCx) { if (PIN_MAP[pin].adc_channel != ADCx) {
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
if (PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS) return false; if (PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS) return false;
@@ -74,13 +74,13 @@ bool isAnalogPin(const pin_t pin) {
return false; return false;
} }
bool getValidPinMode(const pin_t pin) { bool GET_PINMODE(const pin_t pin) {
return isValidPin(pin) && !IS_INPUT(pin); return VALID_PIN(pin) && !IS_INPUT(pin);
} }
bool getPinIsDigitalByIndex(const int16_t array_pin) { bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
const pin_t pin = getPinByIndex(array_pin); const pin_t pin = GET_ARRAY_PIN(array_pin);
return (!isAnalogPin(pin) return (!IS_ANALOG(pin)
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
|| PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS || PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS
#endif #endif
@@ -89,7 +89,7 @@ bool getPinIsDigitalByIndex(const int16_t array_pin) {
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
void printPinPWM(const pin_t pin) { void pwm_details(const pin_t pin) {
if (PWM_PIN(pin)) { if (PWM_PIN(pin)) {
timer_dev * const tdev = PIN_MAP[pin].timer_device; timer_dev * const tdev = PIN_MAP[pin].timer_device;
const uint8_t channel = PIN_MAP[pin].timer_channel; const uint8_t channel = PIN_MAP[pin].timer_channel;
@@ -111,7 +111,7 @@ void printPinPWM(const pin_t pin) {
bool pwm_status(const pin_t pin) { return PWM_PIN(pin); } bool pwm_status(const pin_t pin) { return PWM_PIN(pin); }
void printPinPort(const pin_t pin) { void print_port(const pin_t pin) {
const char port = 'A' + char(pin >> 4); // pin div 16 const char port = 'A' + char(pin >> 4); // pin div 16
const int16_t gbit = PIN_MAP[pin].gpio_bit; const int16_t gbit = PIN_MAP[pin].gpio_bit;
char buffer[8]; char buffer[8];
+1 -1
View File
@@ -25,7 +25,7 @@
* STM32F1 (Maple) LCD-specific defines * STM32F1 (Maple) LCD-specific defines
*/ */
uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // u8g_com_stm32duino_swspi.cpp uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn
+1 -1
View File
@@ -98,7 +98,7 @@ uint32_t __get_PRIMASK(void); // CMSIS
// ------------------------ // ------------------------
#ifndef analogInputToDigitalPin #ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) pin_t((p < 12U) ? (p) + 54U : -1) #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
#endif #endif
#define HAL_ADC_VREF_MV 3300 #define HAL_ADC_VREF_MV 3300
@@ -64,7 +64,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN)); TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN)); TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_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_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN)); TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN)); TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));

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