Compare commits

..

78 Commits

Author SHA1 Message Date
InsanityAutomation 4894f35e39 Merge branch 'Trex_2.0.x_Devel' of https://github.com/InsanityAutomation/Marlin into Trex_2.0.x_Devel 2024-06-26 10:53:20 -04:00
InsanityAutomation 11ae89e290 Bump to current 2024-04-15 14:16:11 -04:00
InsanityAutomation 0e1b62e094 Reduce ram and SPI speed 2022-10-23 12:35:46 -04:00
InsanityAutomation 64ffa0d4f4 Merge branch 'bugfix-2.1.x' into Trex_2.0.x_Devel 2022-10-21 15:29:10 -04:00
InsanityAutomation e6680ddfdf Update menu_advanced.cpp 2022-10-11 11:37:22 -04:00
InsanityAutomation 5c0696b51a updates 2022-10-11 11:36:31 -04:00
InsanityAutomation d438436f0c Merge branch 'bugfix-2.1.x' into Trex_2.0.x_Devel 2022-10-10 16:36:53 -04:00
InsanityAutomation 2f322e8084 Update Configuration.h 2022-04-09 11:22:20 -04:00
InsanityAutomation a3a4da5ff2 Merge branch 'Implement-M591-Configurable-Runout-Sensors' into Trex_2.0.x_Devel 2022-04-05 10:41:19 -04:00
InsanityAutomation bba892e327 Trim output on slim menus 2022-04-03 17:03:52 -04:00
InsanityAutomation 25172b3acf M591Fixes 2022-04-03 14:54:16 -04:00
InsanityAutomation 0b6ecbd553 Merge branch 'bugfix-2.0.x' into Implement-M591-Configurable-Runout-Sensors 2022-04-03 10:33:18 -04:00
InsanityAutomation de6246f826 Merge branch 'Implement-M591-Configurable-Runout-Sensors' of https://github.com/InsanityAutomation/Marlin into Implement-M591-Configurable-Runout-Sensors 2022-04-03 10:32:57 -04:00
Scott Lahteine e813742ae0 Merge branch 'bugfix-2.0.x' into pr/23899 2022-03-29 03:25:51 -05:00
Scott Lahteine 46c8204990 Extend enum 2022-03-27 19:46:47 -05:00
Scott Lahteine bdfe4ca4d1 Simplify menu items, use enum, adjust settings 2022-03-26 21:10:16 -05:00
Scott Lahteine 6741f5182d Simplify menu items, use enum 2022-03-26 18:54:02 -05:00
InsanityAutomation 489b75ae3c Update menu_advanced.cpp 2022-03-15 12:47:14 -04:00
InsanityAutomation 378fc12628 Add runout menu, small fixes 2022-03-15 12:28:19 -04:00
InsanityAutomation 0cedad36d1 Reorganize config options, remove obsolete option. 2022-03-14 09:29:53 -04:00
Scott Lahteine 07b2480d30 glue for CI test 2022-03-14 00:37:41 -05:00
Scott Lahteine dd88eb56ee Allow user to change 2022-03-14 00:37:41 -05:00
Scott Lahteine fc77afd93e misc. cleanup 2022-03-14 00:37:41 -05:00
InsanityAutomation 26af3e70bc Remove obsolete state from tests 2022-03-13 19:51:12 -04:00
InsanityAutomation 0c15e8e751 Fix up pause trigger, adjust config options minor changes 2022-03-13 18:57:24 -04:00
InsanityAutomation 639a2dc0b3 M591 Cleanup and tweaks 2022-03-13 13:48:33 -04:00
InsanityAutomation 91a094d8cb Update Configuration.h 2022-03-12 15:55:57 -05:00
InsanityAutomation 66efa0b09b Initial commit - Flexible Runout Configuration M591 2022-03-12 15:54:07 -05:00
InsanityAutomation 3226adf2a6 Update Configuration.h 2022-03-08 17:54:24 -05:00
InsanityAutomation 29822ee60e Update Configuration_adv.h 2022-03-08 17:54:22 -05:00
InsanityAutomation 442d28485e Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2022-03-08 17:32:43 -05:00
InsanityAutomation 29f85afe50 Update settings.cpp 2021-10-14 18:48:59 -04:00
InsanityAutomation c653a0f423 Merge branch 'BLTouch-HS-Mode-EEPROM' into Trex_2.0.x_Devel 2021-10-14 18:33:57 -04:00
InsanityAutomation 1fab2ef94f Update menu_tramming.cpp 2021-10-14 14:01:42 -04:00
InsanityAutomation 102c43dcd5 Update G35.cpp 2021-10-14 13:50:56 -04:00
InsanityAutomation 5284f45c62 Update menu_tramming.cpp 2021-10-14 13:41:31 -04:00
InsanityAutomation 9aaa7b1100 Add missing include 2021-10-14 13:34:31 -04:00
Scott Lahteine a6c4c5a3f7 Update motion.cpp 2021-10-12 22:22:15 -05:00
Scott Lahteine 78c57f2847 Update menu_tramming.cpp 2021-10-12 22:21:43 -05:00
Scott Lahteine 90b0be5e12 Merge 'upstream/bugfix-2.0.x' into pr/22916 2021-10-12 21:45:54 -05:00
Scott Lahteine c24456353f Merge 'upstream/bugfix-2.0.x' into pr/22916 2021-10-12 20:20:28 -05:00
InsanityAutomation 9a9a112673 Simplify macro 2021-10-11 22:07:45 -04:00
Scott Lahteine 0977129353 Update planner.cpp 2021-10-11 19:31:52 -04:00
InsanityAutomation ffa8e0ce60 potentially fix multi nozzle duplication as well 2021-10-11 19:31:42 -04:00
InsanityAutomation cbaf1af0fe Followup to IDEX fix 2021-10-10 19:51:56 -04:00
Scott Lahteine ec7a4eb69e clean up and fix 2021-10-09 18:57:38 -05:00
InsanityAutomation 4f62ae9764 Return on mode change without deploying 2021-10-09 14:07:11 -04:00
InsanityAutomation b8dfc53693 Return on mode change without deploying 2021-10-09 14:07:02 -04:00
InsanityAutomation a30ae0aeca BLTouch High Speed EEPROM Control 2021-10-09 13:58:45 -04:00
InsanityAutomation 0cc6955ab7 BLTouch High Speed EEPROM Control 2021-10-09 13:58:25 -04:00
InsanityAutomation 32e8f90271 Fix Delay definitions 2021-10-09 11:58:54 -04:00
InsanityAutomation 8b10b829fd Fix IDEX Mode Positioning 2021-10-09 11:58:45 -04:00
InsanityAutomation eab8ad6b16 Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2021-10-09 10:58:30 -04:00
InsanityAutomation 35180fedd8 Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2021-08-28 14:06:37 -04:00
InsanityAutomation 4ddd6d27c1 trim ram 2021-08-08 14:29:24 -04:00
InsanityAutomation 5b6317dd5b Update Configuration_adv.h 2021-08-06 20:11:23 -04:00
InsanityAutomation 125e537dd1 Update Configuration.h 2021-08-06 13:10:05 -04:00
InsanityAutomation 1055cd4efa Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2021-08-05 22:19:49 -04:00
InsanityAutomation 9b6037515f Update Configuration.h 2021-07-31 14:47:58 -04:00
InsanityAutomation 6bdc99be5f Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2021-07-31 14:38:43 -04:00
InsanityAutomation d6abfd2523 Fix move directly after G28X 2021-01-01 18:50:47 -05:00
InsanityAutomation 4f0615be7b Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2021-01-01 18:50:31 -05:00
InsanityAutomation dd345679d3 Add display timings for new supplier 2020-11-21 15:16:47 -05:00
InsanityAutomation b59301894a Merge branch 'bugfix-2.0.x' into Trex_2.0.x_Devel 2020-11-21 15:09:26 -05:00
InsanityAutomation 3165043527 Merge branch 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin into bugfix-2.0.x 2020-11-21 14:33:24 -05:00
Luu Lac cd3bf4c766 Fix "autotune" LCD message (#20127) 2020-11-13 18:48:59 -06:00
Scott Lahteine 30162df320 Optimize M360 2020-11-13 18:47:34 -06:00
InsanityAutomation 2d160b8461 force set directions on all blocks in stepper isr 2020-10-22 09:20:37 -04:00
InsanityAutomation aa5a7f5c13 Add SKR12Pro Support 2020-10-22 09:19:44 -04:00
InsanityAutomation e4e9915d84 Update Configuration_adv.h 2020-10-22 09:18:30 -04:00
InsanityAutomation 8fe3650376 Bump to head, fix compile errors 2020-10-22 09:18:30 -04:00
InsanityAutomation 23d024309e Update runout.cpp 2020-10-22 09:18:30 -04:00
InsanityAutomation 62465cdf23 Disable mesh validation pattern for UBL builds to fit 2020-10-22 09:18:00 -04:00
InsanityAutomation 9eb4fc1cfd Update Configuration_adv.h 2020-10-22 09:18:00 -04:00
InsanityAutomation 40de56b58b Bump to head, fix compile errors 2020-10-22 09:18:00 -04:00
InsanityAutomation 4a56689801 Merge branch 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin into bugfix-2.0.x 2020-10-22 09:13:59 -04:00
Scott Lahteine 0216e032be Host prompt followup 2020-10-19 04:34:14 -05:00
Scott Lahteine 2d8aa0cea1 Tweak a host prompt call 2020-10-19 04:25:48 -05:00
515 changed files with 12086 additions and 19808 deletions
-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
-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
#
name: CI - Build Tests
name: CI
on:
pull_request:
@@ -14,8 +14,6 @@ on:
- config/**
- data/**
- docs/**
- test/**
- Marlin/tests/**
- '**/*.md'
push:
branches:
@@ -25,19 +23,16 @@ on:
- config/**
- data/**
- docs/**
- test/**
- Marlin/tests/**
- '**/*.md'
jobs:
test_builds:
name: Build Test
name: Run All Tests
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
test-platform:
+7 -46
View File
@@ -2,23 +2,17 @@ SCRIPTS_DIR := buildroot/share/scripts
CONTAINER_RT_BIN := docker
CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
CONTAINER_IMAGE := marlin-dev
UNIT_TEST_CONFIG ?= default
help:
@echo "Tasks for local development:"
@echo "make marlin : Build marlin for the configured board"
@echo "make format-pins -j : Reformat all pins files (-j for parallel execution)"
@echo "make validate-pins -j : Validate all pins files, fails if any require reformatting"
@echo "make format-pins : Reformat all pins files"
@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-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker"
@echo "make unit-test-single-local : Run unit tests for a single config locally"
@echo "make unit-test-single-local-docker : Run unit tests for a single config locally, using docker"
@echo "make unit-test-all-local : Run all code tests locally"
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker"
@echo "make setup-local-docker : Setup local docker using buildx"
@echo "make setup-local-docker : Build the local docker image"
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@@ -28,9 +22,6 @@ help:
@echo " run on GitHub CI"
@echo " ONLY_TEST Limit tests to only those that contain this, or"
@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 " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
@@ -52,53 +43,23 @@ tests-single-local:
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 ! $(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:
@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 VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& for TEST_TARGET in $$(python $(SCRIPTS_DIR)/get_test_targets.py) ; do \
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
&& for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
tests-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 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
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
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')
.PHONY: $(PINS) format-pins validate-pins
$(PINS): %:
@echo "Formatting $@"
@python $(SCRIPTS_DIR)/pinsformat.py $< $@
@echo "Formatting $@" && node $(SCRIPTS_DIR)/pinsformat.js $@
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)
+376 -123
View File
@@ -1,3 +1,50 @@
// If you have a trex 3, stock is this option plus 2208 on all axis. None in spreadcycle.
#define TREX3
// If you have a trex 3 that was upgraded from a 2+ with the kit, modifies home position and offsets.
//#define TREX3_UPGRADE
//Stock 2+ X is a 4988, all options off defaults to this
//#define X_2208
//#define X_Spreadcycle
//#define X_S109
// Y all options off defaults to 2+ 8825 / 3 2208
//#define Y_2208 // Highly recommended as large prints with high mass can cause layer shifts with stealthchop at high speed
//#define Y_Spreadcycle
//#define Y_4988 // Some machines shipped with 4988 drivers across the board. Set this if you arent sure what you have and all the drivers look identical
//#define Y_S109
//Stock 2+ Z is a 8825, all options off defaults to this
//#define Z_2208 // NOT Recommended! Dual stepper current draw is above the recommended limit for this driver
//#define Z_4988 // Some machines shipped with 4988 drivers across the board. Set this if you arent sure what you have and all the drivers look identical
//#define Z_Spreadcycle
//#define Z_S109
//Stock 2+ Z is a 4988, all options off defaults to this
//#define E_2208 // Not Recommended! Stealthchop mode faults with linear advance
//#define E_Spreadcycle
//#define E_S109
#define BedAC
#define tallVersion
#define ABL_Bilinear
/*
* Enables a filament sensor plugged into the laser pin. Disables the laser
*/
//#define FilamentSensor // Standard older TM3D runout sensor
//#define lerdgeFilSensor // Newer inverted logic TM3D Runout Sensor
//#define filamentEncoder
//#define autoCalibrationKit
//#define SKR12Pro
//////////////////////////////////DO not edit below here unless you know what youre doing! //////////////////////////////////
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
@@ -21,6 +68,22 @@
*/
#pragma once
// The TREX2+ upgraded to the 3 enables most of the same options, simplify here
#if ENABLED(TREX3_UPGRADE)
#define TREX3
#endif
#if ENABLED(TREX3)
#if DISABLED(X_S109)
#define X_2208
#endif
#if DISABLED(Y_S109)
#define Y_2208
#endif
#define Z_2208
#define E_2208
#endif
/**
* Configuration.h
*
@@ -61,14 +124,20 @@
// @section info
// Author info of this build printed to the host during boot and M115
#define STRING_CONFIG_H_AUTHOR "InsanityAutomation" // Who made the changes.
//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
#define STRING_CONFIG_H_AUTHOR "Tinymachines3D" // Who made the changes.
#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
// @section machine
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
#define MOTHERBOARD BOARD_EBAB
#if ENABLED(SKR12Pro)
#define MOTHERBOARD BOARD_BTT_SKR_PRO_V1_2
#elif ENABLED(TREX3)
#define MOTHERBOARD BOARD_FORMBOT_TREX3
#else
#define MOTHERBOARD BOARD_FORMBOT_TREX2PLUS
#endif
#endif
/**
@@ -79,7 +148,11 @@
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
#define SERIAL_PORT -1
#if ENABLED(SKR12Pro)
#define SERIAL_PORT -1
#else
#define SERIAL_PORT 0
#endif
/**
* Serial Port Baud Rate
@@ -101,7 +174,9 @@
* Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
//#define SERIAL_PORT_2 1
#if ENABLED(SKR12Pro)
#define SERIAL_PORT_2 1
#endif
//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE
/**
@@ -115,8 +190,15 @@
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// Name displayed in the LCD "Ready" message and Info menu
#define CUSTOM_MACHINE_NAME "FatBoy"
// Optional custom name for your RepStrap or other custom machine
// Displayed in the LCD "Ready" message
#if ENABLED(TREX3_UPGRADE)
#define CUSTOM_MACHINE_TIME "T-REX 3(u)"
#elif ENABLED(TREX3)
#define CUSTOM_MACHINE_NAME "T-REX 3"
#else
#define CUSTOM_MACHINE_NAME "T-REX 2+"
#endif
// Printer's unique ID, used by some programs to differentiate between machines.
// Choose your own or use a service like https://www.uuidgenerator.net/version4
@@ -139,21 +221,77 @@
* TMC5160, TMC5160_STANDALONE
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
*/
#define X_DRIVER_TYPE TMC5160
#define Y_DRIVER_TYPE TMC5160
#define Z_DRIVER_TYPE TB6600
#if ENABLED(SKR12Pro)
#if ENABLED(TMC2209Upgrade)
#define X_DRIVER_TYPE TMC2209
#define X2_DRIVER_TYPE TMC2209
#define Y_DRIVER_TYPE TMC2209
#define Z_DRIVER_TYPE TMC2209
#define E0_DRIVER_TYPE TMC2209
#define E1_DRIVER_TYPE TMC2209
#else
#define X_DRIVER_TYPE TMC2208
#define X2_DRIVER_TYPE TMC2208
#define Y_DRIVER_TYPE TMC2208
#define Z_DRIVER_TYPE TMC2208
#define E0_DRIVER_TYPE TMC2208
#define E1_DRIVER_TYPE TMC2208
#endif
#else
#if ENABLED(X_2208)
#define X_DRIVER_TYPE TMC2208_STANDALONE
#define X2_DRIVER_TYPE TMC2208_STANDALONE
#else
#define X_DRIVER_TYPE A4988
#define X2_DRIVER_TYPE A4988
#endif
#if ENABLED(Y_2208)
#define Y_DRIVER_TYPE TMC2208_STANDALONE
#elif ENABLED(Y_4988)
#define Y_DRIVER_TYPE A4988
#else
#define Y_DRIVER_TYPE DRV8825
#endif
#if ENABLED(Z_2208)
#define Z_DRIVER_TYPE TMC2208_STANDALONE
#elif ENABLED(Z_4988)
#define Z_DRIVER_TYPE A4988
#else
#define Z_DRIVER_TYPE DRV8825
#endif
#if ENABLED(E_2208)
#define E0_DRIVER_TYPE TMC2208_STANDALONE
#define E1_DRIVER_TYPE TMC2208_STANDALONE
#else
#define E0_DRIVER_TYPE DRV8825
#define E1_DRIVER_TYPE DRV8825
#endif
#endif
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
//#define E4_DRIVER_TYPE A4988
//#define E5_DRIVER_TYPE A4988
//#define E6_DRIVER_TYPE A4988
//#define E7_DRIVER_TYPE A4988
//#define X_DRIVER_TYPE A4988
//#define Y_DRIVER_TYPE A4988
//#define Z_DRIVER_TYPE A4988
//#define X2_DRIVER_TYPE A4988
#define Y2_DRIVER_TYPE TMC5160
#define Z2_DRIVER_TYPE TB6600
#define Z3_DRIVER_TYPE TB6600
#define Z4_DRIVER_TYPE TB6600
//#define Y2_DRIVER_TYPE A4988
//#define Z2_DRIVER_TYPE A4988
//#define Z3_DRIVER_TYPE A4988
//#define Z4_DRIVER_TYPE A4988
//#define I_DRIVER_TYPE A4988
//#define J_DRIVER_TYPE A4988
//#define K_DRIVER_TYPE A4988
//#define U_DRIVER_TYPE A4988
//#define V_DRIVER_TYPE A4988
//#define W_DRIVER_TYPE A4988
#define E0_DRIVER_TYPE TMC2209
//#define E0_DRIVER_TYPE A4988
//#define E1_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
@@ -208,7 +346,7 @@
// This defines the number of extruders
// :[0, 1, 2, 3, 4, 5, 6, 7, 8]
#define EXTRUDERS 1
#define EXTRUDERS 2
// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75
@@ -362,7 +500,12 @@
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
//#define HOTEND_OFFSET_X { 0.0, 20.00 } // (mm) relative X-offset for each nozzle
#if ENABLED(TREX3)
#define HOTEND_OFFSET_X {0.0, 438.5} // (mm) relative X-offset for each nozzle
#else
#define HOTEND_OFFSET_X {0.0, 442.0} // (mm) relative X-offset for each nozzle
#endif
//#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle
//#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle
@@ -399,7 +542,7 @@
//#define MKS_PWC // Using the MKS PWC add-on
//#define PS_OFF_CONFIRM // Confirm dialog when power off
//#define PS_OFF_SOUND // Beep 1s when power off
#define PSU_ACTIVE_STATE HIGH // Set 'LOW' for ATX, 'HIGH' for X-Box
#define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box
//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
//#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power
@@ -414,22 +557,13 @@
//#define PS_ON1_EDM_PIN 9
#define PS_EDM_RESPONSE 250 // (ms) Time to allow for relay action
#define PSU_OFF_REDUNDANT // Second pin for redundant power control
//#define PSU_OFF_REDUNDANT_OPPOSING // Redundant pin works opposite standard pin
#define PS_ON_PIN P4_28 // Redundant Pin
#define PS_ON1_PIN P1_03 // Redundant Pin
#define PS_ON_EDM_PIN P4_29 // EDM Pins to monitor feedback on external power control relay. Fault on mismatch.
#define PS_ON1_EDM_PIN P1_17
#define PS_EDM_RESPONSE 1000 // Time in MS to allow for relay action
//#define POWER_OFF_TIMER // Enable M81 D<seconds> to power off after a delay
//#define POWER_OFF_WAIT_FOR_COOLDOWN // Enable M81 S to power off only after cooldown
//#define PSU_POWERUP_GCODE "M355 S1" // G-code to run after power-on (e.g., case light on)
//#define PSU_POWEROFF_GCODE "M355 S0" // G-code to run before power-off (e.g., case light off)
#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU for fans
#define AUTO_POWER_E_FANS // Turn on PSU for E Fans
@@ -562,15 +696,24 @@
* 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below.
* 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below.
*/
#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#if ENABLED(TREX3)
#define TEMP_SENSOR_0 1047
#define TEMP_SENSOR_1 61
#else
#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 1
#endif
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 11
#if(ENABLED(BedAC))
#define TEMP_SENSOR_BED 11
#else
#define TEMP_SENSOR_BED 0
#endif
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
@@ -597,14 +740,14 @@
#endif
#if HAS_E_TEMP_SENSOR
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#define TEMP_RESIDENCY_TIME 2 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 5 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 5 // (°C) Temperature proximity considered "close enough" to the target
#endif
#if TEMP_SENSOR_BED
#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190
#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_BED_WINDOW 2 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#endif
@@ -646,15 +789,20 @@
// Above this temperature the heater will be switched off.
// This can protect components from overheating, but NOT from shorts and failures.
// (Use MINTEMP for thermistor short/failure protection.)
#define HEATER_0_MAXTEMP 300
#define HEATER_1_MAXTEMP 275
#if ENABLED(TREX3)
#define HEATER_0_MAXTEMP 350
#define HEATER_1_MAXTEMP 350
#else
#define HEATER_0_MAXTEMP 410
#define HEATER_1_MAXTEMP 295
#endif
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
#define HEATER_4_MAXTEMP 275
#define HEATER_5_MAXTEMP 275
#define HEATER_6_MAXTEMP 275
#define HEATER_7_MAXTEMP 275
#define BED_MAXTEMP 120
#define BED_MAXTEMP 150
#define CHAMBER_MAXTEMP 60
/**
@@ -663,7 +811,7 @@
* (especially before PID tuning). Setting the target temperature too close to MAXTEMP guarantees
* a MAXTEMP shutdown! Use these values to forbid temperatures being set too close to MAXTEMP.
*/
#define HOTEND_OVERSHOOT 10 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT
#define HOTEND_OVERSHOOT 15 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT
#define BED_OVERSHOOT 10 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT
#define COOLER_OVERSHOOT 2 // (°C) Forbid temperatures closer than OVERSHOOT
@@ -681,26 +829,32 @@
* 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 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_K1 0.95 // Smoothing factor within any PID loop
#if ENABLED(PIDTEMP)
//#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation.
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with G-code: M301 E[extruder number, 0-2]
#if ENABLED(PID_PARAMS_PER_HOTEND)
// Specify up to one value per hotend here, according to your setup.
// If there are fewer values, the last one applies to the remaining hotends.
#define DEFAULT_Kp_LIST { 22.20, 22.20 }
#define DEFAULT_Ki_LIST { 1.08, 1.08 }
#define DEFAULT_Kd_LIST { 114.00, 114.00 }
#if ENABLED(TREX3)
#define DEFAULT_Kp_LIST { 14.64, 14.64 }
#define DEFAULT_Ki_LIST { 1.08, 1.08 }
#define DEFAULT_Kd_LIST { 53.36, 53.36 }
#else
#define DEFAULT_Kp_LIST { 22.20, 22.20 }
#define DEFAULT_Ki_LIST { 1.08, 1.08 }
#define DEFAULT_Kd_LIST { 114.00, 114.00 }
#endif
#else
#define DEFAULT_Kp 22.20
#define DEFAULT_Ki 1.08
#define DEFAULT_Kd 114.00
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki 1.08
#define DEFAULT_Kd 114
#endif
#else
#define BANG_MAX 255 // Limit hotend current while in bang-bang mode; 255=full current
@@ -766,7 +920,7 @@
* When set to any value below 255, enables a form of PWM to the bed that acts like a divider
* so don't use it unless you are OK with PWM on your bed. (See the comment on enabling PIDTEMPBED)
*/
#define MAX_BED_POWER 180 // limits duty cycle to bed; 255=full current
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
/**
* PID Bed Heating
@@ -1179,7 +1333,7 @@
* Endstop "Hit" State
* Set to the state (HIGH or LOW) that applies to each endstop.
*/
#define X_MIN_ENDSTOP_HIT_STATE LOW
#define X_MIN_ENDSTOP_HIT_STATE HIGH
#define X_MAX_ENDSTOP_HIT_STATE HIGH
#define Y_MIN_ENDSTOP_HIT_STATE LOW
#define Y_MAX_ENDSTOP_HIT_STATE HIGH
@@ -1201,7 +1355,7 @@
// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
//#define ENDSTOP_INTERRUPTS_FEATURE
#define ENDSTOP_INTERRUPTS_FEATURE
/**
* Endstop Noise Threshold
@@ -1238,14 +1392,28 @@
* following movement settings. If fewer factors are given than the
* total number of extruders, the last value applies to the rest.
*/
//#define DISTINCT_E_FACTORS
#define DISTINCT_E_FACTORS
/**
* Default Axis Steps Per Unit (linear=steps/mm, rotational=steps/°)
* Override with M92 (when enabled below)
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
*/
#define DEFAULT_AXIS_STEPS_PER_UNIT { 40, 40, 200, 425 }
#if(ENABLED(Y_2208) || ENABLED(Y_4988) || ENABLED(Y_S109))
#define Y_STEPSMM 80
#else
#define Y_STEPSMM 160
#endif
#if(ENABLED(Z_2208) || ENABLED(Z_4988))
#define Z_STEPSMM 800
#else
#define Z_STEPSMM 1600
#endif
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, Y_STEPSMM, Z_STEPSMM, 93, 93 }
/**
* Enable support for M92. Disable to save at least ~530 bytes of flash.
@@ -1257,11 +1425,16 @@
* Override with M203
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
*/
#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 }
#if ENABLED(Y_2208) && DISABLED(Y_Spreadcycle)
#define Y_MAXFEED 100
#else
#define Y_MAXFEED 150
#endif
#define DEFAULT_MAX_FEEDRATE { 200, Y_MAXFEED, 8, 75, 75 }
//#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2
#if ENABLED(LIMITED_MAX_FR_EDITING)
#define MAX_FEEDRATE_EDIT_VALUES { 600, 600, 10, 50 } // ...or, set your own edit limits
#define MAX_FEEDRATE_EDIT_VALUES { 300, 200, 15, 150 } // ...or, set your own edit limits
#endif
/**
@@ -1270,11 +1443,11 @@
* Override with M201
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
*/
#define DEFAULT_MAX_ACCELERATION { 50000, 50000, 500, 10000 }
#define DEFAULT_MAX_ACCELERATION { 750, 500, 400, 3000, 3000 }
//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
#define MAX_ACCEL_EDIT_VALUES { 6000, 6000, 200, 20000 } // ...or, set your own edit limits
#define MAX_ACCEL_EDIT_VALUES { 1500, 1500, 800, 5000 } // ...or, set your own edit limits
#endif
/**
@@ -1285,9 +1458,9 @@
* M204 R Retract Acceleration
* M204 T Travel Acceleration
*/
#define DEFAULT_ACCELERATION 7000 // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts
#define DEFAULT_TRAVEL_ACCELERATION 7000 // X, Y, Z acceleration for travel (non printing) moves
#define DEFAULT_ACCELERATION 500 // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION 2000 // E acceleration for retracts
#define DEFAULT_TRAVEL_ACCELERATION 500 // X, Y, Z acceleration for travel (non printing) moves
/**
* Default Jerk limits (mm/s)
@@ -1300,7 +1473,7 @@
#define CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
#define DEFAULT_XJERK 10.0
#define DEFAULT_YJERK 10.0
#define DEFAULT_YJERK 5.0
#define DEFAULT_ZJERK 0.3
#define DEFAULT_EJERK 5.0
//#define DEFAULT_IJERK 0.3
@@ -1314,7 +1487,7 @@
//#define LIMITED_JERK_EDITING // Limit edit via M205 or LCD to DEFAULT_aJERK * 2
#if ENABLED(LIMITED_JERK_EDITING)
#define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10 } // ...or, set your own edit limits
#define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10, 10 } // ...or, set your own edit limits
#endif
#endif
@@ -1355,10 +1528,10 @@
* The probe replaces the Z-MIN endstop and is used for Z homing.
* (Automatically enables USE_PROBE_FOR_Z_HOMING.)
*/
//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
// Force the use of the probe for Z-axis homing
#define USE_PROBE_FOR_Z_HOMING
//#define USE_PROBE_FOR_Z_HOMING
/**
* Z_MIN_PROBE_PIN
@@ -1590,7 +1763,6 @@
* | [-] |
* O-- FRONT --+
*/
#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
// Enable and set to use a specific tool for probing. Disable to allow any tool.
#define PROBING_TOOL 0
@@ -1598,6 +1770,11 @@
//#define PROBE_TOOLCHANGE_NO_MOVE // Suppress motion on probe tool-change
#endif
#if ENABLED(TREX3)
#define NOZZLE_TO_PROBE_OFFSET { -3, 31, 0 }
#else
#define NOZZLE_TO_PROBE_OFFSET { -7, 29, 0 }
#endif
// Most probes should stay away from the edges of the bed, but
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
#define PROBING_MARGIN 10
@@ -1606,7 +1783,7 @@
#define XY_PROBE_FEEDRATE (133*60)
// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2)
#define Z_PROBE_FEEDRATE_FAST (4*60)
#define Z_PROBE_FEEDRATE_FAST (10*60)
// Feedrate (mm/min) for the "accurate" probe of each point
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2)
@@ -1673,21 +1850,27 @@
* 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.
*/
#define Z_CLEARANCE_DEPLOY_PROBE 10 // (mm) Z Clearance for Deploy/Stow
#if ENABLED(TREX3)
#define NOZZLE_TO_PROBE_OFFSET { -3, 31, 0 }
#else
#define NOZZLE_TO_PROBE_OFFSET { -7, 29, 0 }
#endif
#define Z_CLEARANCE_DEPLOY_PROBE 5 // (mm) Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 5 // (mm) Z Clearance between probe points
#define Z_CLEARANCE_MULTI_PROBE 5 // (mm) Z Clearance between multiple probes
#define Z_PROBE_ERROR_TOLERANCE 3 // (mm) Tolerance for early trigger (<= -probe.offset.z + ZPET)
//#define Z_AFTER_PROBING 5 // (mm) Z position after probing is done
#define Z_PROBE_LOW_POINT -5 // (mm) Farthest distance below the trigger-point to go before stopping
#define Z_PROBE_LOW_POINT -3 // (mm) Farthest distance below the trigger-point to go before stopping
// For M851 provide ranges for adjusting the X, Y, and Z probe offsets
//#define PROBE_OFFSET_XMIN -50 // (mm)
//#define PROBE_OFFSET_XMAX 50 // (mm)
//#define PROBE_OFFSET_YMIN -50 // (mm)
//#define PROBE_OFFSET_YMAX 50 // (mm)
//#define PROBE_OFFSET_ZMIN -20 // (mm)
//#define PROBE_OFFSET_ZMAX 20 // (mm)
#define PROBE_OFFSET_ZMIN -3 // (mm)
#define PROBE_OFFSET_ZMAX 3 // (mm)
// Enable the M48 repeatability test to test probe accuracy
//#define Z_MIN_PROBE_REPEATABILITY_TEST
@@ -1758,9 +1941,21 @@
// @section motion
// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#define INVERT_X_DIR true
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#if ANY(X_2208, SKR12Pro)
#define INVERT_X_DIR true
#else
#define INVERT_X_DIR false
#endif
#if ANY(Y_2208, SKR12Pro)
#define INVERT_Y_DIR true
#else
#define INVERT_Y_DIR false
#endif
#if ANY(Z_2208, SKR12Pro)
#define INVERT_Z_DIR false
#else
#define INVERT_Z_DIR true
#endif
//#define INVERT_I_DIR false
//#define INVERT_J_DIR false
//#define INVERT_K_DIR false
@@ -1771,8 +1966,13 @@
// @section extruder
// For direct drive extruder v9 set to true, for geared extruder set to false.
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#if ANY(E_2208, SKR12Pro) && DISABLED(TREX3)
#define INVERT_E0_DIR true
#define INVERT_E1_DIR false
#else
#define INVERT_E0_DIR false
#define INVERT_E1_DIR true
#endif
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false
#define INVERT_E4_DIR false
@@ -1803,7 +2003,7 @@
// Direction of endstops when homing; 1=MAX, -1=MIN
// :[-1,1]
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Y_HOME_DIR 1
#define Z_HOME_DIR -1
//#define I_HOME_DIR -1
//#define J_HOME_DIR -1
@@ -1829,17 +2029,29 @@
// @section geometry
// The size of the printable area
#define X_BED_SIZE 1200
#define Y_BED_SIZE 1200
// The size of the print bed
#define X_BED_SIZE 400
#define Y_BED_SIZE 400
// Travel limits (linear=mm, rotational=°) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 1000
#if DISABLED(TREX3) || ENABLED(TREX3_UPGRADE)
#define X_MIN_POS -42
#define Y_MIN_POS 0
#define Z_MIN_POS -3
#define X_MAX_POS 450
#define Y_MAX_POS Y_BED_SIZE
#else
#define X_MIN_POS -47
#define Y_MIN_POS 0
#define Z_MIN_POS -3
#define X_MAX_POS 460
#define Y_MAX_POS Y_BED_SIZE
#endif
#if(ENABLED(tallVersion))
#define Z_MAX_POS 700
#else
#define Z_MAX_POS 500
#endif
//#define I_MIN_POS 0
//#define I_MAX_POS 50
//#define J_MIN_POS 0
@@ -1902,15 +2114,19 @@
* Marlin knows a print job is running when:
* 1. Running a print job from media started with M24.
* 2. The Print Job Timer has been started with M75.
* 3. The heaters were turned on and PRINTJOB_TIMER_AUTOSTART is enabled.
* 3. The heaters were turned on with a wait command (M109) and PRINTJOB_TIMER_AUTOSTART is enabled.
*
* RAMPS-based boards use SERVO3_PIN for the first runout sensor.
* For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc.
*/
//#define FILAMENT_RUNOUT_SENSOR
#define FILAMENT_RUNOUT_SENSOR
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500.
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
#if ENABLED(TREX3)
#define NUM_RUNOUT_SENSORS 2
#else
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
#endif
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
@@ -1953,13 +2169,17 @@
// Commands to execute on filament runout.
// With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c")
// NOTE: After 'M412 H1' the host handles filament runout and this script does not apply.
#define FILAMENT_RUNOUT_SCRIPT "M600"
// NOTE: After 'M591 H1' the host handles filament runout and this script does not apply.
#define FILAMENT_RUNOUT_SCRIPT "M600 %c"
// After a runout is detected, continue printing this length of filament
// before executing the runout script. Useful for a sensor at the end of
// a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead.
//#define FILAMENT_RUNOUT_DISTANCE_MM 25
#if ENABLED(TREX3)
// #define FIL_RUNOUT_DISTANCE_MM { 15, 15 }
#else
// #define FIL_RUNOUT_DISTANCE_MM { 15 }
#endif
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
// Enable this option to use an encoder disc that toggles the runout pin
@@ -2008,6 +2228,34 @@
#endif
#endif
#endif
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
// Override individually if the runout sensors vary
//#define FIL_RUNOUT1_PULLUP
//#define FIL_RUNOUT1_PULLDOWN
//#define FIL_RUNOUT2_PULLUP
//#define FIL_RUNOUT2_PULLDOWN
//#define FIL_RUNOUT3_PULLUP
//#define FIL_RUNOUT3_PULLDOWN
//#define FIL_RUNOUT4_PULLUP
//#define FIL_RUNOUT4_PULLDOWN
//#define FIL_RUNOUT5_PULLUP
//#define FIL_RUNOUT5_PULLDOWN
//#define FIL_RUNOUT6_PULLUP
//#define FIL_RUNOUT6_PULLDOWN
//#define FIL_RUNOUT7_PULLUP
//#define FIL_RUNOUT7_PULLDOWN
//#define FIL_RUNOUT8_PULLUP
//#define FIL_RUNOUT8_PULLDOWN
#endif
//===========================================================================
@@ -2050,15 +2298,18 @@
*/
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
#define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
#if ENABLED(ABL_Bilinear)
#define AUTO_BED_LEVELING_BILINEAR
#else
#define AUTO_BED_LEVELING_UBL
#endif
//#define MESH_BED_LEVELING
/**
* Commands to execute at the end of G29 probing.
* Useful to retract or move the Z probe out of the way.
*/
//#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10"
//#define EVENT_GCODE_AFTER_G29 "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10"
/**
* Normally G28 leaves leveling disabled on completion. Enable one of
@@ -2080,7 +2331,7 @@
/**
* Enable detailed logging of G28, G29, M48, etc.
* Turn on with the command 'M111 S32'.
* NOTE: Requires a lot of PROGMEM!
* NOTE: Requires a lot of flash!
*/
//#define DEBUG_LEVELING_FEATURE
@@ -2111,7 +2362,9 @@
/**
* Enable the G26 Mesh Validation Pattern tool.
*/
#define G26_MESH_VALIDATION
#if ENABLED(ABL_Bilinear)
#define G26_MESH_VALIDATION
#endif
#if ENABLED(G26_MESH_VALIDATION)
#define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle.
#define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for G26.
@@ -2127,7 +2380,7 @@
#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
// Set the number of grid points per dimension.
#define GRID_MAX_POINTS_X 15
#define GRID_MAX_POINTS_X 11
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
// Probe along the Y axis, advancing X after each column
@@ -2137,7 +2390,7 @@
// Beyond the probed grid, continue the implied tilt?
// Default is to maintain the height of the nearest edge.
#define EXTRAPOLATE_BEYOND_GRID
//#define EXTRAPOLATE_BEYOND_GRID
//
// Subdivision of the grid by Catmull-Rom method.
@@ -2157,13 +2410,13 @@
//========================= Unified Bed Leveling ============================
//===========================================================================
//#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh
#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh
#define MESH_INSET 1 // Set Mesh bounds as an inset region of the bed
#define GRID_MAX_POINTS_X 10 // Don't use more than 15 points per axis, implementation limited.
#define MESH_INSET 3 // Set Mesh bounds as an inset region of the bed
#define GRID_MAX_POINTS_X 15 // Don't use more than 15 points per axis, implementation limited.
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
//#define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points
#define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points
//#define UBL_TILT_ON_MESH_POINTS // Use nearest mesh points with G29 J for better Z reference
//#define UBL_TILT_ON_MESH_POINTS_3POINT // Use nearest mesh points with G29 J0 (3-point)
@@ -2171,7 +2424,7 @@
#define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle
#define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500
//#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used
#define UBL_Z_RAISE_WHEN_OFF_MESH 0.0 // When the nozzle is off the mesh, this value is used
// as the Z-Height correction value.
//#define UBL_MESH_WIZARD // Run several commands in a row to get a complete mesh
@@ -2213,12 +2466,12 @@
* Add a bed leveling sub-menu for ABL or MBL.
* Include a guided procedure if manual probing is enabled.
*/
#define LCD_BED_LEVELING
//#define LCD_BED_LEVELING
#if ENABLED(LCD_BED_LEVELING)
#define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis.
#define LCD_PROBE_Z_RANGE 8 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment
#define MESH_EDIT_MENU // Add a menu to edit mesh points
#define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment
//#define MESH_EDIT_MENU // Add a menu to edit mesh points
#endif
// Add a menu item to move between bed corners for manual bed adjustment
@@ -2227,7 +2480,7 @@
#if ENABLED(LCD_BED_TRAMMING)
#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_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_USE_PROBE
#if ENABLED(BED_TRAMMING_USE_PROBE)
@@ -2265,7 +2518,7 @@
// For DELTA this is the top-center of the Cartesian print volume.
//#define MANUAL_X_HOME_POS 0
//#define MANUAL_Y_HOME_POS 0
//#define MANUAL_Z_HOME_POS 0
#define MANUAL_Z_HOME_POS 0
//#define MANUAL_I_HOME_POS 0
//#define MANUAL_J_HOME_POS 0
//#define MANUAL_K_HOME_POS 0
@@ -2369,11 +2622,11 @@
*/
#define EEPROM_SETTINGS // Persistent storage with M500 and M501
//#define DISABLE_M503 // Saves ~2700 bytes of flash. Disable for release!
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save flash.
#define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load
#if ENABLED(EEPROM_SETTINGS)
#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
//#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
#endif
// @section host
@@ -2434,7 +2687,7 @@
#if ENABLED(NOZZLE_PARK_FEATURE)
// Specify a park position as { X, Y, Z_raise }
#define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MIN_POS + 10), 5 }
#define NOZZLE_PARK_POINT { 150, (Y_MIN_POS + 10), 10 }
#define NOZZLE_PARK_MOVE 0 // Park motion: 0 = XY Move, 1 = X Only, 2 = Y Only, 3 = X before Y, 4 = Y before X
#define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance
#define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis)
@@ -2477,7 +2730,7 @@
*
* Caveats: The ending Z should be the same as starting Z.
*/
//#define NOZZLE_CLEAN_FEATURE
#define NOZZLE_CLEAN_FEATURE
#if ENABLED(NOZZLE_CLEAN_FEATURE)
#define NOZZLE_CLEAN_PATTERN_LINE // Provide 'G12 P0' - a simple linear cleaning pattern
@@ -2487,7 +2740,7 @@
// Default pattern to use when 'P' is not provided to G12. One of the enabled options above.
#define NOZZLE_CLEAN_DEFAULT_PATTERN 0
#define NOZZLE_CLEAN_STROKES 12 // Default number of pattern repetitions
#define NOZZLE_CLEAN_STROKES 4 // Default number of pattern repetitions
#if ENABLED(NOZZLE_CLEAN_PATTERN_ZIGZAG)
#define NOZZLE_CLEAN_TRIANGLES 3 // Default number of triangles
@@ -2495,8 +2748,8 @@
// Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
// Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
#define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } }
#define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } }
#define NOZZLE_CLEAN_START_POINT { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
#define NOZZLE_CLEAN_END_POINT { { (-30), (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { (430), (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
#if ENABLED(NOZZLE_CLEAN_PATTERN_CIRCLE)
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5 // (mm) Circular pattern radius
@@ -2507,11 +2760,11 @@
// Move the nozzle to the initial position after cleaning
#define NOZZLE_CLEAN_GOBACK
// For a purge/clean station that's always at the gantry height (thus no Z move)
//#define NOZZLE_CLEAN_NO_Z
// Enable for a purge/clean station that's always at the gantry height (thus no Z move)
#define NOZZLE_CLEAN_NO_Z
// For a purge/clean station mounted on the X axis
//#define NOZZLE_CLEAN_NO_Y
#define NOZZLE_CLEAN_NO_Y
// Require a minimum hotend temperature for cleaning
#define NOZZLE_CLEAN_MIN_TEMP 170
@@ -2657,6 +2910,7 @@
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
*/
#define SD_SPI_SPEED SPI_HALF_SPEED
#define SDSUPPORT
/**
@@ -2738,7 +2992,7 @@
// Add individual axis homing items (Home X, Home Y, and Home Z) to the LCD menu.
//
#define INDIVIDUAL_AXIS_HOMING_MENU
//#define INDIVIDUAL_AXIS_HOMING_SUBMENU
#define INDIVIDUAL_AXIS_HOMING_SUBMENU
//
// SPEAKER/BUZZER
@@ -3424,9 +3678,7 @@
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
#if ANY(TFT_CLASSIC_UI, TFT_COLOR_UI)
//#define NO_BACK_MENU_ITEM // Don't display a top menu item to go back to the parent menu
#endif
//#define DISABLE_ENCODER // Disable the click encoder, if any
#define TOUCH_SCREEN_CALIBRATION
@@ -3470,8 +3722,9 @@
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not as annoying as with the hardware PWM. On the other hand, if this frequency
// is too low, you should also increment SOFT_PWM_SCALE.
//#define FAN_SOFT_PWM
#if ENABLED(TREX3) && DISABLED(SKR12Pro)
#define FAN_SOFT_PWM
#endif
// Incrementing this by 1 will double the software PWM frequency,
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
// However, control resolution will be halved for each increment;
+180 -152
View File
@@ -304,8 +304,8 @@
* THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 40 // (seconds)
#define THERMAL_PROTECTION_HYSTERESIS 4 // (°C)
#define THERMAL_PROTECTION_PERIOD 60 // (seconds)
#define THERMAL_PROTECTION_HYSTERESIS 15 // (°C)
#define ADAPTIVE_FAN_SLOWING // Slow down the part-cooling fan if the temperature drops
#if ENABLED(ADAPTIVE_FAN_SLOWING)
@@ -327,7 +327,7 @@
* and/or decrease WATCH_TEMP_INCREASE. WATCH_TEMP_INCREASE should not be set
* below 2.
*/
#define WATCH_TEMP_PERIOD 40 // (seconds)
#define WATCH_TEMP_PERIOD 60 // (seconds)
#define WATCH_TEMP_INCREASE 2 // (°C)
#endif
@@ -335,13 +335,13 @@
* Thermal Protection parameters for the bed are just as above for hotends.
*/
#if ENABLED(THERMAL_PROTECTION_BED)
#define THERMAL_PROTECTION_BED_PERIOD 90 // (seconds)
#define THERMAL_PROTECTION_BED_PERIOD 120 // (seconds)
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // (°C)
/**
* As described above, except for the bed (M140/M190/M303).
*/
#define WATCH_BED_TEMP_PERIOD 60 // (seconds)
#define WATCH_BED_TEMP_PERIOD 120 // (seconds)
#define WATCH_BED_TEMP_INCREASE 2 // (°C)
#endif
@@ -549,8 +549,8 @@
*/
#define HOTEND_IDLE_TIMEOUT
#if ENABLED(HOTEND_IDLE_TIMEOUT)
#define HOTEND_IDLE_TIMEOUT_SEC (30*60) // (seconds) Time without extruder movement to trigger protection
#define HOTEND_IDLE_MIN_TRIGGER 170 // (°C) Minimum temperature to enable hotend protection
#define HOTEND_IDLE_TIMEOUT_SEC (15*60) // (seconds) Time without extruder movement to trigger protection
#define HOTEND_IDLE_MIN_TRIGGER 180 // (°C) Minimum temperature to enable hotend protection
#define HOTEND_IDLE_NOZZLE_TARGET 0 // (°C) Safe temperature for the nozzle after timeout
#define HOTEND_IDLE_BED_TARGET 0 // (°C) Safe temperature for the bed after timeout
#endif
@@ -603,9 +603,7 @@
* (Does not work on Sanguinololu with FAN_SOFT_PWM.)
*/
#define FAN_KICKSTART_TIME 100 // (ms)
#define FAN_KICKSTART_POWER 255 // 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.
//#define FAN_KICKSTART_POWER 180 // 64-255
// Some coolers may require a non-zero "off" state.
//#define FAN_OFF_PWM 1
@@ -683,8 +681,17 @@
* Multiple extruders can be assigned to the same pin in which case
* the fan will turn on when any selected extruder is above the threshold.
*/
#define E0_AUTO_FAN_PIN -1
#define E1_AUTO_FAN_PIN -1
#if ENABLED(SKR12Pro, TREX3)
#define E0_AUTO_FAN_PIN FAN2_PIN
#define E1_AUTO_FAN_PIN FAN2_PIN
#elif ENABLED(TREX3)
#define E0_AUTO_FAN_PIN 6
#define E1_AUTO_FAN_PIN 45
#else
#define E0_AUTO_FAN_PIN -1
#define E1_AUTO_FAN_PIN -1
#endif
#define E2_AUTO_FAN_PIN -1
#define E3_AUTO_FAN_PIN -1
#define E4_AUTO_FAN_PIN -1
@@ -750,15 +757,17 @@
* @section caselight
* M355 Case Light on-off / brightness
*/
//#define CASE_LIGHT_ENABLE
#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
//#define CASE_LIGHT_PIN 4 // Override the default pin if needed
#if ENABLED(SKR12Pro)
#define CASE_LIGHT_PIN HEATER_2_PIN // Override the default pin if needed
#endif
#define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW
#define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin)
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 255 // Set default power-up brightness (0-255, requires PWM pin)
//#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting.
//#define CASE_LIGHT_MAX_PWM 128 // Limit PWM duty cycle (0-255)
//#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu
#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu
#if ENABLED(NEOPIXEL_LED)
//#define CASE_LIGHT_USE_NEOPIXEL // Use NeoPixel LED as case light
#endif
@@ -817,22 +826,26 @@
* Set the initial X offset and temperature differential with M605 S2 X[offs] R[deg] and
* follow with M605 S3 to initiate mirrored movement.
*/
//#define DUAL_X_CARRIAGE
#define DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
#define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS
#define X1_MAX_POS X_BED_SIZE // A max coordinate so the X1 carriage can't hit the parked X2 carriage
#define X2_MIN_POS 80 // A min coordinate so the X2 carriage can't hit the parked X1 carriage
#define X2_MAX_POS 353 // The max position of the X2 carriage, typically also the home position
#define X2_MIN_POS 0 // A min coordinate so the X2 carriage can't hit the parked X1 carriage
#if DISABLED(TREX3) || ENABLED(TREX3_UPGRADE)
#define X2_MAX_POS 442 // The max position of the X2 carriage, typically also the home position
#else
#define X2_MAX_POS 446 // The max position of the X2 carriage, typically also the home position
#endif
#define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS.
// NOTE: For Dual X Carriage use M218 T1 Xn to override the X2_HOME_POS.
// This allows recalibration of endstops distance without a rebuild.
// Remember to set the second extruder's X-offset to 0 in your slicer.
// This is the default power-up mode which can be changed later using M605 S<mode>.
// This is the default power-up mode which can be later using M605.
#define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE
// Default x offset in duplication mode (typically set to half print bed width)
#define DEFAULT_DUPLICATION_X_OFFSET 100
#define DEFAULT_DUPLICATION_X_OFFSET 200
// Default action to execute following M605 mode change commands. Typically G28X to apply new mode.
//#define EVENT_GCODE_IDEX_AFTER_MODECHANGE "G28X"
@@ -1005,7 +1018,7 @@
*
* Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset.
*/
//#define BLTOUCH_HS_MODE true
#define BLTOUCH_HS_MODE true
#ifdef BLTOUCH_HS_MODE
// The probe Z offset (M851 Z) is the height at which the probe triggers.
@@ -1022,7 +1035,7 @@
* Z Steppers Auto-Alignment
* Add the G34 command to align multiple Z steppers using a bed probe.
*/
#define Z_STEPPER_AUTO_ALIGN
//#define Z_STEPPER_AUTO_ALIGN
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
/**
* Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]]
@@ -1187,19 +1200,24 @@
* 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
* 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
* 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.
* If the buffer is too small at runtime, input shaping will have reduced
* 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_Y
//#define INPUT_SHAPING_Z
#if ANY(INPUT_SHAPING_X, INPUT_SHAPING_Y, INPUT_SHAPING_Z)
#if ANY(INPUT_SHAPING_X, INPUT_SHAPING_Y)
#if ENABLED(INPUT_SHAPING_X)
#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).
@@ -1208,10 +1226,6 @@
#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).
#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_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.
@@ -1264,7 +1278,11 @@
// Increase the slowdown divisor for larger buffer sizes.
#define SLOWDOWN
#if ENABLED(SLOWDOWN)
#define SLOWDOWN_DIVISOR 2
#if ENABLED(SKR12Pro)
#define SLOWDOWN_DIVISOR 6
#else
#define SLOWDOWN_DIVISOR 2
#endif
#endif
/**
@@ -1287,7 +1305,7 @@
// Define values for backlash distance and correction.
// If BACKLASH_GCODE is enabled these values are the defaults.
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (linear=mm, rotational=°) One value for each linear axis
#define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction
#define BACKLASH_CORRECTION 0.5 // 0.0 = no correction; 1.0 = full correction
// Add steps for motor direction changes on CORE kinematics
//#define CORE_BACKLASH
@@ -1301,7 +1319,7 @@
#if ENABLED(BACKLASH_GCODE)
// Measure the Z backlash when probing (G29) and set with "M425 Z"
#define MEASURE_BACKLASH_WHEN_PROBING
//#define MEASURE_BACKLASH_WHEN_PROBING
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
// When measuring, the probe will move up to BACKLASH_MEASUREMENT_LIMIT
@@ -1327,12 +1345,16 @@
* Note: HOTEND_OFFSET and CALIBRATION_OBJECT_CENTER must be set to within
* ±5mm of true values for G425 to succeed.
*/
//#define CALIBRATION_GCODE
#if ENABLED(autoCalibrationKit)
#define CALIBRATION_GCODE
#endif
#if ENABLED(CALIBRATION_GCODE)
//#define CALIBRATION_SCRIPT_PRE "M117 Starting Auto-Calibration\nT0\nG28\nG12\nM117 Calibrating..."
//#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_FAST 1200 // mm/min
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min
@@ -1341,12 +1363,14 @@
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm
#define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // mm
// Uncomment to enable reporting (required for "G425 V", but consumes PROGMEM).
//#define CALIBRATION_REPORTING
// Uncomment to enable reporting (required for "G425 V", but consumes flash).
#if ENABLED(SKR12Pro)
#define CALIBRATION_REPORTING
#endif
// The true location and dimension the cube/bolt/washer on the bed.
#define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // mm
#define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // mm
#define CALIBRATION_OBJECT_CENTER { 264.0, 25.0, 12.5 } // mm
#define CALIBRATION_OBJECT_DIMENSIONS { 12.55, 12.55, 4.0 } // mm
// Comment out any sides which are unreachable by the probe. For best
// auto-calibration results, all sides must be reachable.
@@ -1370,12 +1394,16 @@
// Probing at the exact top center only works if the center is flat. If
// probing on a screw head or hollow washer, probe near the edges.
//#define CALIBRATION_MEASURE_AT_TOP_EDGES
#define CALIBRATION_MEASURE_AT_TOP_EDGES
// Define the pin to read during calibration
#ifndef CALIBRATION_PIN
//#define CALIBRATION_PIN -1 // Define here to override the default pin
#define CALIBRATION_PIN_INVERTING false // Set to true to invert the custom pin
#if ENABLED(SKR12Pro)
#define CALIBRATION_PIN Z_MAX
#else
#define CALIBRATION_PIN 58 // Override in pins.h or set to -1 to use your Z endstop
#endif
#define CALIBRATION_PIN_INVERTING true // Set to true to invert the pin
//#define CALIBRATION_PIN_PULLDOWN
#define CALIBRATION_PIN_PULLUP
#endif
@@ -1581,9 +1609,9 @@
#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash)
#endif
#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
#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.
#endif
#endif
@@ -1600,10 +1628,10 @@
#endif
// The timeout to return to the status screen from sub-menus
#define LCD_TIMEOUT_TO_STATUS 15000 // (ms)
//#define LCD_TIMEOUT_TO_STATUS 15000 // (ms)
// Scroll a longer status message into view
#define STATUS_MESSAGE_SCROLLING
//#define STATUS_MESSAGE_SCROLLING
// Apply a timeout to low-priority status messages
//#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds)
@@ -1919,7 +1947,9 @@
*
* :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ]
*/
#define SDCARD_CONNECTION ONBOARD
#if ENABLED(SKR12Pro)
#define SDCARD_CONNECTION ONBOARD
#endif
// Enable if SD detect is rendered useless (e.g., by using an SD extender)
//#define NO_SD_DETECT
@@ -2273,7 +2303,7 @@
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
//#define BABYSTEP_INVERT_Z // Enable if Z babysteps should go the other way
//#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps
#define BABYSTEP_MULTIPLICATOR_Z 25 // (steps or mm) Steps or millimeter distance for each Z babystep
#define BABYSTEP_MULTIPLICATOR_Z 20 // (steps or mm) Steps or millimeter distance for each Z babystep
#define BABYSTEP_MULTIPLICATOR_XY 1 // (steps or mm) Steps or millimeter distance for each XY babystep
#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
@@ -2290,8 +2320,8 @@
#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
//#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets
//#define BABYSTEP_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets
#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
#endif
#endif
@@ -2315,9 +2345,9 @@
#define LIN_ADVANCE
#if ENABLED(LIN_ADVANCE)
#if ENABLED(DISTINCT_E_FACTORS)
#define ADVANCE_K { 0.22 } // (mm) Compression length per 1mm/s extruder speed, per extruder
#define ADVANCE_K { 0.0 } // (mm) Compression length per 1mm/s extruder speed, per extruder
#else
#define ADVANCE_K 0.22 // (mm) Compression length applying to all extruders
#define ADVANCE_K 0.0 // (mm) Compression length applying to all extruders
#endif
//#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L.
//#define LA_DEBUG // Print debug information to serial during operation. Disable for production use.
@@ -2329,7 +2359,6 @@
*
* 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).
* For better results also enable ADAPTIVE_STEP_SMOOTHING.
*/
//#define NONLINEAR_EXTRUSION
@@ -2388,10 +2417,10 @@
#if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
// Override the mesh area if the automatic (max) area is too large
//#define MESH_MIN_X MESH_INSET
//#define MESH_MIN_Y MESH_INSET
//#define MESH_MAX_X X_BED_SIZE - (MESH_INSET)
//#define MESH_MAX_Y Y_BED_SIZE - (MESH_INSET)
#define MESH_MIN_X X_MIN_POS + MESH_INSET
#define MESH_MIN_Y Y_MIN_POS + MESH_INSET
#define MESH_MAX_X X_MAX_POS - MESH_INSET
#define MESH_MAX_Y Y_MAX_POS - MESH_INSET
#endif
#if ALL(AUTO_BED_LEVELING_UBL, EEPROM_SETTINGS)
@@ -2506,7 +2535,7 @@
#endif
// G5 Bézier Curve Support with XYZE destination and IJPQ offsets
#define BEZIER_CURVE_SUPPORT // Requires ~2666 bytes
//#define BEZIER_CURVE_SUPPORT // Requires ~2666 bytes
#if ANY(ARC_SUPPORT, BEZIER_CURVE_SUPPORT)
//#define CNC_WORKSPACE_PLANES // Allow G2/G3/G5 to operate in XY, ZX, or YZ planes
@@ -2557,32 +2586,31 @@
//#define MINIMUM_STEPPER_PRE_DIR_DELAY 650
/**
* Minimum stepper driver pulse width (in ns)
* If undefined, these defaults (from Conditionals_adv.h) apply:
* 100 : Minimum for TMC2xxx stepper drivers
* 500 : Minimum for LV8729
* 1000 : Minimum for A4988 and A5984 stepper drivers
* 2000 : Minimum for DRV8825 stepper drivers
* 3000 : Minimum for TB6600 stepper drivers
* 30000 : Minimum for TB6560 stepper drivers
* Minimum stepper driver pulse width (in µs)
* 0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers
* 0 : Minimum 500ns for LV8729, adjusted in stepper.h
* 1 : Minimum for A4988 and A5984 stepper drivers
* 2 : Minimum for DRV8825 stepper drivers
* 3 : Minimum for TB6600 stepper drivers
* 30 : Minimum for TB6560 stepper drivers
*
* Override the default value based on the driver type set in Configuration.h.
*/
#define MINIMUM_STEPPER_PULSE_NS 3500
//#define MINIMUM_STEPPER_PULSE 2
/**
* Maximum stepping rate (in Hz) the stepper driver allows
* If undefined, these defaults (from Conditionals_adv.h) apply:
* If undefined, defaults to 1MHz / (2 * MINIMUM_STEPPER_PULSE)
* 5000000 : Maximum for TMC2xxx stepper drivers
* 1000000 : Maximum for LV8729 stepper driver
* 500000 : Maximum for A4988 stepper driver
* 250000 : Maximum for DRV8825 stepper driver
* 150000 : Maximum for TB6600 stepper driver
* 15000 : Maximum for TB6560 stepper driver
* 500000 : Maximum for A4988 stepper driver
* 250000 : Maximum for DRV8825 stepper driver
* 150000 : Maximum for TB6600 stepper driver
* 15000 : Maximum for TB6560 stepper driver
*
* Override the default value based on the driver type set in Configuration.h.
*/
#define MAXIMUM_STEPPER_RATE 150000
//#define MAXIMUM_STEPPER_RATE 250000
// @section temperature
@@ -2599,16 +2627,20 @@
#if ALL(HAS_MEDIA, DIRECT_STEPPING)
#define BLOCK_BUFFER_SIZE 8
#elif HAS_MEDIA
#define BLOCK_BUFFER_SIZE 32
#define BLOCK_BUFFER_SIZE 16
#else
#define BLOCK_BUFFER_SIZE 32
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif
// @section serial
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
#define BUFSIZE 16
#if ENABLED(SKR12Pro)
#define BUFSIZE 16
#else
#define BUFSIZE 4
#endif
// Transmission to Host Buffer Size
// To save 386 bytes of flash (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
@@ -2699,7 +2731,7 @@
* 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
* 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.
*/
//#define SERIAL_DMA
@@ -2740,7 +2772,9 @@
*
* Note that M207 / M208 / M209 settings are saved to EEPROM.
*/
//#define FWRETRACT
#if ANY(ABL_Bilinear, SKR12Pro)
#define FWRETRACT
#endif
#if ENABLED(FWRETRACT)
#define FWRETRACT_AUTORETRACT // Override slicer retractions
#if ENABLED(FWRETRACT_AUTORETRACT)
@@ -2770,9 +2804,9 @@
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 2 // (mm)
//#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
//#define TOOLCHANGE_NO_RETURN // Never return to previous position on tool-change
#define TOOLCHANGE_NO_RETURN // Never return to previous position on tool-change
#if ENABLED(TOOLCHANGE_NO_RETURN)
//#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change
#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change
#endif
/**
@@ -2801,11 +2835,11 @@
* Retract and prime filament on tool-change to reduce
* ooze and stringing and to get cleaner transitions.
*/
//#define TOOLCHANGE_FILAMENT_SWAP
#define TOOLCHANGE_FILAMENT_SWAP
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
// Load / Unload
#define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length
#define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart. Adjust with LCD or M217 B.
#define TOOLCHANGE_FS_LENGTH 4 // (mm) Load / Unload length
#define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 2 // (mm) Extra length for better restart. Adjust with LCD or M217 B.
#define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading)
#define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down)
@@ -2891,45 +2925,45 @@
#define ADVANCED_PAUSE_FEATURE
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#define PAUSE_PARK_RETRACT_FEEDRATE 60 // (mm/s) Initial retract feedrate.
#define PAUSE_PARK_RETRACT_LENGTH 2 // (mm) Initial retract.
#define PAUSE_PARK_RETRACT_LENGTH 4 // (mm) Initial retract.
// This short retract is done immediately, before parking the nozzle.
#define FILAMENT_CHANGE_UNLOAD_FEEDRATE 10 // (mm/s) Unload filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_UNLOAD_FEEDRATE 41 // (mm/s) Unload filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_UNLOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate.
#define FILAMENT_CHANGE_UNLOAD_LENGTH 100 // (mm) The length of filament for a complete unload.
#define FILAMENT_CHANGE_UNLOAD_LENGTH 70 // (mm) The length of filament for a complete unload.
// For Bowden, the full length of the tube and nozzle.
// For direct drive, the full length of the nozzle.
// Set to 0 for manual unloading.
#define FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE 6 // (mm/s) Slow move when starting load.
#define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 // (mm) Slow length, to allow time to insert material.
// 0 to disable start loading and skip to fast load only
#define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 6 // (mm/s) Load filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 30 // (mm/s) Load filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_FAST_LOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate.
#define FILAMENT_CHANGE_FAST_LOAD_LENGTH 0 // (mm) Load length of filament, from extruder gear to nozzle.
#define FILAMENT_CHANGE_FAST_LOAD_LENGTH 50 // (mm) Load length of filament, from extruder gear to nozzle.
// For Bowden, the full length of the tube and nozzle.
// For direct drive, the full length of the nozzle.
//#define ADVANCED_PAUSE_CONTINUOUS_PURGE // Purge continuously up to the purge length until interrupted.
#define ADVANCED_PAUSE_PURGE_FEEDRATE 3 // (mm/s) Extrude feedrate (after loading). Should be slower than load feedrate.
#define ADVANCED_PAUSE_PURGE_LENGTH 50 // (mm) Length to extrude after loading.
#define ADVANCED_PAUSE_PURGE_LENGTH 20 // (mm) Length to extrude after loading.
// Set to 0 for manual extrusion.
// Filament can be extruded repeatedly from the Filament Change menu
// until extrusion is consistent, and to purge old filament.
#define ADVANCED_PAUSE_RESUME_PRIME 0 // (mm) Extra distance to prime nozzle after returning from park.
//#define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused.
#define ADVANCED_PAUSE_RESUME_PRIME 2 // (mm) Extra distance to prime nozzle after returning from park.
#define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused.
// Filament Unload does a Retract, Delay, and Purge first:
#define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length.
#define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_RETRACT 4 // (mm) Unload initial retract length.
#define FILAMENT_UNLOAD_PURGE_DELAY 2000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.
#define FILAMENT_UNLOAD_PURGE_FEEDRATE 25 // (mm/s) feedrate to purge before unload
#define PAUSE_PARK_NOZZLE_TIMEOUT 45 // (seconds) Time limit before the nozzle is turned off for safety.
#define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed.
#define FILAMENT_CHANGE_ALERT_BEEPS 1 // Number of alert beeps to play when a response is needed.
#define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable for XYZ steppers to stay powered on during filament change.
//#define FILAMENT_CHANGE_RESUME_ON_INSERT // Automatically continue / load filament when runout sensor is triggered again.
//#define PAUSE_REHEAT_FAST_RESUME // Reduce number of waits by not prompting again post-timeout before continuing.
#define PARK_HEAD_ON_PAUSE // Park the nozzle during pause and filament change.
//#define HOME_BEFORE_FILAMENT_CHANGE // If needed, home before parking for filament change
#define HOME_BEFORE_FILAMENT_CHANGE // If needed, home before parking for filament change
#define FILAMENT_LOAD_UNLOAD_GCODES // Add M701/M702 Load/Unload G-codes, plus Load/Unload in the LCD Prepare menu.
#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302)
@@ -2961,7 +2995,7 @@
*/
#if HAS_TRINAMIC_CONFIG
#define HOLD_MULTIPLIER 0.7 // Scales down the holding current from run current
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
/**
* Interpolate microsteps to 256
@@ -2970,10 +3004,10 @@
#define INTERPOLATE true
#if AXIS_IS_TMC_CONFIG(X)
#define X_CURRENT 1200 // (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 sensorless homing
#define X_MICROSTEPS 16 // 0..256
#define X_RSENSE 0.022
#define X_RSENSE 0.11
#define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
//#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis
//#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis
@@ -2990,10 +3024,10 @@
#endif
#if AXIS_IS_TMC_CONFIG(Y)
#define Y_CURRENT 1200
#define Y_CURRENT 800
#define Y_CURRENT_HOME Y_CURRENT
#define Y_MICROSTEPS 16
#define Y_RSENSE 0.022
#define Y_RSENSE 0.11
#define Y_CHAIN_POS -1
//#define Y_INTERPOLATE true
//#define Y_HOLD_MULTIPLIER 0.5
@@ -3110,7 +3144,7 @@
#endif
#if AXIS_IS_TMC_CONFIG(E0)
#define E0_CURRENT 900
#define E0_CURRENT 800
#define E0_MICROSTEPS 16
#define E0_RSENSE 0.11
#define E0_CHAIN_POS -1
@@ -3215,7 +3249,7 @@
* The default SW SPI pins are defined the respective pins files,
* but you can override or define them here.
*/
#define TMC_USE_SW_SPI
//#define TMC_USE_SW_SPI
//#define TMC_SPI_MOSI -1
//#define TMC_SPI_MISO -1
//#define TMC_SPI_SCK -1
@@ -3275,7 +3309,7 @@
* When disabled, Marlin will use spreadCycle stepping mode.
*/
#if HAS_STEALTHCHOP
//#define STEALTHCHOP_XY
#define STEALTHCHOP_XY
#define STEALTHCHOP_Z
#define STEALTHCHOP_I
#define STEALTHCHOP_J
@@ -3283,7 +3317,7 @@
#define STEALTHCHOP_U
#define STEALTHCHOP_V
#define STEALTHCHOP_W
//#define STEALTHCHOP_E
#define STEALTHCHOP_E
#endif
/**
@@ -3301,11 +3335,11 @@
* Define your own with:
* { <off_time[1..15]>, <hysteresis_end[-3..12]>, hysteresis_start[1..8] }
*/
//#define CHOPPER_TIMING CHOPPER_DEFAULT_36V // All axes (override below)
#define CHOPPER_TIMING_X CHOPPER_DEFAULT_36V // For X Axes (override below)
#define CHOPPER_TIMING CHOPPER_DEFAULT_24V // All axes (override below)
//#define CHOPPER_TIMING_X CHOPPER_TIMING // For X Axes (override below)
//#define CHOPPER_TIMING_X2 CHOPPER_TIMING_X
#define CHOPPER_TIMING_Y CHOPPER_DEFAULT_36V // For Y Axes (override below)
#define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y
//#define CHOPPER_TIMING_Y CHOPPER_TIMING // For Y Axes (override below)
//#define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y
//#define CHOPPER_TIMING_Z CHOPPER_TIMING // For Z Axes (override below)
//#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z
//#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z
@@ -3316,7 +3350,7 @@
//#define CHOPPER_TIMING_U CHOPPER_TIMING // For U Axis
//#define CHOPPER_TIMING_V CHOPPER_TIMING // For V Axis
//#define CHOPPER_TIMING_W CHOPPER_TIMING // For W Axis
#define CHOPPER_TIMING_E CHOPPER_DEFAULT_24V // For Extruders (override below)
//#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below)
//#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
//#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E
//#define CHOPPER_TIMING_E3 CHOPPER_TIMING_E
@@ -3343,7 +3377,7 @@
#if ENABLED(MONITOR_DRIVER_STATUS)
#define CURRENT_STEP_DOWN 50 // [mA]
#define REPORT_CURRENT_CHANGE
//#define STOP_ON_ERROR
#define STOP_ON_ERROR
#endif
// @section tmc/hybrid
@@ -3451,7 +3485,7 @@
* Enable M122 debugging command for TMC stepper drivers.
* M122 S0/1 will enable continuous reporting.
*/
#define TMC_DEBUG
//#define TMC_DEBUG
/**
* You can set your own advanced settings by filling in predefined functions.
@@ -3573,7 +3607,10 @@
#if ANY(SPINDLE_FEATURE, LASER_FEATURE)
#define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if SPINDLE_LASER_ENA_PIN is active HIGH
#define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power
#if ENABLED(SKR12Pro)
#define SPINDLE_LASER_ENA_PIN PE4
#endif
//#define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power
#if ENABLED(SPINDLE_LASER_USE_PWM)
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower
#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC)
@@ -3624,8 +3661,8 @@
#define SPINDLE_CHANGE_DIR_STOP // Enable if the spindle should stop before changing spin direction
#define SPINDLE_INVERT_DIR false // Set to "true" if the spin direction is reversed
#define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop
#define SPINDLE_LASER_POWERUP_DELAY 1 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 1 // (ms) Delay to allow the spindle to stop
/**
* M3/M4 Power Equation
@@ -4004,33 +4041,41 @@
// @section custom main menu
// Custom Menu: Main Menu
//#define CUSTOM_MENU_MAIN
#define CUSTOM_MENU_MAIN
#if ENABLED(CUSTOM_MENU_MAIN)
//#define CUSTOM_MENU_MAIN_TITLE "Custom Commands"
#define CUSTOM_MENU_MAIN_SCRIPT_DONE "M117 User Script Done"
//#define CUSTOM_MENU_MAIN_SCRIPT_DONE "M117 User Script Done"
#define CUSTOM_MENU_MAIN_TITLE "Setup"
#define CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK
//#define CUSTOM_MENU_MAIN_SCRIPT_RETURN // Return to status screen after a script
#define CUSTOM_MENU_MAIN_SCRIPT_RETURN // Return to status screen after a script
#define CUSTOM_MENU_MAIN_ONLY_IDLE // Only show custom menu when the machine is idle
#define MAIN_MENU_ITEM_1_DESC "Home & UBL Info"
#define MAIN_MENU_ITEM_1_GCODE "G28\nG29 W"
//#define MAIN_MENU_ITEM_1_CONFIRM // Show a confirmation dialog before this action
#if ENABLED(TREX3)
#define COMMFANNSPEED " "
#else
#define COMMFANNSPEED "M106 S128 \n"
#endif
#define MAIN_MENU_ITEM_2_DESC "Preheat for " PREHEAT_1_LABEL
#define MAIN_MENU_ITEM_2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
//#define MAIN_MENU_ITEM_2_CONFIRM
#define MAIN_MENU_ITEM_1_DESC "Mesh Setup"
#define MAIN_MENU_ITEM_1_CONFIRM
#define MAIN_MENU_ITEM_3_DESC "Prep for Z Adjust"
#if ENABLED(ABL_Bilinear)
#define MAIN_MENU_ITEM_1_GCODE "M502 \n M500 \n M501 \n M190 S75 \n G28 \n G29 \n M500 \n G28 \n M420 S1 \n " COMMFANNSPEED " M109 S225 \n G1 X100 Y 100 \n G1 Z0 \n M77 \n M117 Set Z Offset"
#define MAIN_MENU_ITEM_3_GCODE "M190 S75 \n " COMMFANNSPEED " M104 235 \n G28 \n M420 S1 \n G1 X100 Y 100 \n G1 Z0"
#else
#define MAIN_MENU_ITEM_1_GCODE "M502 \n M500 \n M501 \n M190 S75 \n G28 \n G29 P1 \n G29 S1 \n G29 S0 \n G29 F 10.0 \n G29 A \n M500 \n G28 \n G29 L1 \n " COMMFANNSPEED " M109 S225 \n G1 X150 Y 150 \n G1 Z0 \n M77 \n M117 Set Z Offset"
#define MAIN_MENU_ITEM_3_GCODE "M190 S75 \n " COMMFANNSPEED " M104 235 \n G28 \n G29 L1 \n G1 X100 Y 100 \n G1 Z0"
#endif
//#define MAIN_MENU_ITEM_3_DESC "Preheat for " PREHEAT_2_LABEL
//#define MAIN_MENU_ITEM_3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
//#define MAIN_MENU_ITEM_3_CONFIRM
#define MAIN_MENU_ITEM_4_DESC "Fill Mesh Points"
#define MAIN_MENU_ITEM_4_GCODE "G29 P3 \n G29 P3 \n G29 P3 \n G29 T"
//#define MAIN_MENU_ITEM_4_DESC "Heat Bed/Home/Level"
//#define MAIN_MENU_ITEM_4_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
//#define MAIN_MENU_ITEM_4_CONFIRM
#define MAIN_MENU_ITEM_2_DESC "PID Bed"
#define MAIN_MENU_ITEM_2_GCODE "M303 C4 S75 E-1 U \n M500 \n M117 PID Tune Done"
#define MAIN_MENU_ITEM_2_CONFIRM
//#define MAIN_MENU_ITEM_5_DESC "Home & Info"
//#define MAIN_MENU_ITEM_5_GCODE "G28\nM503"
//#define MAIN_MENU_ITEM_5_CONFIRM
#define MAIN_MENU_ITEM_5_DESC "Run Mesh Validation"
#define MAIN_MENU_ITEM_5_GCODE "G26"
#define MAIN_MENU_ITEM_5_CONFIRM
#endif
// @section custom config menu
@@ -4080,22 +4125,6 @@
#define BUTTON1_GCODE "G28"
#define BUTTON1_DESC "Homing" // Optional string to set the LCD status
#endif
//#define BUTTON2_PIN -1
#if PIN_EXISTS(BUTTON2)
#define BUTTON2_HIT_STATE LOW
#define BUTTON2_WHEN_PRINTING false
#define BUTTON2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
#define BUTTON2_DESC "Preheat for " PREHEAT_1_LABEL
#endif
//#define BUTTON3_PIN -1
#if PIN_EXISTS(BUTTON3)
#define BUTTON3_HIT_STATE LOW
#define BUTTON3_WHEN_PRINTING false
#define BUTTON3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
#define BUTTON3_DESC "Preheat for " PREHEAT_2_LABEL
#endif
#endif
// @section host
@@ -4262,8 +4291,7 @@
/**
* Instant freeze / unfreeze functionality
* Potentially useful for rapid stop that allows being resumed. Halts stepper movement.
* Note this does NOT pause spindles, lasers, fans, heaters or any other auxiliary device.
* Potentially useful for emergency stop that allows being resumed.
* @section interface
*/
//#define FREEZE_FEATURE
@@ -4491,7 +4519,7 @@
//
// M42 - Set pin states
//
#define DIRECT_PIN_CONTROL
//#define DIRECT_PIN_CONTROL
//
// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
+6 -6
View File
@@ -28,25 +28,25 @@
/**
* Marlin release version identifier
*/
//#define SHORT_BUILD_VERSION "bugfix-2.1.x"
#define SHORT_BUILD_VERSION "2.1.x-TR1"
/**
* Verbose version identifier which should contain a reference to the location
* from where the binary was downloaded or the source code was compiled.
*/
//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " TM3D"
/**
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2024-07-07"
//#define STRING_DISTRIBUTION_DATE "2024-04-11"
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
*/
//#define MACHINE_NAME "3D Printer"
#define MACHINE_NAME "TM3D Trex"
/**
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
@@ -54,7 +54,7 @@
* has a distinct Github fork— the Source Code URL should just be the main
* Marlin repository.
*/
//#define SOURCE_CODE_URL "github.com/MarlinFirmware/Marlin"
#define SOURCE_CODE_URL "https://github.com/InsanityAutomation/Marlin/tree/TM_Trex2+_2.0.x"
/**
* Default generic printer UUID.
@@ -65,7 +65,7 @@
* The WEBSITE_URL is the location where users can get more information such as
* documentation about a specific Marlin release.
*/
//#define WEBSITE_URL "marlinfw.org"
#define WEBSITE_URL "tinymachines3d.com"
/**
* Set the vendor info the serial USB interface, if changable
+93
View File
@@ -0,0 +1,93 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Custom Bitmap for splashscreen
*
* You may use one of the following tools to generate the C++ bitmap array from
* a black and white image:
*
* - http://www.marlinfw.org/tools/u8glib/converter.html
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
*/
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
#define CUSTOM_BOOTSCREEN_INVERTED
const unsigned char custom_start_bmp[] PROGMEM = {
B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,
B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111,
B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111,
B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111,
B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111,
B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111,
B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111,
B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111,
B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111,
B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111,
B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111,
B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111,
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111,
B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111,
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111,
B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111,
B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111,
B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011,
B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011,
B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011,
B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011,
B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111,
B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111,
B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111
};
+74
View File
@@ -0,0 +1,74 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Custom Status Screen bitmap
*
* Place this file in the root with your configuration files
* and enable CUSTOM_STATUS_SCREEN_IMAGE in Configuration.h.
*
* Use the Marlin Bitmap Converter to make your own:
* http://marlinfw.org/tools/u8glib/converter.html
*/
//
// Status Screen Logo bitmap
//
#define STATUS_LOGO_Y 3
#define STATUS_LOGO_WIDTH 24
const unsigned char status_logo_bmp[] PROGMEM = {
B11111111,B11111111,B11111111,
B10000000,B00000000,B00000001,
B10001110,B00000000,B11100001,
B10011111,B00000001,B11110001,
B10010011,B10000001,B00111001,
B10011111,B10000001,B11111001,
B10011111,B10000001,B11111001,
B10011111,B10111001,B11111001,
B10001111,B00101000,B11110001,
B10000000,B00111000,B00000001,
B10000000,B00000000,B00000001,
B10011111,B11111111,B11111001,
B10010001,B01110100,B10011001,
B10011011,B00000110,B10101001,
B10011011,B01010100,B10101001,
B10011011,B01010110,B10101001,
B10011011,B01010100,B10011001,
B10011111,B11111111,B11111001,
B11111111,B11111111,B11111111
};
//
// Use default bitmaps
//
#define STATUS_HOTEND_ANIM
#define STATUS_BED_ANIM
#if HOTENDS < 2
#define STATUS_LOGO_X 8
#define STATUS_HEATERS_X 40
#define STATUS_BED_X 72
#else
#define STATUS_LOGO_X 0
#define STATUS_HEATERS_X 32
#define STATUS_BED_X 80
#endif
+2 -2
View File
@@ -141,7 +141,7 @@ typedef Servo hal_servo_t;
#error "LCD_SERIAL_PORT must be from 0 to 3."
#endif
#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()
#endif
#endif
@@ -159,7 +159,7 @@ typedef Servo hal_servo_t;
#define GET_PIN_MAP_INDEX(pin) pin
#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__
#define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
+1 -1
View File
@@ -629,7 +629,7 @@ MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser);
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#if HAS_DGUS_LCD
template<typename Cfg>
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.
+1 -1
View File
@@ -205,7 +205,7 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#if HAS_DGUS_LCD
static ring_buffer_pos_t get_tx_buffer_free();
#endif
-8
View File
@@ -345,14 +345,6 @@ void setup_endstop_interrupts() {
pciSetup(Z_MIN_PROBE_PIN);
#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.
}
+1 -1
View File
@@ -150,7 +150,7 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
else {
if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2
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_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
* 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
*
* Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA
* AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg
*/
#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
* 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"
+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
* 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"
+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
* 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
@@ -27,6 +27,9 @@
* 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
* 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"
@@ -120,7 +120,7 @@ void u8g_spiSend_sw_AVR_mode_3(uint8_t val) {
U8G_ATOMIC_END();
}
#if U8G_SPI_USE_MODE_3
#if ENABLED(FYSETC_MINI_12864)
#define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_3
#else
#define SPISEND_SW_AVR u8g_spiSend_sw_AVR_mode_0
@@ -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;
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 (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
#if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
}
-1
View File
@@ -64,7 +64,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_PIN));
TERN_(USE_CALIBRATION, _ATTACH(CALIBRATION_PIN));
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
+1 -1
View File
@@ -61,7 +61,7 @@
#else
#define G2_PWM_Z 0
#endif
#if HAS_MOTOR_CURRENT_PWM_E
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
#define G2_PWM_E 1
#else
#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
* 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)
#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 DISABLED(SOFTWARE_SPI) && ENABLED(TMC_USE_SW_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."
#endif
#if ENABLED(SOFTWARE_SPI) && DISABLED(TMC_USE_SW_SPI)
#if ENABLED(TMC_USE_SW_SPI)
#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."
#endif
#elif ENABLED(SOFTWARE_SPI)
#error "DUE software SPI is required but is incompatible with TMC2130 hardware SPI. Enable TMC_USE_SW_SPI to fix."
#endif
#undef _IS_HW_SPI
#endif
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
+1 -1
View File
@@ -24,7 +24,7 @@
/**
* 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
@@ -66,7 +66,7 @@
#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
#else
#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;
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 (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
#if ENABLED(FYSETC_MINI_12864) // LCD SPI is running mode 3 while SD card is running mode 0
if (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1); //set SCK to mode 3 idle state before CS goes active
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, LOW);
}
else {
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, HIGH);
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); // Set SCK to mode 0 idle state after CS goes inactive
u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); //set SCK to mode 0 idle state after CS goes inactive
}
#else
u8g_SetPILevel_DUE(u8g, U8G_PI_CS, !arg_val);
+1 -1
View File
@@ -11,7 +11,7 @@ if pioutil.is_pio_build():
if current_OS == 'Windows':
env = pioutil.env
Import("env")
# Use bossac.exe on Windows
env.Replace(
+16 -14
View File
@@ -18,32 +18,32 @@ extern "C" {
void sd_mmc_spi_mem_init() {
}
inline bool media_ready() {
return IS_SD_INSERTED() && !IS_SD_PRINTING() && !IS_SD_FILE_OPEN() && card.isMounted();
}
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() {
#ifdef DISABLE_DUE_SD_MMC
return CTRL_NO_PRESENT;
#endif
if (!media_ready()) return CTRL_NO_PRESENT;
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
return CTRL_GOOD;
}
// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
if (!media_ready()) 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;
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
/**
* \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
return CTRL_NO_PRESENT;
#endif
if (!media_ready()) return CTRL_NO_PRESENT;
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#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
return CTRL_NO_PRESENT;
#endif
if (!media_ready()) return CTRL_NO_PRESENT;
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return CTRL_NO_PRESENT;
#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.
//!/
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.
@@ -87,7 +87,7 @@ void sd_mmc_spi_mem_init();
//! Media not present -> CTRL_NO_PRESENT
//! 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.
@@ -98,7 +98,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready();
//! Media ready -> CTRL_GOOD
//! 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
*
@@ -109,7 +109,7 @@ Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
*
* \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.
@@ -120,14 +120,14 @@ bool sd_mmc_spi_unload(bool unload);
//!
//! @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.
//!
//! @return false -> The memory isn't removed
//!
bool sd_mmc_spi_removal();
extern bool sd_mmc_spi_removal(void);
//---- ACCESS DATA FUNCTIONS ----
@@ -147,7 +147,7 @@ bool sd_mmc_spi_removal();
//! It is ready -> CTRL_GOOD
//! 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
//!
@@ -161,7 +161,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
//! It is ready -> CTRL_GOOD
//! 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
@@ -59,7 +59,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_PIN));
TERN_(USE_CALIBRATION, _ATTACH(CALIBRATION_PIN));
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
+1 -20
View File
@@ -142,31 +142,12 @@
// ADC
//
#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_INDEX(pin) pin
#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
//
+2 -33
View File
@@ -123,11 +123,6 @@ void MarlinHAL::init() {
// Register 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() {}
@@ -152,31 +147,7 @@ void MarlinHAL::delay_ms(const int ms) {
delay(ms);
}
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
}
void MarlinHAL::idletask() {}
uint8_t MarlinHAL::get_reset_source() {
// Query reset cause from RMU
@@ -232,9 +203,7 @@ int MarlinHAL::freeMemory() {
return &top - _sbrk(0);
}
void MarlinHAL::adc_init() {
analogReadResolution(HAL_ADC_RESOLUTION);
}
void MarlinHAL::adc_init() {}
void MarlinHAL::adc_enable(const pin_t pin) {
#if TEMP_SENSOR_SOC
+3 -23
View File
@@ -46,34 +46,14 @@ constexpr bool serial_handles_emergency(int port) {
//
// Define serial ports
//
// serial port where RX and TX use IRQs
#define DEFINE_IRQ_SERIAL_MARLIN(name, n) \
#define DEFINE_HWSERIAL_MARLIN(name, n) \
MSerialT name(serial_handles_emergency(n), \
&USART##n##_config, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN);
// serial port where RX uses DMA and TX uses IRQs
// all serial ports use DMA1
// 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
DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
//
// Serial port assertions
+8 -38
View File
@@ -25,42 +25,17 @@
#include <drivers/usart/Usart.h>
// Optionally set uart IRQ priority to reduce overflow errors
//#define UART_RX_IRQ_PRIO 1
//#define UART_TX_IRQ_PRIO 1
//#define UART_RX_DMA_IRQ_PRIO 1
// #define UART_IRQ_PRIO 1
struct MarlinSerial : public Usart {
MarlinSerial(
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
}
MarlinSerial(struct usart_config_t *usart_device, gpio_pin_t tx_pin, gpio_pin_t rx_pin) : Usart(usart_device, tx_pin, rx_pin) {}
#if defined(UART_RX_IRQ_PRIO) || defined(UART_TX_IRQ_PRIO) || defined(UART_RX_DMA_IRQ_PRIO)
#ifdef UART_IRQ_PRIO
void setPriority() {
#if defined(UART_RX_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_RX_IRQ_PRIO);
#endif
#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
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_IRQ_PRIO);
}
void begin(uint32_t baud) {
@@ -72,12 +47,7 @@ struct MarlinSerial : public Usart {
Usart::begin(baud, config);
setPriority();
}
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
#endif
};
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(CALIBRATION);
#undef SETUP
}
// Ensure 1 - 10 IRQs are registered
// 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
#error "Too many endstop interrupts! HC32F460 only supports 10 endstop interrupts."
#elif ENDSTOPS_INTERRUPTS_COUNT == 0
-29
View File
@@ -20,20 +20,6 @@
*
*/
#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
#error "BOARD_XTAL_FREQUENCY is required for HC32F460."
@@ -88,18 +74,3 @@
#error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN."
#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
// USART_RX_DMA_SUPPORT does not implement core_hook_usart_rx_irq, which is required for the emergency parser
#if ENABLED(EMERGENCY_PARSER)
#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
+17 -26
View File
@@ -54,7 +54,7 @@
fn \
}
stc_sd_handle_t *handle = nullptr;
stc_sd_handle_t *handle;
bool SDIO_Init() {
// Configure SDIO pins
@@ -66,45 +66,36 @@ bool SDIO_Init() {
GPIO_SetFunc(BOARD_SDIO_CMD, 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
stc_sdcard_dma_init_t *dmaConf = new stc_sdcard_dma_init_t;
dmaConf->DMAx = SDIO_DMA_PERIPHERAL;
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
handle = new stc_sd_handle_t;
handle->SDIOCx = SDIO_PERIPHERAL;
handle->enDevMode = SdCardDmaMode;
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
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);
return rc == Ok;
}
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(dst != nullptr, "SDIO_ReadBlock dst is NULL", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(dst != NULL, "SDIO_ReadBlock dst is NULL");
WITH_RETRY(SDIO_READ_RETRIES, {
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) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(src != nullptr, "SDIO_WriteBlock src is NULL", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(src != NULL, "SDIO_WriteBlock src is NULL");
WITH_RETRY(SDIO_WRITE_RETRIES, {
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() {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
return bool(handle->stcCardStatus.READY_FOR_DATA);
}
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
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
// sysclk is now configured according to F_CPU (i.e., 200MHz PLL output)
constexpr uint32_t sysclock = F_CPU;
// Setup clock divisors for sysclk = 200 MHz
// 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)
constexpr stc_clk_sysclk_cfg_t sysClkConf = {
stc_clk_sysclk_cfg_t sysClkConf = {
.enHclkDiv = ClkSysclkDiv1, // HCLK = 200 MHz (CPU)
.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))
.enPclk2Div = ClkSysclkDiv8, // PCLK2 = 25 MHz (ADC)
.enPclk3Div = ClkSysclkDiv8, // PCLK3 = 25 MHz (I2C, WDT)
.enPclk2Div = ClkSysclkDiv4, // PCLK2 = 50 MHz (ADC)
.enPclk3Div = ClkSysclkDiv4, // PCLK3 = 50 MHz (I2C, WDT)
.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);
// 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
CLK_SetSysClkSource(CLKSysSrcMPLL);
// 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
+27 -31
View File
@@ -38,48 +38,44 @@ extern Timer0 step_timer;
// Timer Configurations
//
/**
* HAL_TIMER_RATE must be known at compile time since it's used to calculate
* STEPPER_TIMER_RATE, which is used in 'constexpr' calculations.
* On the HC32F460 the timer rate depends on PCLK1, which is derived from the
* system clock configured at runtime. As a workaround, we use the existing
* 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'.
*
* If you face issues with this assumption, please double-check with the values
* printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
*
* 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
// TODO: some calculations (step irq min_step_rate) require the timer rate to be known at compile time
// this is not possible with the HC32F460, as the timer rate depends on PCLK1
// as a workaround, PCLK1 = 50MHz is assumed (check with clock dump in MarlinHAL::init())
#define HAL_TIMER_RATE 50000000 // 50MHz
// #define HAL_TIMER_RATE TIMER0_BASE_FREQUENCY
// 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
#undef CYCLES_PER_MICROSECOND
#define CYCLES_PER_MICROSECOND (HAL_TIMER_RATE / 1000000UL)
// Temperature timer
#define TEMP_TIMER_NUM (&temp_timer)
#define TEMP_TIMER_PRIORITY DDL_IRQ_PRIORITY_02
#define TEMP_TIMER_PRESCALE 16UL // 12.5MHz
#define TEMP_TIMER_RATE 1000 // 1kHz
#define TEMP_TIMER_FREQUENCY TEMP_TIMER_RATE // 1kHz also
#define TEMP_TIMER_NUM (&temp_timer)
#define TEMP_TIMER_PRIORITY DDL_IRQ_PRIORITY_02
#define TEMP_TIMER_PRESCALE 16ul
#define TEMP_TIMER_RATE 1000 // 1kHz
#define TEMP_TIMER_FREQUENCY TEMP_TIMER_RATE // Alias for Marlin
// Stepper timer
#define STEP_TIMER_NUM (&step_timer)
#define STEP_TIMER_PRIORITY DDL_IRQ_PRIORITY_00 // Top priority, nothing else uses it
#define STEPPER_TIMER_PRESCALE 16UL // 12.5MHz
#define STEP_TIMER_NUM (&step_timer)
#define STEP_TIMER_PRIORITY DDL_IRQ_PRIORITY_01
#define STEPPER_TIMER_PRESCALE 16ul
#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // 50MHz / 16 = 3.125MHz
#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000UL) // Integer 3
// TODO: STEPPER_TIMER_RATE seems to work fine like this, but requires further testing...
#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)
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
//
// Channel aliases
//
#define MF_TIMER_TEMP TEMP_TIMER_NUM
#define MF_TIMER_STEP STEP_TIMER_NUM
#define MF_TIMER_PULSE PULSE_TIMER_NUM
#define MF_TIMER_TEMP TEMP_TIMER_NUM
#define MF_TIMER_STEP STEP_TIMER_NUM
#define MF_TIMER_PULSE PULSE_TIMER_NUM
//
// 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) {
#if U8G_SPI_USE_MODE_3
#if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed);
#else
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;
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
#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
// 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);
}
else {
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
WRITE(DOGLCD_CS, !arg_val);
+1 -4
View File
@@ -37,10 +37,7 @@ Timer::Timer() {
}
Timer::~Timer() {
if (timerid != 0) {
timer_delete(timerid);
timerid = 0;
}
timer_delete(timerid);
}
void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
-2
View File
@@ -21,7 +21,6 @@
*/
#ifdef __PLAT_LINUX__
#ifndef UNIT_TEST
//#define GPIO_LOGGING // Full GPIO and Positional Logging
@@ -136,5 +135,4 @@ int main() {
read_serial.join();
}
#endif // UNIT_TEST
#endif // __PLAT_LINUX__
+6
View File
@@ -28,6 +28,12 @@
// spiBeginTransaction.
#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
#ifndef SD_SCK_PIN
#define SD_SCK_PIN 50
+2 -2
View File
@@ -100,7 +100,7 @@ extern DefaultSerial1 USBSerial;
#else
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
#endif
#endif
@@ -159,7 +159,7 @@ constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) {
// Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
// 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
@@ -146,12 +146,6 @@ void setup_endstop_interrupts() {
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#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 !LPC1768_PIN_INTERRUPT_M(I_MAX_PIN)
#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*/) {
if (!LPC176x::pin_is_valid(pin)) return;
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(pin, duty);
}
if (LPC176x::pwm_attach_pin(pin))
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
}
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)
/// toggle a pin
#define _TOGGLE(IO) LPC176x::gpio_toggle(IO)
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
/// set pin as input
#define _SET_INPUT(IO) SET_DIR_INPUT(IO)
+6 -7
View File
@@ -28,13 +28,12 @@
// spiBeginTransaction.
#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
/** onboard SD card */
//#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 */
#ifndef SD_SCK_PIN
#define SD_SCK_PIN P0_15
#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 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);
#else
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;
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 (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
#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
// 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_CS, LOW);
}
else {
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
u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
@@ -13,9 +13,9 @@ if pioutil.is_pio_build():
target_drive = "REARM"
import platform
current_OS = platform.system()
env = pioutil.env
current_OS = platform.system()
Import("env")
def print_error(e):
print('\nUnable to find destination disk (%s)\n' \
-125
View File
@@ -1,125 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"
#include "../../../gcode/parser.h"
DefaultSerial1 USBSerial(false, MCDCSerial0);
uint32_t MarlinHAL::adc_result = 0;
// U8glib required functions
extern "C" {
void u8g_xMicroDelay(uint16_t val) { DELAY_US(val); }
void u8g_MicroDelay() { u8g_xMicroDelay(1); }
void u8g_10MicroDelay() { u8g_xMicroDelay(10); }
void u8g_Delay(uint16_t val) { delay(val); }
}
// return free heap space
int freeMemory() {
char stack_end;
void *heap_start = malloc(sizeof(uint32_t));
if (heap_start == 0) return 0;
uint32_t result = (uint32_t)&stack_end - (uint32_t)heap_start;
free(heap_start);
return result;
}
void MarlinHAL::reboot() { MCUCore::nvic_system_reset(); }
uint8_t MarlinHAL::get_reset_source() {
#if ENABLED(USE_WATCHDOG)
if (watchdog_timed_out()) return RST_WATCHDOG;
#endif
return RST_POWER_ON;
}
void MarlinHAL::clear_reset_source() { watchdog_clear_timeout_flag(); }
void flashFirmware(const int16_t) {
delay(500); // Give OS time to disconnect
//USB_Connect(false); // USB clear connection
delay(1000); // Give OS time to notice
hal.reboot();
}
#if ENABLED(USE_WATCHDOG)
#define WDT_TIMEOUT TERN(WATCHDOG_DURATION_8S, 8.0f, 4.0f) // 4 or 8 second timeout
void MarlinHAL::watchdog_init() {
#if ENABLED(WATCHDOG_RESET_MANUAL)
// We enable the watchdog timer, but only for the interrupt.
// Configure WDT to only trigger an interrupt
// Disable WDT interrupt (just in case, to avoid triggering it!)
NVIC_DisableIRQ(WDT_IRQn);
// We NEED memory barriers to ensure Interrupts are actually disabled!
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
__DSB();
__ISB();
// WDT defaults to trigger an interrupt
// Configure and enable WDT interrupt.
NVIC_ClearPendingIRQ(WDT_IRQn);
NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups
NVIC_EnableIRQ(WDT_IRQn);
#else
MCUI::watchdog_set_timeout_triggers_reset();
#endif
MCUI::watchdog_set_timeout_in_seconds(WDT_TIMEOUT);
MCUI::watchdog_enable();
}
void MarlinHAL::watchdog_refresh() {
MCUI::watchdog_feed();
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
static millis_t next_flash = millis();
if (ELAPSED(millis(), next_flash)) {
next_flash = millis() + 200;
TOGGLE(LED_PIN); // heartbeat indicator
}
#endif
}
// Timeout state
bool MarlinHAL::watchdog_timed_out() { return MCUI::watchdog_has_triggered(); }
void MarlinHAL::watchdog_clear_timeout_flag() { MCUI::watchdog_clear_timeout_flag(); }
#endif // USE_WATCHDOG
// For M42/M43, scan command line for pin code
// return index into pin map array if found and the pin is valid.
// return dval if not found or not a valid pin.
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2;
return ind > -1 ? ind : dval;
}
#endif // TARGET_LPC4078
-276
View File
@@ -1,276 +0,0 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* HAL_LPC1768/HAL.h
* Hardware Abstraction Layer for NXP LPC1768
*/
#define CPU_32_BIT
#include <stdint.h>
#include <stdarg.h>
#include <algorithm>
#include "../shared/Marduino.h"
#include "../shared/Delay.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "fastio.h"
#include "MarlinSerial.h"
#include <mcu_interface.h>
// ------------------------
// Serial ports
// ------------------------
typedef ForwardSerial1Class< decltype(MCDCSerial0) > DefaultSerial1;
extern DefaultSerial1 USBSerial;
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
#if SERIAL_PORT == -1
#define MYSERIAL1 USBSerial
#elif WITHIN(SERIAL_PORT, 0, 3)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else
#error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1
#define MYSERIAL2 USBSerial
#elif WITHIN(SERIAL_PORT_2, 0, 3)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif
#ifdef SERIAL_PORT_3
#if SERIAL_PORT_3 == -1
#define MYSERIAL3 USBSerial
#elif WITHIN(SERIAL_PORT_3, 0, 3)
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
#else
#error "SERIAL_PORT_3 must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL USBSerial
#elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL USBSerial
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#else
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.available()
#endif
#endif
//
// Interrupts
//
#define CRITICAL_SECTION_START() const bool irqon = !MCUCore::primask(); MCUCore::nvic_interrupts_disable()
#define CRITICAL_SECTION_END() if (irqon) MCUCore::nvic_interrupts_enable()
#define cli() noInterrupts()
#define sei() interrupts()
//
// ADC
//
#define ADC_MEDIAN_FILTER_SIZE (23) // Higher values increase step delay (phase shift),
// (ADC_MEDIAN_FILTER_SIZE + 1) / 2 sample step delay (12 samples @ 500Hz: 24ms phase shift)
// Memory usage per ADC channel (bytes): (6 * ADC_MEDIAN_FILTER_SIZE) + 16
// 8 * ((6 * 23) + 16 ) = 1232 Bytes for 8 channels
#define ADC_LOWPASS_K_VALUE (2) // Higher values increase rise time
// Rise time sample delays for 100% signal convergence on full range step
// (1 : 13, 2 : 32, 3 : 67, 4 : 139, 5 : 281, 6 : 565, 7 : 1135, 8 : 2273)
// K = 6, 565 samples, 500Hz sample rate, 1.13s convergence on full range step
// Memory usage per ADC channel (bytes): 4 (32 Bytes for 8 channels)
#define HAL_ADC_VREF 3.3 // ADC voltage reference
#define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t
#define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL
//
// Pin Mapping for M42, M43, M226
//
// Test whether the pin is valid
constexpr bool VALID_PIN(const pin_t pin) {
return MCUI::pin_is_valid(pin);
}
// Get the analog index for a digital pin
constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t pin) {
return (MCUI::pin_is_valid(pin) && MCUI::pin_has_adc(pin)) ? pin : -1;
}
//
// Misc. Functions
//
#ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) (p)
#endif
// Return the index of a pin number
constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) {
return MCUI::pin_index(pin);
}
// Get the pin number at the given index
constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) {
return MCUI::pin_index(index);
}
// Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
// P0.6 thru P0.9 are for the onboard SD card
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09,
// ------------------------
// Defines
// ------------------------
void flashFirmware(const int16_t);
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
// Default graphical display delays
#define CPU_ST7920_DELAY_1 600
#define CPU_ST7920_DELAY_2 750
#define CPU_ST7920_DELAY_3 750
// ------------------------
// Free Memory Accessor
// ------------------------
#pragma GCC diagnostic push
#if GCC_VERSION <= 50000
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
int freeMemory();
#pragma GCC diagnostic pop
// ------------------------
// MarlinHAL Class
// ------------------------
class MarlinHAL {
public:
// Earliest possible init, before setup()
MarlinHAL() {}
static void init(); // Called early in setup()
static void init_board() {} // Called less early in setup()
static void reboot(); // Restart the firmware from 0x0
// Interrupts
static bool isr_state() { return MCUCore::primask(); }
static void isr_on() { MCUCore::nvic_interrupts_enable(); }
static void isr_off() { MCUCore::nvic_interrupts_disable(); }
static void delay_ms(const int ms) { DELAY_US(ms * 1000); }
// Watchdog
static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {});
static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {});
static bool watchdog_timed_out() IF_DISABLED(USE_WATCHDOG, { return false; });
static void watchdog_clear_timeout_flag() IF_DISABLED(USE_WATCHDOG, {});
// Tasks, called from idle()
static void idletask();
// Reset
static uint8_t get_reset_source();
static void clear_reset_source();
// Free SRAM
static int freeMemory() { return ::freeMemory(); }
//
// ADC Methods
//
using FilteredADC = MCUI::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
// Called by Temperature::init once at startup
static void adc_init() {
// Turn on and initialise ADC in burst mode
MCUI::adc_hardware.init();
MCUI::adc_hardware.burst_start();
}
// Called by Temperature::init for each sensor at startup
static void adc_enable(const pin_t pin) {
FilteredADC::enable_channel(pin);
}
// Begin ADC sampling on the given pin. Called from Temperature::isr!
static uint32_t adc_result;
static void adc_start(const pin_t pin) {
adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
}
// Is the ADC ready for reading?
static bool adc_ready() { return true; }
// The current value of the ADC register
static uint16_t adc_value() { return uint16_t(adc_result); }
/**
* Set the PWM duty cycle for the pin to the given value.
* Optionally invert the duty cycle [default = false]
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
*/
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
/**
* Set the frequency of the timer corresponding to the provided pin
* All Hardware PWM pins will run at the same frequency and
* All Software PWM pins will run at the same frequency
*/
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
};
-376
View File
@@ -1,376 +0,0 @@
// /**
// * Marlin 3D Printer Firmware
// * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
// *
// * Based on Sprinter and grbl.
// * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see <https://www.gnu.org/licenses/>.
// *
// */
// /**
// * Software SPI functions originally from Arduino Sd2Card Library
// * Copyright (c) 2009 by William Greiman
// */
// /**
// * For TARGET_LPC4078
// */
// /**
// * Hardware SPI and Software SPI implementations are included in this file.
// * The hardware SPI runs faster and has higher throughput but is not compatible
// * with some LCD interfaces/adapters.
// *
// * Control of the slave select pin(s) is handled by the calling routines.
// *
// * Some of the LCD interfaces/adapters result in the LCD SPI and the SD card
// * SPI sharing pins. The SCK, MOSI & MISO pins can NOT be set/cleared with
// * WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
// * active. If any of these pins are shared then the software SPI must be used.
// *
// * A more sophisticated hardware SPI can be found at the following link.
// * This implementation has not been fully debugged.
// * https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
// */
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
#include <SPI.h>
// Hardware SPI and SPIClass
#include "../shared/HAL_SPI.h"
#define LPC_SOFTWARE_SPI
// ------------------------
// Public functions
// ------------------------
#if ENABLED(LPC_SOFTWARE_SPI)
#include "SoftwareSPI.h"
// Software SPI
static uint8_t SPI_speed = SPI_FULL_SPEED;
static uint8_t spiTransfer(uint8_t b) {
return swSpiTransfer(b, SPI_speed, SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN);
}
void spiBegin() {
swSpiBegin(SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN);
}
void spiInit(uint8_t spiRate) {
SPI_speed = swSpiInit(spiRate, SD_SCK_PIN, SD_MOSI_PIN);
}
uint8_t spiRec() { return spiTransfer(0xFF); }
void spiRead(uint8_t*buf, uint16_t nbyte) {
for (int i = 0; i < nbyte; i++)
buf[i] = spiTransfer(0xFF);
}
void spiSend(uint8_t b) { (void)spiTransfer(b); }
void spiSend(const uint8_t *buf, size_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++)
(void)spiTransfer(buf[i]);
}
void spiSendBlock(uint8_t token, const uint8_t *buf) {
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
#else
#ifdef SD_SPI_SPEED
#define INIT_SPI_SPEED SD_SPI_SPEED
#else
#define INIT_SPI_SPEED SPI_FULL_SPEED
#endif
void spiBegin() { spiInit(INIT_SPI_SPEED); } // Set up SCK, MOSI & MISO pins for SSP0
void spiInit(uint8_t spiRate) {
#if SD_MISO_PIN == BOARD_SPI1_MISO_PIN
SPI.setModule(1);
#elif SD_MISO_PIN == BOARD_SPI2_MISO_PIN
SPI.setModule(2);
#endif
SPI.setDataSize(DATA_SIZE_8BIT);
SPI.setDataMode(SPI_MODE0);
SPI.setClock(SPISettings::spiRate2Clock(spiRate));
SPI.begin();
}
static uint8_t doio(uint8_t b) {
return SPI.transfer(b & 0x00FF) & 0x00FF;
}
void spiSend(uint8_t b) { doio(b); }
void spiSend(const uint8_t *buf, size_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++) doio(buf[i]);
}
void spiSend(uint32_t chan, byte b) {}
void spiSend(uint32_t chan, const uint8_t *buf, size_t nbyte) {}
// Read single byte from SPI
uint8_t spiRec() { return doio(0xFF); }
uint8_t spiRec(uint32_t chan) { return 0; }
// Read from SPI into buffer
void spiRead(uint8_t *buf, uint16_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF);
}
uint8_t spiTransfer(uint8_t b) { return doio(b); }
// Write from buffer to SPI
void spiSendBlock(uint8_t token, const uint8_t *buf) {
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
// Begin SPI transaction, set clock, bit order, data mode
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
// TODO: Implement this method
}
#endif // LPC_SOFTWARE_SPI
// /**
// * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
// */
static inline void waitSpiTxEnd(void *spi_d) {
// while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1
// while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
}
// // Retain the pin init state of the SPI, to avoid init more than once,
// // even if more instances of SPIClass exist
static bool spiInitialised[BOARD_NR_SPI] = {};
SPIClass::SPIClass(uint8_t device) {
// // Init things specific to each SPI device
// // clock divider setup is a bit of hack, and needs to be improved at a later date.
#if BOARD_NR_SPI >= 1
_settings[0].device_id = 0;
_settings[0].m_config.pin_miso = BOARD_SPI1_MISO_PIN;
_settings[0].m_config.pin_mosi = BOARD_SPI1_MOSI_PIN;
_settings[0].m_config.pin_sck = BOARD_SPI1_SCK_PIN;
_settings[0].m_config.pin_ssel = BOARD_SPI1_NSS_PIN;
_settings[0].m_config.frequency = 100000;
_settings[0].m_config.data_bits = 8;
_settings[0].m_config.mode = 0;
_settings[0].m_config.format = MCUI::SSP::Config::Format::SPI;
// _settings[0].dataMode = SPI_MODE0;
// _settings[0].dataSize = DATA_SIZE_8BIT;
// _settings[0].clock = SPI_CLOCK_MAX;
// //_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
#endif
#if BOARD_NR_SPI >= 2
_settings[1].device_id = 2;
_settings[1].m_config.pin_miso = BOARD_SPI2_MISO_PIN;
_settings[1].m_config.pin_mosi = BOARD_SPI2_MOSI_PIN;
_settings[1].m_config.pin_sck = BOARD_SPI2_SCK_PIN;
_settings[1].m_config.pin_ssel = BOARD_SPI2_NSS_PIN;
// _settings[1].dataMode = SPI_MODE0;
// _settings[1].dataSize = DATA_SIZE_8BIT;
// _settings[1].clock = SPI_CLOCK_MAX;
// //_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
#endif
#if BOARD_NR_SPI >= 3
_settings[2].device_id = 1;
_settings[2].m_config.pin_miso = BOARD_SPI3_MISO_PIN;
_settings[2].m_config.pin_mosi = BOARD_SPI3_MOSI_PIN;
_settings[2].m_config.pin_sck = BOARD_SPI3_SCK_PIN;
_settings[2].m_config.pin_ssel = BOARD_SPI3_NSS_PIN;
// _settings[1].dataMode = SPI_MODE0;
// _settings[1].dataSize = DATA_SIZE_8BIT;
// _settings[1].clock = SPI_CLOCK_MAX;
// //_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
#endif
setModule(device);
// // Init the GPDMA controller
// // TODO: call once in the constructor? or each time?
// GPDMA_Init();
}
SPIClass::SPIClass(pin_t mosi, pin_t miso, pin_t sclk, pin_t ssel) {
#if BOARD_NR_SPI >= 1
if (mosi == BOARD_SPI1_MOSI_PIN) SPIClass(1);
#endif
#if BOARD_NR_SPI >= 2
if (mosi == BOARD_SPI2_MOSI_PIN) SPIClass(2);
#endif
#if BOARD_NR_SPI >= 3
if (mosi == BOARD_SPI3_MOSI_PIN) SPIClass(3);
#endif
}
void SPIClass::begin() {
// // Init the SPI pins in the first begin call
if ((_currentSetting->device_id == 0 && spiInitialised[0] == false) ||
(_currentSetting->device_id == 1 && spiInitialised[1] == false) ||
(_currentSetting->device_id == 2 && spiInitialised[2] == false)) {
MCUI::SSP::init(_currentSetting->device_id, _currentSetting->m_config);
spiInitialised[_currentSetting->device_id] = true;
}
updateSettings();
}
void SPIClass::beginTransaction(const SPISettings &cfg) {
setBitOrder(cfg.bitOrder);
setDataMode(cfg.dataMode);
setDataSize(cfg.dataSize);
//setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock));
begin();
}
uint8_t SPIClass::transfer(const uint16_t b) {
uint16_t rx_word = 0;
// clear rx fifo
while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) == 1);
MCUI::SSP::write(_currentSetting->device_id, b);
while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) != 1);
return rx_word;
}
uint16_t SPIClass::transfer16(const uint16_t data) {
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
}
void SPIClass::end() {
// // Neither is needed for Marlin
// //SSP_Cmd(_currentSetting->spi_d, DISABLE);
// //SSP_DeInit(_currentSetting->spi_d);
}
void SPIClass::send(uint8_t data) {
MCUI::SSP::write(_currentSetting->device_id, data);
}
void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
// //TODO: LPC dma can only write 0xFFF bytes at once.
// GPDMA_Channel_CFG_Type GPDMACfg;
// /* Configure GPDMA channel 0 -------------------------------------------------------------*/
// /* DMA Channel 0 */
// GPDMACfg.ChannelNum = 0;
// // Source memory
// GPDMACfg.SrcMemAddr = (uint32_t)buf;
// // Destination memory - Not used
// GPDMACfg.DstMemAddr = 0;
// // Transfer size
// GPDMACfg.TransferSize = length;
// // Transfer width
// GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
// // Transfer type
// GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
// // Source connection - unused
// GPDMACfg.SrcConn = 0;
// // Destination connection
// GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx;
// GPDMACfg.DMALLI = 0;
// // Enable dma on SPI
// SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
// // Only increase memory if minc is true
// GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
// // Setup channel with given parameter
// GPDMA_Setup(&GPDMACfg);
// // Enable DMA
// GPDMA_ChannelCmd(0, ENABLE);
// // Wait for data transfer
// while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
// // Clear err and int
// GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
// GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
// // Disable DMA
// GPDMA_ChannelCmd(0, DISABLE);
// waitSpiTxEnd(_currentSetting->spi_d);
// SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
}
uint16_t SPIClass::read() {
uint16_t rx_word = 0;
MCUI::SSP::read(_currentSetting->device_id, &rx_word);
return rx_word;
}
void SPIClass::read(uint8_t *buf, uint32_t len) {
uint16_t rx_word = 0;
// clear rx fifo
while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) == 1);
for (uint16_t i = 0; i < len; i++) {
MCUI::SSP::write(_currentSetting->device_id, 0xFF);
while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) != 1);
buf[i] = rx_word;
}
}
void SPIClass::setClock(uint32_t clock) { _currentSetting->clock = clock; }
void SPIClass::setModule(uint8_t device) { _currentSetting = &_settings[device - 1]; } // SPI channels are called 1, 2, and 3 but the array is zero-indexed
void SPIClass::setBitOrder(uint8_t bitOrder) { _currentSetting->bitOrder = bitOrder; }
void SPIClass::setDataMode(uint8_t dataMode) { _currentSetting->dataMode = dataMode; }
void SPIClass::setDataSize(uint32_t dataSize) { _currentSetting->dataSize = dataSize; }
// /**
// * Set up/tear down
// */
void SPIClass::updateSettings() {
MCUI::SSP::configure(_currentSetting->device_id, _currentSetting->m_config);
}
SPIClass SPI(1);
#if SD_MISO_PIN == BOARD_SPI1_MISO_PIN
SPIClass SPI(1);
#elif SD_MISO_PIN == BOARD_SPI2_MISO_PIN
SPIClass SPI(2);
#endif
#endif // TARGET_LPC4078
-45
View File
@@ -1,45 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <SPI.h>
/**
* Marlin currently requires 3 SPI classes:
*
* SPIClass:
* This class is normally provided by frameworks and has a semi-default interface.
* This is needed because some libraries reference it globally.
*
* SPISettings:
* Container for SPI configs for SPIClass. As above, libraries may reference it globally.
*
* These two classes are often provided by frameworks so we cannot extend them to add
* useful methods for Marlin.
*
* MarlinSPI:
* Provides the default SPIClass interface plus some Marlin goodies such as a simplified
* interface for SPI DMA transfer.
*
*/
using MarlinSPI = SPIClass;
-78
View File
@@ -1,78 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
#include "MarlinSerial.h"
#include "../../inc/MarlinConfig.h"
MarlinCDCSerial MCDCSerial0;
#define MarlinSerial(ID) \
MarlinSerial _MSerial##ID(ID); \
MSerialT MSerial##ID(true, _MSerial##ID)
#if USING_HW_SERIAL0
MarlinSerial(0);
#endif
#if USING_HW_SERIAL1
MarlinSerial(1);
#endif
#if USING_HW_SERIAL2
MarlinSerial(2);
#endif
#if USING_HW_SERIAL3
MarlinSerial(3);
#endif
#if ENABLED(EMERGENCY_PARSER)
bool MarlinSerial::recv_callback(const char c) {
// Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro)
if (false) {}
#if USING_HW_SERIAL0
else if (this == &_MSerial0) emergency_parser.update(MSerial0.emergency_state, c);
#endif
#if USING_HW_SERIAL1
else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c);
#endif
#if USING_HW_SERIAL2
else if (this == &_MSerial2) emergency_parser.update(MSerial2.emergency_state, c);
#endif
#if USING_HW_SERIAL3
else if (this == &_MSerial3) emergency_parser.update(MSerial3.emergency_state, c);
#endif
return true;
}
#include "../../feature/e_parser.h"
EmergencyParser::State emergency_state;
bool CDC_RecvCallback(const char c) {
emergency_parser.update(emergency_state, c);
return true;
}
#endif
#endif // TARGET_LPC4078
-108
View File
@@ -1,108 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <mcu_interface.h>
#include <interface/uart.h>
#include <driver/usb_cdc.h>
#include <UART.h>
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(EMERGENCY_PARSER)
#include "../../feature/e_parser.h"
#endif
#include "../../core/serial_hook.h"
#ifndef SERIAL_PORT
#define SERIAL_PORT 0
#endif
#ifndef RX_BUFFER_SIZE
#define RX_BUFFER_SIZE 128
#endif
#ifndef TX_BUFFER_SIZE
#define TX_BUFFER_SIZE 32
#endif
class MarlinCDCSerial : public HardwareSerial {
public:
MarlinCDCSerial() {}
void begin(unsigned long baudrate) override {}
void begin(unsigned long baudrate, uint16_t config) override { }
void end() override { }
int available() override {
return MCUI::CDCSerial0::available();
}
int peek() override { char c = 0; return MCUI::CDCSerial0::peek((uint8_t*)&c)? c : -1; }
int read() override { char c = 0; return MCUI::CDCSerial0::read((uint8_t*)&c, 1)? c : -1; }
void flush() override {};
size_t write(uint8_t c) override { return write(&c, 1); }
size_t write(const uint8_t *buffer, size_t size) override { return MCUI::CDCSerial0::connected() ? MCUI::CDCSerial0::write(buffer, size) : 0; }
using Print::write;
operator bool() override { return true; }
};
extern MarlinCDCSerial MCDCSerial0;
class MarlinSerial : public HardwareSerial {
public:
MarlinSerial(const uint32_t uart_id) : uart_device(uart_id) {}
void begin(unsigned long baudrate) override {
uart_device.configure_pins(P0_02, P0_03);
uart_device.init({ .baud = baudrate });
#if ENABLED(EMERGENCY_PARSER)
uart_device.set_rx_callback([this](char rx_value){ return this->recv_callback(rx_value); } );
#endif
}
void begin(unsigned long baudrate, uint16_t config) override {
begin(baudrate);
}
void end() override { }
int available() override {
return uart_device.rx_available();
}
int peek() override { char c = 0; return uart_device.peek(&c)? c : -1; }
int read() override { char c = 0; return uart_device.read(&c)? c : -1; }
void flush() override {};
size_t write(uint8_t c) override { return write(&c, 1); }
size_t write(const uint8_t *buffer, size_t size) override { return uart_device.write((const char *)buffer, size); }
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool() override { return true; }
bool recv_callback(char value);
private:
MCUI::BufferedUARTC uart_device;
};
// On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads
// of 'available' and 'read' method are not used in this multiple inheritance scenario.
// Instead, use a ForwardSerial here that adapts the interface.
typedef ForwardSerial1Class<MarlinSerial> MSerialT;
extern MSerialT MSerial0;
extern MSerialT MSerial1;
extern MSerialT MSerial2;
extern MSerialT MSerial3;
// Consequently, we can't use a RuntimeSerial either. The workaround would be to use
// a RuntimeSerial<ForwardSerial<MarlinSerial>> type here. Ignore for now until it's actually required.
#if ENABLED(SERIAL_RUNTIME_HOOK)
#error "SERIAL_RUNTIME_HOOK is not yet supported for LPC176x."
#endif
-51
View File
@@ -1,51 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
#include "HAL.h"
#if ENABLED(POSTMORTEM_DEBUGGING)
#include "../shared/MinSerial.h"
#include <debug_frmwrk.h>
static void TX(char c) { _DBC(c); }
void install_min_serial() { HAL_min_serial_out = &TX; }
#if DISABLED(DYNAMIC_VECTORTABLE)
extern "C" {
__attribute__((naked)) void JumpHandler_ASM() {
__asm__ __volatile__ (
"b CommonHandler_ASM\n"
);
}
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
}
#endif
#endif // POSTMORTEM_DEBUGGING
#endif // TARGET_LPC4078
-69
View File
@@ -1,69 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
* Copyright (c) 2009 Michael Margolis. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
/**
* Based on "servo.h - Interrupt driven Servo library for Arduino using 16 bit timers -
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
*
* The only modification was to update/delete macros to match the LPC176x.
*/
#include <Servo.h>
class libServo: public Servo {
public:
void move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach
write(value);
safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
}
}
};
class libServo;
typedef libServo hal_servo_t;
-47
View File
@@ -1,47 +0,0 @@
#ifdef TARGET_LPC4078
#include <Arduino.h>
#include "SoftwareSPI.h"
#include <mcu_interface.h>
uint8_t swSpiTransfer(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin) {
for (uint8_t i = 0; i < 8; i++) {
if (spi_speed == 0) {
MCUI::gpio_set(mosi_pin, !!(b & 0x80));
MCUI::gpio_set(sck_pin, HIGH);
b <<= 1;
if (miso_pin >= 0 && MCUI::gpio_get(miso_pin)) b |= 1;
MCUI::gpio_set(sck_pin, LOW);
}
else {
const uint8_t state = (b & 0x80) ? HIGH : LOW;
for (uint8_t j = 0; j < spi_speed; j++)
MCUI::gpio_set(mosi_pin, state);
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
MCUI::gpio_set(sck_pin, HIGH);
b <<= 1;
if (miso_pin >= 0 && MCUI::gpio_get(miso_pin)) b |= 1;
for (uint8_t j = 0; j < spi_speed; j++)
MCUI::gpio_set(sck_pin, LOW);
}
}
return b;
}
void swSpiBegin(const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin) {
pinMode(sck_pin, OUTPUT);
if (MCUI::pin_is_valid(miso_pin)) pinMode(miso_pin, INPUT);
pinMode(mosi_pin, OUTPUT);
}
uint8_t swSpiInit(const uint8_t spiRate, const pin_t sck_pin, const pin_t mosi_pin) {
MCUI::gpio_set(mosi_pin, HIGH);
MCUI::gpio_set(sck_pin, LOW);
return (SystemCoreClock == 120000000 ? 44 : 38) / std::pow(2, 6 - std::min(spiRate, (uint8_t)6));
}
#endif // TARGET_LPC4078
-5
View File
@@ -1,5 +0,0 @@
#include <mcu_interface.h>
uint8_t swSpiTransfer(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin);
void swSpiBegin(const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin);
uint8_t swSpiInit(const uint8_t spiRate, const pin_t sck_pin, const pin_t mosi_pin);
-116
View File
@@ -1,116 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
/**
* Emulate EEPROM storage using Flash Memory
*
* Use a single 32K flash sector to store EEPROM data. To reduce the
* number of erase operations a simple "leveling" scheme is used that
* maintains a number of EEPROM "slots" within the larger flash sector.
* Each slot is used in turn and the entire sector is only erased when all
* slots have been used.
*
* A simple RAM image is used to hold the EEPROM data during I/O operations
* and this is flushed to the next available slot when an update is complete.
* If RAM usage becomes an issue we could store this image in one of the two
* 16Kb I/O buffers (intended to hold DMA USB and Ethernet data, but currently
* unused).
*/
#include "../../inc/MarlinConfig.h"
#include "../shared/eeprom_api.h"
//#include <cstdio>
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 4032 // 4KB
#endif
size_t PersistentStore::capacity() { return 4032; }
constexpr uint32_t page_size = MCUI::EEPROM::page_size;
uint32_t buffered_page = 0;
uint8_t page_buffer[page_size];
bool buffered_page_dirty = false;
bool PersistentStore::access_start() {
MCUI::EEPROM::init();
MCUI::EEPROM::read_page(buffered_page, page_buffer, page_size);
return true;
}
bool PersistentStore::access_finish() {
if (buffered_page_dirty) {
MCUI::EEPROM::write_page(buffered_page, page_buffer, page_size);
}
return true;
}
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
uint32_t address = pos;
//printf("Marlin::eeprom::write(pos = %d, size = %d)\n", pos, size);
uint32_t value_index = 0;
for (uint32_t addr = address; addr < address + size; ++addr) {
uint32_t page_address = addr & 0xFFFFFFC0;
if (page_address != buffered_page) {
//printf("Marlin::eeprom::write(@%ld):: page change new(%ld) != current(%d)\n",addr, page_address, buffered_page);
if (buffered_page_dirty == true) MCUI::EEPROM::write_page(buffered_page, page_buffer, page_size);
buffered_page = page_address;
buffered_page_dirty = false;
MCUI::EEPROM::read_page(buffered_page, page_buffer, page_size);
}
page_buffer[addr & ~0xFFFFFFC0] = value[value_index++];
buffered_page_dirty = true;
}
pos += size;
crc16(crc, value, size);
return false; // return true for any error
}
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
uint32_t address = pos;
//printf("Marlin::eeprom::read(pos = %d, size = %d, writing = %d)\n", pos, size, writing);
uint32_t value_index = 0;
for (uint32_t addr = address; addr < address + size; ++addr) {
uint32_t page_address = addr & 0xFFFFFFC0;
if (page_address != buffered_page) {
if (buffered_page_dirty) {
MCUI::EEPROM::write_page(buffered_page, page_buffer, page_size);
buffered_page_dirty = false;
}
buffered_page = page_address;
MCUI::EEPROM::read_page(buffered_page, page_buffer, page_size);
}
if (writing) value[value_index++] = page_buffer[addr & ~0xFFFFFFC0];
else crc16(crc, &page_buffer[addr & ~0xFFFFFFC0], 1);
}
if (writing) crc16(crc, value, size);
pos += size;
return false; // return true for any error
}
#endif // TARGET_LPC4078
-191
View File
@@ -1,191 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Endstop Interrupts
*
* Without endstop interrupts the endstop pins must be polled continually in
* the temperature-ISR via endstops.update(), most of the time finding no change.
* With this feature endstops.update() is called only when we know that at
* least one endstop has changed state, saving valuable CPU cycles.
*
* This feature only works when all used endstop pins can generate an 'external interrupt'.
*
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
*/
#include "../../module/endstops.h"
// One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
#define LPC1768_PIN_INTERRUPT_M(pin) ((pin >> 0x5 & 0x7) == 0 || (pin >> 0x5 & 0x7) == 2)
#if HAS_X_MAX
#if !LPC1768_PIN_INTERRUPT_M(X_MAX_PIN)
#error "X_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(X_MAX_PIN);
#endif
#if HAS_X_MIN
#if !LPC1768_PIN_INTERRUPT_M(X_MIN_PIN)
#error "X_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(X_MIN_PIN);
#endif
#if HAS_Y_MAX
#if !LPC1768_PIN_INTERRUPT_M(Y_MAX_PIN)
#error "Y_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Y_MAX_PIN);
#endif
#if HAS_Y_MIN
#if !LPC1768_PIN_INTERRUPT_M(Y_MIN_PIN)
#error "Y_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Y_MIN_PIN);
#endif
#if HAS_Z_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z_MAX_PIN)
#error "Z_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z_MAX_PIN);
#endif
#if HAS_Z_MIN
#if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PIN)
#error "Z_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z_MIN_PIN);
#endif
#if HAS_Z2_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z2_MAX_PIN)
#error "Z2_MAX_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
#if !LPC1768_PIN_INTERRUPT_M(Z2_MIN_PIN)
#error "Z2_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z3_MAX_PIN)
#error "Z3_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
#if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
#error "Z3_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z4_MAX_PIN)
#error "Z4_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
#if !LPC1768_PIN_INTERRUPT_M(Z4_MIN_PIN)
#error "Z4_MIN_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
#if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
#error "Z_MIN_PROBE_PIN is not INTERRUPT-capable. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#endif
#if HAS_I_MAX
#if !LPC1768_PIN_INTERRUPT_M(I_MAX_PIN)
#error "I_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(I_MAX_PIN);
#elif HAS_I_MIN
#if !LPC1768_PIN_INTERRUPT_M(I_MIN_PIN)
#error "I_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(I_MIN_PIN);
#endif
#if HAS_J_MAX
#if !LPC1768_PIN_INTERRUPT_M(J_MAX_PIN)
#error "J_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(J_MAX_PIN);
#elif HAS_J_MIN
#if !LPC1768_PIN_INTERRUPT_M(J_MIN_PIN)
#error "J_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(J_MIN_PIN);
#endif
#if HAS_K_MAX
#if !LPC1768_PIN_INTERRUPT_M(K_MAX_PIN)
#error "K_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(K_MAX_PIN);
#elif HAS_K_MIN
#if !LPC1768_PIN_INTERRUPT_M(K_MIN_PIN)
#error "K_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(K_MIN_PIN);
#endif
#if HAS_U_MAX
#if !LPC1768_PIN_INTERRUPT_M(U_MAX_PIN)
#error "U_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(U_MAX_PIN);
#elif HAS_U_MIN
#if !LPC1768_PIN_INTERRUPT_M(U_MIN_PIN)
#error "U_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(U_MIN_PIN);
#endif
#if HAS_V_MAX
#if !LPC1768_PIN_INTERRUPT_M(V_MAX_PIN)
#error "V_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(V_MAX_PIN);
#elif HAS_V_MIN
#if !LPC1768_PIN_INTERRUPT_M(V_MIN_PIN)
#error "V_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(V_MIN_PIN);
#endif
#if HAS_W_MAX
#if !LPC1768_PIN_INTERRUPT_M(W_MAX_PIN)
#error "W_MAX_PIN is not INTERRUPT-capable."
#endif
_ATTACH(W_MAX_PIN);
#elif HAS_W_MIN
#if !LPC1768_PIN_INTERRUPT_M(W_MIN_PIN)
#error "W_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(W_MIN_PIN);
#endif
}
-37
View File
@@ -1,37 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
#include <mcu_interface.h>
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
if (!MCUI::pin_is_valid(pin)) return;
if (MCUI::pwm_attach_pin(pin))
MCUI::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
}
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
MCUI::pwm_set_frequency(pin, f_desired);
}
#endif // TARGET_LPC4078
-120
View File
@@ -1,120 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Fast I/O Routines for LPC1768/9
* Use direct port manipulation to save scads of processor time.
* Contributed by Triffid_Hunter and modified by Kliment, thinkyhead, Bob-the-Kuhn, et.al.
*/
/**
* Description: Fast IO functions LPC1768
*
* For TARGET LPC1768
*/
#include "../shared/Marduino.h"
#include <mcu_interface.h>
#define PWM_PIN(P) true // all pins are software PWM capable
#define LPC_PIN(pin) MCUI::gpio_pin(pin)
#define LPC_GPIO(port) MCUI::gpio_port(port)
#define SET_DIR_INPUT(IO) MCUI::gpio_set_input(IO)
#define SET_DIR_OUTPUT(IO) MCUI::gpio_set_output(IO)
#define SET_MODE(IO, mode) pinMode(IO, mode)
#define WRITE_PIN_SET(IO) MCUI::gpio_set(IO)
#define WRITE_PIN_CLR(IO) MCUI::gpio_clear(IO)
#define READ_PIN(IO) MCUI::gpio_get(IO)
#define WRITE_PIN(IO,V) MCUI::gpio_set(IO, V)
/**
* Magic I/O routines
*
* Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW);
*
* Why double up on these macros? see https://gcc.gnu.org/onlinedocs/gcc-4.8.5/cpp/Stringification.html
*/
/// Read a pin
#define _READ(IO) READ_PIN(IO)
/// Write to a pin
#define _WRITE(IO,V) WRITE_PIN(IO,V)
/// toggle a pin
#define _TOGGLE(IO) MCUI::gpio_toggle(IO)
/// set pin as input
#define _SET_INPUT(IO) SET_DIR_INPUT(IO)
/// set pin as output
#define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO)
/// set pin as input with pullup mode
#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
/// set pin as input with pulldown mode
#define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
/// check if pin is an input
#define _IS_INPUT(IO) (!MCUI::gpio_get_dir(IO))
/// check if pin is an output
#define _IS_OUTPUT(IO) (MCUI::gpio_get_dir(IO))
/// Read a pin wrapper
#define READ(IO) _READ(IO)
/// Write to a pin wrapper
#define WRITE(IO,V) _WRITE(IO,V)
/// toggle a pin wrapper
#define TOGGLE(IO) _TOGGLE(IO)
/// set pin as input wrapper
#define SET_INPUT(IO) _SET_INPUT(IO)
/// set pin as input with pullup wrapper
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
/// set pin as input with pulldown wrapper
#define SET_INPUT_PULLDOWN(IO) do{ _SET_INPUT(IO); _PULLDOWN(IO, HIGH); }while(0)
/// set pin as output wrapper - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
// set pin as PWM
#define SET_PWM SET_OUTPUT
/// check if pin is an input wrapper
#define IS_INPUT(IO) _IS_INPUT(IO)
/// check if pin is an output wrapper
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
// Shorthand
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO)
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
@@ -1,22 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
@@ -1,26 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#if DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
@@ -1,34 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#if USE_FALLBACK_EEPROM
#define FLASH_EEPROM_EMULATION
#elif ANY(I2C_EEPROM, SPI_EEPROM)
#define USE_SHARED_EEPROM 1
#endif
// LPC1768 boards seem to lose steps when saving to EEPROM during print (issue #20785)
// TODO: Which other boards are incompatible?
#if defined(MCU_LPC1768) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0
#define PRINTCOUNTER_SYNC 1
#endif
@@ -1,22 +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
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
-276
View File
@@ -1,276 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
// #if PIO_PLATFORM_VERSION < 1001
// #error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
// #endif
// #if PIO_FRAMEWORK_VERSION < 2006
// #error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
// #endif
/**
* Detect an old pins file by checking for old ADC pins values.
*/
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board
#if _OLD_TEMP_PIN(TEMP_BED)
#error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_0)
#error "TEMP_0_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_1)
#error "TEMP_1_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_2)
#error "TEMP_2_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_3)
#error "TEMP_3_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_4)
#error "TEMP_4_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_5)
#error "TEMP_5_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_6)
#error "TEMP_6_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_7)
#error "TEMP_7_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#endif
#undef _OLD_TEMP_PIN
/**
* Because PWM hardware channels all share the same frequency, along with the
* fallback software channels, FAST_PWM_FAN is incompatible with Servos.
*/
static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards.");
#if SPINDLE_LASER_FREQUENCY
static_assert(!NUM_SERVOS, "BLTOUCH and Servos are incompatible with SPINDLE_LASER_FREQUENCY on LPC176x boards.");
#endif
/**
* Test LPC176x-specific configuration values for errors at compile-time.
*/
//#if ENABLED(SPINDLE_LASER_USE_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
//#endif
#if MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF)
#if IS_RRD_FG_SC && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 requires TMC_USE_SW_SPI."
#endif
#endif
static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported on LPC176x.");
/**
* Flag any serial port conflicts
*
* Port | TX | RX |
* --- | --- | --- |
* Serial | P0_02 | P0_03 |
* Serial1 | P0_15 | P0_16 |
* Serial2 | P0_10 | P0_11 |
* Serial3 | P0_00 | P0_01 |
*/
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
#if USING_HW_SERIAL0
#define IS_TX0(P) (P == P0_02)
#define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
#error "Serial port pins (0) conflict with Trinamic SPI pins!"
#elif HAS_PRUSA_MMU1 && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN))
#error "Serial port pins (0) conflict with Multi-Material-Unit multiplexer pins!"
#elif (AXIS_HAS_SPI(X) && IS_TX0(X_CS_PIN)) || (AXIS_HAS_SPI(Y) && IS_RX0(Y_CS_PIN))
#error "Serial port pins (0) conflict with X/Y axis SPI pins!"
#endif
#undef IS_TX0
#undef IS_RX0
#endif
#if USING_HW_SERIAL1
#define IS_TX1(P) (P == P0_15)
#define IS_RX1(P) (P == P0_16)
#define _IS_TX1_1 IS_TX1
#define _IS_RX1_1 IS_RX1
#if IS_TX1(TMC_SW_SCK)
#error "Serial port pins (1) conflict with other pins!"
#elif HAS_ROTARY_ENCODER
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
#error "Serial port pins (1) conflict with Encoder Buttons!"
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
#error "Serial port pins (1) conflict with LCD pins!"
#endif
#endif
#undef IS_TX1
#undef IS_RX1
#undef _IS_TX1_1
#undef _IS_RX1_1
#endif
#if USING_HW_SERIAL2
#define IS_TX2(P) (P == P0_10)
#define IS_RX2(P) (P == P0_11)
#define _IS_TX2_1 IS_TX2
#define _IS_RX2_1 IS_RX2
#if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
#error "Serial port pins (2) conflict with X2 pins!"
#elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
#error "Serial port pins (2) conflict with Y2 pins!"
#elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
#error "Serial port pins (2) conflict with Z2 pins!"
#elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
#error "Serial port pins (2) conflict with Z3 pins!"
#elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
#error "Serial port pins (2) conflict with Z4 pins!"
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
#error "Serial port pins (2) conflict with other pins!"
#elif Y_HOME_TO_MIN && IS_TX2(Y_STOP_PIN)
#error "Serial port pins (2) conflict with Y endstop pin!"
#elif USES_Z_MIN_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
#error "Serial port pins (2) conflict with probe pin!"
#elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
#error "Serial port pins (2) conflict with X/Y stepper pins!"
#elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
#error "Serial port pins (2) conflict with E1 stepper pins!"
#elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN)
#error "Serial port pins (2) conflict with E stepper pins!"
#endif
#undef IS_TX2
#undef IS_RX2
#undef _IS_TX2_1
#undef _IS_RX2_1
#endif
#if USING_HW_SERIAL3
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
#error "Serial port pins (3) conflict with X endstop pins!"
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
#error "Serial port pins (3) conflict with X/Y axis UART pins!"
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
#error "Serial port pins (3) conflict with X2 pins!"
#elif PIN_IS_TX3(Y2_DIR) || PIN_IS_RX3(Y2_STEP)
#error "Serial port pins (3) conflict with Y2 pins!"
#elif PIN_IS_TX3(Z2_DIR) || PIN_IS_RX3(Z2_STEP)
#error "Serial port pins (3) conflict with Z2 pins!"
#elif PIN_IS_TX3(Z3_DIR) || PIN_IS_RX3(Z3_STEP)
#error "Serial port pins (3) conflict with Z3 pins!"
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
#error "Serial port pins (3) conflict with Z4 pins!"
#elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
#error "Serial port pins (3) conflict with E1 pins!"
#endif
#undef PIN_IS_TX3
#undef PIN_IS_RX3
#endif
#undef ANY_TX
#undef ANY_RX
//
// Flag any i2c pin conflicts
//
#if ANY(HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM)
#define USEDI2CDEV_M 1 // <Arduino>/Wire.cpp
#if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1)
#define PIN_IS_SDA0(P) (P##_PIN == P0_27)
#define IS_SCL0(P) (P == P0_28)
#if ENABLED(SDSUPPORT) && PIN_IS_SDA0(SD_DETECT)
#error "SDA0 overlaps with SD_DETECT_PIN!"
#elif PIN_IS_SDA0(E0_AUTO_FAN)
#error "SDA0 overlaps with E0_AUTO_FAN_PIN!"
#elif PIN_IS_SDA0(BEEPER)
#error "SDA0 overlaps with BEEPER_PIN!"
#elif IS_SCL0(BTN_ENC)
#error "SCL0 overlaps with Encoder Button!"
#elif IS_SCL0(SD_SS_PIN)
#error "SCL0 overlaps with SD_SS_PIN!"
#elif IS_SCL0(LCD_SDSS)
#error "SCL0 overlaps with LCD_SDSS!"
#endif
#undef PIN_IS_SDA0
#undef IS_SCL0
#elif USEDI2CDEV_M == 1 // P0_00 [D20] (SCA) ............ P0_01 [D21] (SCL)
#define PIN_IS_SDA1(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
#define PIN_IS_SCL1(P) (P##_PIN == P0_01)
#if PIN_IS_SDA1(X_MIN) || PIN_IS_SCL1(X_MAX)
#error "One or more i2c (1) pins overlaps with X endstop pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(X2_DIR) || PIN_IS_SCL1(X2_STEP)
#error "One or more i2c (1) pins overlaps with X2 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Y2_DIR) || PIN_IS_SCL1(Y2_STEP)
#error "One or more i2c (1) pins overlaps with Y2 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Z2_DIR) || PIN_IS_SCL1(Z2_STEP)
#error "One or more i2c (1) pins overlaps with Z2 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Z3_DIR) || PIN_IS_SCL1(Z3_STEP)
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
#endif
#undef PIN_IS_SDA1
#undef PIN_IS_SCL1
#elif USEDI2CDEV_M == 2 // P0_10 [D38] (X_ENABLE_PIN) ... P0_11 [D55] (X_DIR_PIN)
#define PIN_IS_SDA2(P) (P##_PIN == P0_10)
#define PIN_IS_SCL2(P) (P##_PIN == P0_11)
#if PIN_IS_SDA2(Y_STOP)
#error "i2c SDA2 overlaps with Y endstop pin!"
#elif USES_Z_MIN_PROBE_PIN && PIN_IS_SDA2(Z_MIN_PROBE)
#error "i2c SDA2 overlaps with Z probe pin!"
#elif PIN_IS_SDA2(X_ENABLE) || PIN_IS_SDA2(Y_ENABLE)
#error "i2c SDA2 overlaps with X/Y ENABLE pin!"
#elif AXIS_HAS_SPI(X) && PIN_IS_SDA2(X_CS)
#error "i2c SDA2 overlaps with X CS pin!"
#elif PIN_IS_SDA2(X2_ENABLE)
#error "i2c SDA2 overlaps with X2 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Y2_ENABLE)
#error "i2c SDA2 overlaps with Y2 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Z2_ENABLE)
#error "i2c SDA2 overlaps with Z2 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Z3_ENABLE)
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(Z4_ENABLE)
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE)
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
#elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
#elif PIN_IS_SDA2(X_DIR) || PIN_IS_SDA2(Y_DIR)
#error "One or more i2c pins overlaps with X/Y DIR pin! Disable i2c peripherals."
#endif
#undef PIN_IS_SDA2
#undef PIN_IS_SCL2
#endif
#undef USEDI2CDEV_M
#endif
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on LPC176x."
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
#error "SERIAL_STATS_DROPPED_RX is not supported on LPX176x."
#endif
-209
View File
@@ -1,209 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../shared/HAL_SPI.h"
#include <stdint.h>
#include <mcu_interface.h>
//#define MSBFIRST 1
#define SPI_MODE0 0
#define SPI_MODE1 1
#define SPI_MODE2 2
#define SPI_MODE3 3
#define SSP_CR0_DSS(n) ((uint32_t)((n-1)&0xF))
#define SSP_DATABIT_4 SSP_CR0_DSS(4) /*!< Databit number = 4 */
#define SSP_DATABIT_5 SSP_CR0_DSS(5) /*!< Databit number = 5 */
#define SSP_DATABIT_6 SSP_CR0_DSS(6) /*!< Databit number = 6 */
#define SSP_DATABIT_7 SSP_CR0_DSS(7) /*!< Databit number = 7 */
#define SSP_DATABIT_8 SSP_CR0_DSS(8) /*!< Databit number = 8 */
#define SSP_DATABIT_9 SSP_CR0_DSS(9) /*!< Databit number = 9 */
#define SSP_DATABIT_10 SSP_CR0_DSS(10) /*!< Databit number = 10 */
#define SSP_DATABIT_11 SSP_CR0_DSS(11) /*!< Databit number = 11 */
#define SSP_DATABIT_12 SSP_CR0_DSS(12) /*!< Databit number = 12 */
#define SSP_DATABIT_13 SSP_CR0_DSS(13) /*!< Databit number = 13 */
#define SSP_DATABIT_14 SSP_CR0_DSS(14) /*!< Databit number = 14 */
#define SSP_DATABIT_15 SSP_CR0_DSS(15) /*!< Databit number = 15 */
#define SSP_DATABIT_16 SSP_CR0_DSS(16) /*!< Databit number = 16 */
#define DATA_SIZE_8BIT SSP_DATABIT_8
#define DATA_SIZE_16BIT SSP_DATABIT_16
#define SPI_CLOCK_MAX_TFT 30000000UL
#define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
#define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
#define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
#define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
#define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
#define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
#define BOARD_NR_SPI 3
// SSP0 TMC port
#define BOARD_SPI1_NSS_PIN P_NC
#define BOARD_SPI1_SCK_PIN P1_20
#define BOARD_SPI1_MISO_PIN P1_23
#define BOARD_SPI1_MOSI_PIN P1_24
// SSP2 LCD SD port
#define BOARD_SPI2_NSS_PIN P_NC
#define BOARD_SPI2_SCK_PIN P1_00
#define BOARD_SPI2_MISO_PIN P1_04
#define BOARD_SPI2_MOSI_PIN P1_01
// SSP1 Onboard SD port
#define BOARD_SPI3_NSS_PIN P_NC
#define BOARD_SPI3_SCK_PIN P0_07
#define BOARD_SPI3_MISO_PIN P0_08
#define BOARD_SPI3_MOSI_PIN P0_09
class SPISettings {
public:
SPISettings(uint32_t spiRate, int inBitOrder, int inDataMode) {
init_AlwaysInline(spiRate2Clock(spiRate), inBitOrder, inDataMode, DATA_SIZE_8BIT);
}
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
if (__builtin_constant_p(inClock))
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
else
init_MightInline(inClock, inBitOrder, inDataMode, inDataSize);
}
SPISettings() {
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
}
//uint32_t spiRate() const { return spi_speed; }
static uint32_t spiRate2Clock(uint32_t spiRate) {
uint32_t Marlin_speed[7]; // CPSR is always 2
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
return Marlin_speed[spiRate > 6 ? 6 : spiRate];
}
private:
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
}
void init_AlwaysInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) __attribute__((__always_inline__)) {
clock = inClock;
bitOrder = inBitOrder;
dataMode = inDataMode;
dataSize = inDataSize;
m_config = {};
m_config.frequency = 400000;
}
MCUI::SSP::Config m_config;
//uint32_t spi_speed;
uint32_t clock;
uint32_t dataSize;
//uint32_t clockDivider;
uint8_t bitOrder;
uint8_t dataMode;
uint8_t device_id;
friend class SPIClass;
};
/**
* @brief Wirish SPI interface.
*
* This is the same interface is available across HAL
*
* This implementation uses software slave management, so the caller
* is responsible for controlling the slave select line.
*/
class SPIClass {
public:
/**
* @param spiPortNumber Number of the SPI port to manage.
*/
SPIClass(uint8_t spiPortNumber);
/**
* Init using pins
*/
SPIClass(pin_t mosi, pin_t miso, pin_t sclk, pin_t ssel = (pin_t)-1);
/**
* Select and configure the current selected SPI device to use
*/
void begin();
/**
* Disable the current SPI device
*/
void end();
void beginTransaction(const SPISettings&);
void endTransaction() {}
// Transfer using 1 "Data Size"
uint8_t transfer(uint16_t data);
// Transfer 2 bytes in 8 bit mode
uint16_t transfer16(uint16_t data);
void send(uint8_t data);
uint16_t read();
void read(uint8_t *buf, uint32_t len);
void dmaSend(void *buf, uint16_t length, bool minc);
/**
* @brief Sets the number of the SPI peripheral to be used by
* this HardwareSPI instance.
*
* @param spi_num Number of the SPI port. 1-2 in low density devices
* or 1-3 in high density devices.
*/
void setModule(uint8_t device);
void setClock(uint32_t clock);
void setBitOrder(uint8_t bitOrder);
void setDataMode(uint8_t dataMode);
void setDataSize(uint32_t ds);
inline uint32_t getDataSize() { return _currentSetting->dataSize; }
private:
SPISettings _settings[BOARD_NR_SPI];
SPISettings *_currentSetting;
void updateSettings();
};
extern SPIClass SPI;
-111
View File
@@ -1,111 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
#include "../../core/millis_t.h"
#include "../../sd/cardreader.h"
#include <mcu_interface.h>
#include <driver/usb_device.h>
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
void MarlinHAL::init() {
MCUI::pwm_init();
// Init LEDs
#if PIN_EXISTS(LED)
SET_DIR_OUTPUT(LED_PIN);
WRITE_PIN_CLR(LED_PIN);
#if PIN_EXISTS(LED2)
SET_DIR_OUTPUT(LED2_PIN);
WRITE_PIN_CLR(LED2_PIN);
#if PIN_EXISTS(LED3)
SET_DIR_OUTPUT(LED3_PIN);
WRITE_PIN_CLR(LED3_PIN);
#if PIN_EXISTS(LED4)
SET_DIR_OUTPUT(LED4_PIN);
WRITE_PIN_CLR(LED4_PIN);
#endif
#endif
#endif
// Flash status LED 3 times to indicate Marlin has started booting
for(int i = 0; i < 6; ++i) {
TOGGLE(LED_PIN);
delay(100);
}
#endif
// Init Servo Pins
#define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW)
#if HAS_SERVO_0
INIT_SERVO(0);
#endif
#if HAS_SERVO_1
INIT_SERVO(1);
#endif
#if HAS_SERVO_2
INIT_SERVO(2);
#endif
#if HAS_SERVO_3
INIT_SERVO(3);
#endif
#if PIN_EXISTS(SD_SS)
OUT_WRITE(SD_SS_PIN, HIGH);
#endif
#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN
OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH);
#endif
TERN_(HAS_SD_HOST_DRIVE, MCUI::USBDevice::msc_storage_init()); // Enable USB SD card access
MCUI::USBDevice::connect(2000, LED_PIN);
HAL_timer_init();
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
}
// HAL idle task
void MarlinHAL::idletask() {
#if HAS_SHARED_MEDIA
// If Marlin is using the SD card we need to lock it to prevent access from
// a PC via USB.
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
// this will not reliably detect delete operations. To be safe we will lock
// the disk if Marlin has it mounted. Unfortunately there is currently no way
// to unmount the disk from the LCD menu.
// if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
if (card.isMounted())
MCUI::USBDevice::msc_storage_lock();
else
MCUI::USBDevice::msc_storage_release();
#endif
// Perform USB stack housekeeping
MCUI::USBDevice::msc_run_deferred_commands();
}
#endif // TARGET_LPC4078
-57
View File
@@ -1,57 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Support routines for LPC1768
*/
/**
* Translation of routines & variables used by pinsDebug.h
*/
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
#define digitalRead_mod(p) extDigitalRead(p)
#define PRINT_PORT(p)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), MCUI::pin_port(p), MCUI::pin_bit(p)); SERIAL_ECHO(buffer); }while(0)
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR("_A%d "), MCUI::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
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
#ifndef M43_NEVER_TOUCH
#define M43_NEVER_TOUCH(Q) ((Q) == P0_29 || (Q) == P0_30 || (Q) == P2_09) // USB pins
#endif
bool GET_PINMODE(const pin_t pin) {
if (!MCUI::pin_is_valid(pin) || MCUI::pin_adc_enabled(pin)) // found an invalid pin or active analog pin
return false;
return MCUI::gpio_direction(pin);
}
#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
void print_port(const pin_t) {}
void pwm_details(const pin_t) {}
bool pwm_status(const pin_t) { return false; }
-54
View File
@@ -1,54 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../../core/macros.h"
#if ALL(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
// spiBeginTransaction.
#endif
/** onboard SD card */
//#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 */
#ifndef SD_SCK_PIN
#define SD_SCK_PIN P0_15
#endif
#ifndef SD_MISO_PIN
#define SD_MISO_PIN P0_17
#endif
#ifndef SD_MOSI_PIN
#define SD_MOSI_PIN P0_18
#endif
#ifndef SD_SS_PIN
#define SD_SS_PIN P1_23
#endif
#if !defined(SDSS) || SDSS == P_NC // gets defaulted in pins.h
#undef SDSS
#define SDSS SD_SS_PIN
#endif
-65
View File
@@ -1,65 +0,0 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Description:
*
* Timers for LPC1768
*/
#ifdef TARGET_LPC4078
#include "../../inc/MarlinConfig.h"
void HAL_timer_init() {
SBI(MCUI::system_control.PCONP, SBIT_TIMER0); // Power ON Timer 0
STEP_TIMER_REF.PR = (HAL_TIMER_RATE) / (STEPPER_TIMER_RATE) - 1; // Use prescaler to set frequency if needed
SBI(MCUI::system_control.PCONP, SBIT_TIMER1); // Power ON Timer 1
TEMP_TIMER_REF.PR = (HAL_TIMER_RATE) / 1000000 - 1;
}
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case MF_TIMER_STEP:
STEP_TIMER_REF.MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
STEP_TIMER_REF.MR0 = uint32_t(STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency
STEP_TIMER_REF.TCR = _BV(SBIT_CNTEN); // Counter Enable
MCUCore::nvic_set_priority(MCUI::IRQNumber::TIMER0, MCUCore::nvic_encode_priority(0, 1, 0));
MCUCore::nvic_enable_irq(MCUI::IRQNumber::TIMER0);
break;
case MF_TIMER_TEMP:
TEMP_TIMER_REF.MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
TEMP_TIMER_REF.MR0 = uint32_t(TEMP_TIMER_RATE) / frequency;
TEMP_TIMER_REF.TCR = _BV(SBIT_CNTEN); // Counter Enable
MCUCore::nvic_set_priority(MCUI::IRQNumber::TIMER1, MCUCore::nvic_encode_priority(0, 2, 0));
MCUCore::nvic_enable_irq(MCUI::IRQNumber::TIMER1);
break;
default: break;
}
}
#endif // TARGET_LPC4078
-165
View File
@@ -1,165 +0,0 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* HAL For LPC1768
*/
#include <stdint.h>
#include <mcu_interface.h>
#include "../../core/macros.h"
#define SBIT_TIMER0 1
#define SBIT_TIMER1 2
#define SBIT_CNTEN 0
#define SBIT_MR0I 0 // Timer 0 Interrupt when TC matches MR0
#define SBIT_MR0R 1 // Timer 0 Reset TC on Match
#define SBIT_MR0S 2 // Timer 0 Stop TC and PC on Match
#define SBIT_MR1I 3
#define SBIT_MR1R 4
#define SBIT_MR1S 5
#define SBIT_MR2I 6
#define SBIT_MR2R 7
#define SBIT_MR2S 8
#define SBIT_MR3I 9
#define SBIT_MR3R 10
#define SBIT_MR3S 11
// ------------------------
// Defines
// ------------------------
#define _HAL_TIMER(T) _CAT(MCUI::timer, T)
#define _HAL_TIMER_IRQ(T) TIMER##T##_IRQn
#define __HAL_TIMER_ISR(T) extern "C" void TIMER##T##_IRQHandler()
#define _HAL_TIMER_ISR(T) __HAL_TIMER_ISR(T)
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
#ifndef MF_TIMER_STEP
#define MF_TIMER_STEP 0 // Timer Index for Stepper
#endif
#ifndef MF_TIMER_PULSE
#define MF_TIMER_PULSE MF_TIMER_STEP
#endif
#ifndef MF_TIMER_TEMP
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
#endif
#ifndef MF_TIMER_PWM
#define MF_TIMER_PWM 3 // Timer Index for PWM
#endif
#define TEMP_TIMER_RATE 1000000
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
#ifndef HAL_STEP_TIMER_ISR
#define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_STEP)
#endif
#ifndef HAL_TEMP_TIMER_ISR
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_TEMP)
#endif
// Timer references by index
#define STEP_TIMER_REF _HAL_TIMER(MF_TIMER_STEP)
#define TEMP_TIMER_REF _HAL_TIMER(MF_TIMER_TEMP)
// ------------------------
// Public functions
// ------------------------
void HAL_timer_init();
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
switch (timer_num) {
case MF_TIMER_STEP: STEP_TIMER_REF.MR0 = compare; break; // Stepper Timer Match Register 0
case MF_TIMER_TEMP: TEMP_TIMER_REF.MR0 = compare; break; // Temp Timer Match Register 0
}
}
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: return STEP_TIMER_REF.MR0; // Stepper Timer Match Register 0
case MF_TIMER_TEMP: return TEMP_TIMER_REF.MR0; // Temp Timer Match Register 0
}
return 0;
}
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: return STEP_TIMER_REF.TC; // Stepper Timer Count
case MF_TIMER_TEMP: return TEMP_TIMER_REF.TC; // Temp Timer Count
}
return 0;
}
FORCE_INLINE static void HAL_timer_enable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: MCUCore::nvic_enable_irq(MCUI::IRQNumber::TIMER0); break; // Enable interrupt handler
case MF_TIMER_TEMP: MCUCore::nvic_enable_irq(MCUI::IRQNumber::TIMER1); break; // Enable interrupt handler
}
}
FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: MCUCore::nvic_disable_irq(MCUI::IRQNumber::TIMER0); break; // Disable interrupt handler
case MF_TIMER_TEMP: MCUCore::nvic_disable_irq(MCUI::IRQNumber::TIMER1); break; // Disable interrupt handler
}
}
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: return MCUCore::nvic_irq_is_enabled(MCUI::IRQNumber::TIMER0); // Check if interrupt is enabled or not
case MF_TIMER_TEMP: return MCUCore::nvic_irq_is_enabled(MCUI::IRQNumber::TIMER1); // Check if interrupt is enabled or not
}
return false;
}
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
switch (timer_num) {
case MF_TIMER_STEP: SBI(STEP_TIMER_REF.IR, SBIT_CNTEN); break;
case MF_TIMER_TEMP: SBI(TEMP_TIMER_REF.IR, SBIT_CNTEN); break;
}
}
#define HAL_timer_isr_epilogue(T) NOOP
@@ -1,89 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
// adapted from I2C/master/master.c example
// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
#ifdef TARGET_LPC1768
#include "../include/i2c_util.h"
#include "../../../core/millis_t.h"
extern int millis();
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////////////
#define I2CDEV_S_ADDR 0x78 // From SSD1306 (actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write)
// Send slave address and write bit
uint8_t u8g_i2c_start(const uint8_t sla) {
// Sometimes TX data ACK or NAK status is returned. That mean the start state didn't
// happen which means only the value of the slave address was send. Keep looping until
// the slave address and write bit are actually sent.
do{
_I2C_Stop(I2CDEV_M); // output stop state on I2C bus
_I2C_Start(I2CDEV_M); // output start state on I2C bus
while ((I2C_status != I2C_I2STAT_M_TX_START)
&& (I2C_status != I2C_I2STAT_M_TX_RESTART)
&& (I2C_status != I2C_I2STAT_M_TX_DAT_ACK)
&& (I2C_status != I2C_I2STAT_M_TX_DAT_NACK)); //wait for start to be asserted
LPC_I2C1->I2CONCLR = I2C_I2CONCLR_STAC; // clear start state before tansmitting slave address
LPC_I2C1->I2DAT = I2CDEV_S_ADDR & I2C_I2DAT_BITMASK; // transmit slave address & write bit
LPC_I2C1->I2CONSET = I2C_I2CONSET_AA;
LPC_I2C1->I2CONCLR = I2C_I2CONCLR_SIC;
while ((I2C_status != I2C_I2STAT_M_TX_SLAW_ACK)
&& (I2C_status != I2C_I2STAT_M_TX_SLAW_NACK)
&& (I2C_status != I2C_I2STAT_M_TX_DAT_ACK)
&& (I2C_status != I2C_I2STAT_M_TX_DAT_NACK)); //wait for slaw to finish
}while ( (I2C_status == I2C_I2STAT_M_TX_DAT_ACK) || (I2C_status == I2C_I2STAT_M_TX_DAT_NACK));
return 1;
}
void u8g_i2c_init(const uint8_t clock_option) {
configure_i2c(clock_option);
u8g_i2c_start(0); // Send slave address and write bit
}
uint8_t u8g_i2c_send_byte(uint8_t data) {
#define I2C_TIMEOUT 3
LPC_I2C1->I2DAT = data & I2C_I2DAT_BITMASK; // transmit data
LPC_I2C1->I2CONSET = I2C_I2CONSET_AA;
LPC_I2C1->I2CONCLR = I2C_I2CONCLR_SIC;
const millis_t timeout = millis() + I2C_TIMEOUT;
while ((I2C_status != I2C_I2STAT_M_TX_DAT_ACK) && (I2C_status != I2C_I2STAT_M_TX_DAT_NACK) && PENDING(millis(), timeout)); // wait for xmit to finish
// had hangs with SH1106 so added time out - have seen temporary screen corruption when this happens
return 1;
}
void u8g_i2c_stop() {
}
#ifdef __cplusplus
}
#endif
#endif // TARGET_LPC1768
@@ -1,28 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
void u8g_i2c_init(const uint8_t clock_options);
//uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
uint8_t u8g_i2c_start(uint8_t sla);
uint8_t u8g_i2c_send_byte(uint8_t data);
void u8g_i2c_stop();
-46
View File
@@ -1,46 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* LPC1768 LCD-specific defines
*/
#ifndef U8G_HAL_LINKS
#define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn // See U8glib-HAL
#else
uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_LPC1768_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_LPC1768_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn
#define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn
#endif
-43
View File
@@ -1,43 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* LCD delay routines - used by all the drivers.
*
* These are based on the LPC1768 routines.
*
* Couldn't just call exact copies because the overhead
* results in a one microsecond delay taking about 4µS.
*/
#ifdef __cplusplus
extern "C" {
#endif
void U8g_delay(int msec);
void u8g_MicroDelay();
void u8g_10MicroDelay();
#ifdef __cplusplus
}
#endif
@@ -1,59 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Low level pin manipulation routines - used by all the drivers.
*
* These are based on the LPC1768 pinMode, digitalRead & digitalWrite routines.
*
* Couldn't just call exact copies because the overhead killed the LCD update speed
* With an intermediate level the softspi was running in the 10-20kHz range which
* resulted in using about about 25% of the CPU's time.
*/
#ifdef TARGET_LPC4078
#include <mcu_interface.h>
extern "C" {
#include "LCD_pin_routines.h"
void u8g_SetPinOutput(uint8_t pin) {
MCUI::gpio_set_output(pin);
}
void u8g_SetPinInput(uint8_t pin) {
MCUI::gpio_set_input(pin);
}
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status) {
MCUI::gpio_set(pin, pin_status);
}
uint8_t u8g_GetPinLevel(uint8_t pin) {
return MCUI::gpio_get(pin);
}
}
#endif // TARGET_LPC4078
@@ -1,37 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Low level pin manipulation routines - used by all the drivers.
*
* These are based on the LPC1768 pinMode, digitalRead & digitalWrite routines.
*
* Couldn't just call exact copies because the overhead killed the LCD update speed
* With an intermediate level the softspi was running in the 10-20kHz range which
* resulted in using about about 25% of the CPU's time.
*/
void u8g_SetPinOutput(uint8_t internal_pin_number);
void u8g_SetPinInput(uint8_t internal_pin_number);
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status);
uint8_t u8g_GetPinLevel(uint8_t pin);
@@ -1,129 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Based on u8g_com_msp430_hw_spi.c
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2011, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef TARGET_LPC4078
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB
#include <U8glib-HAL.h>
#include "../../shared/HAL_SPI.h"
#ifndef LCD_SPI_SPEED
#ifdef SD_SPI_SPEED
#define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD
#else
#define LCD_SPI_SPEED SPI_FULL_SPEED // Use full speed if SD speed is not supplied
#endif
#endif
uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_INIT:
u8g_SetPILevel(u8g, U8G_PI_CS, 1);
u8g_SetPILevel(u8g, U8G_PI_A0, 1);
u8g_SetPILevel(u8g, U8G_PI_RESET, 1);
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_SetPIOutput(u8g, U8G_PI_A0);
u8g_SetPIOutput(u8g, U8G_PI_RESET);
u8g_Delay(5);
spiBegin();
spiInit(LCD_SPI_SPEED);
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
break;
case U8G_COM_MSG_CHIP_SELECT:
u8g_SetPILevel(u8g, U8G_PI_CS, (arg_val ? 0 : 1));
break;
case U8G_COM_MSG_RESET:
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_WRITE_BYTE:
spiSend((uint8_t)arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
spiSend(*ptr++);
arg_val--;
}
}
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
spiSend(*ptr++);
arg_val--;
}
}
break;
}
return 1;
}
#endif // HAS_MARLINUI_U8GLIB
#endif // TARGET_LPC4078
@@ -1,198 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Based on u8g_com_arduino_ssd_i2c.c
*
* COM interface for Arduino (AND ATmega) and the SSDxxxx chip (SOLOMON) variant
* I2C protocol
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2011, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Special pin usage:
* U8G_PI_I2C_OPTION additional options
* U8G_PI_A0_STATE used to store the last value of the command/data register selection
* U8G_PI_SET_A0 1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
* U8G_PI_SCL clock line (NOT USED)
* U8G_PI_SDA data line (NOT USED)
*
* U8G_PI_RESET reset line (currently disabled, see below)
*
* Protocol:
* SLA, Cmd/Data Selection, Arguments
* The command/data register is selected by a special instruction byte, which is sent after SLA
*
* The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
*/
#ifdef TARGET_LPC1768
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB
#include <U8glib-HAL.h>
#define I2C_SLA (0x3C*2)
//#define I2C_CMD_MODE 0x080
#define I2C_CMD_MODE 0x000
#define I2C_DATA_MODE 0x040
uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
/* are we requested to set the a0 state? */
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
/* setup bus, might be a repeated start */
if (u8g_i2c_start(I2C_SLA) == 0) return 0;
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
}
else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0)
return 0;
u8g->pin_list[U8G_PI_SET_A0] = 0;
return 1;
}
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
//u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
//u8g->pin_list[U8G_PI_A0_STATE] = 0; /* initial RS state: unknown mode */
u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
u8g_com_ssd_I2C_start_sequence(u8g);
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
/* Currently disabled, but it could be enable. Previous restrictions have been removed */
/* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
break;
case U8G_COM_MSG_CHIP_SELECT:
u8g->pin_list[U8G_PI_A0_STATE] = 0;
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
if (arg_val == 0 ) {
/* disable chip, send stop condition */
u8g_i2c_stop();
}
else {
/* enable, do nothing: any byte writing will trigger the i2c start */
}
break;
case U8G_COM_MSG_WRITE_BYTE:
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0) {
u8g_i2c_stop();
return 0;
}
if (u8g_i2c_send_byte(arg_val) == 0) {
u8g_i2c_stop();
return 0;
}
// u8g_i2c_stop();
break;
case U8G_COM_MSG_WRITE_SEQ: {
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0) {
u8g_i2c_stop();
return 0;
}
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
if (u8g_i2c_send_byte(*ptr++) == 0) {
u8g_i2c_stop();
return 0;
}
arg_val--;
}
}
// u8g_i2c_stop();
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0) {
u8g_i2c_stop();
return 0;
}
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
if (u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0)
return 0;
ptr++;
arg_val--;
}
}
// u8g_i2c_stop();
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
break;
} // switch
return 1;
}
#endif // HAS_MARLINUI_U8GLIB
#endif // TARGET_LPC1768
@@ -1,138 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Based on u8g_com_LPC1768_st7920_hw_spi.c
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2011, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef TARGET_LPC4078
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB
#include <U8glib-HAL.h>
#include "../../shared/HAL_SPI.h"
#include "../../shared/Delay.h"
void spiBegin();
void spiInit(uint8_t spiRate);
void spiSend(uint8_t b);
void spiSend(const uint8_t *buf, size_t n);
static uint8_t rs_last_state = 255;
static void u8g_com_LPC1768_st7920_write_byte_hw_spi(uint8_t rs, uint8_t val) {
if (rs != rs_last_state) { // Time to send a command/data byte
rs_last_state = rs;
spiSend(rs ? 0x0FA : 0x0F8); // Send data or command
DELAY_US(40); // Give the controller some time: 20 is bad, 30 is OK, 40 is safe
}
spiSend(val & 0xF0);
spiSend(val << 4);
}
uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_Delay(5);
spiBegin();
spiInit(SPI_EIGHTH_SPEED); // ST7920 max speed is about 1.1 MHz
u8g->pin_list[U8G_PI_A0_STATE] = 0; // initial RS state: command mode
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_ADDRESS: // Define cmd (arg_val = 0) or data mode (arg_val = 1)
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
break;
case U8G_COM_MSG_CHIP_SELECT:
u8g_SetPILevel(u8g, U8G_PI_CS, arg_val); // Note: the ST7920 has an active high chip-select
break;
case U8G_COM_MSG_WRITE_BYTE:
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
}
return 1;
}
#endif // HAS_MARLINUI_U8GLIB
#endif // TARGET_LPC4078
@@ -1,147 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Based on u8g_com_st7920_hw_spi.c
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2011, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef TARGET_LPC4078
#include "../../../inc/MarlinConfigPre.h"
#if IS_U8GLIB_ST7920
#include <U8glib-HAL.h>
#include "../SoftwareSPI.h"
#include "../../shared/Delay.h"
#include "../../shared/HAL_SPI.h"
#ifndef LCD_SPI_SPEED
#define LCD_SPI_SPEED SPI_EIGHTH_SPEED // About 1 MHz
#endif
static pin_t SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL;
static uint8_t SPI_speed = 0;
static void u8g_com_LPC1768_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
static uint8_t rs_last_state = 255;
if (rs != rs_last_state) {
// Transfer Data (FA) or Command (F8)
swSpiTransfer(rs ? 0x0FA : 0x0F8, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
rs_last_state = rs;
DELAY_US(40); // Give the controller time to process the data: 20 is bad, 30 is OK, 40 is safe
}
swSpiTransfer(val & 0x0F0, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
swSpiTransfer(val << 4, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
}
uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
SCK_pin_ST7920_HAL = u8g->pin_list[U8G_PI_SCK];
MOSI_pin_ST7920_HAL_HAL = u8g->pin_list[U8G_PI_MOSI];
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_SetPIOutput(u8g, U8G_PI_SCK);
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
u8g_Delay(5);
SPI_speed = swSpiInit(LCD_SPI_SPEED, SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL);
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
u8g_SetPILevel(u8g, U8G_PI_SCK, 0);
u8g_SetPILevel(u8g, U8G_PI_MOSI, 0);
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* initial RS state: command mode */
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
break;
case U8G_COM_MSG_CHIP_SELECT:
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS]) u8g_SetPILevel(u8g, U8G_PI_CS, arg_val); //note: the st7920 has an active high chip select
break;
case U8G_COM_MSG_WRITE_BYTE:
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t*) arg_ptr;
while (arg_val > 0) {
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--;
}
}
break;
}
return 1;
}
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC4078
@@ -1,209 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Based on u8g_com_std_sw_spi.c
*
* Universal 8bit Graphics Library
*
* Copyright (c) 2015, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef TARGET_LPC4078
#include "../../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#include <SoftwareSPI.h>
#include "../../shared/HAL_SPI.h"
#ifndef LCD_SPI_SPEED
#define LCD_SPI_SPEED SPI_QUARTER_SPEED // About 2 MHz
#endif
#include <Arduino.h>
#include <algorithm>
#include <LPC17xx.h>
#include <gpio.h>
#include <U8glib-HAL.h>
uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
LOOP_L_N(i, 8) {
if (spi_speed == 0) {
LPC176x::gpio_set(mosi_pin, !!(b & 0x80));
LPC176x::gpio_set(sck_pin, HIGH);
b <<= 1;
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
LPC176x::gpio_set(sck_pin, LOW);
}
else {
const uint8_t state = (b & 0x80) ? HIGH : LOW;
LOOP_L_N(j, spi_speed)
LPC176x::gpio_set(mosi_pin, state);
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
LPC176x::gpio_set(sck_pin, HIGH);
b <<= 1;
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
LOOP_L_N(j, spi_speed)
LPC176x::gpio_set(sck_pin, LOW);
}
}
return b;
}
uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
LOOP_L_N(i, 8) {
const uint8_t state = (b & 0x80) ? HIGH : LOW;
if (spi_speed == 0) {
LPC176x::gpio_set(sck_pin, LOW);
LPC176x::gpio_set(mosi_pin, state);
LPC176x::gpio_set(mosi_pin, state); // need some setup time
LPC176x::gpio_set(sck_pin, HIGH);
}
else {
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
LPC176x::gpio_set(sck_pin, LOW);
LOOP_L_N(j, spi_speed)
LPC176x::gpio_set(mosi_pin, state);
LOOP_L_N(j, spi_speed)
LPC176x::gpio_set(sck_pin, HIGH);
}
b <<= 1;
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
}
return b;
}
static uint8_t SPI_speed = 0;
static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
#if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
#else
swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin);
#endif
}
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
u8g_SetPIOutput(u8g, U8G_PI_SCK);
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
u8g_SetPIOutput(u8g, U8G_PI_CS);
u8g_SetPIOutput(u8g, U8G_PI_A0);
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET);
SPI_speed = swSpiInit(LCD_SPI_SPEED, u8g->pin_list[U8G_PI_SCK], u8g->pin_list[U8G_PI_MOSI]);
u8g_SetPILevel(u8g, U8G_PI_SCK, 0);
u8g_SetPILevel(u8g, U8G_PI_MOSI, 0);
break;
case U8G_COM_MSG_STOP:
break;
case U8G_COM_MSG_RESET:
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;
case U8G_COM_MSG_CHIP_SELECT:
#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
// 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_CS, LOW);
}
else {
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
}
#else
u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
#endif
break;
case U8G_COM_MSG_WRITE_BYTE:
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
arg_val--;
}
}
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
ptr++;
arg_val--;
}
}
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
break;
}
return 1;
}
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // TARGET_LPC4078
@@ -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) {
#if U8G_SPI_USE_MODE_3
#if ANY(FYSETC_MINI_12864, MKS_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
#else
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;
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 (arg_val) { // SCK idle state needs to be set to the proper idle state before
// the next chip select goes active
u8g_SetPILevel(u8g, U8G_PI_SCK, 1); // Set SCK to mode 3 idle state before CS goes active
#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
// 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_CS, LOW);
}
else {
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
u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
+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_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_CALIBRATION_EILINE(P) TERN0(USE_CALIBRATION, DEFER4(MATCH_EILINE)(P, CALIBRATION_PIN))
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
&& !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_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P) \
&& !MATCH_CALIBRATION_EILINE(P) )
&& !MATCH_Z_MIN_PROBE_EILINE(P) )
// One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); }
@@ -210,12 +208,6 @@ void setup_endstop_interrupts() {
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#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 !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+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_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_CALIBRATION_EILINE(P) TERN0(USE_CALIBRATION, DEFER4(MATCH_EILINE)(P, CALIBRATION_PIN))
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
&& !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_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P) \
&& !MATCH_CALIBRATION_EILINE(P) )
&& !MATCH_Z_MIN_PROBE_EILINE(P) )
// One ISR for all EXT-Interrupts
void endstop_ISR() { endstops.update(); }
@@ -185,12 +183,6 @@ void setup_endstop_interrupts() {
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#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 !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
+1 -1
View File
@@ -112,7 +112,7 @@
#else
#error "LCD_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
#endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
+1 -1
View File
@@ -37,7 +37,7 @@ static SPISettings spiConfig;
// Public functions
// ------------------------
#if ANY(SOFTWARE_SPI, FORCE_SOFT_SPI)
#if ENABLED(SOFTWARE_SPI)
// ------------------------
// Software SPI
-1
View File
@@ -53,7 +53,6 @@
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
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:
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_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_PIN));
TERN_(USE_CALIBRATION, _ATTACH(CALIBRATION_PIN));
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
@@ -30,3 +30,6 @@
#undef F_CPU
#define F_CPU BOARD_F_CPU
#endif
// The Sensitive Pins array is not optimizable
#define RUNTIME_ONLY_ANALOG_TO_DIGITAL
+3 -3
View File
@@ -25,8 +25,8 @@
* 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
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32_sw_spi_fn
uint8_t u8g_com_std_sw_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
+1 -1
View File
@@ -138,7 +138,7 @@
#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.")
#endif
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
+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) {
#if U8G_SPI_USE_MODE_3
#if ENABLED(FYSETC_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed);
#else
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;
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
#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
// 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);
}
else {
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
WRITE(DOGLCD_CS, !arg_val);
@@ -70,7 +70,6 @@ void setup_endstop_interrupts() {
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
TERN_(USE_Z_MIN_PROBE, _ATTACH(Z_MIN_PROBE_PIN));
TERN_(USE_CALIBRATION, _ATTACH(CALIBRATION_PIN));
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));

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